MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / HandleDownloads

Method HandleDownloads

neo/framework/async/AsyncClient.cpp:1947–2133  ·  view source on GitHub ↗

================== idAsyncClient::HandleDownloads ================== */

Source from the content-addressed store, hash-verified

1945==================
1946*/
1947void idAsyncClient::HandleDownloads( void ) {
1948
1949 if ( updateState == UPDATE_SENT && clientTime > updateSentTime + 2000 ) {
1950 // timing out on no reply
1951 updateState = UPDATE_DONE;
1952 if ( showUpdateMessage ) {
1953 session->MessageBox( MSG_OK, common->GetLanguageDict()->GetString ( "#str_04839" ), common->GetLanguageDict()->GetString ( "#str_04837" ), true );
1954 showUpdateMessage = false;
1955 }
1956 common->DPrintf( "No update available\n" );
1957 } else if ( backgroundDownload.completed ) {
1958 // only enter these if the download slot is free
1959 if ( updateState == UPDATE_READY ) {
1960 //
1961 if ( session->MessageBox( MSG_YESNO, updateMSG, common->GetLanguageDict()->GetString ( "#str_04330" ), true, "yes" )[0] ) {
1962 if ( !updateDirectDownload ) {
1963 sys->OpenURL( updateURL, true );
1964 updateState = UPDATE_DONE;
1965 } else {
1966
1967 // we're just creating the file at toplevel inside fs_savepath
1968 updateURL.ExtractFileName( updateFile );
1969 idFile_Permanent *f = static_cast< idFile_Permanent *>( fileSystem->OpenFileWrite( updateFile ) );
1970 dltotal = 0;
1971 dlnow = 0;
1972
1973 backgroundDownload.completed = false;
1974 backgroundDownload.opcode = DLTYPE_URL;
1975 backgroundDownload.f = f;
1976 backgroundDownload.url.status = DL_WAIT;
1977 backgroundDownload.url.dlnow = 0;
1978 backgroundDownload.url.dltotal = 0;
1979 backgroundDownload.url.url = updateURL;
1980 fileSystem->BackgroundDownload( &backgroundDownload );
1981
1982 updateState = UPDATE_DLING;
1983 SendVersionDLUpdate( 0 );
1984 session->DownloadProgressBox( &backgroundDownload, va( "Downloading %s\n", updateFile.c_str() ) );
1985 updateState = UPDATE_DONE;
1986 if ( backgroundDownload.url.status == DL_DONE ) {
1987 SendVersionDLUpdate( 1 );
1988 idStr fullPath = f->GetFullPath();
1989 fileSystem->CloseFile( f );
1990 if ( session->MessageBox( MSG_YESNO, common->GetLanguageDict()->GetString ( "#str_04331" ), common->GetLanguageDict()->GetString ( "#str_04332" ), true, "yes" )[0] ) {
1991 if ( updateMime == DL_FILE_EXEC ) {
1992 sys->StartProcess( fullPath, true );
1993 } else {
1994 sys->OpenURL( va( "file://%s", fullPath.c_str() ), true );
1995 }
1996 } else {
1997 session->MessageBox( MSG_OK, va( common->GetLanguageDict()->GetString ( "#str_04333" ), fullPath.c_str() ), common->GetLanguageDict()->GetString ( "#str_04334" ), true );
1998 }
1999 } else {
2000 if ( backgroundDownload.url.dlerror[ 0 ] ) {
2001 common->Warning( "update download failed. curl error: %s", backgroundDownload.url.dlerror );
2002 }
2003 SendVersionDLUpdate( 2 );
2004 idStr name = f->GetName();

Callers

nothing calls this directly

Calls 15

vaFunction · 0.85
sprintfFunction · 0.85
Mem_AllocFunction · 0.85
MinFunction · 0.85
Mem_FreeFunction · 0.85
ExtractFileNameMethod · 0.80
OpenFileWriteMethod · 0.80
BackgroundDownloadMethod · 0.80
DownloadProgressBoxMethod · 0.80
CloseFileMethod · 0.80
RemoveFileMethod · 0.80
MakeTemporaryFileMethod · 0.80

Tested by

no test coverage detected