Fix line endings.
This commit is contained in:
parent
ec84f27733
commit
c59c314283
384
atari/download.c
384
atari/download.c
|
@ -1,47 +1,47 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 Ole Loots <ole@monochrom.net>
|
* Copyright 2010 Ole Loots <ole@monochrom.net>
|
||||||
*
|
*
|
||||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||||
*
|
*
|
||||||
* NetSurf is free software; you can redistribute it and/or modify
|
* NetSurf is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; version 2 of the License.
|
* the Free Software Foundation; version 2 of the License.
|
||||||
*
|
*
|
||||||
* NetSurf is distributed in the hope that it will be useful,
|
* NetSurf is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "content/urldb.h"
|
#include "content/urldb.h"
|
||||||
#include "content/fetch.h"
|
#include "content/fetch.h"
|
||||||
#include "desktop/gui.h"
|
#include "desktop/gui.h"
|
||||||
#include "desktop/netsurf.h"
|
#include "desktop/netsurf.h"
|
||||||
#include "utils/nsoption.h"
|
#include "utils/nsoption.h"
|
||||||
#include "desktop/save_complete.h"
|
#include "desktop/save_complete.h"
|
||||||
#include "desktop/textinput.h"
|
#include "desktop/textinput.h"
|
||||||
#include "desktop/download.h"
|
#include "desktop/download.h"
|
||||||
#include "render/html.h"
|
#include "render/html.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
#include "utils/messages.h"
|
#include "utils/messages.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
#include "atari/gui.h"
|
#include "atari/gui.h"
|
||||||
#include "atari/misc.h"
|
#include "atari/misc.h"
|
||||||
#include "atari/res/netsurf.rsh"
|
#include "atari/res/netsurf.rsh"
|
||||||
#include "atari/download.h"
|
#include "atari/download.h"
|
||||||
#include "atari/osspec.h"
|
#include "atari/osspec.h"
|
||||||
|
|
||||||
extern struct gui_window * input_window;
|
extern struct gui_window * input_window;
|
||||||
extern GRECT desk_area;
|
extern GRECT desk_area;
|
||||||
|
@ -122,7 +122,7 @@ static short on_aes_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
|
||||||
}
|
}
|
||||||
|
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_redraw(struct gui_download_window *dw, GRECT *clip)
|
static void on_redraw(struct gui_download_window *dw, GRECT *clip)
|
||||||
{
|
{
|
||||||
|
@ -146,8 +146,8 @@ static void on_redraw(struct gui_download_window *dw, GRECT *clip)
|
||||||
((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_PERCENT))->te_ptext = dw->lbl_percent;
|
((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_PERCENT))->te_ptext = dw->lbl_percent;
|
||||||
((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_SPEED))->te_ptext = dw->lbl_speed;
|
((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_SPEED))->te_ptext = dw->lbl_speed;
|
||||||
|
|
||||||
if (dw->size_total > 0 ) {
|
if (dw->size_total > 0 ) {
|
||||||
p = ((double)dw->size_downloaded / (double)dw->size_total * 100);
|
p = ((double)dw->size_downloaded / (double)dw->size_total * 100);
|
||||||
}
|
}
|
||||||
tree[DOWNLOAD_PROGRESS_DONE].ob_width = MAX( MIN( p*(DOWNLOAD_BAR_MAX/100),
|
tree[DOWNLOAD_PROGRESS_DONE].ob_width = MAX( MIN( p*(DOWNLOAD_BAR_MAX/100),
|
||||||
DOWNLOAD_BAR_MAX ), 1);
|
DOWNLOAD_BAR_MAX ), 1);
|
||||||
|
@ -167,58 +167,58 @@ static void on_redraw(struct gui_download_window *dw, GRECT *clip)
|
||||||
wind_get_grect(dw->aes_handle, WF_NEXTXYWH, &visible);
|
wind_get_grect(dw->aes_handle, WF_NEXTXYWH, &visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_abort_click(struct gui_download_window *dw)
|
static void on_abort_click(struct gui_download_window *dw)
|
||||||
{
|
{
|
||||||
if( dw->status == NSATARI_DOWNLOAD_COMPLETE
|
if( dw->status == NSATARI_DOWNLOAD_COMPLETE
|
||||||
|| dw->status == NSATARI_DOWNLOAD_ERROR ) {
|
|| dw->status == NSATARI_DOWNLOAD_ERROR ) {
|
||||||
gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0,0,0,0);
|
gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0,0,0,0);
|
||||||
}
|
}
|
||||||
else if( dw->status != NSATARI_DOWNLOAD_CANCELED ){
|
else if( dw->status != NSATARI_DOWNLOAD_CANCELED ){
|
||||||
dw->abort = true;
|
dw->abort = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_cbrdy_click(struct gui_download_window *dw)
|
static void on_cbrdy_click(struct gui_download_window *dw)
|
||||||
{
|
{
|
||||||
dw->close_on_finish = !dw->close_on_finish;
|
dw->close_on_finish = !dw->close_on_finish;
|
||||||
if (dw->close_on_finish && dw->status == NSATARI_DOWNLOAD_COMPLETE) {
|
if (dw->close_on_finish && dw->status == NSATARI_DOWNLOAD_COMPLETE) {
|
||||||
gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0,0,0,0);
|
gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0,0,0,0);
|
||||||
}
|
}
|
||||||
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
||||||
evnt_timer(250);
|
evnt_timer(250);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_close(struct gui_download_window * dw)
|
static void on_close(struct gui_download_window * dw)
|
||||||
{
|
{
|
||||||
gui_download_window_destroy(dw);
|
gui_download_window_destroy(dw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gui_download_window_destroy( struct gui_download_window * gdw)
|
static void gui_download_window_destroy( struct gui_download_window * gdw)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
LOG((""));
|
LOG((""));
|
||||||
if (gdw->status == NSATARI_DOWNLOAD_WORKING) {
|
if (gdw->status == NSATARI_DOWNLOAD_WORKING) {
|
||||||
download_context_abort(gdw->ctx);
|
download_context_abort(gdw->ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
download_context_destroy(gdw->ctx);
|
download_context_destroy(gdw->ctx);
|
||||||
|
|
||||||
if (gdw->destination) {
|
if (gdw->destination) {
|
||||||
free( gdw->destination );
|
free( gdw->destination );
|
||||||
}
|
}
|
||||||
if (gdw->fd != NULL) {
|
if (gdw->fd != NULL) {
|
||||||
fclose(gdw->fd);
|
fclose(gdw->fd);
|
||||||
gdw->fd = NULL;
|
gdw->fd = NULL;
|
||||||
}
|
}
|
||||||
if (gdw->fbuf != NULL) {
|
if (gdw->fbuf != NULL) {
|
||||||
free( gdw->fbuf );
|
free( gdw->fbuf );
|
||||||
}
|
}
|
||||||
gemtk_wm_remove(gdw->guiwin);
|
gemtk_wm_remove(gdw->guiwin);
|
||||||
wind_close(gdw->aes_handle);
|
wind_close(gdw->aes_handle);
|
||||||
wind_delete(gdw->aes_handle);
|
wind_delete(gdw->aes_handle);
|
||||||
free(gdw);
|
free(gdw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char * select_filepath( const char * path, const char * filename )
|
static char * select_filepath( const char * path, const char * filename )
|
||||||
|
@ -242,14 +242,14 @@ static char * select_filepath( const char * path, const char * filename )
|
||||||
|
|
||||||
printf("download file: %s\n", ret);
|
printf("download file: %s\n", ret);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct gui_download_window *
|
static struct gui_download_window *
|
||||||
gui_download_window_create(download_context *ctx, struct gui_window *parent)
|
gui_download_window_create(download_context *ctx, struct gui_window *parent)
|
||||||
{
|
{
|
||||||
const char *filename;
|
const char *filename;
|
||||||
char *destination;
|
char *destination;
|
||||||
char gdos_path[PATH_MAX];
|
char gdos_path[PATH_MAX];
|
||||||
struct gui_download_window * gdw;
|
struct gui_download_window * gdw;
|
||||||
int dlgres = 0;
|
int dlgres = 0;
|
||||||
OBJECT * tree = gemtk_obj_get_tree(DOWNLOAD);
|
OBJECT * tree = gemtk_obj_get_tree(DOWNLOAD);
|
||||||
|
@ -258,19 +258,19 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent)
|
||||||
|
|
||||||
LOG(("Creating download window for gui window: %p", parent));
|
LOG(("Creating download window for gui window: %p", parent));
|
||||||
|
|
||||||
/* TODO: Implement real form and use messages file strings! */
|
/* TODO: Implement real form and use messages file strings! */
|
||||||
|
|
||||||
if (tree == NULL){
|
if (tree == NULL){
|
||||||
die("Couldn't find AES Object tree for download window!");
|
die("Couldn't find AES Object tree for download window!");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = download_context_get_filename((const download_context*)ctx);
|
filename = download_context_get_filename((const download_context*)ctx);
|
||||||
snprintf(alert, 200, "[2][Accept download?|%.*s][Yes|Save as...|No]",
|
snprintf(alert, 200, "[2][Accept download?|%.*s][Yes|Save as...|No]",
|
||||||
40,filename);
|
40,filename);
|
||||||
dlgres = form_alert(2, alert);
|
dlgres = form_alert(2, alert);
|
||||||
if( dlgres == 3){
|
if( dlgres == 3){
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
else if( dlgres == 2 ){
|
else if( dlgres == 2 ){
|
||||||
gemdos_realpath(nsoption_charp(downloads_path), gdos_path);
|
gemdos_realpath(nsoption_charp(downloads_path), gdos_path);
|
||||||
|
@ -285,38 +285,38 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent)
|
||||||
destination = malloc( dstsize );
|
destination = malloc( dstsize );
|
||||||
snprintf(destination, dstsize, "%s/%s", gdos_path, filename);
|
snprintf(destination, dstsize, "%s/%s", gdos_path, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
gdw = calloc(1, sizeof(struct gui_download_window));
|
gdw = calloc(1, sizeof(struct gui_download_window));
|
||||||
if( gdw == NULL ){
|
if( gdw == NULL ){
|
||||||
warn_user(NULL, "Out of memory!");
|
warn_user(NULL, "Out of memory!");
|
||||||
free( destination );
|
free( destination );
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
gdw->ctx = ctx;
|
gdw->ctx = ctx;
|
||||||
gdw->abort = false;
|
gdw->abort = false;
|
||||||
gdw->start = clock() / CLOCKS_PER_SEC;
|
gdw->start = clock() / CLOCKS_PER_SEC;
|
||||||
gdw->lastrdw = 0;
|
gdw->lastrdw = 0;
|
||||||
gdw->status = NSATARI_DOWNLOAD_WORKING;
|
gdw->status = NSATARI_DOWNLOAD_WORKING;
|
||||||
gdw->parent = parent;
|
gdw->parent = parent;
|
||||||
gdw->fbufsize = MAX(BUFSIZ, 48000);
|
gdw->fbufsize = MAX(BUFSIZ, 48000);
|
||||||
gdw->size_downloaded = 0;
|
gdw->size_downloaded = 0;
|
||||||
gdw->size_total = download_context_get_total_length(ctx);
|
gdw->size_total = download_context_get_total_length(ctx);
|
||||||
gdw->destination = destination;
|
gdw->destination = destination;
|
||||||
gdw->tree = tree;
|
gdw->tree = tree;
|
||||||
|
|
||||||
gdw->fd = fopen(gdw->destination, "wb");
|
gdw->fd = fopen(gdw->destination, "wb");
|
||||||
if( gdw->fd == NULL ){
|
if( gdw->fd == NULL ){
|
||||||
char spare[200];
|
char spare[200];
|
||||||
snprintf(spare, 200, "Couldn't open %s for writing!", gdw->destination);
|
snprintf(spare, 200, "Couldn't open %s for writing!", gdw->destination);
|
||||||
gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, spare);
|
gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, spare);
|
||||||
gui_download_window_destroy(gdw);
|
gui_download_window_destroy(gdw);
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
gdw->fbuf = malloc( gdw->fbufsize+1 );
|
gdw->fbuf = malloc( gdw->fbufsize+1 );
|
||||||
if( gdw->fbuf != NULL ){
|
if( gdw->fbuf != NULL ){
|
||||||
setvbuf( gdw->fd, gdw->fbuf, _IOFBF, gdw->fbufsize );
|
setvbuf( gdw->fd, gdw->fbuf, _IOFBF, gdw->fbufsize );
|
||||||
}
|
}
|
||||||
|
|
||||||
gdw->aes_handle = wind_create_grect(CLOSER | NAME | MOVER, &desk_area);
|
gdw->aes_handle = wind_create_grect(CLOSER | NAME | MOVER, &desk_area);
|
||||||
|
@ -324,17 +324,17 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent)
|
||||||
unsigned long gwflags = GEMTK_WM_FLAG_DEFAULTS;
|
unsigned long gwflags = GEMTK_WM_FLAG_DEFAULTS;
|
||||||
gdw->guiwin = gemtk_wm_add(gdw->aes_handle, gwflags, on_aes_event);
|
gdw->guiwin = gemtk_wm_add(gdw->aes_handle, gwflags, on_aes_event);
|
||||||
if( gdw->guiwin == NULL || gdw->fd == NULL ){
|
if( gdw->guiwin == NULL || gdw->fd == NULL ){
|
||||||
die("could not create guiwin");
|
die("could not create guiwin");
|
||||||
gui_download_window_destroy(gdw);
|
gui_download_window_destroy(gdw);
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
gemtk_wm_set_user_data(gdw->guiwin, gdw);
|
gemtk_wm_set_user_data(gdw->guiwin, gdw);
|
||||||
gemtk_wm_set_toolbar(gdw->guiwin, tree, 0, 0);
|
gemtk_wm_set_toolbar(gdw->guiwin, tree, 0, 0);
|
||||||
gemtk_wm_set_toolbar_redraw_func(gdw->guiwin, toolbar_redraw_cb);
|
gemtk_wm_set_toolbar_redraw_func(gdw->guiwin, toolbar_redraw_cb);
|
||||||
|
|
||||||
strncpy((char*)&gdw->lbl_file, filename, MAX_SLEN_LBL_FILE-1);
|
strncpy((char*)&gdw->lbl_file, filename, MAX_SLEN_LBL_FILE-1);
|
||||||
LOG(("created download: %s (total size: %d)",
|
LOG(("created download: %s (total size: %d)",
|
||||||
gdw->destination, gdw->size_total
|
gdw->destination, gdw->size_total
|
||||||
));
|
));
|
||||||
|
|
||||||
GRECT work, curr;
|
GRECT work, curr;
|
||||||
|
@ -353,17 +353,17 @@ gui_download_window_create(download_context *ctx, struct gui_window *parent)
|
||||||
|
|
||||||
return(gdw);
|
return(gdw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static nserror gui_download_window_data(struct gui_download_window *dw,
|
|
||||||
const char *data, unsigned int size)
|
|
||||||
{
|
|
||||||
|
|
||||||
uint32_t clck = clock();
|
|
||||||
uint32_t tnow = clck / (CLOCKS_PER_SEC>>3);
|
static nserror gui_download_window_data(struct gui_download_window *dw,
|
||||||
|
const char *data, unsigned int size)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32_t clck = clock();
|
||||||
|
uint32_t tnow = clck / (CLOCKS_PER_SEC>>3);
|
||||||
uint32_t sdiff = (clck / (CLOCKS_PER_SEC)) - dw->start;
|
uint32_t sdiff = (clck / (CLOCKS_PER_SEC)) - dw->start;
|
||||||
uint32_t p = 0;
|
uint32_t p = 0;
|
||||||
float speed;
|
float speed;
|
||||||
float pf = 0;
|
float pf = 0;
|
||||||
|
|
||||||
LOG((""));
|
LOG((""));
|
||||||
|
@ -371,85 +371,85 @@ static nserror gui_download_window_data(struct gui_download_window *dw,
|
||||||
OBJECT * tree = dw->tree;
|
OBJECT * tree = dw->tree;
|
||||||
|
|
||||||
if(dw->abort == true){
|
if(dw->abort == true){
|
||||||
dw->status = NSATARI_DOWNLOAD_CANCELED;
|
dw->status = NSATARI_DOWNLOAD_CANCELED;
|
||||||
dw->abort = false;
|
dw->abort = false;
|
||||||
download_context_abort(dw->ctx);
|
download_context_abort(dw->ctx);
|
||||||
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
||||||
return(NSERROR_OK);
|
return(NSERROR_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save data */
|
/* save data */
|
||||||
fwrite( data , size, sizeof(unsigned char),dw->fd );
|
fwrite( data , size, sizeof(unsigned char),dw->fd );
|
||||||
dw->size_downloaded += size;
|
dw->size_downloaded += size;
|
||||||
|
|
||||||
/* Update GUI */
|
/* Update GUI */
|
||||||
if ((tnow - dw->lastrdw) > 1) {
|
if ((tnow - dw->lastrdw) > 1) {
|
||||||
|
|
||||||
dw->lastrdw = tnow;
|
dw->lastrdw = tnow;
|
||||||
speed = dw->size_downloaded / sdiff;
|
speed = dw->size_downloaded / sdiff;
|
||||||
|
|
||||||
if( dw->size_total > 0 ){
|
if( dw->size_total > 0 ){
|
||||||
p = ((double)dw->size_downloaded / (double)dw->size_total * 100);
|
p = ((double)dw->size_downloaded / (double)dw->size_total * 100);
|
||||||
snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
|
snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
|
||||||
"%lu%s", p, "%"
|
"%lu%s", p, "%"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
|
snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
|
||||||
"%s", "?%"
|
"%s", "?%"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
snprintf( (char*)&dw->lbl_speed, MAX_SLEN_LBL_SPEED, "%s/s",
|
snprintf( (char*)&dw->lbl_speed, MAX_SLEN_LBL_SPEED, "%s/s",
|
||||||
human_friendly_bytesize(speed)
|
human_friendly_bytesize(speed)
|
||||||
);
|
);
|
||||||
snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
|
snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
|
||||||
human_friendly_bytesize(dw->size_downloaded),
|
human_friendly_bytesize(dw->size_downloaded),
|
||||||
(dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : "?"
|
(dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : "?"
|
||||||
);
|
);
|
||||||
|
|
||||||
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
||||||
}
|
}
|
||||||
return NSERROR_OK;
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gui_download_window_error(struct gui_download_window *dw,
|
static void gui_download_window_error(struct gui_download_window *dw,
|
||||||
const char *error_msg)
|
const char *error_msg)
|
||||||
{
|
{
|
||||||
LOG(("%s", error_msg));
|
LOG(("%s", error_msg));
|
||||||
strncpy((char*)&dw->lbl_file, error_msg, MAX_SLEN_LBL_FILE-1);
|
strncpy((char*)&dw->lbl_file, error_msg, MAX_SLEN_LBL_FILE-1);
|
||||||
dw->status = NSATARI_DOWNLOAD_ERROR;
|
dw->status = NSATARI_DOWNLOAD_ERROR;
|
||||||
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
||||||
gui_window_set_status(input_window, messages_get("Done") );
|
gui_window_set_status(input_window, messages_get("Done") );
|
||||||
// TODO: change abort to close
|
// TODO: change abort to close
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gui_download_window_done(struct gui_download_window *dw)
|
static void gui_download_window_done(struct gui_download_window *dw)
|
||||||
{
|
{
|
||||||
OBJECT * tree;
|
OBJECT * tree;
|
||||||
LOG((""));
|
LOG((""));
|
||||||
|
|
||||||
// TODO: change abort to close
|
// TODO: change abort to close
|
||||||
dw->status = NSATARI_DOWNLOAD_COMPLETE;
|
dw->status = NSATARI_DOWNLOAD_COMPLETE;
|
||||||
|
|
||||||
if( dw->fd != NULL ) {
|
if( dw->fd != NULL ) {
|
||||||
fclose( dw->fd );
|
fclose( dw->fd );
|
||||||
dw->fd = NULL;
|
dw->fd = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
tree = dw->tree;
|
tree = dw->tree;
|
||||||
if (dw->close_on_finish) {
|
if (dw->close_on_finish) {
|
||||||
gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0, 0, 0, 0);
|
gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
|
snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
|
||||||
"%lu%s", 100, "%"
|
"%lu%s", 100, "%"
|
||||||
);
|
);
|
||||||
snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
|
snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
|
||||||
human_friendly_bytesize(dw->size_downloaded),
|
human_friendly_bytesize(dw->size_downloaded),
|
||||||
(dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : human_friendly_bytesize(dw->size_downloaded)
|
(dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : human_friendly_bytesize(dw->size_downloaded)
|
||||||
);
|
);
|
||||||
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
gemtk_wm_exec_redraw(dw->guiwin, NULL);
|
||||||
}
|
}
|
||||||
gui_window_set_status(input_window, messages_get("Done") );
|
gui_window_set_status(input_window, messages_get("Done") );
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct gui_download_table download_table = {
|
static struct gui_download_table download_table = {
|
||||||
.create = gui_download_window_create,
|
.create = gui_download_window_create,
|
||||||
|
|
Loading…
Reference in New Issue