diff --git a/src/bfu/leds.c b/src/bfu/leds.c index b5e77a903..3ee3307f4 100644 --- a/src/bfu/leds.c +++ b/src/bfu/leds.c @@ -38,7 +38,7 @@ * 2 - JavaScript Error indicator * 3 - JavaScript pop-up blocking indicator * 4 - unused, reserved for Lua - * 5 - unused */ + * 5 - download in progress */ /* XXX: Currently, the leds toggling is quite hackish, some more work should go * to it (ie. some led hooks called in sync_leds() to light the leds @@ -129,6 +129,12 @@ set_led_value(struct led *led, unsigned char value) } } +unsigned char +get_led_value(struct led *led) +{ + return led->value__; +} + void unset_led_value(struct led *led) { @@ -268,6 +274,25 @@ sync_leds(struct session *ses) return 0; } +static void +update_download_led(struct session *ses) +{ + struct session_status *status = &ses->status; + + if (status->downloads_in_progress) { + unsigned char led = get_led_value(status->download_led); + + switch (led) { + case '-' : led = '\\'; break; + case '\\': led = '|'; break; + case '|' : led = '/'; break; + default: led = '-'; + } + + set_led_value(status->download_led, led); + } +} + /* Timer callback for @redraw_timer. As explained in @install_timer, * this function must erase the expired timer ID from all variables. */ static void @@ -288,6 +313,7 @@ redraw_leds(void *xxx) drawing = 1; foreach (ses, sessions) { + update_download_led(ses); if (!sync_leds(ses)) continue; redraw_terminal(ses->tab->term); @@ -306,7 +332,7 @@ menu_leds_info(struct terminal *term, void *xxx, void *xxxx) msg_text(term, N_("What the different LEDs indicate:\n" "\n" "[SIJP--]\n" - " |||||`- Unused\n" + " |||||`- Download in progress\n" " ||||`-- Unused\n" " |||`--- A JavaScript pop-up window was blocked\n" " ||`---- A JavaScript error has occured\n" diff --git a/src/bfu/leds.h b/src/bfu/leds.h index d6109dd8b..4ed6c65f8 100644 --- a/src/bfu/leds.h +++ b/src/bfu/leds.h @@ -46,6 +46,7 @@ void menu_leds_info(struct terminal *term, void *xxx, void *xxxx); struct led *register_led(struct session *ses, int number); void unregister_led(struct led *); void set_led_value(struct led *led, unsigned char value); +unsigned char get_led_value(struct led *led); void unset_led_value(struct led *led); #endif diff --git a/src/session/download.c b/src/session/download.c index 94c1250f4..397ddc1cd 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -136,6 +136,10 @@ abort_download(struct file_download *file_download) * download dialog code potentially could access free()d memory. */ assert(!is_object_used(file_download)); #endif + struct session *ses = file_download->ses; + struct session_status *status = &ses->status; + + status->downloads_in_progress = 0; done_download_display(file_download); @@ -336,19 +340,25 @@ static void download_data_store(struct download *download, struct file_download *file_download) { struct terminal *term = file_download->term; + struct session *ses = file_download->ses; + struct session_status *status = &ses->status; if (!term) { /* No term here, so no beep. --Zas */ abort_download(file_download); return; } - + if (is_in_progress_state(download->state)) { + status->downloads_in_progress = 1; + if (file_download->dlg_data) redraw_dialog(file_download->dlg_data, 1); return; } + status->downloads_in_progress = 0; + if (download->state != S_OK) { unsigned char *url = get_uri_string(file_download->uri, URI_PUBLIC); enum connection_state state = download->state; diff --git a/src/session/session.c b/src/session/session.c index 963171008..2197dfee5 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -873,6 +873,8 @@ init_session(struct session *base_session, struct terminal *term, ses->status.insert_mode_led = register_led(ses, 1); ses->status.ecmascript_led = register_led(ses, 2); ses->status.popup_led = register_led(ses, 3); + + ses->status.download_led = register_led(ses, 5); #endif ses->status.force_show_status_bar = -1; ses->status.force_show_title_bar = -1; diff --git a/src/session/session.h b/src/session/session.h index d23c00fee..763e1be58 100644 --- a/src/session/session.h +++ b/src/session/session.h @@ -103,6 +103,7 @@ struct session_status { struct led *insert_mode_led; struct led *ecmascript_led; struct led *popup_led; + struct led *download_led; #endif /** Has the tab been visited yet. */ unsigned int visited:1; @@ -110,6 +111,7 @@ struct session_status { /** Is processing file requests. */ unsigned int processing_file_requests:1; unsigned int show_tabs_bar_at_top:1; + unsigned int downloads_in_progress:1; }; enum insert_mode {