Mercurial > mercurial > hgweb_rsearcher.cgi
comparison src/net.cpp @ 9:ae89ce4793d8
add satellite-view.
author | pyon@macmini |
---|---|
date | Wed, 31 Oct 2018 20:10:29 +0900 |
parents | 82f9af6aa7e4 |
children | 36811fd22bd2 |
comparison
equal
deleted
inserted
replaced
8:82f9af6aa7e4 | 9:ae89ce4793d8 |
---|---|
1 // Filename : net.cpp | 1 // Filename : net.cpp |
2 // Last Change: 2018-10-30 火 11:08:25. | 2 // Last Change: 2018-10-31 水 10:42:06. |
3 // | 3 // |
4 | 4 |
5 #include <wx/datetime.h> | 5 #include <wx/datetime.h> |
6 #include <wx/stream.h> | 6 #include <wx/stream.h> |
7 #include <wx/zstream.h> | 7 #include <wx/zstream.h> |
15 | 15 |
16 RsHttp::~RsHttp() | 16 RsHttp::~RsHttp() |
17 { | 17 { |
18 } | 18 } |
19 | 19 |
20 void RsHttp::Get( wxString url, wxString file ) | 20 bool RsHttp::Get( wxString url, wxString file ) |
21 { | 21 { |
22 bool ret = false; | |
22 wxHTTP get; | 23 wxHTTP get; |
24 get.SetFlags( wxSOCKET_WAITALL|wxSOCKET_BLOCK ); | |
23 while ( !get.Connect( m_server, m_port ) ) | 25 while ( !get.Connect( m_server, m_port ) ) |
24 wxSleep( 1 ); | 26 wxSleep( 1 ); |
25 | 27 |
26 wxInputStream *httpStream = get.GetInputStream( url ); | 28 wxInputStream *httpStream = get.GetInputStream( url ); |
27 if ( get.GetError() == wxPROTO_NOERR ) { | 29 if ( get.GetError() == wxPROTO_NOERR ) { |
28 wxFileOutputStream out_stream( file ); | 30 wxFileOutputStream out_stream( file ); |
29 httpStream->Read( out_stream ); | 31 httpStream->Read( out_stream ); |
32 ret = true; | |
30 } else { | 33 } else { |
31 wxMessageBox( wxT( "Re:Searcher Error: get err" ) ); | 34 wxMessageBox( wxT( "Re:Searcher Error: cannot get data." ) ); |
32 } | 35 } |
33 | 36 |
34 wxDELETE( httpStream ); | 37 wxDELETE( httpStream ); |
35 get.Close(); | 38 get.Close(); |
39 return ret; | |
36 } | 40 } |
37 | 41 |
38 void RsHttp::GetDB( void ) | 42 bool RsHttp::GetDB( void ) |
39 { | 43 { |
40 Get( wxT( "/db/auth.db"), wxT( "auth.db") ); | 44 bool ret = false; |
41 Get( wxT( "/db/hhs.db"), wxT( "hhs.db") ); | 45 ret = Get( wxT( "/db/auth.db"), wxT( "auth.db") ); |
46 ret = Get( wxT( "/db/hhs.db"), wxT( "hhs.db") ); | |
42 wxDateTime now = wxDateTime::Now(); | 47 wxDateTime now = wxDateTime::Now(); |
43 if ( now.GetDay() % 14 == 0 ) | 48 if ( now.GetDay() % 14 == 0 ) |
44 Get( wxT( "/db/index.db"), wxT( "index.db" ) ); | 49 Get( wxT( "/db/index.db"), wxT( "index.db" ) ); |
50 return ret; | |
45 } | 51 } |
46 | 52 |
47 int RsHttp::GetImagesSize( wxString hhs, wxString date ) | 53 int RsHttp::GetImagesSize( wxString hhs, wxString date ) |
48 { | 54 { |
49 wxHTTP get; | 55 wxHTTP get; |
78 wxInputStream *http_istream = get.GetInputStream( url ); | 84 wxInputStream *http_istream = get.GetInputStream( url ); |
79 if ( get.GetError() == wxPROTO_NOERR ) { | 85 if ( get.GetError() == wxPROTO_NOERR ) { |
80 //int size = http_istream->GetSize(); | 86 //int size = http_istream->GetSize(); |
81 wxZlibInputStream zlib_istream( http_istream ); // 0: no cache : bad | 87 wxZlibInputStream zlib_istream( http_istream ); // 0: no cache : bad |
82 | 88 |
83 /* | |
84 wxMemoryOutputStream mm_ostream; // 1: ok | |
85 http_istream->Read( mm_ostream ); | |
86 wxMemoryInputStream mm_istream( mm_ostream ); | |
87 wxZlibInputStream zlib_istream( mm_istream ); | |
88 */ | |
89 | |
90 wxTarEntry* entry; | 89 wxTarEntry* entry; |
91 wxTarInputStream tar_istream( zlib_istream ); | 90 wxTarInputStream tar_istream( zlib_istream ); |
92 int i = 1; | 91 int i = 1; |
93 while ( ( entry = tar_istream.GetNextEntry() ) != NULL ) { | 92 while ( ( entry = tar_istream.GetNextEntry() ) != NULL ) { |
94 //wxString name = entry->GetName(); | 93 //wxString name = entry->GetName(); |