75 if (
w->hwnd == NULL) {
81 int i = 0, temp =
w->time_remaining;
84 i = strlen(
w->time_left);
90 w->time_left = malloc(i +
SLEN(
" s") + 1);
91 if (
w->time_left != NULL) {
92 if (
w->time_remaining > 3600)
93 sprintf(
w->time_left,
"%d h",
94 w->time_remaining / 3600);
95 else if (
w->time_remaining > 60)
96 sprintf(
w->time_left,
"%d m",
97 w->time_remaining / 60);
99 sprintf(
w->time_left,
"%d s",
103 char label[strlen(
w->title) + strlen(
size) + strlen(
w->total_size) +
104 + strlen(
w->domain) + strlen(
w->filename) +
105 SLEN(
"download from to \n[\t/\t]\n estimate of time"
106 " remaining ") + i + 1];
107 sprintf(label,
"download %s from %s to %s\n[%s\t/\t%s] [%d%%]\n"
108 "estimate of time remaining %s",
w->title,
w->domain,
109 w->filename,
size,
w->total_size,
w->progress / 100,
111 if (
w->time_left != NULL) {
115 SendMessage(sub, WM_SETTEXT, (WPARAM)0, (LPARAM)label);
116 if (
w->progress < 10000) {
125 if (
w->hwnd == NULL) {
130 SendMessage(sub, PBM_SETPOS, (WPARAM)(
w->progress / 100), 0);
131 if (
w->progress < 10000) {
141 if (
w->title != NULL)
143 if (
w->filename != NULL)
145 if (
w->domain != NULL)
147 if (
w->time_left != NULL)
149 if (
w->total_size != NULL)
168 switch(LOWORD(wparam)) {
178 EndDialog(
hwnd, IDCANCEL);
188 w->hwnd = CreateDialog(
hinst,
192 if (
w->hwnd == NULL) {
219 const char *
size = (unknown_size) ?
251 SHGetFolderPath(NULL, CSIDL_DESKTOP, NULL, SHGFP_TYPE_CURRENT,
257 NSLOG(netsurf, INFO,
"download %s [%s] from %s to %s",
filename,
262 w->total_size = strdup(
size);
263 if (
w->total_size == NULL) {
273 gettimeofday(&(
w->start_time), NULL);
274 w->time_remaining = -1;
282 if (
w->file == NULL) {
312 if ((
w == NULL) || (
w->file == NULL))
316 res = fwrite((
void *)data, 1, size, w->
file);
318 NSLOG(netsurf, INFO,
"file write error %d of %d", size - res,
323 gettimeofday(&val, NULL);
331 const char *error_msg)
333 NSLOG(netsurf, INFO,
"error %s", error_msg);
342 EndDialog(w->
hwnd, IDOK);
Fetching of data from a URL (interface).
nsurl * download_context_get_url(const download_context *ctx)
Retrieve the URL for a download.
unsigned long long int download_context_get_total_length(const download_context *ctx)
Retrieve total byte length of download.
Core download context (interface)
nserror
Enumeration of error codes.
@ NSERROR_SAVE_FAILED
Failed to save data.
static BOOL CALLBACK nsws_download_event_callback(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
static struct gui_download_table download_table
static nserror gui_download_window_data(struct gui_download_window *w, const char *data, unsigned int size)
struct gui_download_table * win32_download_table
static struct gui_download_window * gui_download_window_create(download_context *ctx, struct gui_window *gui)
static void nsws_download_update_progress(void *p)
static void gui_download_window_done(struct gui_download_window *w)
static void nsws_download_clear_data(struct gui_download_window *w)
static void gui_download_window_error(struct gui_download_window *w, const char *error_msg)
static void nsws_download_update_label(void *p)
static struct gui_download_window * download1
static bool nsws_download_window_up(struct gui_download_window *w)
Interface to platform-specific download operations.
internet structures and defines
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Localised message support (interface).
NetSurf URL handling (interface).
bool nsurl_has_component(const nsurl *url, nsurl_component part)
Enquire about the existence of componenets in a given URL.
nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions)
Attempt to find a nice filename for a URL.
lwc_string * nsurl_get_component(const nsurl *url, nsurl_component part)
Get part of a URL as a lwc_string, from a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
#define IDC_DOWNLOAD_LABEL
#define IDC_DOWNLOAD_PROGRESS
Interface to utility string handling.
char * human_friendly_bytesize(unsigned long long int bytesize)
Create a human readable representation of a size in bytes.
A context for a download.
function table for download windows.
struct gui_download_window *(* create)(struct download_context *ctx, struct gui_window *parent)
context for each download.
char * original_total_size
struct ami_generic_window w
os_fw file
RISC OS file handle, of temporary file when !saved, and of destination when saved.
struct gui_window * window
unsigned int total_size
Size of resource, or 0 if unknown.
struct download_context * ctx
Associated context, or 0 if the fetch has completed or aborted.
first entry in window list
BSD style timeval macros.
Interface to URL parsing and joining operations.
Interface to a number of general purpose functionality.
#define fallthrough
switch fall through
#define SLEN(x)
Calculate length of constant C string.
nserror win32_warning(const char *warning, const char *detail)
Warn the user of an event.
HINSTANCE hinst
win32 application instance handle.
nserror win32_schedule(int ival, void(*callback)(void *p), void *p)
Schedule a callback.
HWND gui_window_main_window(struct gui_window *w)
Get the main win32 window handle from a gui window.