41#include "atari/res/netsurf.rsh"
58 if (msg != WM_REDRAW) {
59 data = gemtk_wm_get_user_data(
win);
74 data = gemtk_wm_get_user_data(
win);
76 if ((ev_out->emo_events & MU_MESAG) != 0) {
98 case DOWNLOAD_BT_ABORT:
102 case DOWNLOAD_CB_CLOSE_RDY:
114 if ((ev_out->emo_events & MU_KEYBD) != 0) {
118 if ((ev_out->emo_events & MU_BUTTON) != 0) {
131 gemtk_wm_get_grect(dw->
guiwin, GEMTK_WM_AREA_TOOLBAR, &work);
132 tree->ob_x = work.g_x;
133 tree->ob_y = work.g_y;
135 if(!rc_intersect(
clip, &work)){
142 ((TEDINFO *)get_obspec(
tree, DOWNLOAD_FILENAME))->te_ptext = dw->
lbl_file;
143 ((TEDINFO *)get_obspec(
tree, DOWNLOAD_LBL_BYTES))->te_ptext = dw->
lbl_done;
144 ((TEDINFO *)get_obspec(
tree, DOWNLOAD_LBL_PERCENT))->te_ptext = dw->
lbl_percent;
145 ((TEDINFO *)get_obspec(
tree, DOWNLOAD_LBL_SPEED))->te_ptext = dw->
lbl_speed;
153 tree[DOWNLOAD_CB_CLOSE_RDY].ob_state |= (OS_SELECTED | OS_CROSSED);
155 tree[DOWNLOAD_CB_CLOSE_RDY].ob_state &= ~(OS_SELECTED | OS_CROSSED);
157 tree[DOWNLOAD_BT_ABORT].ob_state &= ~OS_SELECTED;
160 wind_get_grect(dw->
aes_handle, WF_FIRSTXYWH, &visible);
161 while (visible.g_x && visible.g_y) {
162 if (rc_intersect(&work, &visible)) {
163 objc_draw_grect(
tree, 0, 8, &visible);
165 wind_get_grect(dw->
aes_handle, WF_NEXTXYWH, &visible);
173 gemtk_wm_send_msg(dw->
guiwin, WM_CLOSED, 0,0,0,0);
184 gemtk_wm_send_msg(dw->
guiwin, WM_CLOSED, 0,0,0,0);
186 gemtk_wm_exec_redraw(dw->
guiwin, NULL);
197 NSLOG(netsurf, INFO,
"gdw %p", gdw);
208 if (gdw->
fd != NULL) {
212 if (gdw->
fbuf != NULL) {
215 gemtk_wm_remove(gdw->
guiwin);
233 if(select_file(res_path, res_file, (
char*)
"*",
235 snprintf(tmp,
PATH_MAX,
"%s%s", res_path, res_file);
236 ret = malloc(strlen(tmp)+1);
240 printf(
"download file: %s\n", ret);
252 OBJECT *
tree = gemtk_obj_get_tree(DOWNLOAD);
256 NSLOG(netsurf, INFO,
"Creating download window for gui window: %p",
262 die(
"Couldn't find AES Object tree for download window!");
267 snprintf(alert, 200,
"[2][Accept download?|%.*s][Yes|Save as...|No]",
269 dlgres = form_alert(2, alert);
273 else if( dlgres == 2 ){
282 dstsize = strlen(gdos_path) + strlen(
filename) + 2;
296 gdw->
start = clock() / CLOCKS_PER_SEC;
307 if( gdw->
fd == NULL ){
309 snprintf(spare, 200,
"Couldn't open %s for writing!", gdw->
destination);
310 gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, spare);
316 if( gdw->
fbuf != NULL ){
321 wind_set_str(gdw->
aes_handle, WF_NAME,
"Download");
322 unsigned long gwflags = GEMTK_WM_FLAG_DEFAULTS;
324 if( gdw->
guiwin == NULL || gdw->
fd == NULL ){
325 die(
"could not create guiwin");
329 gemtk_wm_set_user_data(gdw->
guiwin, gdw);
330 gemtk_wm_set_toolbar(gdw->
guiwin,
tree, 0, 0);
334 NSLOG(netsurf, INFO,
"created download: %s (total size: %d)",
340 work.g_w =
tree->ob_width;
341 work.g_h =
tree->ob_height;
343 wind_calc_grect(WC_BORDER, CLOSER | MOVER | NAME, &work, &curr);
345 curr.g_x = (
desk_area.g_w / 2) - (curr.g_w / 2);
346 curr.g_y = (
desk_area.g_h / 2) - (curr.g_h / 2);
349 gdw->
lastrdw = clock() / (CLOCKS_PER_SEC >> 3);
356 const char *data,
unsigned int size)
358 uint32_t clck = clock();
359 uint32_t tnow = clck / (CLOCKS_PER_SEC>>3);
360 uint32_t sdiff = (clck / (CLOCKS_PER_SEC)) - dw->
start;
362 NSLOG(netsurf, INFO,
"dw %p", dw);
364 if (dw->
abort ==
true){
368 gemtk_wm_exec_redraw(dw->
guiwin, NULL);
373 fwrite( data ,
size,
sizeof(
unsigned char),dw->
fd );
377 if ((tnow - dw->
lastrdw) > 1) {
387 "%"PRIu32
"%s", p,
"%"
402 gemtk_wm_exec_redraw(dw->
guiwin, NULL);
408 const char *error_msg)
410 NSLOG(netsurf, INFO,
"%s", error_msg);
414 gemtk_wm_exec_redraw(dw->
guiwin, NULL);
421 NSLOG(netsurf, INFO,
"dw %p", dw);
426 if( dw->
fd != NULL ) {
432 gemtk_wm_send_msg(dw->
guiwin, WM_CLOSED, 0, 0, 0, 0);
441 gemtk_wm_exec_redraw(dw->
guiwin, NULL);
void atari_window_set_status(struct gui_window *w, const char *text)
Set the status bar of a browser window.
void die(const char *error)
Cause an abnormal program termination.
nserror atari_warn_user(const char *warning, const char *detail)
Warn the user of an event.
Browser window creation and manipulation interface.
void download_context_destroy(download_context *ctx)
Destroy a download context.
const char * download_context_get_filename(const download_context *ctx)
Retrieve the filename for a download.
void download_context_abort(download_context *ctx)
Abort a download fetch.
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.
static char * select_filepath(const char *path, const char *filename)
static void gui_download_window_destroy(struct gui_download_window *gdw)
static struct gui_download_table download_table
static short on_aes_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
struct gui_window * input_window
static nserror gui_download_window_data(struct gui_download_window *dw, const char *data, unsigned int size)
static void on_cbrdy_click(struct gui_download_window *dw)
static void on_close(struct gui_download_window *dw)
static void gui_download_window_error(struct gui_download_window *dw, const char *error_msg)
static void toolbar_redraw_cb(GUIWIN *win, uint16_t msg, GRECT *clip)
static void on_abort_click(struct gui_download_window *dw)
static void gui_download_window_done(struct gui_download_window *dw)
struct gui_download_table * atari_download_table
static void on_redraw(struct gui_download_window *dw, GRECT *clip)
static struct gui_download_window * gui_download_window_create(download_context *ctx, struct gui_window *parent)
@ NSATARI_DOWNLOAD_CANCELED
@ NSATARI_DOWNLOAD_COMPLETE
@ NSATARI_DOWNLOAD_WORKING
#define MAX_SLEN_LBL_PERCENT
#define MAX_SLEN_LBL_FILE
#define MAX_SLEN_LBL_DONE
#define MAX_SLEN_LBL_SPEED
Interface to platform-specific download operations.
Netsurf additional integer type formatting macros.
#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).
char * gemdos_realpath(const char *path, char *rpath)
Save HTML document with dependencies (interface).
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 lbl_speed[MAX_SLEN_LBL_SPEED]
struct gui_window * parent
nsatari_download_status status
char lbl_done[MAX_SLEN_LBL_DONE]
struct download_context * ctx
Associated context, or 0 if the fetch has completed or aborted.
char lbl_file[MAX_SLEN_LBL_FILE]
char lbl_percent[MAX_SLEN_LBL_PERCENT]
first entry in window list
Interface to time operations.
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.
static nserror clip(const struct redraw_context *ctx, const struct rect *clip)
Sets a clip rectangle for subsequent plot operations.