comparison src/main.cpp @ 10:36811fd22bd2

v1.4
author pyon@macmini
date Thu, 08 Nov 2018 19:15:43 +0900
parents ae89ce4793d8
children 799b6008db8e
comparison
equal deleted inserted replaced
9:ae89ce4793d8 10:36811fd22bd2
1 // Filename : main.cpp 1 // Filename : main.cpp
2 // Last Change: 2018-10-31 水 15:18:12. 2 // Last Change: 2018-11-01 木 11:39:22.
3 // 3 //
4 4
5 #include <wx/socket.h>
5 #include "id.h" 6 #include "id.h"
6 #include "main.h" 7 #include "main.h"
7 #include "auth.h" 8 #include "auth.h"
8 #include "rsearcher.h" 9 #include "rsearcher.h"
9 10
29 InitSetting(); 30 InitSetting();
30 31
31 // Main Window 32 // Main Window
32 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE ); 33 MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );
33 mainframe->SetServer( m_serveraddr, m_serverport ); 34 mainframe->SetServer( m_serveraddr, m_serverport );
35 mainframe->InDevelop( true );
34 if ( !mainframe->GetDB() ) { 36 if ( !mainframe->GetDB() ) {
35 mainframe->Destroy(); 37 mainframe->Destroy();
36 return true; 38 return true;
37 } 39 }
38 40
39 // Splash Screen 41 // Splash Screen
40 SplashScreen( splash ); 42 SplashScreen( splash );
41 43
42 // User Dialgo 44 // Mode
45 if ( !unlock_key.IsEmpty() ) {
46 wxIPV4address addr;
47 addr.Hostname( wxGetFullHostName() );
48
49 wxString key = wxT( "re:searcher" ) + addr.IPAddress();
50 wxArrayString args;
51 args.Add( wxT( "crypto.exe" ) );
52 args.Add( wxT( "-a" ) );
53 args.Add( key );
54
55 wxArrayString output, errors;
56 wxExecute( wxJoin( args, ' ', '\\' ), output, errors );
57
58 if ( unlock_key.IsSameAs( output[0] ) ) {
59 mainframe->SetUser( wxT( "root" ) );
60 mainframe->SetTitle( wxT( "Re:Searcher - root" ) );
61 mainframe->LoadDB();
62 mainframe->Show( true );
63 return true;
64 }
65 }
66
67 // User Dialog
43 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Who are you ?" ), wxDefaultPosition, wxDefaultSize, wxCAPTION ); 68 AuthDialog *authdlg = new AuthDialog( NULL, wxID_ANY, wxT( "Who are you ?" ), wxDefaultPosition, wxDefaultSize, wxCAPTION );
44 if ( !authdlg->LoadDB() ) { 69 if ( !authdlg->LoadDB() ) {
45 authdlg->Destroy(); 70 authdlg->Destroy();
46 return false; 71 return false;
47 } 72 }
67 } 92 }
68 93
69 mainframe->SetUser( authdlg->GetUser() ); 94 mainframe->SetUser( authdlg->GetUser() );
70 mainframe->SetTitle( wxT( "Re:Searcher - " ) + authdlg->GetUser() ); 95 mainframe->SetTitle( wxT( "Re:Searcher - " ) + authdlg->GetUser() );
71 mainframe->LoadDB(); 96 mainframe->LoadDB();
72 mainframe->InDevelop( true );
73 mainframe->Show( true ); 97 mainframe->Show( true );
74 } else { 98 } else {
75 mainframe->Destroy(); 99 mainframe->Destroy();
76 } 100 }
77 authdlg->Destroy(); 101 authdlg->Destroy();
112 m_serverport = 80; 136 m_serverport = 80;
113 } 137 }
114 138
115 config->SetPath( wxT( "/Misc" ) ); 139 config->SetPath( wxT( "/Misc" ) );
116 config->Read( wxT( "splash" ), &splash ); 140 config->Read( wxT( "splash" ), &splash );
141 config->Read( wxT( "unlock_key" ), &unlock_key );
117 142
118 delete config; 143 delete config;
119 } 144 }
120 145
121 void MyApp::SaveSetting() 146 void MyApp::SaveSetting()