0
|
1 // Filename : main.cpp
|
2
|
2 // Last Change: 2018-10-02 Tue 21:00:32.
|
0
|
3 //
|
|
4 #include "main.h"
|
|
5 #include "auth.h"
|
|
6 #include "rsearcher.h"
|
|
7
|
|
8 IMPLEMENT_APP( MyApp )
|
|
9
|
|
10 IMPLEMENT_CLASS( MyApp, wxApp )
|
|
11
|
|
12 MyApp::MyApp()
|
|
13 {
|
1
|
14 develop = true;
|
0
|
15 }
|
|
16 MyApp::~MyApp()
|
|
17 {
|
|
18 }
|
|
19
|
|
20 bool MyApp::OnInit()
|
|
21 {
|
|
22 if ( !wxApp::OnInit() ) return false;
|
|
23
|
|
24 wxImage::AddHandler( new wxJPEGHandler );
|
|
25 wxImage::AddHandler( new wxPNGHandler );
|
|
26 InitSetting();
|
|
27 GetData();
|
|
28
|
2
|
29 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize );
|
1
|
30 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxT( "Re:Searcher" ), wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );
|
2
|
31 mainframe->SetServer( m_server );
|
1
|
32
|
|
33 if ( develop ) {
|
|
34 authdlg->InDevelop( true );
|
|
35 mainframe->InDevelop( true );
|
|
36 }
|
|
37
|
0
|
38 authdlg->ShowModal();
|
|
39 authdlg->Destroy();
|
|
40
|
|
41 mainframe->Show( true );
|
|
42
|
|
43 return true;
|
|
44 }
|
|
45
|
|
46 int MyApp::OnExit()
|
|
47 {
|
|
48 SaveSetting();
|
|
49 return 0;
|
|
50 }
|
|
51
|
|
52 void MyApp::InitSetting()
|
|
53 {
|
2
|
54 conf_file = wxGetCwd() + wxFILE_SEP_PATH + wxT( "app.conf" );
|
|
55 config = new wxFileConfig( wxT( "MyApp" ), wxT( "T.Mutoh" ), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
56
|
|
57 config->SetPath( wxT( "/Geometry" ) );
|
|
58 config->Read( wxT( "x" ), &rect.x );
|
|
59 config->Read( wxT( "y" ), &rect.y );
|
|
60 config->Read( wxT( "w" ), &rect.width );
|
|
61 config->Read( wxT( "h" ), &rect.height );
|
0
|
62
|
2
|
63 config->SetPath( wxT( "/Server" ) );
|
|
64 config->Read( wxT( "server" ), &m_server );
|
|
65 config->Read( wxT( "proxy" ), &m_server );
|
0
|
66 delete config;
|
2
|
67
|
|
68 //m_server = wxT( "192.168.79.124:80" );
|
|
69 if ( m_server.IsSameAs( wxEmptyString, false ) )
|
|
70 m_server = wxT( "192.168.21.151:80" ); // nginx
|
0
|
71 }
|
|
72
|
|
73 void MyApp::SaveSetting()
|
|
74 {
|
|
75 config = new wxFileConfig( wxT("MyApp"), wxT("T.Mutoh"), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE );
|
|
76
|
|
77 config->SetPath( wxT("/Geometry") );
|
|
78 config->Write( wxT("x"), rect.x );
|
|
79 config->Write( wxT("y"), rect.y );
|
|
80 config->Write( wxT("w"), rect.width );
|
|
81 config->Write( wxT("h"), rect.height );
|
|
82 delete config;
|
|
83 }
|
|
84
|
|
85 void MyApp::GetData()
|
|
86 {
|
2
|
87 /*
|
0
|
88 // Go のプログラムを起動し,暗号化さた auth, hhs, index データを取得
|
2
|
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 );
|
0
|
99 }
|
|
100
|