/*-----------------------------------------------------------------------------------*/ void htmlparser_newline(void) { char *wptr; if(pagey < firsty) { ++pagey; x = 0; return; } if(!loading) { return; } webpageptr += (WWW_CONF_WEBPAGE_WIDTH - x); ++y; x = 0; wptr = webpageptr - WWW_CONF_WEBPAGE_WIDTH; petsciiconv_topetscii(wptr, WWW_CONF_WEBPAGE_WIDTH); #if WWW_CONF_RENDERSTATE if(renderstate & HTMLPARSER_RENDERSTATE_CENTER) { centerline(wptr); } #endif /* WWW_CONF_RENDERSTATE */ if(y == WWW_CONF_WEBPAGE_HEIGHT) { loading = 0; webclient_close(); } }
/* www_process(): * * The program's signal dispatcher function. Is called whenever a signal arrives. */ PROCESS_THREAD(www_process, ev, data) { static struct ctk_widget *w; #if WWW_CONF_WITH_WGET static char *argptr; #endif /* WWW_CONF_WITH_WGET */ w = (struct ctk_widget *)data; PROCESS_BEGIN(); /* Create the main window. */ memset(webpage, 0, sizeof(webpage)); ctk_window_new(&mainwindow, WWW_CONF_WEBPAGE_WIDTH, WWW_CONF_WEBPAGE_HEIGHT+5, "Web browser"); make_window(); #ifdef WWW_CONF_HOMEPAGE strncpy(editurl, WWW_CONF_HOMEPAGE, sizeof(editurl)); #endif /* WWW_CONF_HOMEPAGE */ CTK_WIDGET_FOCUS(&mainwindow, &urlentry); #if WWW_CONF_WITH_WGET || defined(WWW_CONF_WGET_EXEC) #if CTK_CONF_WINDOWS /* Create download dialog.*/ ctk_dialog_new(&wgetdialog, 38, 7); CTK_WIDGET_ADD(&wgetdialog, &wgetlabel1); CTK_WIDGET_ADD(&wgetdialog, &wgetlabel2); CTK_WIDGET_ADD(&wgetdialog, &wgetnobutton); CTK_WIDGET_ADD(&wgetdialog, &wgetyesbutton); #endif /* CTK_CONF_WINDOWS */ #endif /* WWW_CONF_WITH_WGET || WWW_CONF_WGET_EXEC */ ctk_window_open(&mainwindow); while(1) { PROCESS_WAIT_EVENT(); if(ev == tcpip_event) { webclient_appcall(data); } else if(ev == ctk_signal_widget_activate) { if(w == (struct ctk_widget *)&gobutton || w == (struct ctk_widget *)&urlentry) { start_loading(); firsty = 0; #if WWW_CONF_HISTORY_SIZE > 0 log_back(); #endif /* WWW_CONF_HISTORY_SIZE > 0 */ memcpy(url, editurl, WWW_CONF_MAX_URLLEN); petsciiconv_toascii(url, WWW_CONF_MAX_URLLEN); open_url(); CTK_WIDGET_FOCUS(&mainwindow, &gobutton); #if WWW_CONF_HISTORY_SIZE > 0 } else if(w == (struct ctk_widget *)&backbutton) { firsty = 0; start_loading(); --history_last; if(history_last > WWW_CONF_HISTORY_SIZE) { history_last = WWW_CONF_HISTORY_SIZE - 1; } memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN); open_url(); CTK_WIDGET_FOCUS(&mainwindow, &backbutton); #endif /* WWW_CONF_HISTORY_SIZE > 0 */ } else if(w == (struct ctk_widget *)&downbutton) { firsty = pagey + WWW_CONF_WEBPAGE_HEIGHT - 4; start_loading(); open_url(); CTK_WIDGET_FOCUS(&mainwindow, &downbutton); } else if(w == (struct ctk_widget *)&stopbutton) { loading = 0; webclient_close(); #if WWW_CONF_WITH_WGET || defined(WWW_CONF_WGET_EXEC) } else if(w == (struct ctk_widget *)&wgetnobutton) { #if CTK_CONF_WINDOWS ctk_dialog_close(); #else /* CTK_CONF_WINDOWS */ clear_page(); #endif /* CTK_CONF_WINDOWS */ } else if(w == (struct ctk_widget *)&wgetyesbutton) { #if CTK_CONF_WINDOWS ctk_dialog_close(); #else /* CTK_CONF_WINDOWS */ clear_page(); #endif /* CTK_CONF_WINDOWS */ #if WWW_CONF_WITH_WGET quit(); argptr = arg_alloc((char)WWW_CONF_MAX_URLLEN); if(argptr != NULL) { strncpy(argptr, url, WWW_CONF_MAX_URLLEN); } program_handler_load("wget.prg", argptr); #else /* WWW_CONF_WITH_WGET */ petsciiconv_topetscii(url, sizeof(url)); /* Clear screen */ ctk_restore(); WWW_CONF_WGET_EXEC(url); redraw_window(); show_statustext("Cannot exec wget"); #endif /* WWW_CONF_WITH_WGET */ #endif /* WWW_CONF_WITH_WGET || WWW_CONF_WGET_EXEC */ #if WWW_CONF_FORMS } else { /* Assume form widget. */ struct inputattrib *input = (struct inputattrib *) (((char *)w) - offsetof(struct inputattrib, widget)); formsubmit(input->formptr); #endif /* WWW_CONF_FORMS */ } } else if(ev == ctk_signal_hyperlink_activate) { firsty = 0; #if WWW_CONF_HISTORY_SIZE > 0 log_back(); #endif /* WWW_CONF_HISTORY_SIZE > 0 */ set_link(w->widget.hyperlink.url); show_url(); open_url(); start_loading(); CTK_WIDGET_FOCUS(&mainwindow, &stopbutton); } else if(ev == ctk_signal_hyperlink_hover) { if(CTK_WIDGET_TYPE((struct ctk_widget *)data) == CTK_WIDGET_HYPERLINK) { strncpy(statustexturl, w->widget.hyperlink.url, sizeof(statustexturl)); petsciiconv_topetscii(statustexturl, sizeof(statustexturl)); show_statustext(statustexturl); } #if UIP_UDP } else if(ev == resolv_event_found) { /* Either found a hostname, or not. */ if((char *)data != NULL && resolv_lookup((char *)data, NULL) == RESOLV_STATUS_CACHED) { open_url(); } else { show_statustext("Host not found"); } #endif /* UIP_UDP */ } else if(ev == ctk_signal_window_close || ev == PROCESS_EVENT_EXIT) { quit(); } }
/* www_process(): * * The program's signal dispatcher function. Is called whenever a signal arrives. */ PROCESS_THREAD(www_process, ev, data) { static struct ctk_widget *w; static unsigned char i; #if WWW_CONF_WITH_WGET static char *argptr; #endif /* WWW_CONF_WITH_WGET */ w = (struct ctk_widget *)data; PROCESS_BEGIN(); /* Create the main window. */ memset(webpage, 0, sizeof(webpage)); ctk_window_new(&mainwindow, WWW_CONF_WEBPAGE_WIDTH, WWW_CONF_WEBPAGE_HEIGHT+5, "Web browser"); make_window(); #ifdef WWW_CONF_HOMEPAGE strncpy(editurl, WWW_CONF_HOMEPAGE, sizeof(editurl)); #endif /* WWW_CONF_HOMEPAGE */ CTK_WIDGET_FOCUS(&mainwindow, &urlentry); #if WWW_CONF_WITH_WGET /* Create download dialog.*/ ctk_dialog_new(&wgetdialog, 38, 7); CTK_WIDGET_ADD(&wgetdialog, &wgetlabel1); CTK_WIDGET_ADD(&wgetdialog, &wgetlabel2); CTK_WIDGET_ADD(&wgetdialog, &wgetnobutton); CTK_WIDGET_ADD(&wgetdialog, &wgetyesbutton); #endif /* WWW_CONF_WITH_WGET */ ctk_window_open(&mainwindow); while(1) { PROCESS_WAIT_EVENT(); if(ev == tcpip_event) { webclient_appcall(data); } else if(ev == ctk_signal_widget_activate) { if(w == (struct ctk_widget *)&backbutton) { firsty = 0; start_loading(); --history_last; if(history_last > WWW_CONF_HISTORY_SIZE) { history_last = WWW_CONF_HISTORY_SIZE - 1; } memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN); open_url(); CTK_WIDGET_FOCUS(&mainwindow, &backbutton); } else if(w == (struct ctk_widget *)&downbutton) { firsty = pagey + WWW_CONF_WEBPAGE_HEIGHT - 4; start_loading(); open_url(); CTK_WIDGET_FOCUS(&mainwindow, &downbutton); } else if(w == (struct ctk_widget *)&gobutton || w == (struct ctk_widget *)&urlentry) { start_loading(); firsty = 0; log_back(); memcpy(url, editurl, WWW_CONF_MAX_URLLEN); petsciiconv_toascii(url, WWW_CONF_MAX_URLLEN); open_url(); CTK_WIDGET_FOCUS(&mainwindow, &gobutton); } else if(w == (struct ctk_widget *)&stopbutton) { loading = 0; webclient_close(); #if WWW_CONF_WITH_WGET } else if(w == (struct ctk_widget *)&wgetnobutton) { ctk_dialog_close(); } else if(w == (struct ctk_widget *)&wgetyesbutton) { ctk_dialog_close(); quit(); argptr = arg_alloc((char)WWW_CONF_MAX_URLLEN); if(argptr != NULL) { strncpy(argptr, url, WWW_CONF_MAX_URLLEN); } program_handler_load("wget.prg", argptr); #endif /* WWW_CONF_WITH_WGET */ #if WWW_CONF_FORMS } else { /* Check form buttons */ for(i = 0; i < pagewidgetptr; ++i) { if(&pagewidgets[i] == w) { formsubmit(&pagewidgetattribs[i].form); /* show_statustext(pagewidgetattribs[i].form.formaction);*/ /* PRINTF(("Formaction %s formname %s inputname %s\n", pagewidgetattribs[i].form.formaction, pagewidgetattribs[i].form.formname, pagewidgetattribs[i].form.inputname));*/ break; } } #endif /* WWW_CONF_FORMS */ } } else if(ev == ctk_signal_hyperlink_activate) { firsty = 0; log_back(); open_link(w->widget.hyperlink.url); CTK_WIDGET_FOCUS(&mainwindow, &stopbutton); /* ctk_window_open(&mainwindow);*/ } else if(ev == ctk_signal_hyperlink_hover) { if(CTK_WIDGET_TYPE((struct ctk_widget *)data) == CTK_WIDGET_HYPERLINK) { strncpy(statustexturl, w->widget.hyperlink.url, sizeof(statustexturl)); petsciiconv_topetscii(statustexturl, sizeof(statustexturl)); show_statustext(statustexturl); } } else if(ev == resolv_event_found) { /* Either found a hostname, or not. */ if((char *)data != NULL && resolv_lookup((char *)data) != NULL) { open_url(); } else { show_statustext("Host not found."); } } else if(ev == ctk_signal_window_close || ev == PROCESS_EVENT_EXIT) { quit(); } } PROCESS_END(); }