当前位置: 首页>>代码示例>>C++>>正文


C++ Downloader::downloadFile方法代码示例

本文整理汇总了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;
}
开发者ID:keinkurt,项目名称:rssguard,代码行数:22,代码来源:networkfactory.cpp

示例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();
//.........这里部分代码省略.........
开发者ID:stein1,项目名称:bbk,代码行数:101,代码来源:ReportDialog.cpp


注:本文中的Downloader::downloadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。