ELinks 0.16.1.1
lun_hop Struct Reference

The user is being asked what to do when the local file for the download already exists. More...

Collaboration diagram for lun_hop:

Data Fields

struct terminalterm
 The terminal in which ELinks is asking the question.
char * ofile
 The name of the local file into which the data was originally going to be downloaded, but which already exists.
char * file
 An alternative file name that the user may choose instead of ofile.
lun_callback_Tcallback
 This function will be called when the user answers.
void * data
 A pointer to be passed to callback.
download_flags_T flags
 Saved flags to be passed to callback.

(Note that these are not member symbols.)

typedef void lun_callback_T(struct terminal *term, char *file, void *data, download_flags_T flags)
 Type of the callback function that will be called when the user answers the question posed by lookup_unique_name().
static void lun_alternate (void *lun_hop_)
 The use chose "Save under the alternative name" when asked where to download a file.
static void lun_cancel (void *lun_hop_)
 The use chose "Cancel" when asked where to download a file.
static void lun_overwrite (void *lun_hop_)
 The use chose "Overwrite the original file" when asked where to download a file.
static void lun_resume (void *lun_hop_)
 The user chose "Resume download of the original file" when asked where to download a file.
static void lookup_unique_name (struct terminal *term, char *ofile, download_flags_T flags, lun_callback_T *callback, void *data)
 If attempting to download to an existing file, perhaps ask the user whether to resume, overwrite, or save elsewhere.

Detailed Description

The user is being asked what to do when the local file for the download already exists.

This structure is allocated by lookup_unique_name() and freed by each lun_* function: lun_alternate(), lun_cancel(), lun_overwrite(), and lun_resume().

◆ lookup_unique_name()

void lookup_unique_name ( struct terminal * term,
char * ofile,
download_flags_T flags,
lun_callback_T * callback,
void * data )
related

If attempting to download to an existing file, perhaps ask the user whether to resume, overwrite, or save elsewhere.

This function constructs a struct lun_hop, which will be freed when the user answers the question.

Parameters
termThe terminal in which this function should show its UI.
[in]ofileA proposed name for the local file to which the data would be downloaded. "~" here refers to the home directory. lookup_unique_name() treats this original string as read-only.
[in]flagsFlags controlling how to download the file. DOWNLOAD_RESUME_ALLOWED adds a "Resume" button to the dialog. DOWNLOAD_RESUME_SELECTED means the user already chose to resume downloading (with ACT_MAIN_LINK_DOWNLOAD_RESUME), before ELinks even asked for the file name; thus don't ask whether to overwrite. Other flags, such as DOWNLOAD_EXTERNAL, have no effect at this level but they get passed to callback.
callbackWill be called when the user answers, or right away if the question need not or cannot be asked.
dataA pointer to be passed to callback.

◆ lun_alternate()

void lun_alternate ( void * lun_hop_)
related

The use chose "Save under the alternative name" when asked where to download a file.

lookup_unique_name() passes this function as a done_handler_T to msg_box().

◆ lun_callback_T

typedef void lun_callback_T(struct terminal *term, char *file, void *data, download_flags_T flags)
related

Type of the callback function that will be called when the user answers the question posed by lookup_unique_name().

Parameters
termThe terminal on which the callback should display any windows. Comes directly from the term argument of lookup_unique_name().
fileThe name of the local file to which the data should be downloaded, or NULL if the download should not begin. The callback is responsible of doing mem_free(file).
dataA pointer to any data that the callback cares about. Comes directly from the data argument of lookup_unique_name().
flagsThe same as the flags argument of create_download_file(), except the DOWNLOAD_RESUME_SELECTED bit will be changed to match what the user chose.

◆ lun_cancel()

void lun_cancel ( void * lun_hop_)
related

The use chose "Cancel" when asked where to download a file.

lookup_unique_name() passes this function as a done_handler_T to msg_box().

◆ lun_overwrite()

void lun_overwrite ( void * lun_hop_)
related

The use chose "Overwrite the original file" when asked where to download a file.

lookup_unique_name() passes this function as a done_handler_T to msg_box().

◆ lun_resume()

void lun_resume ( void * lun_hop_)
related

The user chose "Resume download of the original file" when asked where to download a file.

lookup_unique_name() passes this function as a done_handler_T to msg_box().

Field Documentation

◆ callback

lun_callback_T* lun_hop::callback

This function will be called when the user answers.

◆ data

void* lun_hop::data

A pointer to be passed to callback.

◆ file

char* lun_hop::file

An alternative file name that the user may choose instead of ofile.

The string must be freed with mem_free().

◆ flags

download_flags_T lun_hop::flags

Saved flags to be passed to callback.

If the user chooses to resume, then lun_resume() sets DOWNLOAD_RESUME_SELECTED when it calls callback.

Invariant
The DOWNLOAD_RESUME_SELECTED bit should be clear here because otherwise there would have been no reason to ask the user and initialize this structure.

◆ ofile

char* lun_hop::ofile

The name of the local file into which the data was originally going to be downloaded, but which already exists.

In this string, "~" has already been expanded to the home directory. The string must be freed with mem_free().

◆ term

struct terminal* lun_hop::term

The terminal in which ELinks is asking the question.

This gets passed to callback.


The documentation for this struct was generated from the following file: