diff src/main.cpp @ 15:c262e17de9b1

db download skip-mode.
author pyon@macmini
date Sat, 08 Jun 2019 15:50:59 +0900
parents f5ffc34f045a
children
line wrap: on
line diff
--- a/src/main.cpp	Sun Dec 09 14:38:15 2018 +0900
+++ b/src/main.cpp	Sat Jun 08 15:50:59 2019 +0900
@@ -1,5 +1,5 @@
 // Filename   : main.cpp
-// Last Change: 2018-11-14 水 12:54:16.
+// Last Change: 2019-05-29 水 15:04:09.
 //
 
 #include <wx/socket.h>
@@ -44,25 +44,9 @@
 		return false;
 	}
 
-    wxImage::AddHandler( new wxJPEGHandler );
-    wxImage::AddHandler( new wxPNGHandler  );
-	wxFileSystem::AddHandler( new wxZipFSHandler );
-
-	// Main Window
-	MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );
-	mainframe->SetServer( m_serveraddr, m_serverport );
-	mainframe->SetDBdir( m_dbdir );
-	mainframe->InDevelop( true );
-	if ( !mainframe->GetDB( 1, 1, 1 ) ) {
-		mainframe->Destroy();
-		return true;
-	}
-
-	// Splash Screen
-	SplashScreen( splash );
-
-	// Mode
-	if ( !unlock_key.IsEmpty() ) {
+	// Validation Host
+	bool valid_host = false;
+	if ( !m_unlock_key.IsEmpty() ) {
 		wxIPV4address addr;
 		addr.Hostname( wxGetFullHostName() );
 
@@ -75,13 +59,42 @@
 		wxArrayString output, errors;
 		wxExecute( wxJoin( args, ' ', '\\' ), output, errors );
 
-		if ( unlock_key.IsSameAs( output[0] ) ) {
-			mainframe->SetUser( wxT( "root" ) );
-			mainframe->SetTitle( wxT( "Re:Searcher - root" ) );
-			mainframe->LoadDB();
-			mainframe->Show( true );
-			return true;
-		}
+		if ( m_unlock_key.IsSameAs( output[0] ) ) valid_host = true;
+	}
+
+    wxImage::AddHandler( new wxJPEGHandler );
+    wxImage::AddHandler( new wxPNGHandler  );
+	wxFileSystem::AddHandler( new wxZipFSHandler );
+
+	// Main Window
+	MainFrame *mainframe = new MainFrame( NULL, ID_MAIN, wxEmptyString, wxPoint( rect.x, rect.y ), rect.GetSize(), wxDEFAULT_FRAME_STYLE );
+	mainframe->SetServer( m_serveraddr, m_serverport );
+	mainframe->SetDBdir( m_dbdir );
+	mainframe->InDevelop( true );
+
+	bool dlhhs = false;
+	if ( valid_host && !m_qdlhhs ) {
+		dlhhs = true;
+	} else {
+		wxMessageDialog dlg( NULL, wxT("download h-data ?"), wxT("Ask"), wxYES_NO );
+		if ( wxID_YES == dlg.ShowModal() ) dlhhs = true;
+	}
+
+	if ( !mainframe->GetDB( true, dlhhs, false ) ) {
+		mainframe->Destroy();
+		return true;
+	}
+
+	// Splash Screen
+	SplashScreen( m_splash );
+
+	if ( valid_host ) {
+		mainframe->SetUser( wxT( "root" ) );
+		mainframe->SetTitle( wxT( "Re:Searcher - root" ) );
+		mainframe->LoadDB( dlhhs );
+		mainframe->Show( true );
+		mainframe->Raise();
+		return true;
 	}
 
 	// User Dialog
@@ -113,7 +126,7 @@
 
 		mainframe->SetUser( authdlg->GetUser() );
 		mainframe->SetTitle( wxT( "Re:Searcher - " ) + authdlg->GetUser() );
-		mainframe->LoadDB();
+		mainframe->LoadDB( dlhhs );
 		mainframe->Show( true );
 	} else {
 		mainframe->Destroy();
@@ -148,6 +161,7 @@
 
     config->SetPath( wxT( "/DBManage" ) );
     config->Read( wxT( "dbdir" ), &m_dbdir );
+    config->Read( wxT( "qdlhhs" ), &m_qdlhhs );
 
     config->SetPath( wxT( "/Server" ) );
     config->Read( wxT( "proxy_address" ), &m_serveraddr );
@@ -162,9 +176,12 @@
         m_serverport = 80;
 	}
 
+    config->SetPath( wxT( "/Print" ) );
+    config->Read( wxT( "zoom" ), &pzoom );
+
     config->SetPath( wxT( "/Misc" ) );
-    config->Read( wxT( "splash" ), &splash );
-    config->Read( wxT( "unlock_key" ), &unlock_key );
+    config->Read( wxT( "splash" ), &m_splash );
+    config->Read( wxT( "unlock_key" ), &m_unlock_key );
 
     delete config;
 }
@@ -178,6 +195,10 @@
     config->Write( wxT( "y" ), rect.y );
     config->Write( wxT( "w" ), rect.width );
     config->Write( wxT( "h" ), rect.height );
+
+    config->SetPath( wxT( "/Print" ) );
+    config->Write( wxT( "zoom" ), pzoom );
+
     delete config;
 }
 
@@ -193,7 +214,7 @@
 			wxInputStream* s = file->GetStream();
 			wxImage image( *s, wxBITMAP_TYPE_PNG );
 			wxBitmap bmp = wxBitmap( image );
-			wxSplashScreen* splash = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 2000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP );
+			wxSplashScreen* splashwin = new wxSplashScreen( bmp, wxSPLASH_CENTRE_ON_SCREEN|wxSPLASH_TIMEOUT, 2000, NULL, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxSTAY_ON_TOP );
 			delete file;
 		}
 		wxMilliSleep( ms );