void* SearchThread::Entry()
{
	const wxString searchescaped = ConvToIRI(m_search_query);


//   std::cout << "Escaped search query: " << m_search_query.ToAscii().data() << std::endl;
	wxHTTP get;
	get.SetTimeout(10);
	get.Connect(_("api.springfiles.com"));
	const wxString query = wxFormat(_("/json.php?nosensitive=on&logical=or&springname=%s&tag=%s"))  % searchescaped % searchescaped;
	wxInputStream * httpStream = get.GetInputStream(query);
	wxString res;
	if ( get.GetError() == wxPROTO_NOERR ) {

		wxStringOutputStream out_stream(&res);
		httpStream->Read(out_stream);


	}
	wxDELETE(httpStream);
	wxCommandEvent notify(SEARCH_FINISHED,ContentDownloadDialog::ID_SEARCH_FINISHED);
	notify.SetInt(0);
	notify.SetString(res);
	wxPostEvent(m_content_dialog,notify);
//   std::cout << "Search finished" << std::endl;
	return NULL;
}
Exemple #2
0
void ContentDownloadDialog::Search(const wxString& str)
{
	//FIXME: make async!
	const std::string param = ConvToIRI(STD_STRING(str));
	const std::string query = stdprintf("http://api.springfiles.com/json.php?nosensitive=on&logical=or&springname=%s&tag=%s", param.c_str(), param.c_str());
	std::string res;
	CHttpDownloader::DownloadUrl(query, res);
	CHttpDownloader::ParseResult(STD_STRING(str), res, dls);
	wxCommandEvent e;
	OnSearchCompleted(e);
}