diff src/net.cpp @ 9:ae89ce4793d8

add satellite-view.
author pyon@macmini
date Wed, 31 Oct 2018 20:10:29 +0900
parents 82f9af6aa7e4
children 36811fd22bd2
line wrap: on
line diff
--- a/src/net.cpp	Tue Oct 30 17:26:02 2018 +0900
+++ b/src/net.cpp	Wed Oct 31 20:10:29 2018 +0900
@@ -1,5 +1,5 @@
 // Filename   : net.cpp
-// Last Change: 2018-10-30 火 11:08:25.
+// Last Change: 2018-10-31 水 10:42:06.
 //
 
 #include <wx/datetime.h>
@@ -17,9 +17,11 @@
 {
 }
 
-void RsHttp::Get( wxString url, wxString file )
+bool RsHttp::Get( wxString url, wxString file )
 {
+	bool ret = false;
 	wxHTTP get;
+	get.SetFlags( wxSOCKET_WAITALL|wxSOCKET_BLOCK );
 	while ( !get.Connect( m_server, m_port ) )
 		wxSleep( 1 );
 
@@ -27,21 +29,25 @@
 	if ( get.GetError() == wxPROTO_NOERR ) {
 		wxFileOutputStream out_stream( file );
 		httpStream->Read( out_stream );
+		ret = true;
 	} else {
-		wxMessageBox( wxT( "Re:Searcher Error: get err" ) );
+		wxMessageBox( wxT( "Re:Searcher Error: cannot get data." ) );
 	}
 
 	wxDELETE( httpStream );
 	get.Close();
+	return ret;
 }
 
-void RsHttp::GetDB( void )
+bool RsHttp::GetDB( void )
 {
-	Get( wxT( "/db/auth.db"), wxT( "auth.db") );
-	Get( wxT( "/db/hhs.db"),  wxT( "hhs.db") );
+	bool ret = false;
+	ret = Get( wxT( "/db/auth.db"), wxT( "auth.db") );
+	ret = Get( wxT( "/db/hhs.db"),  wxT( "hhs.db") );
 	wxDateTime now = wxDateTime::Now();
 	if ( now.GetDay() % 14 == 0 ) 
 		Get( wxT( "/db/index.db"),  wxT( "index.db" ) );
+	return ret;
 }
 
 int RsHttp::GetImagesSize( wxString hhs, wxString date )
@@ -80,13 +86,6 @@
 		//int size = http_istream->GetSize();
 		wxZlibInputStream zlib_istream( http_istream ); // 0: no cache : bad
 
-		/*
-		wxMemoryOutputStream mm_ostream; 				// 1: ok
-		http_istream->Read( mm_ostream );
-		wxMemoryInputStream mm_istream( mm_ostream );
-		wxZlibInputStream zlib_istream( mm_istream );
-		*/
-
 		wxTarEntry* entry;
 		wxTarInputStream tar_istream( zlib_istream );
 		int i = 1;