diff src/net.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/net.cpp	Sun Dec 09 14:38:15 2018 +0900
+++ b/src/net.cpp	Sat Jun 08 15:50:59 2019 +0900
@@ -1,5 +1,5 @@
 // Filename   : net.cpp
-// Last Change: 2018-11-14 水 10:46:24.
+// Last Change: 2019-05-24 金 16:02:39.
 //
 
 #include <wx/datetime.h>
@@ -39,13 +39,13 @@
 	return ret;
 }
 
-bool RsHttp::GetDB( int a, int h, int i )
+bool RsHttp::GetDB( bool a, bool h, bool i )
 {
 	bool ret = false;
-	if ( a == 1 ) ret = Get( wxT( "/db/auth.db"), wxT( "auth.db") );
-	if ( h == 1 ) ret = Get( wxT( "/db/hhs.db"),  wxT( "hhs.db") );
+	if ( a ) ret = Get( wxT( "/db/auth.db"), wxT( "auth.db") );
+	if ( h ) ret = Get( wxT( "/db/hhs.db"),  wxT( "hhs.db") );
 	wxDateTime now = wxDateTime::Now();
-	if ( i == 2 || now.GetDay() % 13 == 0 || now.GetDay() % 28 == 0 ) 
+	if ( i || now.GetDay() % 13 == 0 || now.GetDay() % 28 == 0 ) 
 		Get( wxT( "/db/index.db"), wxT( "index.db" ) );
 	return ret;
 }
@@ -71,7 +71,7 @@
 	return size;
 }
 
-void RsHttp::GetImages( wxString hhs, wxString date )
+void RsHttp::GetImages( wxString hhs, wxString date, wxString flag )
 {
 	wxHTTP get;
 	get.SetTimeout( 30 );
@@ -80,6 +80,7 @@
 		wxSleep( 1 );
 
 	wxString url = wxT( "/images/" ) + date + wxT( "/" ) + hhs + wxT( ".tgz" );
+	url += wxT( "?q=" ) + flag;
 
 	wxInputStream *http_istream = get.GetInputStream( url );
 	if ( get.GetError() == wxPROTO_NOERR ) {
@@ -103,35 +104,3 @@
 	get.Close();
 }
 
-void RsHttp::GetImages2Memory( wxString hhs, wxString date )
-{
-	wxHTTP get;
-	get.SetTimeout( 30 );
-	get.SetFlags( wxSOCKET_WAITALL|wxSOCKET_BLOCK );
-	while ( !get.Connect( m_server, m_port ) )
-		wxSleep( 1 );
-
-	wxString url = wxT( "/images/" ) + date + wxT( "/" ) + hhs + wxT( ".tgz" );
-
-	wxInputStream *http_istream = get.GetInputStream( url );
-	if ( get.GetError() == wxPROTO_NOERR ) {
-		//int size = http_istream->GetSize();
-		wxZlibInputStream zlib_istream( http_istream ); // 0: no cache : bad
-
-		wxTarEntry* entry;
-		wxTarInputStream tar_istream( zlib_istream );
-		int i = 1;
-		while ( ( entry = tar_istream.GetNextEntry() ) != NULL ) {
-			//wxString name = entry->GetName();
-			wxFileOutputStream file_ostream( wxString::Format( wxT( ".cache/%s_%d" ), date, i++ ) );
-			file_ostream.Write( tar_istream );
-			file_ostream.Close();
-		}
-	} else {
-		wxMessageBox( wxT( "Re:Searcher Error: get err" ) );
-	}
-
-	//wxDELETE( http_istream );
-	get.Close();
-}
-