# HG changeset patch # User pyon@macmini # Date 1538403509 -32400 # Node ID eaa27e4ed5be1591b45011671b8eef8875bf4e43 # Parent d3b8cd5aeb7006cfe3ca017e447a3f6394e776c6 add client_ui.go diff -r d3b8cd5aeb70 -r eaa27e4ed5be Makefile --- a/Makefile Sun Sep 30 17:27:04 2018 +0900 +++ b/Makefile Mon Oct 01 23:18:29 2018 +0900 @@ -1,5 +1,5 @@ # Makefile for wxWidgets Application -# Last Change: 2018-07-17 Tue 04:53:26. +# Last Change: 2018-10-01 Mon 23:12:08. # by Takayuki Mutoh # @@ -50,7 +50,7 @@ $(CXX) $^ -o $@ $(LIBS) -$(OBJDIR)/main.o: main.cpp main.h rsearcher.h +$(OBJDIR)/main.o: main.cpp main.h rsearcher.h auth.h -mkdir -p $(OBJDIR) $(CXX) -c $< -o $@ $(CXXFLAGS) diff -r d3b8cd5aeb70 -r eaa27e4ed5be go/client.go --- a/go/client.go Sun Sep 30 17:27:04 2018 +0900 +++ b/go/client.go Mon Oct 01 23:18:29 2018 +0900 @@ -1,7 +1,7 @@ /* client.go : client-program. - Version : 0.0 - Last Change: 2018-09-30 Sun 17:09:04. + Version : 1.0 + Last Change: 2018-10-01 Mon 21:45:18. install to: rsearcher_root/ @@ -48,12 +48,12 @@ fmt.Fprintf( os.Stderr, "no remote host.\n" ) os.Exit( 1 ) } - fmt.Println( "Getting grsearcher.exe..." ) + fmt.Print( "Getting grsearcher.exe..." ) host := flag.Args()[0] if _, err := get_file( host, "/release/grsearcher.exe", "grsearcher.exe" ); err != nil { log.Fatal( err ) } - fmt.Println( "Getting client.exe..." ) + fmt.Print( "Getting client.exe..." ) if _, err := get_file( host, "/release/client.exe", "client1.exe" ); err != nil { log.Fatal( err ) } @@ -65,18 +65,18 @@ fmt.Fprintf( os.Stderr, "no remote host.\n" ) os.Exit( 1 ) } - fmt.Println( "Getting auth.db..." ) + fmt.Print( "Getting auth.db..." ) host := flag.Args()[0] if _, err := get_file( host, "/db/auth.db", "auth.db" ); err != nil { log.Fatal( err ) } - fmt.Println( "Getting hhs.db..." ) + fmt.Print( "Getting hhs.db..." ) if _, err := get_file( host, "/db/hhs.db", "hhs.db" ); err != nil { log.Fatal( err ) } if time.Now().Day() % 10 == 0 { - fmt.Println( "Getting index.db..." ) + fmt.Print( "Getting index.db..." ) if _, err := get_file( host, "/db/index.db", "index.db" ); err != nil { log.Fatal( err ) } @@ -121,6 +121,10 @@ if err != nil { return nil, err } + fmt.Println( "\t[" + res.Status + "]" ) + if res.StatusCode == http.StatusNotFound { + return nil, nil + } b, err := ioutil.ReadAll( res.Body ) res.Body.Close() if err != nil { @@ -155,7 +159,7 @@ } //f, _ := os.Create( hdr.Name ) fn := fmt.Sprintf( "%s_%d.jpg", d, i ) - fn = fmt.Sprintf( "00000000_%d.jpg", i ) // for test + fn = fmt.Sprintf( "00000000_%d", i ) // for test fn = filepath.Join( ".cache", fn ) f, _ := os.Create( fn ) diff -r d3b8cd5aeb70 -r eaa27e4ed5be go/client_ui.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/go/client_ui.go Mon Oct 01 23:18:29 2018 +0900 @@ -0,0 +1,52 @@ +package main + +import ( + "bufio" + "flag" + "fmt" + "log" + "os" + "os/exec" + "time" +) + +func main() { + mode := flag.Int( "m", 0, "set mode.[1|2]" ) + flag.Parse() + + if *mode != 1 && *mode != 2 { + fmt.Fprintf( os.Stderr, "bad mode." ) + os.Exit( 1 ) + } + + scanner := bufio.NewScanner( os.Stdin ) + + fmt.Print( "被保番? " ) + hhs := "0123456789" + scanner.Scan() + hhs = scanner.Text() + + date := "00000000" + if *mode == 1 { + fmt.Print( "審査会? " ) + scanner.Scan() + date = scanner.Text() + } + + host := "192.168.56.102:3910" + do_client( host, hhs, date ) +} + +func do_client( host, hhs, date string ) { + s := time.Now() + cmd := exec.Command( "./client", host, hhs, date ) + err := cmd.Start() + if err != nil { + log.Fatal( err ) + } + log.Printf( "%v の %v における情報を取得しています...", hhs, date ) + err = cmd.Wait() + t := time.Now().Sub( s ) + log.Printf( "%v かかりました.[err:%v]", t, err ) +} + diff -r d3b8cd5aeb70 -r eaa27e4ed5be go/server.go --- a/go/server.go Sun Sep 30 17:27:04 2018 +0900 +++ b/go/server.go Mon Oct 01 23:18:29 2018 +0900 @@ -1,7 +1,7 @@ /* server.go : server-program. Version : 1.0 - Last Change: 2018-09-30 Sun 16:03:40. + Last Change: 2018-10-01 Mon 22:58:23. install to: server_root/ @@ -26,6 +26,7 @@ var server string var port = ":3910" + var server_root = filepath.Dir (os.Args[0] ) addrs, err := net.InterfaceAddrs() if err != nil { @@ -39,14 +40,9 @@ } } - cwd, err := os.Getwd() - if err != nil { - log.Fatal( err ) - } - fmt.Println( "server start [", server, "]" ) http.HandleFunc( "/", func( w http.ResponseWriter, r *http.Request ) { - file := filepath.Join( cwd, filepath.FromSlash( r.URL.Path ) ) + file := filepath.Join( server_root, filepath.FromSlash( r.URL.Path ) ) fmt.Println( file ) f, err := os.Open( file ) if err != nil { diff -r d3b8cd5aeb70 -r eaa27e4ed5be include/auth.h --- a/include/auth.h Sun Sep 30 17:27:04 2018 +0900 +++ b/include/auth.h Mon Oct 01 23:18:29 2018 +0900 @@ -1,5 +1,5 @@ // Filename : auth.h -// Last Change: 2018-09-29 Sat 06:18:10. +// Last Change: 2018-10-01 Mon 23:08:10. // #ifndef __AUTH_H__ @@ -43,7 +43,7 @@ void OnEnter( wxCommandEvent& event ); void CreateControls( void ); void LoadUserID( void ); - void InDevelop( void ); + void InDevelop( bool ); }; #endif //__AUTH_H__ diff -r d3b8cd5aeb70 -r eaa27e4ed5be include/main.h --- a/include/main.h Sun Sep 30 17:27:04 2018 +0900 +++ b/include/main.h Mon Oct 01 23:18:29 2018 +0900 @@ -1,5 +1,5 @@ // Filename : main.h -// Last Change: 2018-09-17 Mon 21:57:32. +// Last Change: 2018-10-01 Mon 23:13:17. // #include #include @@ -17,6 +17,7 @@ private: wxFileConfig *config; wxString conf_file; + bool develop; public: wxRect rect; diff -r d3b8cd5aeb70 -r eaa27e4ed5be include/rsearcher.h --- a/include/rsearcher.h Sun Sep 30 17:27:04 2018 +0900 +++ b/include/rsearcher.h Mon Oct 01 23:18:29 2018 +0900 @@ -1,5 +1,5 @@ // Filename : rsearcher.h -// Last Change: 2018-09-16 Sun 18:07:49. +// Last Change: 2018-10-01 Mon 23:08:37. // #ifndef __RSEARCH_H__ @@ -76,6 +76,7 @@ MyStaticBitmap* m_staticBitmap3; MyStaticBitmap* m_staticBitmap4; MyStaticBitmap* m_staticBitmap5; + MyStaticBitmap* m_staticBitmap6; wxNotebook* m_notebook; wxScrolledWindow* m_scrolledWindow1; @@ -93,7 +94,7 @@ wxTextCtrl* m_textCtrlLog; wxSlider* m_slider; wxButton* m_buttonPrint; - wxButton* m_button; + wxButton* m_buttonTest; public: MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT( "Searcher Remote" ), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); @@ -103,11 +104,12 @@ //void OnIdle( wxIdleEvent& event ); void Cmd( wxString cmd ); void SaveConfig( wxCloseEvent& event ); + void CreateControls( void ); void LoadBitmaps( void ); - void LoadBitmap( wxStaticBitmap* sb, wxString file ); + void LoadBitmap( wxScrolledWindow* sc, wxStaticBitmap* sb, wxString file ); void GetImage( wxString hhs, wxString no ); void OnTestButton( wxCommandEvent& event ); - void InDevelop( void ); + void InDevelop( bool ); }; diff -r d3b8cd5aeb70 -r eaa27e4ed5be src/auth.cpp --- a/src/auth.cpp Sun Sep 30 17:27:04 2018 +0900 +++ b/src/auth.cpp Mon Oct 01 23:18:29 2018 +0900 @@ -1,5 +1,5 @@ // Filename : auth.cpp -// Last Change: 2018-09-29 Sat 06:18:31. +// Last Change: 2018-10-01 Mon 23:15:27. // #include "auth.h" @@ -9,7 +9,6 @@ { CreateControls(); LoadUserID(); - InDevelop(); } AuthDialog::~AuthDialog() @@ -60,8 +59,9 @@ // ファイルから UserID を読み込む } -void AuthDialog::InDevelop( void ) +void AuthDialog::InDevelop( bool flag ) { + if ( !flag ) return; SetTitle( "now on test" ); m_textCtrlId->SetValue( "test" ); m_textCtrlPw->SetValue( "test" ); diff -r d3b8cd5aeb70 -r eaa27e4ed5be src/main.cpp --- a/src/main.cpp Sun Sep 30 17:27:04 2018 +0900 +++ b/src/main.cpp Mon Oct 01 23:18:29 2018 +0900 @@ -1,5 +1,5 @@ // Filename : main.cpp -// Last Change: 2018-09-29 Sat 15:11:45. +// Last Change: 2018-10-01 Mon 23:14:59. // #include "main.h" #include "auth.h" @@ -11,6 +11,7 @@ MyApp::MyApp() { + develop = true; } MyApp::~MyApp() { @@ -26,10 +27,16 @@ GetData(); AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "" ), wxDefaultPosition, wxDefaultSize ); + MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); + + if ( develop ) { + authdlg->InDevelop( true ); + mainframe->InDevelop( true ); + } + authdlg->ShowModal(); authdlg->Destroy(); - MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); mainframe->Show( true ); return true; diff -r d3b8cd5aeb70 -r eaa27e4ed5be src/rsearcher.cpp --- a/src/rsearcher.cpp Sun Sep 30 17:27:04 2018 +0900 +++ b/src/rsearcher.cpp Mon Oct 01 23:18:29 2018 +0900 @@ -1,5 +1,5 @@ // Filename : rsearcher.cpp -// Last Change: 2018-09-16 Sun 18:25:30. +// Last Change: 2018-10-01 Mon 23:15:33. // #include "rsearcher.h" @@ -147,6 +147,93 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { + CreateControls(); +} + +MainFrame::~MainFrame() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( MainFrame, wxFrame ) + EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked ) + EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged ) + EVT_BUTTON( ID_TEST, MainFrame::OnTestButton ) + EVT_CLOSE( MainFrame::SaveConfig ) + //EVT_IDLE( MainFrame::OnIdle ) +END_EVENT_TABLE() + + +// Event Handler +void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) ) +{ + wxMessageBox( "dcli" ); + int r = m_dataViewListCtrl->GetSelectedRow(); + wxString no = m_dataViewListCtrl->GetTextValue( r, 0 ); + + LoadBitmaps(); +} + +void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) ) +{ + for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) { + m_notebook->SetPageImage( i, 1 ); + } + m_notebook->SetPageImage( m_notebook->GetSelection(), 0 ); +} + +/* +void MainFrame::OnItemSelected( wxDataViewEvent& event ) +{ + dclick or select ? +} +*/ + + +/* +void MainFrame::OnIdle( wxIdleEvent& WXUNUSED(event) ) +{ +} + +*/ +void MainFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) +{ + if ( !IsIconized() && !IsMaximized() ) { + wxGetApp().rect = this->GetRect(); + } + Destroy(); +} + +void MainFrame::OnTestButton( wxCommandEvent& WXUNUSED(event) ) +{ + /* ok + Cmd( m_searchCtrl->GetValue() ); + Cmd( wxT( "0100012345" ) ); + */ + + wxBitmap bmp( wxT(".cache/01_1"), wxBITMAP_TYPE_JPEG ); + int width = bmp.GetWidth(); + int height = bmp.GetHeight(); + wxImage img = bmp.ConvertToImage(); + + int ww, wh; + m_scrolledWindow6->GetSize( &ww, &wh ); + + float w = ww; + float h = w * height / width; + m_staticBitmap6->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); + m_scrolledWindow6->SetScrollbars( 10, 10, w / 10, h / 10 ); + + for ( int i = 0; i < 5; i++ ) { + w *= 1.1; + h *= 1.1; + //m_staticBitmap6->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); + } +} + +// Functions +void MainFrame::CreateControls( void ) +{ this->SetIcon( wxIcon( wxT( "sample" ) ) ); this->SetSizeHints( wxDefaultSize, wxDefaultSize ); //this->SetBackgroundColour( wxColour( 0, 150, 230 ) ); @@ -219,8 +306,8 @@ m_buttonPrint = new wxButton( this, ID_PRINT, wxT( "Print" ), wxDefaultPosition, wxDefaultSize, 0 ); bSizerRight->Add( m_buttonPrint, 0, wxALL, 5 ); - m_button = new wxButton( this, ID_TEST, wxT( "MyButton" ), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerRight->Add( m_button, 0, wxALL, 5 ); + m_buttonTest = new wxButton( this, ID_TEST, wxT( "Test" ), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerRight->Add( m_buttonTest, 0, wxALL, 5 ); bSizerTop->Add( bSizerRight, 0, wxEXPAND, 5 ); @@ -234,92 +321,8 @@ m_staticBitmap3 = new MyStaticBitmap( m_scrolledWindow3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); m_staticBitmap4 = new MyStaticBitmap( m_scrolledWindow4, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); m_staticBitmap5 = new MyStaticBitmap( m_scrolledWindow5, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0, wxEmptyString ); - - InDevelop(); -} - -MainFrame::~MainFrame() -{ -} - -// Event Table -BEGIN_EVENT_TABLE( MainFrame, wxFrame ) - EVT_DATAVIEW_ITEM_ACTIVATED( ID_LIST, MainFrame::OnItemDClicked ) - EVT_NOTEBOOK_PAGE_CHANGED( ID_NBOOK, MainFrame::OnNBookChanged ) - EVT_BUTTON( ID_TEST, MainFrame::OnTestButton ) - EVT_CLOSE( MainFrame::SaveConfig ) - //EVT_IDLE( MainFrame::OnIdle ) -END_EVENT_TABLE() - - -// Event Handler -void MainFrame::OnItemDClicked( wxDataViewEvent& WXUNUSED(event) ) -{ - wxMessageBox( "dcli" ); - int r = m_dataViewListCtrl->GetSelectedRow(); - wxString no = m_dataViewListCtrl->GetTextValue( r, 0 ); - - LoadBitmaps(); -} - -void MainFrame::OnNBookChanged( wxBookCtrlEvent& WXUNUSED(event) ) -{ - for ( int i = 0; i < m_notebook->GetPageCount(); i++ ) { - m_notebook->SetPageImage( i, 1 ); - } - m_notebook->SetPageImage( m_notebook->GetSelection(), 0 ); } -/* -void MainFrame::OnItemSelected( wxDataViewEvent& event ) -{ - dclick or select ? -} -*/ - - -/* -void MainFrame::OnIdle( wxIdleEvent& WXUNUSED(event) ) -{ -} - -*/ -void MainFrame::SaveConfig( wxCloseEvent& WXUNUSED(event) ) -{ - if ( !IsIconized() && !IsMaximized() ) { - wxGetApp().rect = this->GetRect(); - } - Destroy(); -} - -void MainFrame::OnTestButton( wxCommandEvent& WXUNUSED(event) ) -{ - /* ok - Cmd( m_searchCtrl->GetValue() ); - Cmd( wxT( "0100012345" ) ); - */ - - wxBitmap bmp( wxT("db/19970101/img088.jpg"), wxBITMAP_TYPE_JPEG ); - int width = bmp.GetWidth(); - int height = bmp.GetHeight(); - wxImage img = bmp.ConvertToImage(); - - int ww, wh; - m_scrolledWindow1->GetSize( &ww, &wh ); - - float w = ww; - float h = w * height / width; - m_staticBitmap1->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); - m_scrolledWindow1->SetScrollbars( 10, 10, w / 10, h / 10 ); - - for ( int i = 0; i < 5; i++ ) { - w *= 1.1; - h *= 1.1; - m_staticBitmap1->SetImage( i, wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); - } -} - -// Functions void MainFrame::Cmd( wxString cmd ) { m_dataViewListCtrl->DeleteAllItems(); @@ -359,7 +362,7 @@ } } -void MainFrame::LoadBitmap( wxStaticBitmap* sb, wxString file ) +void MainFrame::LoadBitmap( wxScrolledWindow* sc, wxStaticBitmap* sb, wxString file ) { wxBitmap bmp( file, wxBITMAP_TYPE_JPEG ); int width = bmp.GetWidth(); @@ -367,12 +370,12 @@ wxImage img = bmp.ConvertToImage(); int ww, wh; - sb->GetSize( &ww, &wh ); + sc->GetSize( &ww, &wh ); - float w = ww; + float w = ww - 50; float h = w * height / width; sb->SetBitmap( wxBitmap( img.Scale( w, h, wxIMAGE_QUALITY_HIGH ) ) ); - //sb->SetScrollbars( 10, 10, w / 10, h / 10 ); + sc->SetScrollbars( 10, 10, w / 10, h / 10 ); for ( int i = 0; i < 5; i++ ) { w *= 1.1; @@ -383,12 +386,12 @@ void MainFrame::LoadBitmaps( void ) { - int no = 1; - LoadBitmap( m_staticBitmap1, wxString::Format( ".cache/%02d_1", no ) ); - LoadBitmap( m_staticBitmap2, wxString::Format( ".cache/%02d_2", no ) ); - LoadBitmap( m_staticBitmap3, wxString::Format( ".cache/%02d_3", no ) ); - LoadBitmap( m_staticBitmap4, wxString::Format( ".cache/%02d_4", no ) ); - LoadBitmap( m_staticBitmap5, wxString::Format( ".cache/%02d_5", no ) ); + int date = 0; + LoadBitmap( m_scrolledWindow1, m_staticBitmap1, wxString::Format( ".cache/%08d_1", date ) ); + LoadBitmap( m_scrolledWindow2, m_staticBitmap2, wxString::Format( ".cache/%08d_2", date ) ); + LoadBitmap( m_scrolledWindow3, m_staticBitmap3, wxString::Format( ".cache/%08d_3", date ) ); + LoadBitmap( m_scrolledWindow4, m_staticBitmap4, wxString::Format( ".cache/%08d_4", date ) ); + LoadBitmap( m_scrolledWindow5, m_staticBitmap5, wxString::Format( ".cache/%08d_5", date ) ); } void MainFrame::GetImage( wxString hhs, wxString no ) @@ -396,8 +399,9 @@ // http get } -void MainFrame::InDevelop( void ) +void MainFrame::InDevelop( bool flag ) { + if ( !flag ) return; LoadBitmaps(); m_slider->Enable( false ); @@ -406,7 +410,10 @@ m_buttonPrint->Enable( false ); m_buttonPrint->Show( false ); - m_button->Enable( false ); - m_button->Show( false ); + bool tb = false; + m_buttonTest->Enable( tb ); + m_buttonTest->Show( tb ); + + m_searchCtrl->Enable( false ); }