27 #include "../cl_shared.h"
28 #include "../ui/ui_main.h"
30 #include "../../common/sha1.h"
47 char passwordEncoded[512];
49 char usernameEncoded[128];
51 const char sep = strchr(url,
'?') ?
'&' :
'?';
52 if (!
Com_sprintf(buf,
sizeof(buf),
"%s%cusername=%s&password=%s", url, sep, usernameEncoded, passwordEncoded)) {
53 Com_Printf(
"overflow in url length: '%s'\n", buf);
72 if (!
Com_sprintf(buf,
sizeof(buf),
"%s?username=%s&password=%s", url, usernameEncoded, passwordEncoded)) {
73 Com_Printf(
"overflow in url length: '%s'\n", buf);
91 paramUser.
name =
"username";
93 paramUser.
next = ¶mPassword;
94 paramPassword.
name =
"password";
96 paramPassword.
next =
nullptr;
97 if (params !=
nullptr) {
98 params->
next = ¶mUser;
112 if (response ==
nullptr) {
123 Cvar_Set(
"web_userid",
"%i", atoi(response));
142 Com_sprintf(combined,
sizeof(combined),
"%s%s", user, password);
144 Cvar_Set(
"web_username",
"%s", username);
145 Cvar_Set(
"web_password",
"%s", digest);
192 web_password =
Cvar_Get(
"web_password",
"",
CVAR_ARCHIVE,
"The encrypted password for the UFOAI server.");
193 web_userid =
Cvar_Get(
"web_userid",
"0", 0,
"Your userid for the UFOAI server");
195 "The url to perform the authentication against.");
200 Com_Printf(
"\n------- web initialization ---------\n");
212 Com_Printf(
"... web access not yet configured\n");
bool Q_strnull(const char *string)
const char * Cmd_Argv(int arg)
Returns a given argument.
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
bool Com_SHA1Buffer(const unsigned char *buf, unsigned int len, char digest[41])
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
bool WEB_Auth(const char *username, const char *password)
Performs a web auth request.
void Com_Printf(const char *const fmt,...)
void(* http_callback_t)(const char *response, void *userdata)
static cvar_t * web_authurl
void WEB_CGameCommands(void)
#define Q_strvalid(string)
static void WEB_AuthResponse(const char *response, void *userdata)
The callback for the web auth request.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
uiNode_t * UI_PushWindow(const char *name, const char *parentName, linkedList_t *params)
Push a window onto the window stack.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
bool WEB_GetToFile(const char *url, FILE *file)
Downloads the given url directly into the given file. The login credentials are automatically added a...
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.
bool HTTP_PutFile(const char *formName, const char *fileName, const char *url, const upparam_t *params)
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
bool HTTP_GetToFile(const char *url, FILE *file, const char *postfields)
Downloads the given url into the given file.
bool WEB_CheckAuth(void)
Pushes the webauth window if the password is not yet set.
char * Q_strlwr(char *str)
Converts a string to lowercase.
const char * Sys_GetCurrentUser(void)
void WEB_InitStartup(void)
bool HTTP_Encode(const char *url, char *out, size_t outLength)
This function converts the given url to an URL encoded string. All input characters that are not a-z...
UFOAI web interface management. Authentication as well as uploading/downloading stuff to and from you...
bool HTTP_GetURL(const char *url, http_callback_t callback, void *userdata, const char *postfields)
Downloads the given url and return the data to the callback (optional)
void WEB_CGameCvars(void)
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
UFOAI web interface management. c(lient)game related stuff.
static void WEB_Auth_f(void)
Console callback for handling the web auth.
void UI_ExecuteConfunc(const char *fmt,...)
Executes confunc - just to identify those confuncs in the code - in this frame.
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...