Atrinik Client 2.5
Functions | Variables
gui/updater.c File Reference
#include <global.h>

Go to the source code of this file.

Functions

static char * updater_get_dir (char *buf, size_t len)
static void cleanup_patch_files ()
static void popup_draw_func_post (popup_struct *popup)
static int popup_destroy_callback (popup_struct *popup)
void updater_open ()

Variables

static curl_datadl_data = NULL
static update_file_structdownload_packages
static size_t download_packages_num = 0
static size_t download_package_next = 0
static size_t download_packages_downloaded = 0
static uint8 download_package_process = 0
static progress_dots progress

Detailed Description

Handles the update popup, which is triggered by clicking the 'Update' button on the main client screen.

As soon as the update popup is opened, cURL will attempt to check with the update server whether there are any new versions available, by sending it the current client's version, which the update server checks. The update server will send a response, which may be empty, but may contain filenames and SHA-1 sums of updates that the client has to download in order to update to the latest version.

Now, the behavior is different on the platform the client is running on.

For Windows:

When the response is received, it is parsed, and the updates (if any) are stored in download_packages The client will then attempt to download the updates by their file names one-by-one by using cURL, and saving the result in "client_patch_NUM.tar.gz" where NUM is the ID of the update (starting with zero and increasing each time a new file is downloaded) and is padded with zeroes. The directory the file is saved in is determined by updater_get_dir(). On Windows, for example, it would be stored in AppData%/.atrinik/temp. It is not saved in the same directory as the client executable due to Windows UAC, which marks various directories, including Program Files as protected.

Note that if the downloaded file content does not match the SHA-1, the update will be stopped, and it will only install the updates downloaded prior to the one that failed the SHA-1 check (if any).

After the updater has finished downloading all updates (if none, it just informs the user that they are running an up-to-date client), it tells the user to restart their client to apply the updates, and shows a handy 'Restart' button, which closes the client and opens it again. This is done by calling up_dater.exe - which is also the executable called by shortcuts - which runs atrinik_updater.bat as administrator (popping up UAC prompt), which extracts the downloaded updates, removes the temporary directory, and starts up the client. If there are no updates, up_dater.exe simply starts up the Atrinik client normally.

The reason there is up_dater.exe and atrinik_updater.bat is that Windows UAC is unable to only prompt for administrator password when requested from a running program - it can only do so when starting up a program, and administrator rights are necessary to write to protected directories, such as Program Files, where the client may be installed. up_dater.exe has an underscore in its filename because otherwise Windows would (due to backwards compatibility, or some other reason) popup UAC prompt each time it's started, even when there are no updates available and it's not running atrinik_updater.bat as administrator.

For GNU/Linux:

If there are any updates available, the user is simply instructed to use their update manager to update.

Author:
Alex Tokar

Definition in file updater.c.


Function Documentation

static void cleanup_patch_files ( ) [static]

Cleans up updater files - basically recursively removes the temporary directory.

Definition at line 118 of file updater.c.

static int popup_destroy_callback ( popup_struct popup) [static]

Called when the updater popup is destroyed; frees the data used (if any), etc.

Parameters:
popupUpdater popup.

Definition at line 353 of file updater.c.

static void popup_draw_func_post ( popup_struct popup) [static]

Draw contents in the popup.

Definition at line 127 of file updater.c.

static char* updater_get_dir ( char *  buf,
size_t  len 
) [static]

Get temporary directory where updates will be stored.

Parameters:
bufWhere to store the result.
lenSize of 'buf'.
Returns:
'buf'.

Definition at line 109 of file updater.c.

void updater_open ( )

Open the updater popup.

Definition at line 392 of file updater.c.


Variable Documentation

curl_data* dl_data = NULL [static]

Holds data that is currently being downloaded.

Definition at line 90 of file updater.c.

size_t download_package_next = 0 [static]

Next entry in download_packages that should be downloaded.

Definition at line 96 of file updater.c.

Whether we are downloading packages.

Definition at line 100 of file updater.c.

Information about the packages that have to be downloaded.

Definition at line 92 of file updater.c.

size_t download_packages_downloaded = 0 [static]

Number of packages downloaded so far.

Definition at line 98 of file updater.c.

size_t download_packages_num = 0 [static]

Number of packages to download (len of download_packages).

Definition at line 94 of file updater.c.

Progress dots in the popup.

Definition at line 102 of file updater.c.