# HG changeset patch # User pyon@macmini # Date 1542018950 -32400 # Node ID 799b6008db8e74922ca2c20bcd63eda3b9208612 # Parent 36811fd22bd23fceefd3ec7c986f252e6ed07181 auto-upgrade. diff -r 36811fd22bd2 -r 799b6008db8e Makefile --- a/Makefile Thu Nov 08 19:15:43 2018 +0900 +++ b/Makefile Mon Nov 12 19:35:50 2018 +0900 @@ -1,5 +1,5 @@ # Makefile for wxWidgets Application -# Last Change: 2018-10-31 水 17:05:07. +# Last Change: 2018-11-09 金 08:45:49. # by Takayuki Mutoh # @@ -34,6 +34,7 @@ OBJ = $(OBJDIR)/main.o \ $(OBJDIR)/auth.o \ + $(OBJDIR)/mngdb.o \ $(OBJDIR)/rsearcher.o \ $(OBJDIR)/net.o @@ -64,6 +65,9 @@ $(OBJDIR)/net.o: net.cpp net.h $(CXX) -c $< -o $@ $(CXXFLAGS) +$(OBJDIR)/mngdb.o: mngdb.cpp mngdb.h id.h + $(CXX) -c $< -o $@ $(CXXFLAGS) + # for icon ifdef COMSPEC diff -r 36811fd22bd2 -r 799b6008db8e include/id.h --- a/include/id.h Thu Nov 08 19:15:43 2018 +0900 +++ b/include/id.h Mon Nov 12 19:35:50 2018 +0900 @@ -1,5 +1,5 @@ // Filename : id.h -// Last Change: 2018-11-08 木 13:58:34. +// Last Change: 2018-11-09 金 10:54:21. // #ifndef __ID_H__ @@ -7,8 +7,8 @@ #include -#define RSVER "1.4" -#define RSRELEASE "2018.11.01" +#define RSVER "1.5" +#define RSRELEASE "2018.11.12" enum { /* for mainframe */ @@ -33,6 +33,11 @@ /* for auth */ ID_UID, ID_PW, + + /* for mange db */ + ID_MNGBLD, + ID_MNGUPLD, + ID_MNGEXIT, }; #endif // __ID_H__ diff -r 36811fd22bd2 -r 799b6008db8e include/main.h --- a/include/main.h Thu Nov 08 19:15:43 2018 +0900 +++ b/include/main.h Mon Nov 12 19:35:50 2018 +0900 @@ -1,5 +1,5 @@ // Filename : main.h -// Last Change: 2018-11-01 木 11:13:19. +// Last Change: 2018-11-09 金 09:43:03. // #include #include @@ -7,7 +7,6 @@ #include #include #include -#include // private classes // Define a new application type, each program should derive a class from wxApp @@ -34,6 +33,7 @@ void InitSetting(); void SaveSetting(); + wxString GetVersion(); void SplashScreen( int ms ); void RemoveFile( wxString pattern ); }; diff -r 36811fd22bd2 -r 799b6008db8e include/mngdb.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/mngdb.h Mon Nov 12 19:35:50 2018 +0900 @@ -0,0 +1,53 @@ +// Filename : mngdb.h +// Last Change: 2018-11-09 金 09:02:17. +// + +#ifndef __MNGDB_H__ +#define __MNGDB_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class ManageDBFrame : public wxFrame +{ + DECLARE_EVENT_TABLE() + private: + wxString m_server; + + protected: + wxStaticText* m_staticTextDate; + wxDatePickerCtrl* m_datePicker; + wxStaticText* m_staticTextHhs; + wxFilePickerCtrl* m_filePickerHhs; + wxStaticText* m_staticTextCcn; + wxFilePickerCtrl* m_filePickerCcn; + wxStaticLine* m_staticline; + wxButton* m_buttonBuild; + wxButton* m_buttonUpld; + wxButton* m_buttonExit; + + public: + ManageDBFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCAPTION|wxTAB_TRAVERSAL ); + ~ManageDBFrame(); + + void OnBuild( wxCommandEvent& event ); + void OnUpload( wxCommandEvent& event ); + void OnExit( wxCommandEvent& event ); + + void Upload( wxString file ); + void ClearServer( void ); + void UpdateDB( void ); +}; + +#endif //__MNGDB_H__ + diff -r 36811fd22bd2 -r 799b6008db8e include/net.h --- a/include/net.h Thu Nov 08 19:15:43 2018 +0900 +++ b/include/net.h Mon Nov 12 19:35:50 2018 +0900 @@ -1,5 +1,5 @@ // Filename : net.h -// Last Change: 2018-11-08 譛ィ 10:09:04. +// Last Change: 2018-11-09 驥 09:31:59. // #ifndef __NET_H__ diff -r 36811fd22bd2 -r 799b6008db8e src/main.cpp --- a/src/main.cpp Thu Nov 08 19:15:43 2018 +0900 +++ b/src/main.cpp Mon Nov 12 19:35:50 2018 +0900 @@ -1,11 +1,14 @@ // Filename : main.cpp -// Last Change: 2018-11-01 譛ィ 11:39:22. +// Last Change: 2018-11-09 驥 11:54:20. // #include +#include +#include #include "id.h" #include "main.h" #include "auth.h" +#include "net.h" #include "rsearcher.h" IMPLEMENT_APP( MyApp ) @@ -24,10 +27,26 @@ { if ( !wxApp::OnInit() ) return false; + InitSetting(); + + // Check New-Version + wxString newver = GetVersion(); + if ( newver.Cmp( RSVER ) == 1 ) { // 1.9 -> 1.91 -> 1.92 ... + wxString sv = wxString::Format( wxT( "%s:%d" ), m_serveraddr, m_serverport ); + + wxArrayString args; + args.Add( wxT( "upgrade.bat" ) ); + args.Add( sv ); + args.Add( RSVER ); + args.Add( newver ); + + wxExecute( wxJoin( args, ' ', '\\' ) ); + return false; + } + wxImage::AddHandler( new wxJPEGHandler ); wxImage::AddHandler( new wxPNGHandler ); wxFileSystem::AddHandler( new wxZipFSHandler ); - InitSetting(); // Main Window MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); @@ -175,6 +194,28 @@ delete fs; } +wxString MyApp::GetVersion( void ) +{ + wxHTTP get; + get.SetTimeout( 30 ); + get.SetFlags( wxSOCKET_WAITALL|wxSOCKET_BLOCK ); + while ( !get.Connect( m_serveraddr, m_serverport ) ) + wxSleep( 1 ); + + wxString version; + wxString url = wxT( "/release/version" ); + wxInputStream *http_istream = get.GetInputStream( url ); + if ( get.GetError() == wxPROTO_NOERR ) { + wxStringOutputStream out_stream( &version ); + http_istream->Read( out_stream ); + } + + wxDELETE( http_istream ); + get.Close(); + + return version; +} + void MyApp::RemoveFile( wxString pattern ) { wxString file = wxFindFirstFile( pattern ); diff -r 36811fd22bd2 -r 799b6008db8e src/mngdb.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/mngdb.cpp Mon Nov 12 19:35:50 2018 +0900 @@ -0,0 +1,126 @@ +// Filename : mngdeb.cpp +// Last Change: 2018-11-09 驥 13:35:54. +// + +#include "id.h" +#include "mngdb.h" + +ManageDBFrame::ManageDBFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) + : wxFrame( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizerTop = new wxBoxSizer( wxVERTICAL ); + + wxFlexGridSizer* fgSizer = new wxFlexGridSizer( 0, 2, 0, 0 ); + fgSizer->SetFlexibleDirection( wxBOTH ); + fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticTextDate = new wxStaticText( this, wxID_ANY, wxT( "Date" ), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer->Add( m_staticTextDate, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_datePicker = new wxDatePickerCtrl( this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DROPDOWN|wxDP_SHOWCENTURY ); + fgSizer->Add( m_datePicker, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_staticTextHhs = new wxStaticText( this, wxID_ANY, wxT( "HHS" ), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer->Add( m_staticTextHhs, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 ); + + m_filePickerHhs = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT( "Select a file" ), wxT( "*.db" ), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_SMALL|wxFLP_USE_TEXTCTRL ); + fgSizer->Add( m_filePickerHhs, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_staticTextCcn = new wxStaticText( this, wxID_ANY, wxT( "CCN" ), wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer->Add( m_staticTextCcn, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_filePickerCcn = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, wxT( "Select a file" ), wxT( "*.db" ), wxDefaultPosition, wxDefaultSize, wxFLP_FILE_MUST_EXIST|wxFLP_OPEN|wxFLP_SMALL|wxFLP_USE_TEXTCTRL ); + fgSizer->Add( m_filePickerCcn, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizerTop->Add( fgSizer, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + + //--- + m_staticline = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizerTop->Add( m_staticline, 0, wxEXPAND|wxALL, 5 ); + + wxBoxSizer* bSizerBtn = new wxBoxSizer( wxHORIZONTAL ); + + m_buttonBuild = new wxButton( this, ID_MNGBLD, wxT( "Build" ), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerBtn->Add( m_buttonBuild, 0, wxALL, 5 ); + + m_buttonUpld = new wxButton( this, ID_MNGUPLD, wxT( "Upload" ), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerBtn->Add( m_buttonUpld, 0, wxALL, 5 ); + + m_buttonExit = new wxButton( this, ID_MNGEXIT, wxT( "Exit" ), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerBtn->Add( m_buttonExit, 0, wxALL, 5 ); + + bSizerTop->Add( bSizerBtn, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + + this->SetSizer( bSizerTop ); + this->Layout(); + + this->Centre( wxBOTH ); +} + +ManageDBFrame::~ManageDBFrame() +{ +} + +// Event Table +BEGIN_EVENT_TABLE( ManageDBFrame, wxFrame ) + EVT_BUTTON( ID_MNGBLD, ManageDBFrame::OnBuild ) + EVT_BUTTON( ID_MNGUPLD, ManageDBFrame::OnUpload ) + EVT_BUTTON( ID_MNGEXIT, ManageDBFrame::OnExit ) +END_EVENT_TABLE() + +// Event Handler +void ManageDBFrame::OnBuild( wxCommandEvent& WXUNUSED(event) ) +{ + wxMessageBox( wxT( "build done." ) ); +} + +void ManageDBFrame::OnUpload( wxCommandEvent& WXUNUSED(event) ) +{ + ClearServer(); + Upload( wxT( "index.db" ) ); + Upload( wxT( "hhs.db" ) ); + UpdateDB(); + wxMessageBox( wxT( "upload done." ) ); +} + +void ManageDBFrame::OnExit( wxCommandEvent& WXUNUSED(event) ) +{ + Close(); +} + + +// Functions +void ManageDBFrame::Upload( wxString file ) +{ + wxArrayString args; + args.Add( wxT( "client.exe" ) ); + args.Add( wxT( "-a" ) ); + args.Add( m_server ); + args.Add( file ); + + wxExecute( wxJoin( args, ' ', '\\' ) ); +} + +void ManageDBFrame::ClearServer( void ) +{ +// go-server get /clean -> rm -f upload/* + wxArrayString args; + args.Add( wxT( "client.exe" ) ); + args.Add( m_server ); + + wxExecute( wxJoin( args, ' ', '\\' ) ); +} + +void ManageDBFrame::UpdateDB( void ) +{ +// go-server get /mangedb -> mv upload/xxx db/index.db +// mv upload/yyy db/hhs.db + wxArrayString args; + args.Add( wxT( "client.exe" ) ); + args.Add( m_server ); + + wxExecute( wxJoin( args, ' ', '\\' ) ); +} + diff -r 36811fd22bd2 -r 799b6008db8e src/net.cpp --- a/src/net.cpp Thu Nov 08 19:15:43 2018 +0900 +++ b/src/net.cpp Mon Nov 12 19:35:50 2018 +0900 @@ -1,5 +1,5 @@ // Filename : net.cpp -// Last Change: 2018-11-08 譛ィ 10:08:45. +// Last Change: 2018-11-09 驥 09:32:56. // #include diff -r 36811fd22bd2 -r 799b6008db8e src/rsearcher.cpp --- a/src/rsearcher.cpp Thu Nov 08 19:15:43 2018 +0900 +++ b/src/rsearcher.cpp Mon Nov 12 19:35:50 2018 +0900 @@ -1,11 +1,12 @@ // Filename : rsearcher.cpp -// Last Change: 2018-11-08 譛ィ 14:47:21. +// Last Change: 2018-11-09 驥 09:01:40. // #include #include #include #include "id.h" +#include "mngdb.h" #include "rsearcher.h" #include "main.h" @@ -628,8 +629,9 @@ return; } - if ( cmd.IsSameAs( wxT( "k" ), true ) ) { - // hiragana kensaku + if ( cmd.IsSameAs( wxT( "3915" ), true ) ) { + ManageDBFrame *mngframe = new ManageDBFrame( this, wxID_ANY, wxT( "Management Window" ), wxDefaultPosition, wxSize( 300, 180 ), wxCAPTION|wxTAB_TRAVERSAL ); + mngframe->Show(); return; } diff -r 36811fd22bd2 -r 799b6008db8e upgrade.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/upgrade.bat Mon Nov 12 19:35:50 2018 +0900 @@ -0,0 +1,12 @@ +@echo off +echo === +echo === Your version is [%2] +echo === New version released. [%3] +echo === Downloading new version +echo ... +client.exe -r %1 +copy /y client1.exe client.exe +del client1.exe +echo === Download finished +echo ... +pause