本文整理汇总了C++中Downloader::downloadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Downloader::downloadFile方法的具体用法?C++ Downloader::downloadFile怎么用?C++ Downloader::downloadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Downloader
的用法示例。
在下文中一共展示了Downloader::downloadFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: downloadFeedFile
NetworkResult NetworkFactory::downloadFeedFile(const QString &url, int timeout,
QByteArray &output, bool protected_contents,
const QString &username, const QString &password) {
// Here, we want to achieve "synchronous" approach because we want synchronout download API for
// some use-cases too.
Downloader downloader;
QEventLoop loop;
NetworkResult result;
downloader.appendRawHeader("Accept", ACCEPT_HEADER_FOR_FEED_DOWNLOADER);
// We need to quit event loop when the download finishes.
QObject::connect(&downloader, SIGNAL(completed(QNetworkReply::NetworkError)), &loop, SLOT(quit()));
downloader.downloadFile(url, timeout, protected_contents, username, password);
loop.exec();
output = downloader.lastOutputData();
result.first = downloader.lastOutputError();
result.second = downloader.lastContentType();
return result;
}
示例2: Run
bool ReportDialog::Run(int step)
{
wxString output;
if( step == 0 )
{
// Do the tests
m_Done = false;
m_Output->Clear();
m_Output->AppendText( wxString(TPTEST_VERSION_STRING) );
m_Output->AppendText( wxT("\n") );
m_Output->AppendText( wxString(wxDateTime::Now().Format(wxT("%Y-%m-%d %H:%M:%S"))) );
m_Output->AppendText( wxT("\n") );
m_Output->AppendText( wxT("\n") );
#ifdef WIN32
// OS information
OSInfo osinfo;
std::string str_osinfo = osinfo.GetOSInfoString();
if (str_osinfo.length() < 1) {
m_Output->AppendText( wxString(wxT("[Failed to get OS version info]\n")) );
}
else {
m_Output->AppendText( wxString( FROMCSTR(str_osinfo.c_str()) ) );
}
#endif
m_stepDone = true;
}
else if( step == 1 )
{
// Report TCP Window size
TcpWindowSize tcpwsz;
output = FROMCSTR(tcpwsz.GetStr());
m_Output->AppendText( wxString(output) );
m_stepDone = true;
}
else if( step == 2 )
{
// External IP
Downloader *dl = new Downloader();
dl->downloadFile( TOCSTR(wxT("http://ghn.se/cgi-bin/whatsmyip")) );
if( dl->content() != NULL )
{
m_Output->AppendText( wxString( wxT("External IP Address: ") ) );
m_Output->AppendText( FROMCSTR(dl->content()) );
}
else
{
m_Output->AppendText( wxString(wxT("Cannot determine external IP. No connection to TPTEST host.\n\n") ) );
}
delete dl;
m_stepDone = true;
}
else if( step == 3 )
{
// ifconfig
wxString cmd;
#ifdef WIN32
cmd << wxT("ipconfig /all");
#endif
#ifdef MACOSX
cmd << wxT("ifconfig");
#endif
m_proc = new wxProcess(this, wxID_REPORT_PROC);
m_proc->Redirect();
if( wxExecute( cmd, wxEXEC_ASYNC, m_proc ) > 0 )
{
m_proc_running = true;
m_procIn = m_proc->GetInputStream();
}
else
{
this->m_Output->AppendText( wxT("Kan inte k�ra ifconfig.\n\n") );
m_stepDone = true;
m_stepError = true;
}
}
else if( step == 4 )
{
// netstat
wxString cmd;
#ifdef WIN32
cmd << wxT("netstat -na");
#endif
#ifdef MACOSX
cmd << wxT("netstat -nafinet");
#endif
m_proc = new wxProcess(this, wxID_REPORT_PROC);
m_proc->Redirect();
if( wxExecute( cmd, wxEXEC_ASYNC, m_proc ) > 0 )
{
m_proc_running = true;
m_procIn = m_proc->GetInputStream();
//.........这里部分代码省略.........