comparison src/auth.cpp @ 5:e3b10fb860b3

release v1.0.
author pyon@macmini
date Mon, 22 Oct 2018 22:17:02 +0900
parents 06342fc544e4
children 9a8b581c1993
comparison
equal deleted inserted replaced
4:06342fc544e4 5:e3b10fb860b3
1 // Filename : auth.cpp 1 // Filename : auth.cpp
2 // Last Change: 2018-10-12 金 16:17:32. 2 // Last Change: 2018-10-22 月 16:11:52.
3 // 3 //
4 4
5 #include "id.h" 5 #include "id.h"
6 #include "auth.h" 6 #include "auth.h"
7 7
26 END_EVENT_TABLE() 26 END_EVENT_TABLE()
27 27
28 // Event Handler 28 // Event Handler
29 void AuthDialog::OnShow( wxShowEvent& WXUNUSED(event) ) 29 void AuthDialog::OnShow( wxShowEvent& WXUNUSED(event) )
30 { 30 {
31 if ( m_load ) return;
32 wxArrayString args; // http get ( auth.db, hhs.db, index.db )
33 args.Add( wxT( "client.exe" ) );
34 args.Add( wxT( "-u" ) );
35 args.Add( m_server );
36
37 wxExecute( wxJoin( args, ' ', '\\' ), wxEXEC_SYNC|wxEXEC_HIDE_CONSOLE );
38
39 wxTextFile file;
40 file.Open( wxT( "auth.db" ) );
41 for ( int i = 0; i < file.GetLineCount(); i++ ) {
42 wxArrayString line = wxSplit( file.GetLine( i ), ' ', '\\' );
43 m_users.Add( line[ 0 ] );
44 }
45 file.Close();
46
47 m_load = true;
48 } 31 }
49 32
50 void AuthDialog::OnCheckUserID( wxCommandEvent& WXUNUSED(event) ) 33 void AuthDialog::OnCheckUserID( wxCommandEvent& WXUNUSED(event) )
51 { 34 {
52 wxString id = m_textCtrlId->GetValue(); 35 wxString id = m_textCtrlId->GetValue();
134 117
135 this->Centre( wxBOTH ); 118 this->Centre( wxBOTH );
136 m_textCtrlId->SetFocus(); 119 m_textCtrlId->SetFocus();
137 } 120 }
138 121
122 bool AuthDialog::LoadDB( void )
123 {
124 // http get ( auth.db, hhs.db, index.db )
125 wxArrayString args;
126 args.Add( wxT( "client.exe" ) );
127 args.Add( wxT( "-u" ) );
128 args.Add( m_server );
129
130 wxExecute( wxJoin( args, ' ', '\\' ), wxEXEC_SYNC|wxEXEC_HIDE_CONSOLE );
131
132 // load db
133 wxTextFile file;
134 if ( !file.Open( wxT( "auth.db" ) ) ) return false;
135 for ( int i = 0; i < file.GetLineCount(); i++ ) {
136 wxArrayString line = wxSplit( file.GetLine( i ), ' ', '\\' );
137 m_users.Add( line[ 0 ] );
138 }
139 file.Close();
140 return true;
141 }
142
139 bool AuthDialog::IsValidUser( void ) 143 bool AuthDialog::IsValidUser( void )
140 { 144 {
141 wxString id = m_textCtrlId->GetValue(); 145 wxString id = m_textCtrlId->GetValue();
142 wxString pw = m_textCtrlPw->GetValue(); 146 wxString pw = m_textCtrlPw->GetValue();
143 147
156 return false; 160 return false;
157 } 161 }
158 162
159 void AuthDialog::InDevelop( bool flag ) 163 void AuthDialog::InDevelop( bool flag )
160 { 164 {
161 return;
162 if ( !flag ) return; 165 if ( !flag ) return;
163 m_textCtrlId->SetValue( "test" ); 166 m_textCtrlId->SetValue( "test" );
164 m_textCtrlPw->SetValue( "test" ); 167 m_textCtrlPw->SetValue( "test" );
165 m_textCtrlPw->SetFocus(); 168 m_textCtrlPw->SetFocus();
166 } 169 }