Add abstract frontend to HTTP support and stop using curl on Windows
This commit is contained in:
1 parent
bc30e0186b
commit
1cbba07fc3
12 files changed
+187
-299
No files matched your search
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2006 Tony J. White (tjw@tjw.org)
|
||||
|
||||
This file is part of Quake III Arena source code.
|
||||
|
||||
Quake III Arena source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Quake III Arena source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Quake III Arena source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __QCURL_H__
|
||||
#define __QCURL_H__
|
||||
|
||||
#include "../qcommon/q_shared.h"
|
||||
#include "../qcommon/qcommon.h"
|
||||
|
||||
#ifdef USE_LOCAL_HEADERS
|
||||
#include "../curl-8.15.0/include/curl/curl.h"
|
||||
#else
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_CURL_DLOPEN
|
||||
#ifdef WIN32
|
||||
#define DEFAULT_CURL_LIB "libcurl-4.dll"
|
||||
#define ALTERNATE_CURL_LIB "libcurl-3.dll"
|
||||
#elif defined(__APPLE__)
|
||||
#define DEFAULT_CURL_LIB "libcurl.dylib"
|
||||
#else
|
||||
#define DEFAULT_CURL_LIB "libcurl.so.4"
|
||||
#define ALTERNATE_CURL_LIB "libcurl.so.3"
|
||||
#endif
|
||||
|
||||
extern cvar_t *cl_cURLLib;
|
||||
|
||||
extern char* (*qcurl_version)(void);
|
||||
|
||||
extern CURL* (*qcurl_easy_init)(void);
|
||||
extern CURLcode (*qcurl_easy_setopt)(CURL *curl, CURLoption option, ...);
|
||||
extern CURLcode (*qcurl_easy_perform)(CURL *curl);
|
||||
extern void (*qcurl_easy_cleanup)(CURL *curl);
|
||||
extern CURLcode (*qcurl_easy_getinfo)(CURL *curl, CURLINFO info, ...);
|
||||
extern void (*qcurl_easy_reset)(CURL *curl);
|
||||
extern const char *(*qcurl_easy_strerror)(CURLcode);
|
||||
|
||||
extern CURLM* (*qcurl_multi_init)(void);
|
||||
extern CURLMcode (*qcurl_multi_add_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
extern CURLMcode (*qcurl_multi_remove_handle)(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
extern CURLMcode (*qcurl_multi_fdset)(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
extern CURLMcode (*qcurl_multi_perform)(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
extern CURLMcode (*qcurl_multi_cleanup)(CURLM *multi_handle);
|
||||
extern CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle,
|
||||
int *msgs_in_queue);
|
||||
extern const char *(*qcurl_multi_strerror)(CURLMcode);
|
||||
#else
|
||||
#define qcurl_version curl_version
|
||||
|
||||
#define qcurl_easy_init curl_easy_init
|
||||
#define qcurl_easy_setopt curl_easy_setopt
|
||||
#define qcurl_easy_perform curl_easy_perform
|
||||
#define qcurl_easy_cleanup curl_easy_cleanup
|
||||
#define qcurl_easy_getinfo curl_easy_getinfo
|
||||
#define qcurl_easy_duphandle curl_easy_duphandle
|
||||
#define qcurl_easy_reset curl_easy_reset
|
||||
#define qcurl_easy_strerror curl_easy_strerror
|
||||
|
||||
#define qcurl_multi_init curl_multi_init
|
||||
#define qcurl_multi_add_handle curl_multi_add_handle
|
||||
#define qcurl_multi_remove_handle curl_multi_remove_handle
|
||||
#define qcurl_multi_fdset curl_multi_fdset
|
||||
#define qcurl_multi_perform curl_multi_perform
|
||||
#define qcurl_multi_cleanup curl_multi_cleanup
|
||||
#define qcurl_multi_info_read curl_multi_info_read
|
||||
#define qcurl_multi_strerror curl_multi_strerror
|
||||
#endif
|
||||
|
||||
qboolean CL_cURL_Init( void );
|
||||
void CL_cURL_Shutdown( void );
|
||||
void CL_cURL_BeginDownload( const char *localName, const char *remoteURL );
|
||||
void CL_cURL_PerformDownload( void );
|
||||
void CL_cURL_Cleanup( void );
|
||||
#endif // __QCURL_H__
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2006 Tony J. White (tjw@tjw.org)
|
||||
|
||||
This file is part of Quake III Arena source code.
|
||||
|
||||
Quake III Arena source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
Quake III Arena source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Quake III Arena source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#ifndef __CL_HTTP_H__
|
||||
#define __CL_HTTP_H__
|
||||
|
||||
#include "../qcommon/q_shared.h"
|
||||
|
||||
qboolean CL_HTTP_Init( void );
|
||||
qboolean CL_HTTP_Available( void );
|
||||
void CL_HTTP_Shutdown( void );
|
||||
void CL_HTTP_BeginDownload( const char *localName, const char *remoteURL );
|
||||
void CL_HTTP_PerformDownload( void );
|
||||
|
||||
#endif // __CL_HTTP_H__
|
||||
@@ -20,10 +20,23 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#ifdef USE_CURL
|
||||
#ifdef USE_HTTP
|
||||
|
||||
#include "client.h"
|
||||
|
||||
#ifdef USE_CURL_DLOPEN
|
||||
#ifdef USE_LOCAL_HEADERS
|
||||
#include "curl/curl.h"
|
||||
#else
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define DEFAULT_CURL_LIB "libcurl.dylib"
|
||||
#else
|
||||
#define DEFAULT_CURL_LIB "libcurl.so.4"
|
||||
#define ALTERNATE_CURL_LIB "libcurl.so.3"
|
||||
#endif
|
||||
|
||||
#include "../sys/sys_loadlib.h"
|
||||
|
||||
cvar_t *cl_cURLLib;
|
||||
@@ -57,6 +70,10 @@ CURLMsg *(*qcurl_multi_info_read)(CURLM *multi_handle,
|
||||
const char *(*qcurl_multi_strerror)(CURLMcode);
|
||||
|
||||
static void *cURLLib = NULL;
|
||||
static qboolean cURLSymbolLoadFailed = qfalse;
|
||||
|
||||
static CURL *downloadCURL = NULL;
|
||||
static CURLM *downloadCURLM = NULL;
|
||||
|
||||
/*
|
||||
=================
|
||||
@@ -71,7 +88,7 @@ static void *GPA(char *str)
|
||||
if(!rv)
|
||||
{
|
||||
Com_Printf("Can't load symbol %s\n", str);
|
||||
clc.cURLEnabled = qfalse;
|
||||
cURLSymbolLoadFailed = qtrue;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
@@ -80,19 +97,18 @@ static void *GPA(char *str)
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
#endif /* USE_CURL_DLOPEN */
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_cURL_Init
|
||||
CL_HTTP_Init
|
||||
=================
|
||||
*/
|
||||
qboolean CL_cURL_Init()
|
||||
qboolean CL_HTTP_Init()
|
||||
{
|
||||
#ifdef USE_CURL_DLOPEN
|
||||
if(cURLLib)
|
||||
return qtrue;
|
||||
|
||||
cl_cURLLib = Cvar_Get("cl_cURLLib", DEFAULT_CURL_LIB, CVAR_ARCHIVE | CVAR_PROTECTED);
|
||||
|
||||
Com_Printf("Loading \"%s\"...", cl_cURLLib->string);
|
||||
if(!(cURLLib = Sys_LoadDll(cl_cURLLib->string, qtrue)))
|
||||
@@ -104,7 +120,7 @@ qboolean CL_cURL_Init()
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
clc.cURLEnabled = qtrue;
|
||||
cURLSymbolLoadFailed = qfalse;
|
||||
|
||||
qcurl_version = GPA("curl_version");
|
||||
|
||||
@@ -126,30 +142,62 @@ qboolean CL_cURL_Init()
|
||||
qcurl_multi_info_read = GPA("curl_multi_info_read");
|
||||
qcurl_multi_strerror = GPA("curl_multi_strerror");
|
||||
|
||||
if(!clc.cURLEnabled)
|
||||
if(cURLSymbolLoadFailed)
|
||||
{
|
||||
CL_cURL_Shutdown();
|
||||
CL_HTTP_Shutdown();
|
||||
Com_Printf("FAIL One or more symbols not found\n");
|
||||
return qfalse;
|
||||
}
|
||||
Com_Printf("OK\n");
|
||||
|
||||
return qtrue;
|
||||
#else
|
||||
clc.cURLEnabled = qtrue;
|
||||
return qtrue;
|
||||
#endif /* USE_CURL_DLOPEN */
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_cURL_Shutdown
|
||||
CL_HTTP_Available
|
||||
=================
|
||||
*/
|
||||
void CL_cURL_Shutdown( void )
|
||||
qboolean CL_HTTP_Available()
|
||||
{
|
||||
return cURLLib != NULL;
|
||||
}
|
||||
|
||||
static void CL_cURL_Cleanup(void)
|
||||
{
|
||||
if(downloadCURLM) {
|
||||
CURLMcode result;
|
||||
|
||||
if(downloadCURL) {
|
||||
result = qcurl_multi_remove_handle(downloadCURLM,
|
||||
downloadCURL);
|
||||
if(result != CURLM_OK) {
|
||||
Com_DPrintf("qcurl_multi_remove_handle failed: %s\n", qcurl_multi_strerror(result));
|
||||
}
|
||||
qcurl_easy_cleanup(downloadCURL);
|
||||
}
|
||||
result = qcurl_multi_cleanup(downloadCURLM);
|
||||
if(result != CURLM_OK) {
|
||||
Com_DPrintf("CL_cURL_Cleanup: qcurl_multi_cleanup failed: %s\n", qcurl_multi_strerror(result));
|
||||
}
|
||||
downloadCURLM = NULL;
|
||||
downloadCURL = NULL;
|
||||
}
|
||||
else if(downloadCURL) {
|
||||
qcurl_easy_cleanup(downloadCURL);
|
||||
downloadCURL = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_HTTP_Shutdown
|
||||
=================
|
||||
*/
|
||||
void CL_HTTP_Shutdown( void )
|
||||
{
|
||||
CL_cURL_Cleanup();
|
||||
#ifdef USE_CURL_DLOPEN
|
||||
|
||||
if(cURLLib)
|
||||
{
|
||||
Sys_UnloadLibrary(cURLLib);
|
||||
@@ -171,33 +219,6 @@ void CL_cURL_Shutdown( void )
|
||||
qcurl_multi_cleanup = NULL;
|
||||
qcurl_multi_info_read = NULL;
|
||||
qcurl_multi_strerror = NULL;
|
||||
#endif /* USE_CURL_DLOPEN */
|
||||
}
|
||||
|
||||
void CL_cURL_Cleanup(void)
|
||||
{
|
||||
if(clc.downloadCURLM) {
|
||||
CURLMcode result;
|
||||
|
||||
if(clc.downloadCURL) {
|
||||
result = qcurl_multi_remove_handle(clc.downloadCURLM,
|
||||
clc.downloadCURL);
|
||||
if(result != CURLM_OK) {
|
||||
Com_DPrintf("qcurl_multi_remove_handle failed: %s\n", qcurl_multi_strerror(result));
|
||||
}
|
||||
qcurl_easy_cleanup(clc.downloadCURL);
|
||||
}
|
||||
result = qcurl_multi_cleanup(clc.downloadCURLM);
|
||||
if(result != CURLM_OK) {
|
||||
Com_DPrintf("CL_cURL_Cleanup: qcurl_multi_cleanup failed: %s\n", qcurl_multi_strerror(result));
|
||||
}
|
||||
clc.downloadCURLM = NULL;
|
||||
clc.downloadCURL = NULL;
|
||||
}
|
||||
else if(clc.downloadCURL) {
|
||||
qcurl_easy_cleanup(clc.downloadCURL);
|
||||
clc.downloadCURL = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int CL_cURL_CallbackProgress(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
|
||||
@@ -243,13 +264,13 @@ CURLcode qcurl_easy_setopt_warn(CURL *curl, CURLoption option, ...)
|
||||
return result;
|
||||
}
|
||||
|
||||
void CL_cURL_BeginDownload( const char *localName, const char *remoteURL )
|
||||
void CL_HTTP_BeginDownload( const char *localName, const char *remoteURL )
|
||||
{
|
||||
CURLMcode result;
|
||||
|
||||
clc.cURLUsed = qtrue;
|
||||
clc.httpUsed = qtrue;
|
||||
Com_Printf("URL: %s\n", remoteURL);
|
||||
Com_DPrintf("***** CL_cURL_BeginDownload *****\n"
|
||||
Com_DPrintf("***** CL_HTTP_BeginDownload *****\n"
|
||||
"Localname: %s\n"
|
||||
"RemoteURL: %s\n"
|
||||
"****************************\n", localName, remoteURL);
|
||||
@@ -268,81 +289,81 @@ void CL_cURL_BeginDownload( const char *localName, const char *remoteURL )
|
||||
clc.downloadBlock = 0; // Starting new file
|
||||
clc.downloadCount = 0;
|
||||
|
||||
clc.downloadCURL = qcurl_easy_init();
|
||||
if(!clc.downloadCURL) {
|
||||
Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_easy_init() "
|
||||
downloadCURL = qcurl_easy_init();
|
||||
if(!downloadCURL) {
|
||||
Com_Error(ERR_DROP, "CL_HTTP_BeginDownload: qcurl_easy_init() "
|
||||
"failed");
|
||||
return;
|
||||
}
|
||||
clc.download = FS_SV_FOpenFileWrite(clc.downloadTempName);
|
||||
if(!clc.download) {
|
||||
Com_Error(ERR_DROP, "CL_cURL_BeginDownload: failed to open "
|
||||
Com_Error(ERR_DROP, "CL_HTTP_BeginDownload: failed to open "
|
||||
"%s for writing", clc.downloadTempName);
|
||||
return;
|
||||
}
|
||||
|
||||
if(com_developer->integer)
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_VERBOSE, 1);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_URL, clc.downloadURL);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_TRANSFERTEXT, 0);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_REFERER, va("ioQ3://%s",
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_VERBOSE, 1);
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_URL, clc.downloadURL);
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_TRANSFERTEXT, 0);
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_REFERER, va("ioQ3://%s",
|
||||
NET_AdrToString(clc.serverAddress)));
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_USERAGENT, va("%s %s",
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_USERAGENT, va("%s %s",
|
||||
Q3_VERSION, qcurl_version()));
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_WRITEFUNCTION,
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_WRITEFUNCTION,
|
||||
CL_cURL_CallbackWrite);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_WRITEDATA, &clc.download);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_NOPROGRESS, 0);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_XFERINFOFUNCTION,
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_WRITEDATA, &clc.download);
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_NOPROGRESS, 0);
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_XFERINFOFUNCTION,
|
||||
CL_cURL_CallbackProgress);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_PROGRESSDATA, NULL);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_FAILONERROR, 1);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_FOLLOWLOCATION, 1);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_MAXREDIRS, 5);
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_PROTOCOLS_STR, "http,https");
|
||||
qcurl_easy_setopt_warn(clc.downloadCURL, CURLOPT_BUFFERSIZE, CURL_MAX_READ_SIZE);
|
||||
clc.downloadCURLM = qcurl_multi_init();
|
||||
if(!clc.downloadCURLM) {
|
||||
qcurl_easy_cleanup(clc.downloadCURL);
|
||||
clc.downloadCURL = NULL;
|
||||
Com_Error(ERR_DROP, "CL_cURL_BeginDownload: qcurl_multi_init() "
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_PROGRESSDATA, NULL);
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_FAILONERROR, 1);
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_FOLLOWLOCATION, 1);
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_MAXREDIRS, 5);
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_PROTOCOLS_STR, "http,https");
|
||||
qcurl_easy_setopt_warn(downloadCURL, CURLOPT_BUFFERSIZE, CURL_MAX_READ_SIZE);
|
||||
downloadCURLM = qcurl_multi_init();
|
||||
if(!downloadCURLM) {
|
||||
qcurl_easy_cleanup(downloadCURL);
|
||||
downloadCURL = NULL;
|
||||
Com_Error(ERR_DROP, "CL_HTTP_BeginDownload: qcurl_multi_init() "
|
||||
"failed");
|
||||
return;
|
||||
}
|
||||
result = qcurl_multi_add_handle(clc.downloadCURLM, clc.downloadCURL);
|
||||
result = qcurl_multi_add_handle(downloadCURLM, downloadCURL);
|
||||
if(result != CURLM_OK) {
|
||||
qcurl_easy_cleanup(clc.downloadCURL);
|
||||
clc.downloadCURL = NULL;
|
||||
Com_Error(ERR_DROP,"CL_cURL_BeginDownload: qcurl_multi_add_handle() failed: %s", qcurl_multi_strerror(result));
|
||||
qcurl_easy_cleanup(downloadCURL);
|
||||
downloadCURL = NULL;
|
||||
Com_Error(ERR_DROP,"CL_HTTP_BeginDownload: qcurl_multi_add_handle() failed: %s", qcurl_multi_strerror(result));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(clc.sv_allowDownload & DLF_NO_DISCONNECT) &&
|
||||
!clc.cURLDisconnected) {
|
||||
!clc.disconnectedForHttpDownload) {
|
||||
|
||||
CL_AddReliableCommand("disconnect", qtrue);
|
||||
CL_WritePacket();
|
||||
CL_WritePacket();
|
||||
CL_WritePacket();
|
||||
clc.cURLDisconnected = qtrue;
|
||||
clc.disconnectedForHttpDownload = qtrue;
|
||||
}
|
||||
}
|
||||
|
||||
void CL_cURL_PerformDownload(void)
|
||||
void CL_HTTP_PerformDownload(void)
|
||||
{
|
||||
CURLMcode res;
|
||||
CURLMsg *msg;
|
||||
int c;
|
||||
int i = 0;
|
||||
|
||||
res = qcurl_multi_perform(clc.downloadCURLM, &c);
|
||||
res = qcurl_multi_perform(downloadCURLM, &c);
|
||||
while(res == CURLM_CALL_MULTI_PERFORM && i < 100) {
|
||||
res = qcurl_multi_perform(clc.downloadCURLM, &c);
|
||||
res = qcurl_multi_perform(downloadCURLM, &c);
|
||||
i++;
|
||||
}
|
||||
if(res == CURLM_CALL_MULTI_PERFORM)
|
||||
return;
|
||||
msg = qcurl_multi_info_read(clc.downloadCURLM, &c);
|
||||
msg = qcurl_multi_info_read(downloadCURLM, &c);
|
||||
if(msg == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -363,4 +384,5 @@ void CL_cURL_PerformDownload(void)
|
||||
|
||||
CL_NextDownload();
|
||||
}
|
||||
#endif /* USE_CURL */
|
||||
|
||||
#endif /* USE_HTTP */
|
||||
+25
-27
@@ -1210,8 +1210,8 @@ void CL_ShutdownAll(qboolean shutdownRef)
|
||||
if(clc.demorecording)
|
||||
CL_StopRecord_f();
|
||||
|
||||
#ifdef USE_CURL
|
||||
CL_cURL_Shutdown();
|
||||
#ifdef USE_HTTP
|
||||
CL_HTTP_Shutdown();
|
||||
#endif
|
||||
// clear sounds
|
||||
S_DisableSounds();
|
||||
@@ -2088,17 +2088,17 @@ Called when all downloading has been completed
|
||||
*/
|
||||
void CL_DownloadsComplete( void ) {
|
||||
|
||||
#ifdef USE_CURL
|
||||
// if we downloaded with cURL
|
||||
if(clc.cURLUsed) {
|
||||
clc.cURLUsed = qfalse;
|
||||
CL_cURL_Shutdown();
|
||||
if( clc.cURLDisconnected ) {
|
||||
#ifdef USE_HTTP
|
||||
// if we downloaded with HTTP
|
||||
if(clc.httpUsed) {
|
||||
clc.httpUsed = qfalse;
|
||||
CL_HTTP_Shutdown();
|
||||
if( clc.disconnectedForHttpDownload ) {
|
||||
if(clc.downloadRestart) {
|
||||
FS_Restart(clc.checksumFeed);
|
||||
clc.downloadRestart = qfalse;
|
||||
}
|
||||
clc.cURLDisconnected = qfalse;
|
||||
clc.disconnectedForHttpDownload = qfalse;
|
||||
CL_Reconnect_f();
|
||||
return;
|
||||
}
|
||||
@@ -2193,7 +2193,7 @@ void CL_NextDownload(void)
|
||||
{
|
||||
char *s;
|
||||
char *remoteName, *localName;
|
||||
qboolean useCURL = qfalse;
|
||||
qboolean usedHTTP = qfalse;
|
||||
|
||||
// A download has finished, check whether this matches a referenced checksum
|
||||
if(*clc.downloadName)
|
||||
@@ -2230,7 +2230,7 @@ void CL_NextDownload(void)
|
||||
*s++ = 0;
|
||||
else
|
||||
s = localName + strlen(localName); // point at the nul byte
|
||||
#ifdef USE_CURL
|
||||
#ifdef USE_HTTP
|
||||
if(!(cl_allowDownload->integer & DLF_NO_REDIRECT)) {
|
||||
if(clc.sv_allowDownload & DLF_NO_REDIRECT) {
|
||||
Com_Printf("WARNING: server does not "
|
||||
@@ -2243,14 +2243,10 @@ void CL_NextDownload(void)
|
||||
"download redirection, but does not "
|
||||
"have sv_dlURL set\n");
|
||||
}
|
||||
else if(!CL_cURL_Init()) {
|
||||
Com_Printf("WARNING: could not load "
|
||||
"cURL library\n");
|
||||
}
|
||||
else {
|
||||
CL_cURL_BeginDownload(localName, va("%s/%s",
|
||||
else if(CL_HTTP_Available()) {
|
||||
CL_HTTP_BeginDownload(localName, va("%s/%s",
|
||||
clc.sv_dlURL, remoteName));
|
||||
useCURL = qtrue;
|
||||
usedHTTP = qtrue;
|
||||
}
|
||||
}
|
||||
else if(!(clc.sv_allowDownload & DLF_NO_REDIRECT)) {
|
||||
@@ -2259,8 +2255,8 @@ void CL_NextDownload(void)
|
||||
"configuration (cl_allowDownload is %d)\n",
|
||||
cl_allowDownload->integer);
|
||||
}
|
||||
#endif /* USE_CURL */
|
||||
if(!useCURL) {
|
||||
#endif /* USE_HTTP */
|
||||
if(!usedHTTP) {
|
||||
if((cl_allowDownload->integer & DLF_NO_UDP)) {
|
||||
Com_Error(ERR_DROP, "UDP Downloads are "
|
||||
"disabled on your client. "
|
||||
@@ -2934,13 +2930,13 @@ void CL_Frame ( int msec ) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_CURL
|
||||
if(clc.downloadCURLM) {
|
||||
CL_cURL_PerformDownload();
|
||||
#ifdef USE_HTTP
|
||||
if(clc.httpUsed) {
|
||||
CL_HTTP_PerformDownload();
|
||||
// we can't process frames normally when in disconnected
|
||||
// download mode since the ui vm expects clc.state to be
|
||||
// CA_CONNECTED
|
||||
if(clc.cURLDisconnected) {
|
||||
if(clc.disconnectedForHttpDownload) {
|
||||
cls.realFrametime = msec;
|
||||
cls.frametime = msec;
|
||||
cls.realtime += cls.frametime;
|
||||
@@ -3559,9 +3555,6 @@ void CL_Init( void ) {
|
||||
cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0);
|
||||
|
||||
cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE);
|
||||
#ifdef USE_CURL_DLOPEN
|
||||
cl_cURLLib = Cvar_Get("cl_cURLLib", DEFAULT_CURL_LIB, CVAR_ARCHIVE | CVAR_PROTECTED);
|
||||
#endif
|
||||
|
||||
cl_conXOffset = Cvar_Get ("cl_conXOffset", "0", 0);
|
||||
#ifdef __APPLE__
|
||||
@@ -3656,6 +3649,11 @@ void CL_Init( void ) {
|
||||
cl_voipProtocol = Cvar_Get ("cl_voipProtocol", cl_voip->integer ? "opus" : "", CVAR_USERINFO | CVAR_ROM);
|
||||
#endif
|
||||
|
||||
#ifdef USE_HTTP
|
||||
if(!CL_HTTP_Init()) {
|
||||
Com_Printf("WARNING: couldn't initialize HTTP download support\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// cgame might not be initialized before menu is used
|
||||
Cvar_Get ("cg_viewsize", "100", CVAR_ARCHIVE );
|
||||
|
||||
+7
-10
@@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "../cgame/cg_public.h"
|
||||
#include "../game/bg_public.h"
|
||||
|
||||
#ifdef USE_CURL
|
||||
#include "cl_curl.h"
|
||||
#endif /* USE_CURL */
|
||||
#ifdef USE_HTTP
|
||||
#include "cl_http.h"
|
||||
#endif /* USE_HTTP */
|
||||
|
||||
#ifdef USE_VOIP
|
||||
#include <opus.h>
|
||||
@@ -198,14 +198,11 @@ typedef struct {
|
||||
fileHandle_t download;
|
||||
char downloadTempName[MAX_OSPATH];
|
||||
char downloadName[MAX_OSPATH];
|
||||
#ifdef USE_CURL
|
||||
qboolean cURLEnabled;
|
||||
qboolean cURLUsed;
|
||||
qboolean cURLDisconnected;
|
||||
#ifdef USE_HTTP
|
||||
qboolean httpUsed;
|
||||
qboolean disconnectedForHttpDownload;
|
||||
char downloadURL[MAX_OSPATH];
|
||||
CURL *downloadCURL;
|
||||
CURLM *downloadCURLM;
|
||||
#endif /* USE_CURL */
|
||||
#endif /* USE_HTTP */
|
||||
int sv_allowDownload;
|
||||
char sv_dlURL[MAX_CVAR_VALUE_STRING];
|
||||
int downloadNumber;
|
||||
|
||||
Reference in new issue
Block a user