// thread Web::ExitCode Web::Entry() { #ifdef DEBUG fprintf(stdout, "Start Web\n"); #endif wxHTTP get; get.SetHeader(_T("Content-type"), _T("text/html; charset=utf-8")); get.SetTimeout(30); while (!get.Connect(_T("www.workinprogress.ca"))) { if(TestDestroy()) { return (wxThread::ExitCode)0; } else { wxSleep(5); } } wxInputStream *in_stream = get.GetInputStream(whaturl); if (get.GetError() == wxPROTO_NOERR) { bool shutdownRequest = false; unsigned char buffer[DLBUFSIZE+1]; do { Sleep(0); //http://trac.wxwidgets.org/ticket/10720 in_stream->Read(buffer, DLBUFSIZE); size_t bytes_read = in_stream->LastRead(); if (bytes_read > 0) { buffer[bytes_read] = 0; wxString buffRead((const char*)buffer, wxConvUTF8); m_dataRead.Append(buffRead); } // Check termination request from time to time if(TestDestroy()) { shutdownRequest = true; break; } } while ( !in_stream->Eof() ); wxDELETE(in_stream); get.Close(); if(shutdownRequest == false) { delete in_stream; ParseFile(whaturl); } } else { return (wxThread::ExitCode)0; } #ifdef DEBUG fprintf(stdout, "Done Web\n"); #endif return (wxThread::ExitCode)0; // success }
void CompilersDetectorManager::MSWSuggestToDownloadMinGW(bool prompt) { #ifdef __WXMSW__ if(!prompt || ::wxMessageBox(_("Could not locate any MinGW compiler installed on your machine, would you like to " "install one now?"), "CodeLite", wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxCENTER | wxICON_QUESTION) == wxYES) { // No MinGW compiler detected!, offer the user to download one wxStringMap_t mingwCompilers; wxArrayString options; // Load the compilers list from the website wxURL url("http://codelite.org/compilers.json"); if(url.GetError() == wxURL_NOERR) { wxInputStream* in_stream = url.GetInputStream(); if(!in_stream) { return; } unsigned char buffer[DLBUFSIZE + 1]; wxString dataRead; do { in_stream->Read(buffer, DLBUFSIZE); size_t bytes_read = in_stream->LastRead(); if(bytes_read > 0) { buffer[bytes_read] = 0; wxString buffRead((const char*)buffer, wxConvUTF8); dataRead.Append(buffRead); } } while(!in_stream->Eof()); JSONRoot root(dataRead); JSONElement compilers = root.toElement().namedObject("Compilers"); JSONElement arr = compilers.namedObject("MinGW"); int count = arr.arraySize(); for(int i = 0; i < count; ++i) { JSONElement compiler = arr.arrayItem(i); mingwCompilers.insert( std::make_pair(compiler.namedObject("Name").toString(), compiler.namedObject("URL").toString())); options.Add(compiler.namedObject("Name").toString()); } if(options.IsEmpty()) { ::wxMessageBox(_("Unable to fetch compilers list from the website\nhttp://codelite.org/compilers.json"), "CodeLite", wxOK | wxCENTER | wxICON_WARNING); return; } int sel = 0; wxString selection = ::wxGetSingleChoice(_("Select a compiler to download"), _("Choose compiler"), options, sel); if(!selection.IsEmpty()) { // Reset the compiler detection flag so next time codelite is restarted, it will // rescan the machine clConfig::Get().Write(kConfigBootstrapCompleted, false); // Open the browser to start downloading the compiler ::wxLaunchDefaultBrowser(mingwCompilers.find(selection)->second); ::wxMessageBox(_("After install is completed, click the 'Scan' button"), "CodeLite", wxOK | wxCENTER | wxICON_INFORMATION); } } } #endif // __WXMSW__ }