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

UFOAI web interface management. Authentication as well as uploading/downloading stuff to and from your account is done here. More...

#include "web_main.h"
#include "../cl_shared.h"
#include "../ui/ui_main.h"
#include "web_cgame.h"
#include "../../common/sha1.h"
Include dependency graph for web_main.cpp:

Go to the source code of this file.

Functions

bool WEB_GetURL (const char *url, http_callback_t callback, void *userdata)
 Downloads the given url and notify the callback. The login credentials are automatically added as GET parameters.
bool WEB_GetToFile (const char *url, FILE *file)
 Downloads the given url directly into the given file. The login credentials are automatically added as GET parameters.
bool WEB_PutFile (const char *formName, const char *fileName, const char *url, upparam_t *params)
 Uploads a file to the server with the login credentials.
static void WEB_AuthResponse (const char *response, void *userdata)
 The callback for the web auth request.
bool WEB_Auth (const char *username, const char *password)
 Performs a web auth request.
static void WEB_Auth_f (void)
 Console callback for handling the web auth.
bool WEB_CheckAuth (void)
 Pushes the webauth window if the password is not yet set.
void WEB_InitStartup (void)

Variables

static cvar_tweb_authurl
cvar_tweb_username
cvar_tweb_password
cvar_tweb_userid

Detailed Description

UFOAI web interface management. Authentication as well as uploading/downloading stuff to and from your account is done here.

Definition in file web_main.cpp.

Function Documentation

◆ WEB_Auth()

bool WEB_Auth ( const char * username,
const char * password )

Performs a web auth request.

Parameters
[in]usernameThe (unencoded) username
[in]passwordThe (ununcoded) password
Note
the cvars web_username and web_password are going to become overridden here. If the auth failed, the cvar web_password is set to an empty string again.
Returns
true if the auth was successful, false otherwise.

Definition at line 135 of file web_main.cpp.

References Com_SHA1Buffer(), Com_sprintf(), Cvar_Set(), MAX_VAR, password, Q_strlwr(), Q_strncpyz(), Q_strvalid, user, WEB_AuthResponse(), web_authurl, WEB_GetURL(), and web_password.

Referenced by TEST_F(), and WEB_Auth_f().

◆ WEB_Auth_f()

void WEB_Auth_f ( void )
static

Console callback for handling the web auth.

See also
WEB_Auth

Definition at line 159 of file web_main.cpp.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), UI_ExecuteConfunc(), and WEB_Auth().

Referenced by WEB_InitStartup().

◆ WEB_AuthResponse()

void WEB_AuthResponse ( const char * response,
void * userdata )
static

The callback for the web auth request.

Parameters
[in]responseThe web auth response
[in]userdataThe userdata. NULL in this case.

Definition at line 110 of file web_main.cpp.

References Com_DPrintf(), Cvar_Set(), DEBUG_CLIENT, and Q_streq.

Referenced by WEB_Auth(), and WEB_InitStartup().

◆ WEB_CheckAuth()

bool WEB_CheckAuth ( void )

Pushes the webauth window if the password is not yet set.

Returns
true if the user is authenticated, false otherwise

Definition at line 176 of file web_main.cpp.

References Q_strnull(), UI_PushWindow(), and web_password.

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

◆ WEB_GetToFile()

bool WEB_GetToFile ( const char * url,
FILE * file )

Downloads the given url directly into the given file. The login credentials are automatically added as GET parameters.

Parameters
[in]urlThe url to download
[in]fileThe file to write into
Returns
true if the download was successful, false otherwise

Definition at line 65 of file web_main.cpp.

References Com_Printf(), Com_sprintf(), FILE, HTTP_Encode(), HTTP_GetToFile(), MAX_VAR, web_password, and web_username.

◆ WEB_GetURL()

bool WEB_GetURL ( const char * url,
http_callback_t callback,
void * userdata )

Downloads the given url and notify the callback. The login credentials are automatically added as GET parameters.

Parameters
[in]urlThe url to download
[in]callbackThe callback to given the downloaded data to
[in]userdataUserdata that is given to the callback
Returns
true if the download was successful, false otherwise

Definition at line 44 of file web_main.cpp.

References Com_Printf(), Com_sprintf(), HTTP_Encode(), HTTP_GetURL(), web_password, and web_username.

Referenced by WEB_Auth(), WEB_CGameDelete(), WEB_CGameListForUser(), and WEB_InitStartup().

◆ WEB_InitStartup()

◆ WEB_PutFile()

bool WEB_PutFile ( const char * formName,
const char * fileName,
const char * url,
upparam_t * params )

Uploads a file to the server with the login credentials.

Parameters
[in]formNameThe name of the form to submit with the file upload
[in]fileNameThe filename to upload - this must be a full path, not a virtual filesystem path
[in]urlThe url to open
[in]paramsAdditional parameters for the form. The username and password values are automatically filled in and don't have to be specified here.

Definition at line 87 of file web_main.cpp.

References HTTP_PutFile(), upparam_t::name, upparam_t::next, upparam_t::value, web_password, and web_username.

Referenced by WEB_CGameUpload().

Variable Documentation

◆ web_authurl

cvar_t* web_authurl
static

Definition at line 32 of file web_main.cpp.

Referenced by WEB_Auth(), and WEB_InitStartup().

◆ web_password

cvar_t* web_password

◆ web_userid

◆ web_username

cvar_t* web_username

Definition at line 33 of file web_main.cpp.

Referenced by WEB_GetToFile(), WEB_GetURL(), WEB_InitStartup(), and WEB_PutFile().