Mercurial > mercurial > hgweb_rsearcher.cgi
comparison src/main.cpp @ 7:29829e98d510
add net.cpp
author | pyon@macmini |
---|---|
date | Fri, 26 Oct 2018 21:05:11 +0900 |
parents | 9a8b581c1993 |
children | ae89ce4793d8 |
comparison
equal
deleted
inserted
replaced
6:9a8b581c1993 | 7:29829e98d510 |
---|---|
1 // Filename : main.cpp | 1 // Filename : main.cpp |
2 // Last Change: 2018-10-23 火 10:09:42. | 2 // Last Change: 2018-10-26 金 13:14:54. |
3 // | 3 // |
4 #include "id.h" | 4 #include "id.h" |
5 #include "main.h" | 5 #include "main.h" |
6 #include "auth.h" | 6 #include "auth.h" |
7 #include "rsearcher.h" | 7 #include "rsearcher.h" |
24 | 24 |
25 wxImage::AddHandler( new wxJPEGHandler ); | 25 wxImage::AddHandler( new wxJPEGHandler ); |
26 wxImage::AddHandler( new wxPNGHandler ); | 26 wxImage::AddHandler( new wxPNGHandler ); |
27 InitSetting(); | 27 InitSetting(); |
28 | 28 |
29 // Login Dialog | 29 // Main Window |
30 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Who are you ?" ), wxDefaultPosition, wxDefaultSize, wxCAPTION ); | 30 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); |
31 authdlg->SetServer( m_server ); | 31 mainframe->SetServer( m_serveraddr, m_serverport ); |
32 authdlg->GetDB(); | 32 mainframe->GetDB(); |
33 | 33 |
34 // Splash Screen | 34 // Splash Screen |
35 wxFileSystem::AddHandler( new wxZipFSHandler ); | 35 wxFileSystem::AddHandler( new wxZipFSHandler ); |
36 wxFileSystem* fs = new wxFileSystem(); | 36 wxFileSystem* fs = new wxFileSystem(); |
37 wxString archive = wxT( "file:///./myapp.bin" ); | 37 wxString archive = wxT( "file:///./myapp.bin" ); |
39 wxFSFile* file = fs->OpenFile( archive + wxString::Format( wxT( "#zip:startup%02d.png" ), i ) ); | 39 wxFSFile* file = fs->OpenFile( archive + wxString::Format( wxT( "#zip:startup%02d.png" ), i ) ); |
40 if ( file ) { | 40 if ( file ) { |
41 wxInputStream* s = file->GetStream(); | 41 wxInputStream* s = file->GetStream(); |
42 wxImage image( *s, wxBITMAP_TYPE_PNG ); | 42 wxImage image( *s, wxBITMAP_TYPE_PNG ); |
43 wxBitmap bmp = wxBitmap( image ); | 43 wxBitmap bmp = wxBitmap( image ); |
44 wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 2500, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP ); | 44 wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 2000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP ); |
45 delete file; | 45 delete file; |
46 } | 46 } |
47 wxMilliSleep( 200 ); | 47 wxMilliSleep( 150 ); |
48 } | 48 } |
49 delete fs; | 49 delete fs; |
50 | 50 |
51 // User Dialgo | |
52 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Who are you ?" ), wxDefaultPosition, wxDefaultSize, wxCAPTION ); | |
51 if ( !authdlg->LoadDB() ) { | 53 if ( !authdlg->LoadDB() ) { |
52 authdlg->Destroy(); | 54 authdlg->Destroy(); |
53 return false; | 55 return false; |
54 } | 56 } |
55 | 57 |
70 delete file; | 72 delete file; |
71 } | 73 } |
72 delete fs; | 74 delete fs; |
73 } | 75 } |
74 | 76 |
75 // Main Window | 77 mainframe->SetUser( authdlg->GetUser() ); |
76 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); | 78 mainframe->SetTitle( wxT( "Re:Searcher - " ) + authdlg->GetUser() ); |
79 mainframe->LoadDB(); | |
77 mainframe->InDevelop( true ); | 80 mainframe->InDevelop( true ); |
78 mainframe->SetServer( m_server ); | |
79 mainframe->SetUser( authdlg->GetUser() ); | |
80 mainframe->LoadDB(); | |
81 mainframe->SetTitle( wxT( "Re:Searcher - " ) + authdlg->GetUser() ); | |
82 mainframe->Show( true ); | 81 mainframe->Show( true ); |
83 //mainframe->Destroy(); | 82 } else { |
83 mainframe->Destroy(); | |
84 } | 84 } |
85 authdlg->Destroy(); | 85 authdlg->Destroy(); |
86 | 86 |
87 return true; | 87 return true; |
88 } | 88 } |
105 config->Read( wxT( "x" ), &rect.x ); | 105 config->Read( wxT( "x" ), &rect.x ); |
106 config->Read( wxT( "y" ), &rect.y ); | 106 config->Read( wxT( "y" ), &rect.y ); |
107 config->Read( wxT( "w" ), &rect.width ); | 107 config->Read( wxT( "w" ), &rect.width ); |
108 config->Read( wxT( "h" ), &rect.height ); | 108 config->Read( wxT( "h" ), &rect.height ); |
109 | 109 |
110 wxString proxy; | |
111 config->SetPath( wxT( "/Server" ) ); | 110 config->SetPath( wxT( "/Server" ) ); |
112 config->Read( wxT( "server" ), &m_server ); | 111 config->Read( wxT( "proxy_address" ), &m_serveraddr ); |
113 config->Read( wxT( "proxy" ), &proxy ); | 112 config->Read( wxT( "proxy_port" ), &m_serverport ); |
113 if ( m_serveraddr.IsSameAs( wxEmptyString, false ) ) { | |
114 config->Read( wxT( "address" ), &m_serveraddr ); | |
115 config->Read( wxT( "port" ), &m_serverport ); | |
116 } | |
114 delete config; | 117 delete config; |
115 | 118 |
116 if ( !proxy.IsSameAs( wxEmptyString, false ) ) m_server = proxy; | 119 if ( m_serveraddr.IsSameAs( wxEmptyString, false ) ) { |
117 //m_server = wxT( "192.168.79.124:80" ); | 120 m_serveraddr = wxT( "192.168.21.151" ); // nginx |
118 if ( m_server.IsSameAs( wxEmptyString, false ) ) | 121 m_serverport = 80; |
119 m_server = wxT( "192.168.21.151:80" ); // nginx | 122 } |
120 } | 123 } |
121 | 124 |
122 void MyApp::SaveSetting() | 125 void MyApp::SaveSetting() |
123 { | 126 { |
124 config = new wxFileConfig( wxT( "MyApp" ), wxT( "T.Mutoh" ), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); | 127 config = new wxFileConfig( wxT( "MyApp" ), wxT( "T.Mutoh" ), conf_file, wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); |