comparison src/main.cpp @ 3:db4813125eb8

many changes.
author pyon@macmini
date Thu, 11 Oct 2018 22:11:09 +0900
parents 7fe3417cefc8
children 06342fc544e4
comparison
equal deleted inserted replaced
2:7fe3417cefc8 3:db4813125eb8
1 // Filename : main.cpp 1 // Filename : main.cpp
2 // Last Change: 2018-10-02 Tue 21:00:32. 2 // Last Change: 2018-10-11 木 16:52:40.
3 // 3 //
4 #include "main.h" 4 #include "main.h"
5 #include "auth.h" 5 #include "auth.h"
6 #include "rsearcher.h" 6 #include "rsearcher.h"
7 7
22 if ( !wxApp::OnInit() ) return false; 22 if ( !wxApp::OnInit() ) return false;
23 23
24 wxImage::AddHandler( new wxJPEGHandler ); 24 wxImage::AddHandler( new wxJPEGHandler );
25 wxImage::AddHandler( new wxPNGHandler ); 25 wxImage::AddHandler( new wxPNGHandler );
26 InitSetting(); 26 InitSetting();
27 GetData();
28 27
29 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize ); 28 wxBitmap bmp;
29 if ( bmp.LoadFile( "./image/startup.png", wxBITMAP_TYPE_PNG ) ){
30 wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 4000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP );
31 }
32
33 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Check User" ), wxDefaultPosition, wxDefaultSize, wxCAPTION );
34 authdlg->SetServer( m_server );
35
30 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); 36 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );
31 mainframe->SetServer( m_server ); 37 mainframe->SetServer( m_server );
32 38
33 if ( develop ) { 39 if ( develop ) {
34 authdlg->InDevelop( true ); 40 authdlg->InDevelop( true );
35 mainframe->InDevelop( true ); 41 mainframe->InDevelop( true );
36 } 42 }
37 43
38 authdlg->ShowModal(); 44 if ( authdlg->ShowModal() == wxID_OK ) {
39 authdlg->Destroy(); 45 mainframe->SetUser( authdlg->GetUser() );
40 46 mainframe->Show( true );
41 mainframe->Show( true ); 47 } else {
48 mainframe->Destroy();
49 }
50 authdlg->Destroy();
42 51
43 return true; 52 return true;
44 } 53 }
45 54
46 int MyApp::OnExit() 55 int MyApp::OnExit()
58 config->Read( wxT( "x" ), &rect.x ); 67 config->Read( wxT( "x" ), &rect.x );
59 config->Read( wxT( "y" ), &rect.y ); 68 config->Read( wxT( "y" ), &rect.y );
60 config->Read( wxT( "w" ), &rect.width ); 69 config->Read( wxT( "w" ), &rect.width );
61 config->Read( wxT( "h" ), &rect.height ); 70 config->Read( wxT( "h" ), &rect.height );
62 71
72 wxString proxy;
63 config->SetPath( wxT( "/Server" ) ); 73 config->SetPath( wxT( "/Server" ) );
64 config->Read( wxT( "server" ), &m_server ); 74 config->Read( wxT( "server" ), &m_server );
65 config->Read( wxT( "proxy" ), &m_server ); 75 config->Read( wxT( "proxy" ), &proxy );
66 delete config; 76 delete config;
67 77
78 if ( !proxy.IsSameAs( wxEmptyString, false ) ) m_server = proxy;
68 //m_server = wxT( "192.168.79.124:80" ); 79 //m_server = wxT( "192.168.79.124:80" );
69 if ( m_server.IsSameAs( wxEmptyString, false ) ) 80 if ( m_server.IsSameAs( wxEmptyString, false ) )
70 m_server = wxT( "192.168.21.151:80" ); // nginx 81 m_server = wxT( "192.168.21.151:80" ); // nginx
71 } 82 }
72 83
73 void MyApp::SaveSetting() 84 void MyApp::SaveSetting()
74 { 85 {
75 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); 86 config = new wxFileConfig( wxT( "MyApp" ), wxT( "T.Mutoh" ), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
76 87
77 config->SetPath( wxT("/Geometry") ); 88 config->SetPath( wxT( "/Geometry" ) );
78 config->Write( wxT("x"), rect.x ); 89 config->Write( wxT( "x" ), rect.x );
79 config->Write( wxT("y"), rect.y ); 90 config->Write( wxT( "y" ), rect.y );
80 config->Write( wxT("w"), rect.width ); 91 config->Write( wxT( "w" ), rect.width );
81 config->Write( wxT("h"), rect.height ); 92 config->Write( wxT( "h" ), rect.height );
82 delete config; 93 delete config;
83 } 94 }
84 95
85 void MyApp::GetData()
86 {
87 /*
88 // Go のプログラムを起動し,暗号化さた auth, hhs, index データを取得
89 wxArrayString output, errors;
90 wxString cmd = wxT( "./client.exe -u " ) + m_server;
91 wxExecute( cmd, output, errors, wxEXEC_SYNC, NULL ); // ok
92 */
93 wxArrayString args; // http get
94 args.Add( wxT( "client.exe -u" ) );
95 args.Add( m_server );
96
97 //wxMessageBox( wxJoin( args, ' ', '\\' ) );
98 wxExecute( wxJoin( args, ' ', '\\' ), wxEXEC_ASYNC|wxEXEC_HIDE_CONSOLE );
99 }
100