void CShader::addShaders(string vShader , string fShader) { Vshader = glCreateShader(GL_VERTEX_SHADER); Fshader = glCreateShader(GL_FRAGMENT_SHADER); vShader = DownloadFile(vShader); GLchar *VStringPtr[1]; VStringPtr[0] = (GLchar *)vShader.c_str(); glShaderSource(Vshader , 1 , (const GLchar **)VStringPtr , NULL); fShader = DownloadFile(fShader); GLchar *FStringPtr[1]; FStringPtr[0] = (GLchar *)fShader.c_str(); glShaderSource(Fshader , 1 , (const GLchar **)FStringPtr , NULL); glCompileShader(Vshader); char vtex[9999]; glGetShaderInfoLog(Vshader, 9999, NULL, &vtex[0]); fprintf(stdout, "%s\n", &vtex[0]); glCompileShader(Fshader); char ftex[9999]; glGetShaderInfoLog(Fshader, 9999, NULL, &ftex[0]); fprintf(stdout, "%s\n", &ftex[0]); testVal = GL_FALSE; glGetShaderiv(Vshader, GL_COMPILE_STATUS, &testVal); if(testVal == GL_FALSE) { cout << "nie udalo sie skompilowac shadera!"; } glGetShaderiv(Fshader, GL_COMPILE_STATUS, &testVal); if(testVal == GL_FALSE) { cout << "nie udalo sie skompilowac shadera!"; } Program = glCreateProgram(); glAttachShader(Program , Vshader); glAttachShader(Program , Fshader); glLinkProgram(Program); glDeleteShader(Vshader); glDeleteShader(Fshader); }
STDMETHODIMP_(BOOL) CStatistic::SendStatUrlExWithSigned( LPCWSTR lpszType, LPCWSTR lpszAction, BOOL bUseThread /*= TRUE*/, StatUrlSendStateCallback stateCallback /*= NULL*/) { if (!lpszType || !lpszAction) return FALSE; CString strUrl = SIGN_STATS_URL; ReplacePlaceholders(strUrl, lpszType, lpszAction); CString strSignParam = SIGN_PARAM; ReplacePlaceholders(strSignParam, lpszType, lpszAction); Utf8 u8(strSignParam); const char * pszParam = u8.AsSz(); BYTE md5[16] = {}; WCHAR szMd5[MAX_PATH] = {}; CCommonAlgorithm::MakeBuffMd5((LPVOID)pszParam, u8.Len8() - 1, md5);/// -'0' CCommonAlgorithm::ConvertMD5SumToChar(md5, szMd5, MAX_PATH); _tcslwr_s(szMd5); if (strUrl.Find(URL_SIGN) > 0) { strUrl.Replace(URL_SIGN, szMd5); } return DownloadFile(strUrl, NULL, bUseThread, 0, stateCallback); }
// -------------------------------------------------------------------------------- // int DownloadFile( const wxString &Source, const wxString &Target ) { //guLogMessage( wxT( "Downloading %s" ), Source.c_str() ); wxCurlHTTP http; http.AddHeader( wxT( "User-Agent: " ) guDEFAULT_BROWSER_USER_AGENT ); //http.SetVerbose( true ); http.SetOpt( CURLOPT_FOLLOWLOCATION, 1 ); http.Get( Target, Source ); long ResCode = http.GetResponseCode(); if( ( ResCode < 200 ) || ( ResCode > 299 ) ) { //guLogMessage( wxT( "Code : %u\n%s" ), ResCode, http.GetResponseHeader().c_str() ); if( ( ResCode == 301 ) || ( ResCode == 302 ) || ( ResCode == 307 ) ) { wxString Location = http.GetResponseHeader(); int Pos = Location.Lower().Find( wxT( "location: " ) ); if( Pos != wxNOT_FOUND ) { Location = Location.Mid( Pos + 10 ); Location.Truncate( Location.Find( wxT( "\r\n" ) ) ); return DownloadFile( Location, Target ); } return 0; } } else return 1; return 0; }
void UpdateChecker::Run() { // no initialization to do, so signal readiness immediately SignalReady(); try { #ifdef _DEBUG const std::string url = "https://s3.amazonaws.com/qvivo_releases/v2/win32/testing/appcast.xml"; #else const std::string url = Settings::GetAppcastURL(); #endif if ( url.empty() ) throw std::runtime_error("Appcast URL not specified."); StringDownloadSink appcast_xml; DownloadFile(url, &appcast_xml, GetAppcastDownloadFlags()); Appcast appcast; appcast.Load(appcast_xml.data); Settings::WriteConfigValue("LastCheckTime", time(NULL)); const std::string currentVersion = WideToAnsi(Settings::GetAppVersion()); std::string currentBuild = currentVersion.substr(currentVersion.find(":") + 1); std::string appcastBuild = appcast.Build.substr(appcast.Build.find(":") + 1); std::string currentProductionVersion = currentVersion.substr(0, currentVersion.find(",")); std::string appcastProductionVersion = appcast.Build.substr(0, appcast.Build.find(",")); // Check if our version is out of date. if ( CompareVersions(currentProductionVersion, appcastProductionVersion) >= 0 ) { // The same or newer version is already installed. if(m_showUI) UI::NotifyNoUpdates(); return; } // Check if the user opted to ignore this particular version. std::string toSkip; if ( Settings::ReadConfigValue("SkipThisVersion", toSkip) && toSkip == appcast.Version ) { if(m_showUI) UI::NotifyNoUpdates(); return; } UI::NotifyUpdateAvailable(appcast); } catch ( ... ) { UI::NotifyUpdateError(); throw; } }
int main() { std::string url = "http://npm.taobao.org/mirrors/atom/1.4.1/atom-windows.zip"; ProgressCallbackStruture progress = {ProgressCallback, nullptr}; std::cout << "Download File Result: " << DownloadFile(url, NULL, &progress) << std::endl; return 0; }
int KJxUpdaterDlg::CheckVersion() { int nRetCode = false; int nResult = false; int nTempVer = 0; char szConfig[MAX_PATH]; char szUpdateFileName[MAX_PATH]; _sntprintf(szUpdateFileName, MAX_PATH, "%s%s%s", m_szServerUrl, SERVER_ROOT, SERVER_FILE_NAME); _sntprintf(szConfig, MAX_PATH, "%s%s", m_szUpdatePath, SERVER_FILE_NAME); nRetCode = DownloadFile(szUpdateFileName, false, true); KG_PROCESS_ERROR(nRetCode); nTempVer = GetPrivateProfileInt( SERVER_VERSION, SERVER_VERSION, 0, szConfig ); KG_PROCESS_ERROR(nTempVer); if (nTempVer > m_nVersion) { m_nNewVersion = nTempVer; m_bNeedUpdate = true; } _tremove(szConfig); nResult= true; Exit0: return nResult; }
stLoadStatus CFileHandler::LoadNext() { stLoadStatus stReturn; stReturn.iNumberLoaded = m_pFileList->GetCountPopped(); stReturn.iTotalCount = m_pFileList->GetCountLoaded(); stReturn.eObjectLoaded = FileLoaded; if ( m_pFileList->GetCountLeft() == 0 ) { stReturn.sStatus = "Finished!"; m_bLoadFinished = true; if ( m_pFileList != 0 ) delete m_pFileList; m_pFileList = 0; return stReturn; } string sWikiFileName = GetUntilFirst( m_pFileList->GetTagText(), "|" ); string sSaveToFileName = GetAfterFirst( m_pFileList->GetTagText(), "|" ); // Does the file already exist? if ( DoesGameMediaExist( pEngine->GetGameDir(), sSaveToFileName ) == false ) { DownloadFile( sWikiFileName, g_sAppDir+ "\\Media\\" + pEngine->GetGameDir() + "\\" + sSaveToFileName ); } stReturn.sStatus = "File \"" + sWikiFileName + "\" downloaded"; m_pFileList->Pop(); return stReturn; }
/*--- Received when a download has ended ---*/ void Downloader::FileFinished(QNetworkReply* mreply) { qDebug() << "Downloader::FileFinished"; disconnect(reply, SIGNAL(readyRead()), this, SLOT(FilePart())); disconnect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(FileError(QNetworkReply::NetworkError))); mreply->deleteLater(); lastDownloadedSize = 0; downloadedSize = 0; if (bDownloading) { bDownloading = false; timeoutTimer->stop(); currentFile->close(); delete currentFile; if (currentFtpFile == FTP_RELEASE_NOTES_FILE) { emit Stage1(); DownloadFile(FTP_MANIFEST_ROOT, FTP_MANIFEST_FILE); } else if (currentFtpFile == FTP_MANIFEST_FILE) { emit Stage2(); } else { emit FileDownloaded(); } } }
// the icon will be downloaded to "my picture" folder in other OS or low security folder in VISTA // AddFavorite("Favorite Title", "http://www.groovedive.com", "http://mfiles.naver.net/9b4fac7b613b57e4c9b1/data33/2008/6/28/55/tulip-jangtimjang.ico"); BOOL CShortcutNBookmark::AddFavorite(const CString& FavoriteTitle, const CString& FavoriteUrl, const CString& csIconUrl) { BOOL bRet = FALSE; CString csDownloadedFilePath; CString csFileName = csIconUrl.Right( csIconUrl.GetLength() - csIconUrl.ReverseFind('/') -1 ); if ( m_bNoVista ) { // create file under window\\web\\wallpaper\\ CString csLocalFolderPath = ReadREG_SZValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "My Pictures"); //csLocalFolderPath = csLocalFolderPath.Left( csLocalFolderPath.ReverseFind('\\') ); if ( csLocalFolderPath.GetLength() == 0 ) { csLocalFolderPath = "C:"; } csLocalFolderPath.Replace( "%SystemRoot%", GetSpecialFolderLocation(CSIDL_WINDOWS)); csDownloadedFilePath = csLocalFolderPath + "\\" + csFileName; } else { // if it's VISTA create file under c:\\users\\~~\\AppData\\LocalLow\\ CString csLocalFolderPath = GetSpecialFolderLocation(CSIDL_PROFILE ) + "\\AppData\\localLow"; csDownloadedFilePath = csLocalFolderPath + "\\" + csFileName; } if ( DownloadFile(csIconUrl, csDownloadedFilePath) ) { bRet = CreateInternetShortcut(FavoriteTitle +".url" , FavoriteUrl, ReadREG_SZValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Favorites") , csDownloadedFilePath ); } return bRet; }
std::forward_list<std::shared_ptr<FileRequest>> FileClient::DownloadAsync( std::forward_list<std::shared_ptr<FileLocation>> * input_file_locs, std::function<void(File*, bool)> &&callback) { std::forward_list<std::shared_ptr<FileRequest>> fr_list; for(const std::shared_ptr<FileLocation> & file_loc : *input_file_locs) { auto f_ptr = file_loc->file(); std::lock_guard<std::mutex> lock(dl_mutex_); // RAII style locking if(manager_->IsLocal(f_ptr)) { continue; } // check if the File is already in the request map auto got = request_map_.find (f_ptr); // if it is, use this request if (got != request_map_.end()) { LOG_DEBUG("File already downloading: " + *file_loc->output_path()); fr_list.push_front(got->second); continue; } else { auto fr_ptr = std::make_shared<FileRequest>(file_loc, callback); request_map_[f_ptr] = fr_ptr; fr_list.push_front(fr_ptr); if(num_downloads_ < max_downloads_) { DownloadFile(fr_ptr); } else { request_q_.push(fr_ptr); } } } return fr_list; }
/*--- Use password to login ---*/ void Downloader::Login(QString pwd) { qDebug() << "Downloader::Login"; passWd = pwd; baseUrl->setPassword(passWd); DownloadFile("", FTP_RELEASE_NOTES_FILE); }
HRESULT CPatchDlg::DownloadDiffFile() { HRESULT hr=S_OK; POSITION pos=m_mapSvrFileVersion.GetStartPosition(); PFILEUPDATESVRDATA pData=NULL; PFILEUPDATECLIDATA pCliData=NULL; CString sKey; BOOL bDiff=FALSE; CString sUpdataPath; sUpdataPath.AppendFormat(_T("%s\\%s"),sAppPath,sSavePath); do{ bDiff=FALSE; pCliData=NULL; m_mapSvrFileVersion.GetNextAssoc(pos,sKey,(LPVOID&)pData); m_mapCliFileVersion.Lookup(sKey,(LPVOID&)pCliData); if(pCliData==NULL) { bDiff=TRUE; Log(_T("S:%-25s, S:%8s,客户端没有,"),pData->sFileName, pData->sVersion); } else { if(pCliData->sVersion.IsEmpty()) { if(pCliData->nCrc32!=pData->nCrc32) bDiff=TRUE; } else { bDiff=VersionLess(pCliData->sVersion,pData->sVersion); if(!bDiff) //版本一样比较Crc32 { if(pCliData->nCrc32!=pData->nCrc32) bDiff=TRUE; } } if(bDiff) { Log(_T("S:%-25s, C:%-25s, S:%8s, C:%8s,"),pData->sFileName,pCliData->sFileName, pData->sVersion,pCliData->sVersion); //客户端存在的文件 才视为找到新版本.. if(!bFindNewVersion && !IsSpecialFile(pCliData->sFileName)) bFindNewVersion=TRUE; } } if(bDiff) { hr=DownloadFile(sBaseAddress+pData->sFilePath,sUpdataPath+pData->sFileName,TRUE,pData->nCrc32); if(hr==S_OK) Log(_T("下载成功。\r\n")); else Log(_T("下载失败。\r\n")); } }while(pos!=NULL); return hr; }
static void ApplyDownloads(void *param) { HWND hDlg = (HWND)param; ////////////////////////////////////////////////////////////////////////////////////// // if we need to escalate priviledges, launch a atub if (!PrepareEscalation()) { PostMessage(hDlg, WM_CLOSE, 0, 0); return; } ////////////////////////////////////////////////////////////////////////////////////// // ok, let's unpack all zips AutoHandle pipe(hPipe); HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES); OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA); //create needed folders after escalating priviledges. Folders creates when we actually install updates TCHAR tszFileTemp[MAX_PATH], tszFileBack[MAX_PATH]; mir_sntprintf(tszFileBack, _countof(tszFileBack), _T("%s\\Backups"), tszRoot); SafeCreateDirectory(tszFileBack); mir_sntprintf(tszFileTemp, _countof(tszFileTemp), _T("%s\\Temp"), tszRoot); SafeCreateDirectory(tszFileTemp); VARST tszMirandaPath(_T("%miranda_path%")); HANDLE nlc = NULL; for (int i=0; i < todo.getCount(); ++i) { ListView_EnsureVisible(hwndList, i, FALSE); if (todo[i].bEnabled) { // download update ListView_SetItemText(hwndList, i, 1, TranslateT("Downloading...")); if (DownloadFile(&todo[i].File, nlc)) { ListView_SetItemText(hwndList, i, 1, TranslateT("Succeeded.")); if (unzip(todo[i].File.tszDiskPath, tszMirandaPath, tszFileBack,false)) SafeDeleteFile(todo[i].File.tszDiskPath); // remove .zip after successful update } else ListView_SetItemText(hwndList, i, 1, TranslateT("Failed!")); } else ListView_SetItemText(hwndList, i, 1, TranslateT("Skipped.")); } Netlib_CloseHandle(nlc); ShowPopup(TranslateT("Plugin Updater"), TranslateT("Download complete"), POPUP_TYPE_INFO); int rc = MessageBox(hDlg, TranslateT("Download complete. Do you want to go to plugins option page?"), TranslateT("Plugin Updater"), MB_YESNO | MB_ICONQUESTION); if (rc == IDYES) CallFunctionAsync(OpenPluginOptions, 0); PostMessage(hDlg, WM_CLOSE, 0, 0); }
void QmitkXnatEditor::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddSelectionListener(m_SelectionListener.data()); connect( m_Controls.treeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(OnObjectActivated(const QModelIndex&)) ); connect( m_Controls.buttonDownloadResource, SIGNAL(clicked()), this, SLOT(DownloadResource()) ); connect( m_Controls.buttonDownloadFile, SIGNAL(clicked()), this, SLOT(DownloadFile()) ); connect( m_Controls.buttonDataModel, SIGNAL(clicked()), this, SLOT(OnDataModelButtonClicked()) ); connect( m_Controls.buttonProject, SIGNAL(clicked()), this, SLOT(OnProjectButtonClicked()) ); connect( m_Controls.buttonSubject, SIGNAL(clicked()), this, SLOT(OnSubjectButtonClicked()) ); connect( m_Controls.buttonExperiment, SIGNAL(clicked()), this, SLOT(OnExperimentButtonClicked()) ); connect( m_Controls.buttonKindOfData, SIGNAL(clicked()), this, SLOT(OnKindOfDataButtonClicked()) ); connect( m_Controls.buttonSession, SIGNAL(clicked()), this, SLOT(OnSessionButtonClicked()) ); connect( m_Controls.buttonResource, SIGNAL(clicked()), this, SLOT(OnResourceButtonClicked()) ); m_Tracker = new mitk::XnatSessionTracker(mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()); connect( m_Tracker, SIGNAL(AboutToBeClosed(ctkXnatSession*)), this, SLOT(CleanListModel(ctkXnatSession*)) ); connect( m_Tracker, SIGNAL(Opened(ctkXnatSession*)), this, SLOT(UpdateSession(ctkXnatSession*)) ); m_Tracker->Open(); // Makes the breadcrumb feature invisible for(int i = 0; i < m_Controls.breadcrumbHorizontalLayout->count()-1; i++) { QLayoutItem* child = m_Controls.breadcrumbHorizontalLayout->itemAt(i); child->widget()->setVisible(false); } for(int i = 0; i < m_Controls.breadcrumbDescriptionLayout->count()-1; i++) { QLayoutItem* child = m_Controls.breadcrumbDescriptionLayout->itemAt(i); child->widget()->setVisible(false); } QmitkXnatObjectEditorInput::Pointer oPtr = GetEditorInput().Cast<QmitkXnatObjectEditorInput>(); if(oPtr.IsNotNull()) { UpdateList(); } else { ctkXnatSession* session; try { session = mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetService( mitk::org_mitk_gui_qt_xnatinterface_Activator::GetXnatModuleContext()->GetServiceReference<ctkXnatSession>()); } catch(std::invalid_argument) { session = 0; } UpdateSession(session); } }
STDMETHODIMP_(BOOL) CStatistic::SendStatUrl(LPCWSTR lpszUrl, BOOL bUseThread /*= TRUE*/, StatUrlSendStateCallback stateCallback /*= NULL*/) { if (lpszUrl == NULL) return FALSE; CString strUrl = lpszUrl; ReplacePlaceholders(strUrl, L"", L""); return DownloadFile(strUrl, NULL, bUseThread, 0, stateCallback); }
void Synchro::FirstSynchro() { GetJSON(); std::map<int, Folder *> FolderMap = myparse.getFoldermap(); typedef std::map<int, Folder *>::iterator it_type2; for (it_type2 iterator = FolderMap.begin(); iterator != FolderMap.end(); iterator++) { Folder *fold = iterator->second; std::string str = this->folder + fold->getChosenPath() + "/" + fold->getName(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); if (QDir(cstr).exists() == true) return; else QDir().mkdir(cstr); delete[] cstr; } std::map<int, File *> fileMap = myparse.getFileMap(); std::string StrignUpload = "uploads/"; typedef std::map<int, File *>::iterator it_type; for (it_type iterator = fileMap.begin(); iterator != fileMap.end(); iterator++) { File *test = iterator->second; std::string urltodown = this->URL + StrignUpload + test->getPseudoOwner() + "/" + test->getRealPath() + test->getPath(); while (urltodown.find('\\') != std::string::npos) replace(urltodown, "\\", "/"); char *cstr1 = new char[urltodown.length() + 1]; strcpy(cstr1, urltodown.c_str()); std::string str = test->getName() + "." + test->getMimeType(); char *cstr = new char[str.length() + 1]; strcpy(cstr, str.c_str()); str = this->folder + test->getChosenPath() + "/"; char *pathDisk = new char[str.length() + 1]; strcpy(pathDisk, str.c_str()); std::string ty = pathDisk + str; QString URI(ty.c_str()); DownloadFile(cstr1, URI); delete[] cstr; delete[] cstr1; } char acsjson[1024]; strcpy(acsjson, this->folder); strcat(acsjson, ".acsilserver"); QFile txt(acsjson); txt.open(QIODevice::ReadWrite | QIODevice::Text); txt.write(myparse.getJSON().c_str()); txt.close(); }
BOOL KPmacC::ApplyPmacCompCorr(LPCTSTR path) { GetCtrlResponse(CTRL_A); // Coordinate Abort Delay(200); GetCtrlResponse(CTRL_K); // Motor All Kill Delay(200); GetResponse(_T("I51=0")); // Comp Disable if (DownloadFile(path) == false) return FALSE; return TRUE; }
void UpdateChecker::Run() { // no initialization to do, so signal readiness immediately SignalReady(); try { const std::string url = Settings::GetAppcastURL(); if ( url.empty() ) throw std::runtime_error("Appcast URL not specified."); CheckForInsecureURL(url, "appcast feed"); StringDownloadSink appcast_xml; DownloadFile(url, &appcast_xml, GetAppcastDownloadFlags()); Appcast appcast = Appcast::Load(appcast_xml.data); if (!appcast.ReleaseNotesURL.empty()) CheckForInsecureURL(appcast.ReleaseNotesURL, "release notes"); if (!appcast.DownloadURL.empty()) CheckForInsecureURL(appcast.DownloadURL, "update file"); Settings::WriteConfigValue("LastCheckTime", time(NULL)); const std::string currentVersion = WideToAnsi(Settings::GetAppBuildVersion()); // Check if our version is out of date. if ( !appcast.IsValid() || CompareVersions(currentVersion, appcast.Version) >= 0 ) { // The same or newer version is already installed. UI::NotifyNoUpdates(ShouldAutomaticallyInstall()); return; } // Check if the user opted to ignore this particular version. if ( ShouldSkipUpdate(appcast) ) { UI::NotifyNoUpdates(ShouldAutomaticallyInstall()); return; } UI::NotifyUpdateAvailable(appcast, ShouldAutomaticallyInstall()); } catch ( ... ) { UI::NotifyUpdateError(); throw; } }
STDMETHODIMP_(BOOL) CStatistic::SendStatUrlEx(LPCWSTR lpszType, LPCWSTR lpszAction, LPCWSTR lpszExtra /*= NULL*/, BOOL bUseThread /*= TRUE*/, StatUrlSendStateCallback stateCallback /*= NULL*/) { if (!lpszType || !lpszAction) return FALSE; CString strUrl = STATS_URL; ReplacePlaceholders(strUrl, lpszType, lpszAction); if (lpszExtra) { strUrl += lpszExtra; } return DownloadFile(strUrl, NULL, bUseThread, 0, stateCallback); }
void DlgDownloadProc() { CallFunctionAsync(CreateDownloadDialog, 0); if (!DownloadFile(pFileUrl->tszDownloadURL, pFileUrl->tszDiskPath)) { Title = TranslateT("Pack Updater"); Text = TranslateT("An error occurred while downloading the update."); if (ServiceExists(MS_POPUP_ADDPOPUPT) && db_get_b(NULL, "Popup", "ModuleIsEnabled", 1) && db_get_b(NULL, MODNAME, "Popups1", DEFAULT_POPUP_ENABLED)) { Number = 1; show_popup(0, Title, Text, Number, 0); } else if (db_get_b(NULL, MODNAME, "Popups1M", DEFAULT_MESSAGE_ENABLED)) MessageBox(NULL, Text, Title, MB_ICONSTOP); } CallFunctionAsync(DestroyDownloadDialog, 0); }
int FTPSession::DownloadFileCache(const char * sourcefile) { if (!m_running) return -1; if (sourcefile == NULL) return -1; TCHAR target[MAX_PATH]; target[0] = 0; int res = m_currentProfile->GetCacheLocal(sourcefile, target, MAX_PATH); if (res != 0) return res; return DownloadFile(sourcefile, target, false, 0); }
/*--- Timeout has expired, restart file ---*/ void Downloader::Reconnect() { qDebug() << "Downloader::Reconnect"; // Suppress the FTP handler emit Log("Timeout downloading " + currentFtpFile, false); disconnect(timeoutTimer, SIGNAL(timeout()), this, SLOT(Reconnect())); disconnect(ftp, SIGNAL(finished(QNetworkReply*)), this, SLOT(FileFinished(QNetworkReply*))); ftp->deleteLater(); // Restart it ftp = new QNetworkAccessManager(); connect(timeoutTimer, SIGNAL(timeout()), this, SLOT(Reconnect())); connect(ftp, SIGNAL(finished(QNetworkReply*)), this, SLOT(FileFinished(QNetworkReply*))); emit DownloadFile(currentFtpDir, currentFtpFile); }
void UpdateChecker::Run() { // no initialization to do, so signal readiness immediately SignalReady(); try { const std::string url = Settings::GetAppcastURL(); if ( url.empty() ) throw std::runtime_error("Appcast URL not specified."); StringDownloadSink appcast_xml; DownloadFile(url, &appcast_xml, GetAppcastDownloadFlags()); Appcast appcast; appcast.Load(appcast_xml.data); Settings::WriteConfigValue("LastCheckTime", time(NULL)); const std::string currentVersion = WideToAnsi(Settings::GetAppVersion()); // Check if our version is out of date. if ( CompareVersions(currentVersion, appcast.Version) >= 0 ) { // The same or newer version is already installed. UI::NotifyNoUpdates(); return; } // Check if the user opted to ignore this particular version. std::string toSkip; if ( Settings::ReadConfigValue("SkipThisVersion", toSkip) && toSkip == appcast.Version ) { UI::NotifyNoUpdates(); return; } UI::NotifyUpdateAvailable(appcast); } catch ( ... ) { UI::NotifyUpdateError(); throw; } }
bool DownLoader::DownFileList() { //有文件,先删除 if (DownLoadHelper::Access("files.txt",0) == 0) { DownLoadHelper::Remove("files.txt"); } std::string listUrl = m_baseUrl + "resources/files.txt"; DownloadFile("files.txt",listUrl,false); AnalyzeFileList(); //PrintDownList(); StartDownloadThread(); //开启下载线程 return true; }
void FullIntegrationDownloader::Run() { // no initialization to do, so signal readiness immediately SignalReady(); try { const std::string tmpdir = CreateUniqueTempDirectory(); Settings::WriteConfigValue("UpdateTempDir", tmpdir); FullIntegrationDownloadSink sink(*this, tmpdir); DownloadFile(m_appcast.DownloadURL, &sink); sink.Close(); InstallUpdate(sink.GetFilePath()); } CATCH_ALL_EXCEPTIONS }
BOOL CHttpDownload::DownloadThread( FileContainerIterator& it ) { PatchLog( "Attempt to connect(%s).", m_sServer ); if( !HttpConnect() ) { OnError( DOWNLOAD_ERROR_HTTP_CONNECT ); return FALSE; } PatchLog( "Connected" ); #if __CURRENT_LANG == LANG_FRA SetStatusText( _S(IDS_STR_FRA_PATCHPROCESS) ); #else SetStatusText( "Patch in process..." ); #endif for( ; it != m_pPatchManager->m_files.end(); ++it ) { SetTextFileNum( m_nRecvdFile+1, m_pPatchManager->m_files.size() ); UINT nResult = DownloadFile( *it ); if( nResult == DOWNLOAD_ERROR_OK ) { PatchLog( "%s OK", (*it).szServerPath ); ++m_nRecvdFile; } else { OnError( nResult ); return FALSE; } } #if __CURRENT_LANG == LANG_FRA SetStatusText( _S(IDS_STR_FRA_PATCHCOMP) ); #elif __CURRENT_LANG == LANG_POR SetStatusText( _S(IDS_STR_POR_PATCHCOMP) ); #else SetStatusText( "Patch completed." ); #endif return TRUE ; }
DWORD CAutoUpdateDlg::DoDownLoadThread(void) { CString csCurDir = GetModuleDirectory()+UPDATE_PACKAGE; DeleteFile(csCurDir.GetBuffer()); if (m_csDownloadURL.GetLength() <= 0) { TCHAR szLastVer[16] = {0}; TCHAR szUpdateURL[256] = {0}; TCHAR szNote[1024] = {0}; if(GetOnlineInfo(szLastVer,szUpdateURL,szNote)) m_csDownloadURL = szUpdateURL; } if(DownloadFile(m_csDownloadURL,csCurDir)) { m_bFileOK = TRUE; } return PostMessage(WM_ENDMESSAGE,0,0); }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { char szCommand[512]=""; //create a intance of the class CHttpBot bla; //init all values and start message handling bla.SetServerUrl("localhost/bot/"); bla.SetTimeout(2500); bla.StartMessageHandling(); //for example like a never endling loop to check for commands from the server while(1) { //get a command from webconsole if(bla.GetCommandFromQueue(szCommand)) { //parse your commands here received from the server if(strcmp(szCommand, ".quit")==0) { break; } else if(strcmp(szCommand, ".uptime")==0) { //in this way you can send replys to the server bla.AddResultToSend("I'm up for <time> ;)"); } else if(strcmp(szCommand, ".download")==0) { DownloadFile("http://example.com/MyNewVersion.exe", "C:\\MyNewVersion.exe"); } } //wait, so CPU is not at 100% Sleep(1000); } return 0; }
void CPatchDlg::CheckVersion( BOOL *pbFind ) { CString strCfg; strCfg.AppendFormat(_T("%s\\%s%s"),sAppPath,sSavePath,sClientCfgFileName); bCrcChecekUp=TRUE; sCrcHint.Empty(); // 1>下载服务端配置文件到Update if(DownloadFile(sSvrPath,strCfg,0,FALSE)==S_OK){ // 2>读取配置文件中的文件列表和版本号. ParseServerCfg(strCfg); // 3>读取运行中模块的文件名和版本号 GetMoudleList(); // 4>比较版本,有高版本,置升级标志.下载到Update //CompareVersion(); //兼容旧的。。 DownloadDiffFile(); } *pbFind=bFindNewVersion; }
void UpdateDownloader::Run() { // no initialization to do, so signal readiness immediately SignalReady(); try { const std::wstring tmpdir = CreateUniqueTempDirectory(); Settings::WriteConfigValue("UpdateTempDir", tmpdir); UpdateDownloadSink sink(*this, tmpdir); DownloadFile(m_appcast.DownloadURL, &sink); sink.Close(); UI::NotifyUpdateDownloaded(sink.GetFilePath(), m_appcast); } catch ( ... ) { UI::NotifyUpdateError(); throw; } }