diff --git a/clientgui/MainDocument.cpp b/clientgui/MainDocument.cpp index e4da23a36b..b4e00e5709 100644 --- a/clientgui/MainDocument.cpp +++ b/clientgui/MainDocument.cpp @@ -91,13 +91,13 @@ void* CNetworkConnectionThread::Entry() { } if (0 == iRetVal) { - if (!strComputerPassword.empty()) { - iRetVal = m_pDocument->rpc.authorize(strComputerPassword.c_str()); - } - + iRetVal = m_pDocument->rpc.authorize(strComputerPassword.c_str()); if (0 == iRetVal) { wxLogTrace("CNetworkConnectionThread::Entry - Connection Success"); SetStateSuccess( strComputer, strComputerPassword ); + } else if (ERR_AUTHENTICATOR == iRetVal) { + wxLogTrace("CNetworkConnectionThread::Entry - RPC Authorization Failed '%d'", iRetVal); + SetStateErrorAuthentication(); } else { wxLogTrace("CNetworkConnectionThread::Entry - RPC Authorization Failed '%d'", iRetVal); SetStateError(); @@ -140,6 +140,21 @@ wxInt32 CNetworkConnectionThread::SetNewComputerPassword( const wxChar* szPasswo } +void CNetworkConnectionThread::SetStateErrorAuthentication() { + CMainFrame* pFrame = wxGetApp().GetFrame(); + if (pFrame && wxGetApp().GetTopWindow()) { + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + m_bConnected = false; + m_bReconnecting = false; + m_bReconnectOnError = false; + + m_bConnectEvent = false; + + pFrame->FireConnectErrorAuthentication(); + } +} + + void CNetworkConnectionThread::SetStateError() { CMainFrame* pFrame = wxGetApp().GetFrame(); if (pFrame && wxGetApp().GetTopWindow()) { diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index 3e3cf64a4a..4bb71c4ca6 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -43,6 +43,7 @@ public: wxInt32 SetNewComputerName( const wxChar* szComputer ); wxInt32 SetNewComputerPassword( const wxChar* szPassword ); void SetStateError(); + void SetStateErrorAuthentication(); void SetStateReconnecting(); void SetStateSuccess( std::string& strComputer, std::string& strComputerPassword ); void SetStateDisconnected(); diff --git a/clientgui/MainFrame.cpp b/clientgui/MainFrame.cpp index bf5892d63e..ab81859ce8 100644 --- a/clientgui/MainFrame.cpp +++ b/clientgui/MainFrame.cpp @@ -136,6 +136,7 @@ void CStatusBar::OnSize(wxSizeEvent& event) { DEFINE_EVENT_TYPE(wxEVT_MAINFRAME_CONNECT) DEFINE_EVENT_TYPE(wxEVT_MAINFRAME_CONNECT_ERROR) +DEFINE_EVENT_TYPE(wxEVT_MAINFRAME_CONNECT_ERROR_AUTHENTICATION) DEFINE_EVENT_TYPE(wxEVT_MAINFRAME_INITIALIZED) DEFINE_EVENT_TYPE(wxEVT_MAINFRAME_REFRESHVIEW) @@ -157,6 +158,7 @@ BEGIN_EVENT_TABLE (CMainFrame, wxFrame) EVT_HELP(ID_FRAME, CMainFrame::OnHelp) EVT_MAINFRAME_CONNECT(CMainFrame::OnConnect) EVT_MAINFRAME_CONNECT_ERROR(CMainFrame::OnConnectError) + EVT_MAINFRAME_CONNECT_ERROR_AUTHENTICATION(CMainFrame::OnConnectErrorAuthentication) EVT_MAINFRAME_INITIALIZED(CMainFrame::OnInitialized) EVT_MAINFRAME_REFRESH(CMainFrame::OnRefreshView) EVT_TIMER(ID_REFRESHSTATETIMER, CMainFrame::OnRefreshState) @@ -1138,6 +1140,19 @@ void CMainFrame::OnConnectError(CMainFrameEvent&) { } +void CMainFrame::OnConnectErrorAuthentication(CMainFrameEvent&) { + wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnConnectErrorAuthentication - Function Begin")); + + ::wxMessageBox( + _("The password you have provided is incorrect, please try again."), + _("Connection Error"), + wxICON_ERROR + ); + + wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnConnectErrorAuthentication - Function End")); +} + + void CMainFrame::OnInitialized(CMainFrameEvent&) { wxLogTrace(wxT("Function Start/End"), wxT("CMainFrame::OnInitialized - Function Begin")); @@ -1390,6 +1405,12 @@ void CMainFrame::FireConnectError() { } +void CMainFrame::FireConnectErrorAuthentication() { + CMainFrameEvent event(wxEVT_MAINFRAME_CONNECT_ERROR_AUTHENTICATION, this); + AddPendingEvent(event); +} + + void CMainFrame::FireRefreshView() { CMainFrameEvent event(wxEVT_MAINFRAME_REFRESHVIEW, this); AddPendingEvent(event); diff --git a/clientgui/MainFrame.h b/clientgui/MainFrame.h index dd90fa94c8..99b7d57d49 100644 --- a/clientgui/MainFrame.h +++ b/clientgui/MainFrame.h @@ -81,6 +81,7 @@ public: void OnConnect( CMainFrameEvent& event ); void OnConnectError( CMainFrameEvent& event ); + void OnConnectErrorAuthentication( CMainFrameEvent& event ); void OnInitialized( CMainFrameEvent& event ); void OnRefreshView( CMainFrameEvent& event ); @@ -88,6 +89,7 @@ public: void FireConnect(); void FireConnectError(); + void FireConnectErrorAuthentication(); void FireRefreshView(); void ProcessRefreshView(); @@ -142,12 +144,15 @@ public: BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_CONNECT, 10000 ) DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_CONNECT_ERROR, 10001 ) -DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_INITIALIZED, 10002 ) -DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_REFRESHVIEW, 10003 ) +DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_CONNECT_ERROR_AUTHENTICATION, 10002 ) +DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_INITIALIZED, 10003 ) +DECLARE_EVENT_TYPE( wxEVT_MAINFRAME_REFRESHVIEW, 10004 ) END_DECLARE_EVENT_TYPES() #define EVT_MAINFRAME_CONNECT(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MAINFRAME_CONNECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), #define EVT_MAINFRAME_CONNECT_ERROR(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MAINFRAME_CONNECT_ERROR, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), +#define EVT_MAINFRAME_CONNECT_ERROR_AUTHENTICATION(fn) \ + DECLARE_EVENT_TABLE_ENTRY(wxEVT_MAINFRAME_CONNECT_ERROR_AUTHENTICATION, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), #define EVT_MAINFRAME_INITIALIZED(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MAINFRAME_INITIALIZED, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), #define EVT_MAINFRAME_REFRESH(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MAINFRAME_REFRESHVIEW, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),