UFO: Alien Invasion
Loading...
Searching...
No Matches
web_cgame.cpp File Reference

UFOAI web interface management. c(lient)game related stuff. More...

#include "web_cgame.h"
#include "web_main.h"
#include "../cl_shared.h"
#include "../cgame/cl_game.h"
#include "../ui/ui_main.h"
#include "../../shared/parse.h"
Include dependency graph for web_cgame.cpp:

Go to the source code of this file.

Macros

#define URL_SIZE   576

Functions

static const char * WEB_CGameGetURL (char *out, size_t outSize, const char *url, const char *cgameId, int category, const char *filename, int userId=-1)
 Replaces placeholders in the urls with given values.
bool WEB_CGameUpload (const char *cgameId, int category, const char *filename)
 Uploads a file to the server.
bool WEB_CGameDelete (const char *cgameId, int category, const char *filename)
 Deletes a user owned file on the server.
bool WEB_CGameDownloadFromUser (const char *cgameId, int category, const char *filename, int userId)
 Downloads a file from the server and store it in the user directory.
static void WEB_ListCGameFilesCallback (const char *responseBuf, void *userdata)
 The http callback for the cgame list command.
int WEB_CGameListForUser (const char *cgameId, int category, int userId)
 Shows the uploaded files for the particular cgame category and the given userid.
static void WEB_UploadCGame_f (void)
static void WEB_DeleteCGame_f (void)
static void WEB_DownloadCGame_f (void)
static void WEB_ListCGame_f (void)
void WEB_CGameCvars (void)
void WEB_CGameCommands (void)

Variables

static cvar_tweb_cgamedownloadurl
static cvar_tweb_cgamedeleteurl
static cvar_tweb_cgameuploadurl
static cvar_tweb_cgamelisturl

Detailed Description

UFOAI web interface management. c(lient)game related stuff.

Definition in file web_cgame.cpp.

Macro Definition Documentation

◆ URL_SIZE

#define URL_SIZE   576

Function Documentation

◆ WEB_CGameCommands()

void WEB_CGameCommands ( void )

◆ WEB_CGameCvars()

void WEB_CGameCvars ( void )

◆ WEB_CGameDelete()

bool WEB_CGameDelete ( const char * cgameId,
int category,
const char * filename )

Deletes a user owned file on the server.

Parameters
[in]cgameIdThe cgame id that is used to get the file.
[in]categoryThe category of the cgame.
[in]filenameThe filename to replace in the URL.
Note
The current authenticated user will be taken.
Returns
true if the deletion of the file was successful, false otherwise.

Definition at line 152 of file web_cgame.cpp.

References Com_Printf(), Com_SkipPath(), Com_StripExtension(), MAX_VAR, UI_ExecuteConfunc(), URL_SIZE, web_cgamedeleteurl, WEB_CGameGetURL(), WEB_CheckAuth(), WEB_GetURL(), and web_userid.

Referenced by GAME_WebDelete(), TEST_F(), and WEB_DeleteCGame_f().

◆ WEB_CGameDownloadFromUser()

bool WEB_CGameDownloadFromUser ( const char * cgameId,
int category,
const char * filename,
int userId )

Downloads a file from the server and store it in the user directory.

Parameters
[in]cgameIdThe cgame id that is used to get the file.
[in]categoryThe category of the cgame.
[in]filenameThe filename to replace in the URL.
[in]userIdThe user id to get the file for. If this is -1 (the default), the current authenticated user will be taken.
Returns
true if the download of the file was successful, false otherwise.

Definition at line 187 of file web_cgame.cpp.

References Com_Printf(), f, FILE_WRITE, FS_OpenFile(), GAME_GetRelativeSavePath(), HTTP_GetToFile(), MAX_OSPATH, Q_strcat(), URL_SIZE, web_cgamedownloadurl, and WEB_CGameGetURL().

Referenced by GAME_WebDownloadFromUser(), TEST_F(), and WEB_DownloadCGame_f().

◆ WEB_CGameGetURL()

const char * WEB_CGameGetURL ( char * out,
size_t outSize,
const char * url,
const char * cgameId,
int category,
const char * filename,
int userId = -1 )
static

Replaces placeholders in the urls with given values.

Parameters
[out]outThe final url
[in]outSizeThe size of the out buffer
[in]urlThe url with all the placeholders included
[in]cgameIdThe cgame id. Mandatory. May not be null.
[in]categoryThe category of the cgame. If -1 then skip it.
[in]filenameThe filename to replace. If null, then skip it.
[in]userIdThe user id to replace. If -1 then skip it.
Returns
The buf pointer, or null in case of an error.

Definition at line 50 of file web_cgame.cpp.

References Com_Printf(), Com_sprintf(), HTTP_Encode(), i, id, lengthof, MAX_VAR, Q_strncpyz(), Q_strreplace(), and URL_SIZE.

Referenced by WEB_CGameDelete(), WEB_CGameDownloadFromUser(), WEB_CGameListForUser(), and WEB_CGameUpload().

◆ WEB_CGameListForUser()

int WEB_CGameListForUser ( const char * cgameId,
int category,
int userId )

Shows the uploaded files for the particular cgame category and the given userid.

Parameters
[in]cgameIdThe cgame id that is used to get a filelist for.
[in]categoryThe category of the cgame.
[in]userIdThe user id to get the file list for. If this is -1 (the default), the current authenticated user will be taken.
Returns
The amount of files that were found on the server. Or -1 on error.

Definition at line 310 of file web_cgame.cpp.

References Com_Printf(), count, UI_ExecuteConfunc(), URL_SIZE, WEB_CGameGetURL(), web_cgamelisturl, WEB_CheckAuth(), WEB_GetURL(), WEB_ListCGameFilesCallback(), and web_userid.

Referenced by GAME_WebListForUser(), TEST_F(), and WEB_ListCGame_f().

◆ WEB_CGameUpload()

bool WEB_CGameUpload ( const char * cgameId,
int category,
const char * filename )

Uploads a file to the server.

Parameters
[in]cgameIdThe cgame id that is used to upload the file.
[in]categoryThe category of the cgame.
[in]filenameThe filename part below the gamedir
Note
The current authenticated user will be taken.
Files can only get uploaded from within the user directory. You can't upload game provided content.
Returns
true if the upload of the file was successful, false otherwise.

Definition at line 106 of file web_cgame.cpp.

References Com_Printf(), FS_FileExists(), FS_Gamedir(), Q_strnull(), UI_ExecuteConfunc(), URL_SIZE, va(), WEB_CGameGetURL(), web_cgameuploadurl, WEB_CheckAuth(), and WEB_PutFile().

Referenced by GAME_WebUpload(), TEST_F(), and WEB_UploadCGame_f().

◆ WEB_DeleteCGame_f()

void WEB_DeleteCGame_f ( void )
static

Definition at line 352 of file web_cgame.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), GAME_GetCurrentName(), name, and WEB_CGameDelete().

Referenced by WEB_CGameCommands().

◆ WEB_DownloadCGame_f()

void WEB_DownloadCGame_f ( void )
static

◆ WEB_ListCGame_f()

void WEB_ListCGame_f ( void )
static

◆ WEB_ListCGameFilesCallback()

void WEB_ListCGameFilesCallback ( const char * responseBuf,
void * userdata )
static

The http callback for the cgame list command.

Parameters
[in]responseBufThe cgame list in ufo script format
[in]userdataThis can be used to return the amount of files that were listed

Definition at line 218 of file web_cgame.cpp.

References Com_DPrintf(), Com_EParseValue(), Com_Parse(), Com_Printf(), Com_SkipPath(), Com_StripExtension(), count, DEBUG_CLIENT, level, MAX_OSPATH, MAX_VAR, MEMBER_SIZEOF, name, OBJZERO, value_t::ofs, Q_streq, value_t::size, value_t::string, value_t::type, UI_ExecuteConfunc(), V_INT, V_NULL, V_STRING, and web_userid.

Referenced by WEB_CGameListForUser().

◆ WEB_UploadCGame_f()

void WEB_UploadCGame_f ( void )
static

Variable Documentation

◆ web_cgamedeleteurl

cvar_t* web_cgamedeleteurl
static

Definition at line 33 of file web_cgame.cpp.

Referenced by WEB_CGameCvars(), and WEB_CGameDelete().

◆ web_cgamedownloadurl

cvar_t* web_cgamedownloadurl
static

Definition at line 32 of file web_cgame.cpp.

Referenced by WEB_CGameCvars(), and WEB_CGameDownloadFromUser().

◆ web_cgamelisturl

cvar_t* web_cgamelisturl
static

Definition at line 35 of file web_cgame.cpp.

Referenced by WEB_CGameCvars(), and WEB_CGameListForUser().

◆ web_cgameuploadurl

cvar_t* web_cgameuploadurl
static

Definition at line 34 of file web_cgame.cpp.

Referenced by WEB_CGameCvars(), and WEB_CGameUpload().