# HG changeset patch # User pyon@macmini # Date 1539601658 -32400 # Node ID 06342fc544e4aa39633d1a644bba17d0d44b6566 # Parent db4813125eb80a92356213ed49f8ba03db4c264f mouse gesture. diff -r db4813125eb8 -r 06342fc544e4 doc/Todo --- a/doc/Todo Thu Oct 11 22:11:09 2018 +0900 +++ b/doc/Todo Mon Oct 15 20:07:38 2018 +0900 @@ -3,7 +3,7 @@ * verup.bat をダブルクリック # verup.bat client -r 192.168.0.1:3910 - # GET /release/grsearcher.exe, /release/client1.exe + # GET /release/grsearcher.exe, /release/crypto.exe, /release/client1.exe copy client1.exe client.exe * 毎回 clientで auth.db と hhs.db を取得 @@ -11,12 +11,19 @@ # GET /db/auth.db, /db/hhs.db, /db/index.db (10day) + GUI(grsearcher) 終了時に auth.db と hhs.db は削除 * auth.db は任意の、hhs.db は月一のアップデートだが、漏洩防止のため毎回削除 - * 毎月10のつく日に index.db を取得 + * 毎月14日と28日に index.db を取得 * client で画像取得 > client.exe 192.168.0.1:3910 0800012345 20170105 # date:00000000 で最新審査会を取得する構想は廃止 +* client でアップロード + > client.exe -a 192.168.0.1:3910 localfile + +* バージョンアップ + + パスワード機能を追加 ( ver1.11 ) + + ヘッダ拒否機能を追加 ( ver1.2 ) + ** crypto/crypto.exe の機能 ***************************************************** * crypto.go 作成 + auth 用 ( ハッシュ化 ) @@ -26,7 +33,7 @@ > crypto.exe -b auth.csv -s salt > auth.db * -c で 認証チェック # gui > crypto.exe -c auth.db -s salt user passwd - + user/passwd が一致したら "valid user を表示し "39 を返す + + user/passwd が一致したら "valid user" を表示し、"39" を返す + 認証なしのテストのときは user/passwd: test/test + auth.db のための salt は gui に内蔵する + hhs 用 ( 双方向、キーは crypto.go と gui に内蔵 ) @@ -42,15 +49,18 @@ ** server の機能 **************************************************************** * 単なる web-server - + upload 機能を追加 ( ver1.1 ) - + log 機能を追加 ( ver1.2 ) - + log 機能を強化(user-id) ( ver1.3 ) +* バージョンアップ + + ヘッダ拒否機能を追加 ( ver1.2 ) + + log 機能を追加 ( ver1.3 ) + + log 機能を強化(user-id) ( ver1.4 ) ** grsearcher の機能 **************************************************************** - * 10分間 Idle なら password - * mouse gesture 次、前のタブへ - * dark-mode の搭載 - * プライベートフォルダに写真 userid/startup.jpg, default.jpg, avatar.jpg +* バージョンアップ + + client に pw + + 10分間 Idle なら password + + mouse gesture 次、前のタブへ + + dark-mode の搭載 + + プライベートフォルダに写真 userid/startup.jpg, default.jpg, avatar.jpg ** その他 *********************************************************************** * IP Address @@ -70,7 +80,7 @@ * client ( Windows ) rsearcher_root/grsearcher.exe, client.exe, crypto.exe auth.db, hhs.db, index.db - + .cache/20180707_1.jpg, ... + + .cache/20180707_1, ... + image/*.png, *.jpg __DONE__ diff -r db4813125eb8 -r 06342fc544e4 go/client.go --- a/go/client.go Thu Oct 11 22:11:09 2018 +0900 +++ b/go/client.go Mon Oct 15 20:07:38 2018 +0900 @@ -1,7 +1,7 @@ /* client.go : client-program. - Version : 1.0a - Last Change: 2018-10-03 豌エ 13:44:11. + Version : 1.1 + Last Change: 2018-10-12 驥 13:42:55. install to: rsearcher_root/ @@ -14,7 +14,7 @@ + index.db ( 10 days ) + image/*.png, *.jpg + doc/ - + .cache/*.jpg ( temporary ) + + .cache/* ( temporary ) $ client.exe -r 192.168.0.1:3910 # get new release $ client.exe -u 192.168.0.1:3910 # get new dbs @@ -38,14 +38,55 @@ "time" ) +var version string + +func init() { + version = "1.1" +} + func main() { var upgrade = flag.Bool( "r", false, "" ) // get grsearcher.exe, client.exe - var update = flag.Bool( "u", false, "" ) // get auth.db, hhs.db, index.db(5day) + var update = flag.Bool( "u", false, "" ) // get auth.db, hhs.db, index.db(14,28) + var upload = flag.Bool( "a", false, "" ) // post somefile + var printver = flag.Bool( "v", false, "" ) // print version flag.Parse() + // print version + if *printver { + fmt.Println( "client ( version ", version, ")" ) + os.Exit( 0 ) + } + + // upload + if *upload { + if flag.NArg() != 2 { + fmt.Fprintf( os.Stderr, "bad host or file.\n" ) + os.Exit( 1 ) + } + host := flag.Args()[0] + file := flag.Args()[1] + fmt.Printf( "Sending %s...", file ) + f, err := os.Open( file ) + if err != nil { + log.Fatal( err ) + } + defer f.Close() + + res, err := http.Post( "http://" + host + "/upload", "binary/octet-stream", f ) + if err != nil { + log.Fatal( err ) + } + defer res.Body.Close() + message, _ := ioutil.ReadAll( res.Body ) + fmt.Println( string( message ) ) + + os.Exit( 0 ) + } + + // software upgrade if *upgrade { if flag.NArg() != 1 { - fmt.Fprintf( os.Stderr, "no remote host.\n" ) + fmt.Fprintf( os.Stderr, "bad remote host.\n" ) os.Exit( 1 ) } fmt.Print( "Getting grsearcher.exe..." ) @@ -53,6 +94,10 @@ if _, err := get_file( host, "/release/grsearcher.exe", "grsearcher.exe" ); err != nil { log.Fatal( err ) } + fmt.Print( "Getting crypto.exe..." ) + if _, err := get_file( host, "/release/crypto.exe", "crypto.exe" ); err != nil { + log.Fatal( err ) + } fmt.Print( "Getting client.exe..." ) if _, err := get_file( host, "/release/client.exe", "client1.exe" ); err != nil { log.Fatal( err ) @@ -60,9 +105,10 @@ os.Exit( 0 ) } + // database update if *update { if flag.NArg() != 1 { - fmt.Fprintf( os.Stderr, "no remote host.\n" ) + fmt.Fprintf( os.Stderr, "bad remote host.\n" ) os.Exit( 1 ) } fmt.Print( "Getting auth.db..." ) @@ -75,7 +121,7 @@ log.Fatal( err ) } - if time.Now().Day() % 10 == 0 { + if time.Now().Day() % 14 == 0 { fmt.Print( "Getting index.db..." ) if _, err := get_file( host, "/db/index.db", "index.db" ); err != nil { log.Fatal( err ) @@ -84,7 +130,7 @@ os.Exit( 0 ) } - // main + // main : image download if flag.NArg() != 3 { fmt.Fprintf( os.Stderr, "bad argument.\n" ) os.Exit( 1 ) @@ -159,7 +205,6 @@ } //f, _ := os.Create( hdr.Name ) fn := fmt.Sprintf( "%s_%d", d, i ) // 1.0a - //fn = fmt.Sprintf( "00000000_%d", i ) // for test fn = filepath.Join( ".cache", fn ) f, _ := os.Create( fn ) diff -r db4813125eb8 -r 06342fc544e4 go/server.go --- a/go/server.go Thu Oct 11 22:11:09 2018 +0900 +++ b/go/server.go Mon Oct 15 20:07:38 2018 +0900 @@ -1,7 +1,7 @@ /* server.go : server-program. - Version : 1.0 - Last Change: 2018-10-03 豌エ 10:22:04. + Version : 1.1 + Last Change: 2018-10-12 驥 14:37:48. install to: server_root/ @@ -26,10 +26,12 @@ var server string var port string var server_root string +var version string func init() { port = ":3910" server_root = filepath.Dir( os.Args[0] ) + version = "1.1" } func main() { @@ -48,8 +50,9 @@ } // start Web-server - fmt.Println( "server start [", server, "]" ) - http.HandleFunc( "/", handler ) + fmt.Println( "server start [", server, "] ( program version", version, ")" ) + http.HandleFunc( "/", handler ) + http.HandleFunc( "/upload", upload_handler ) log.Fatal( http.ListenAndServe( server, nil ) ) } @@ -64,3 +67,22 @@ defer f.Close() io.Copy( w, f ) } + +func upload_handler( w http.ResponseWriter, r *http.Request ) { + fmt.Println( "[access]", r.RemoteAddr, "|", time.Now().Format( "2006-01-02 15:04" ), "|", "/upload" ) + now := time.Now().Format( "20060102_150405" ) + file := filepath.Join( server_root, "upload", now ) + f, err := os.Create( file ) + if err != nil { + http.NotFound( w, r ) + return + } + n, err := io.Copy( f, r.Body ) + if err != nil { + http.NotFound( w, r ) + return + } + f.Close() + w.Write( []byte( fmt.Sprintf( "%d bytes are recieved.\n", n ) ) ) +} + diff -r db4813125eb8 -r 06342fc544e4 image/hw201810.jpg Binary file image/hw201810.jpg has changed diff -r db4813125eb8 -r 06342fc544e4 image/startup.png Binary file image/startup.png has changed diff -r db4813125eb8 -r 06342fc544e4 include/id.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/id.h Mon Oct 15 20:07:38 2018 +0900 @@ -0,0 +1,22 @@ +// Filename : id.h +// Last Change: 2018-10-12 金 16:19:50. +// + +#ifndef __ID_H__ +#define __ID_H__ + +#include + +enum { + ID_MAIN = wxID_HIGHEST + 1, + ID_SEARCH, + ID_LIST, + ID_NBOOK, + ID_SLDR, + ID_TIMER, + ID_LOGOUT, + ID_TEST, +}; + +#endif // __ID_H__ + diff -r db4813125eb8 -r 06342fc544e4 include/main.h --- a/include/main.h Thu Oct 11 22:11:09 2018 +0900 +++ b/include/main.h Mon Oct 15 20:07:38 2018 +0900 @@ -1,15 +1,11 @@ // Filename : main.h -// Last Change: 2018-10-03 水 18:11:51. +// Last Change: 2018-10-12 金 16:16:45. // #include #include #include #include -enum { - ID_MAIN = wxID_HIGHEST + 1, -}; - // private classes // Define a new application type, each program should derive a class from wxApp class MyApp : public wxApp diff -r db4813125eb8 -r 06342fc544e4 include/rsearcher.h --- a/include/rsearcher.h Thu Oct 11 22:11:09 2018 +0900 +++ b/include/rsearcher.h Mon Oct 15 20:07:38 2018 +0900 @@ -1,5 +1,5 @@ // Filename : rsearcher.h -// Last Change: 2018-10-11 木 18:29:13. +// Last Change: 2018-10-12 金 16:16:26. // #ifndef __RSEARCH_H__ @@ -48,6 +48,7 @@ int m_zoom = 0; wxBitmap m_bmp[5]; wxScrolledWindow* m_parent; + int select_tab = 0; public: MyStaticBitmap( wxScrolledWindow *parent, wxWindowID id, const wxBitmap &label, const wxPoint &pos, const wxSize &size, long style, const wxString &name ); @@ -61,6 +62,7 @@ void OnWheel( wxMouseEvent& event ); void SetImage( int i, wxBitmap bmp ) { m_bmp[i] = bmp; }; void SetZoom( int m_zoom ); + void ChangeBook( int i ); }; class MainFrame : public wxFrame @@ -75,16 +77,6 @@ wxTimer m_timer; protected: - enum { - ID_SEARCH = wxID_HIGHEST + 100, - ID_LIST, - ID_NBOOK, - ID_SLDR, - ID_TIMER, - ID_LOGOUT, - ID_TEST, - }; - MySearchCtrl* m_searchCtrl; MyStaticBitmap* m_staticBitmap1; MyStaticBitmap* m_staticBitmap2; @@ -140,6 +132,5 @@ void OnTestButton( wxCommandEvent& event ); }; - #endif // __RSEARCH_H__ diff -r db4813125eb8 -r 06342fc544e4 src/auth.cpp --- a/src/auth.cpp Thu Oct 11 22:11:09 2018 +0900 +++ b/src/auth.cpp Mon Oct 15 20:07:38 2018 +0900 @@ -1,7 +1,8 @@ // Filename : auth.cpp -// Last Change: 2018-10-11 譛ィ 16:47:30. +// Last Change: 2018-10-12 驥 16:17:32. // +#include "id.h" #include "auth.h" AuthDialog::AuthDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) @@ -157,6 +158,7 @@ void AuthDialog::InDevelop( bool flag ) { + return; if ( !flag ) return; m_textCtrlId->SetValue( "test" ); m_textCtrlPw->SetValue( "test" ); diff -r db4813125eb8 -r 06342fc544e4 src/main.cpp --- a/src/main.cpp Thu Oct 11 22:11:09 2018 +0900 +++ b/src/main.cpp Mon Oct 15 20:07:38 2018 +0900 @@ -1,6 +1,7 @@ // Filename : main.cpp -// Last Change: 2018-10-11 譛ィ 16:52:40. +// Last Change: 2018-10-12 驥 16:17:39. // +#include "id.h" #include "main.h" #include "auth.h" #include "rsearcher.h" @@ -26,7 +27,7 @@ InitSetting(); wxBitmap bmp; - if ( bmp.LoadFile( "./image/startup.png", wxBITMAP_TYPE_PNG ) ){ + if ( bmp.LoadFile( wxT( "./image/startup.png" ), wxBITMAP_TYPE_PNG ) ){ wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 4000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP ); } diff -r db4813125eb8 -r 06342fc544e4 src/rsearcher.cpp --- a/src/rsearcher.cpp Thu Oct 11 22:11:09 2018 +0900 +++ b/src/rsearcher.cpp Mon Oct 15 20:07:38 2018 +0900 @@ -1,9 +1,10 @@ // Filename : rsearcher.cpp -// Last Change: 2018-10-11 木 18:28:07. +// Last Change: 2018-10-12 金 16:40:12. // #include #include +#include "id.h" #include "rsearcher.h" #include "main.h" @@ -93,7 +94,6 @@ Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( OnStartRGesture ), NULL, this ); Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( OnEndRGesture ), NULL, this ); - } // Event Handlers @@ -164,21 +164,37 @@ float pi = 3.14159; // to right - if ( rad < pi/8 && dx > 0 ) { - wxMessageBox("right"); + if ( rad < pi / 8 && dx > 0 ) { + ChangeBook( 1 ); } // to left - else if ( rad > pi/8*7 && rad < pi && dx < 0 ) { - wxMessageBox("left"); + else if ( rad > pi / 8 * 7 && rad < pi && dx < 0 ) { + ChangeBook( -1 ); } // to up-right - else if ( rad > pi/8 && rad < pi/8*3 && dx > 0 ) { - wxMessageBox("right-up"); - //Close(); + else if ( rad > pi / 8 && rad < pi / 8 * 3 && dx > 0 ) { } + // down + else if ( rad > pi / 8 * 3 && rad < pi / 8 * 5 && dy > 0 ) { + MainFrame* mf = (MainFrame*)FindWindowById( ID_MAIN ); + mf->PrintImages(); + } + //wxMessageBox( wxString::Format( "%d %d %f", dx, dy, rad )); } // Functions +void MyStaticBitmap::ChangeBook( int i ) +{ + wxNotebook* nb = (wxNotebook*)FindWindowById( ID_NBOOK ); + int n = nb->GetSelection(); + if ( i > 0 ) { + if ( n == nb->GetPageCount() - 1 ) return; + nb->SetSelection( ++n ); + } else { + if ( n == 0 ) return; + nb->SetSelection( --n ); + } +} /********************/ /** Main Frame **/ @@ -527,6 +543,10 @@ void MainFrame::PrintImages( void ) { int r = m_dataViewListCtrl->GetSelectedRow(); + if ( r == wxNOT_FOUND ) { + wxMessageBox( wxT( "Not Ready for Print !!" ) ); + return; + } wxString ready = m_dataViewListCtrl->GetTextValue( r, 2 ); if ( !ready.IsSameAs( wxT( "OK" ), true ) ) { @@ -585,6 +605,8 @@ m_buttonTest->Enable( tb ); m_buttonTest->Show( tb ); + return; + // search m_searchCtrl->SetValue( wxT( "0100122642" ) ); }