Merge pull request #1346 from oliverschmidt/master

Client requested close takes precedence over server initiated close.
This commit is contained in:
Oliver Schmidt 2015-11-01 16:34:40 +01:00
commit 19cb3227ca
2 changed files with 17 additions and 8 deletions

View file

@ -479,6 +479,11 @@ webclient_appcall(void *state)
if(uip_closed()) { if(uip_closed()) {
tcp_markconn(uip_conn, NULL); tcp_markconn(uip_conn, NULL);
/* Client requested close takes precedence over server initiated close. */
if(s.state == WEBCLIENT_STATE_CLOSE) {
webclient_closed();
return;
}
switch(s.httpflag) { switch(s.httpflag) {
case HTTPFLAG_HTTPS: case HTTPFLAG_HTTPS:
/* Send some info to the user. */ /* Send some info to the user. */

View file

@ -292,6 +292,15 @@ show_statustext(char *text)
CTK_WIDGET_REDRAW(&statustext); CTK_WIDGET_REDRAW(&statustext);
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
static void
end_page(char *status, void *focus)
{
show_statustext(status);
petsciiconv_topetscii(webpageptr - x, x);
CTK_WIDGET_FOCUS(&mainwindow, focus);
redraw_window();
}
/*-----------------------------------------------------------------------------------*/
/* open_url(): /* open_url():
* *
* Called when the URL present in the global "url" variable should be * Called when the URL present in the global "url" variable should be
@ -660,10 +669,7 @@ webclient_timedout(void)
void void
webclient_closed(void) webclient_closed(void)
{ {
show_statustext("Stopped"); end_page("Stopped", &downbutton);
petsciiconv_topetscii(webpageptr - x, x);
CTK_WIDGET_FOCUS(&mainwindow, &downbutton);
redraw_window();
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* webclient_connected(): /* webclient_connected():
@ -710,6 +716,7 @@ webclient_datahandler(char *data, uint16_t len)
" Would you like to download instead?"); " Would you like to download instead?");
CTK_WIDGET_ADD(&mainwindow, &wgetnobutton); CTK_WIDGET_ADD(&mainwindow, &wgetnobutton);
CTK_WIDGET_ADD(&mainwindow, &wgetyesbutton); CTK_WIDGET_ADD(&mainwindow, &wgetyesbutton);
CTK_WIDGET_FOCUS(&mainwindow, &wgetyesbutton);
redraw_window(); redraw_window();
#endif /* CTK_CONF_WINDOWS */ #endif /* CTK_CONF_WINDOWS */
#endif /* WWW_CONF_WITH_WGET || WWW_CONF_WGET_EXEC */ #endif /* WWW_CONF_WITH_WGET || WWW_CONF_WGET_EXEC */
@ -721,10 +728,7 @@ webclient_datahandler(char *data, uint16_t len)
if(data == NULL) { if(data == NULL) {
loading = 0; loading = 0;
show_statustext("Done"); end_page("Done", &urlentry);
petsciiconv_topetscii(webpageptr - x, x);
CTK_WIDGET_FOCUS(&mainwindow, &urlentry);
redraw_window();
} }
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/