#include ctk-textentry-cmdline.h, plus a bunch of whitespace removed
This commit is contained in:
parent
f95c5df7d9
commit
40003196ef
1 changed files with 34 additions and 33 deletions
|
@ -1,19 +1,19 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2002, Adam Dunkels.
|
* Copyright (c) 2002, Adam Dunkels.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above
|
* 2. Redistributions in binary form must reproduce the above
|
||||||
* copyright notice, this list of conditions and the following
|
* copyright notice, this list of conditions and the following
|
||||||
* disclaimer in the documentation and/or other materials provided
|
* disclaimer in the documentation and/or other materials provided
|
||||||
* with the distribution.
|
* with the distribution.
|
||||||
* 3. The name of the author may not be used to endorse or promote
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
* products derived from this software without specific prior
|
* products derived from this software without specific prior
|
||||||
* written permission.
|
* written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
@ -25,17 +25,18 @@
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki desktop environment
|
* This file is part of the Contiki desktop environment
|
||||||
*
|
*
|
||||||
* $Id: www.c,v 1.9 2008/02/08 22:53:11 oliverschmidt Exp $
|
* $Id: www.c,v 1.10 2009/02/25 08:52:27 adamdunkels Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "ctk/ctk.h"
|
#include "ctk/ctk.h"
|
||||||
|
#include "lib/ctk-textentry-cmdline.h"
|
||||||
#include "contiki-net.h"
|
#include "contiki-net.h"
|
||||||
#include "lib/petsciiconv.h"
|
#include "lib/petsciiconv.h"
|
||||||
#include "sys/arg.h"
|
#include "sys/arg.h"
|
||||||
|
@ -175,7 +176,7 @@ static void formsubmit(struct formattribs *attribs);
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
make_window(void)
|
make_window(void)
|
||||||
{
|
{
|
||||||
CTK_WIDGET_ADD(&mainwindow, &backbutton);
|
CTK_WIDGET_ADD(&mainwindow, &backbutton);
|
||||||
CTK_WIDGET_ADD(&mainwindow, &downbutton);
|
CTK_WIDGET_ADD(&mainwindow, &downbutton);
|
||||||
CTK_WIDGET_ADD(&mainwindow, &stopbutton);
|
CTK_WIDGET_ADD(&mainwindow, &stopbutton);
|
||||||
|
@ -206,7 +207,7 @@ clear_page(void)
|
||||||
ctk_window_clear(&mainwindow);
|
ctk_window_clear(&mainwindow);
|
||||||
make_window();
|
make_window();
|
||||||
redraw_window();
|
redraw_window();
|
||||||
memset(webpage, 0, WWW_CONF_WEBPAGE_WIDTH * WWW_CONF_WEBPAGE_HEIGHT);
|
memset(webpage, 0, WWW_CONF_WEBPAGE_WIDTH * WWW_CONF_WEBPAGE_HEIGHT);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
|
@ -270,10 +271,10 @@ open_url(void)
|
||||||
--urlptr;
|
--urlptr;
|
||||||
}
|
}
|
||||||
strncpy(url, http_http, 7);
|
strncpy(url, http_http, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find host part of the URL. */
|
/* Find host part of the URL. */
|
||||||
urlptr = &url[7];
|
urlptr = &url[7];
|
||||||
for(i = 0; i < sizeof(host); ++i) {
|
for(i = 0; i < sizeof(host); ++i) {
|
||||||
if(*urlptr == 0 ||
|
if(*urlptr == 0 ||
|
||||||
*urlptr == '/' ||
|
*urlptr == '/' ||
|
||||||
|
@ -302,7 +303,7 @@ open_url(void)
|
||||||
|
|
||||||
/* Try to lookup the hostname. If it fails, we initiate a hostname
|
/* Try to lookup the hostname. If it fails, we initiate a hostname
|
||||||
lookup and print out an informative message on the statusbar. */
|
lookup and print out an informative message on the statusbar. */
|
||||||
if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
|
if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
|
||||||
if(resolv_lookup(host) == NULL) {
|
if(resolv_lookup(host) == NULL) {
|
||||||
resolv_query(host);
|
resolv_query(host);
|
||||||
show_statustext("Resolving host...");
|
show_statustext("Resolving host...");
|
||||||
|
@ -340,7 +341,7 @@ open_link(char *link)
|
||||||
variable, starting after the http (which already is present in
|
variable, starting after the http (which already is present in
|
||||||
the url variable since we were able to open the web page on
|
the url variable since we were able to open the web page on
|
||||||
which this link was found in the first place). */
|
which this link was found in the first place). */
|
||||||
strncpy(&url[5], link, WWW_CONF_MAX_URLLEN);
|
strncpy(&url[5], link, WWW_CONF_MAX_URLLEN);
|
||||||
} else if(*link == ISO_slash) {
|
} else if(*link == ISO_slash) {
|
||||||
/* The link starts with a slash, so it is a non-relative link
|
/* The link starts with a slash, so it is a non-relative link
|
||||||
within the same web site. We find the start of the filename of
|
within the same web site. We find the start of the filename of
|
||||||
|
@ -348,8 +349,8 @@ open_link(char *link)
|
||||||
head off to the new URL. */
|
head off to the new URL. */
|
||||||
for(urlptr = &url[7];
|
for(urlptr = &url[7];
|
||||||
*urlptr != 0 && *urlptr != ISO_slash;
|
*urlptr != 0 && *urlptr != ISO_slash;
|
||||||
++urlptr);
|
++urlptr);
|
||||||
strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
|
strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
|
||||||
} else {
|
} else {
|
||||||
/* A fully relative link is found. We find the last slash in the
|
/* A fully relative link is found. We find the last slash in the
|
||||||
current URL and paste the link there. */
|
current URL and paste the link there. */
|
||||||
|
@ -359,7 +360,7 @@ open_link(char *link)
|
||||||
urlptr != url && *urlptr != ISO_slash;
|
urlptr != url && *urlptr != ISO_slash;
|
||||||
--urlptr);
|
--urlptr);
|
||||||
++urlptr;
|
++urlptr;
|
||||||
strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
|
strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open the URL. */
|
/* Open the URL. */
|
||||||
|
@ -412,12 +413,12 @@ PROCESS_THREAD(www_process, ev, data)
|
||||||
|
|
||||||
/* Create the main window. */
|
/* Create the main window. */
|
||||||
memset(webpage, 0, sizeof(webpage));
|
memset(webpage, 0, sizeof(webpage));
|
||||||
ctk_window_new(&mainwindow, WWW_CONF_WEBPAGE_WIDTH,
|
ctk_window_new(&mainwindow, WWW_CONF_WEBPAGE_WIDTH,
|
||||||
WWW_CONF_WEBPAGE_HEIGHT+5, "Web browser");
|
WWW_CONF_WEBPAGE_HEIGHT+5, "Web browser");
|
||||||
make_window();
|
make_window();
|
||||||
#ifdef WWW_CONF_HOMEPAGE
|
#ifdef WWW_CONF_HOMEPAGE
|
||||||
strncpy(editurl, WWW_CONF_HOMEPAGE, sizeof(editurl));
|
strncpy(editurl, WWW_CONF_HOMEPAGE, sizeof(editurl));
|
||||||
#endif /* WWW_CONF_HOMEPAGE */
|
#endif /* WWW_CONF_HOMEPAGE */
|
||||||
CTK_WIDGET_FOCUS(&mainwindow, &urlentry);
|
CTK_WIDGET_FOCUS(&mainwindow, &urlentry);
|
||||||
|
|
||||||
#if WWW_CONF_WITH_WGET
|
#if WWW_CONF_WITH_WGET
|
||||||
|
@ -448,7 +449,7 @@ PROCESS_THREAD(www_process, ev, data)
|
||||||
}
|
}
|
||||||
memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN);
|
memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN);
|
||||||
open_url();
|
open_url();
|
||||||
CTK_WIDGET_FOCUS(&mainwindow, &backbutton);
|
CTK_WIDGET_FOCUS(&mainwindow, &backbutton);
|
||||||
} else if(w == (struct ctk_widget *)&downbutton) {
|
} else if(w == (struct ctk_widget *)&downbutton) {
|
||||||
firsty = pagey + WWW_CONF_WEBPAGE_HEIGHT - 4;
|
firsty = pagey + WWW_CONF_WEBPAGE_HEIGHT - 4;
|
||||||
start_loading();
|
start_loading();
|
||||||
|
@ -471,14 +472,14 @@ PROCESS_THREAD(www_process, ev, data)
|
||||||
} else if(w == (struct ctk_widget *)&wgetnobutton) {
|
} else if(w == (struct ctk_widget *)&wgetnobutton) {
|
||||||
ctk_dialog_close();
|
ctk_dialog_close();
|
||||||
} else if(w == (struct ctk_widget *)&wgetyesbutton) {
|
} else if(w == (struct ctk_widget *)&wgetyesbutton) {
|
||||||
ctk_dialog_close();
|
ctk_dialog_close();
|
||||||
quit();
|
quit();
|
||||||
argptr = arg_alloc((char)WWW_CONF_MAX_URLLEN);
|
argptr = arg_alloc((char)WWW_CONF_MAX_URLLEN);
|
||||||
if(argptr != NULL) {
|
if(argptr != NULL) {
|
||||||
strncpy(argptr, url, WWW_CONF_MAX_URLLEN);
|
strncpy(argptr, url, WWW_CONF_MAX_URLLEN);
|
||||||
}
|
}
|
||||||
program_handler_load("wget.prg", argptr);
|
program_handler_load("wget.prg", argptr);
|
||||||
#endif /* WWW_CONF_WITH_WGET */
|
#endif /* WWW_CONF_WITH_WGET */
|
||||||
#if WWW_CONF_FORMS
|
#if WWW_CONF_FORMS
|
||||||
} else {
|
} else {
|
||||||
/* Check form buttons */
|
/* Check form buttons */
|
||||||
|
@ -581,7 +582,7 @@ webclient_timedout(void)
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
webclient_closed(void)
|
webclient_closed(void)
|
||||||
{
|
{
|
||||||
show_statustext("Stopped.");
|
show_statustext("Stopped.");
|
||||||
petsciiconv_topetscii(&webpage[(WWW_CONF_WEBPAGE_HEIGHT - 1) *
|
petsciiconv_topetscii(&webpage[(WWW_CONF_WEBPAGE_HEIGHT - 1) *
|
||||||
WWW_CONF_WEBPAGE_WIDTH], WWW_CONF_WEBPAGE_WIDTH);
|
WWW_CONF_WEBPAGE_WIDTH], WWW_CONF_WEBPAGE_WIDTH);
|
||||||
|
@ -604,13 +605,13 @@ webclient_connected(void)
|
||||||
show_statustext("Request sent...");
|
show_statustext("Request sent...");
|
||||||
set_url(webclient_hostname(), webclient_port(), webclient_filename());
|
set_url(webclient_hostname(), webclient_port(), webclient_filename());
|
||||||
|
|
||||||
#if WWW_CONF_RENDERSTATE
|
#if WWW_CONF_RENDERSTATE
|
||||||
renderstate = HTMLPARSER_RENDERSTATE_NONE;
|
renderstate = HTMLPARSER_RENDERSTATE_NONE;
|
||||||
#endif /* WWW_CONF_RENDERSTATE */
|
#endif /* WWW_CONF_RENDERSTATE */
|
||||||
htmlparser_init();
|
htmlparser_init();
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/* webclient_datahandler():
|
/* webclient_datahandler():
|
||||||
*
|
*
|
||||||
* Callback function. Called from the webclient module when HTTP data
|
* Callback function. Called from the webclient module when HTTP data
|
||||||
* has arrived.
|
* has arrived.
|
||||||
|
@ -619,7 +620,7 @@ void
|
||||||
webclient_datahandler(char *data, u16_t len)
|
webclient_datahandler(char *data, u16_t len)
|
||||||
{
|
{
|
||||||
if(len > 0) {
|
if(len > 0) {
|
||||||
if(strcmp(webclient_mimetype(), http_texthtml) == 0) {
|
if(strcmp(webclient_mimetype(), http_texthtml) == 0) {
|
||||||
count = (count + 1) & 3;
|
count = (count + 1) & 3;
|
||||||
show_statustext(receivingmsgs[count]);
|
show_statustext(receivingmsgs[count]);
|
||||||
htmlparser_parse(data, len);
|
htmlparser_parse(data, len);
|
||||||
|
@ -648,7 +649,7 @@ webclient_datahandler(char *data, u16_t len)
|
||||||
static void *
|
static void *
|
||||||
add_pagewidget(char *text, unsigned char len, unsigned char type,
|
add_pagewidget(char *text, unsigned char len, unsigned char type,
|
||||||
unsigned char border)
|
unsigned char border)
|
||||||
{
|
{
|
||||||
register struct ctk_widget *lptr;
|
register struct ctk_widget *lptr;
|
||||||
register char *wptr;
|
register char *wptr;
|
||||||
static unsigned char maxwidth;
|
static unsigned char maxwidth;
|
||||||
|
@ -715,7 +716,7 @@ add_pagewidget(char *text, unsigned char len, unsigned char type,
|
||||||
y + 3, len, 1,
|
y + 3, len, 1,
|
||||||
wptr, len);
|
wptr, len);
|
||||||
((struct formattribs *)dataptr)->inputvalue = wptr;
|
((struct formattribs *)dataptr)->inputvalue = wptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CTK_WIDGET_SET_FLAG(lptr, CTK_WIDGET_FLAG_MONOSPACE);
|
CTK_WIDGET_SET_FLAG(lptr, CTK_WIDGET_FLAG_MONOSPACE);
|
||||||
CTK_WIDGET_ADD(&mainwindow, lptr);
|
CTK_WIDGET_ADD(&mainwindow, lptr);
|
||||||
|
@ -801,7 +802,7 @@ htmlparser_newline(void)
|
||||||
if(renderstate & HTMLPARSER_RENDERSTATE_CENTER) {
|
if(renderstate & HTMLPARSER_RENDERSTATE_CENTER) {
|
||||||
centerline(wptr);
|
centerline(wptr);
|
||||||
}
|
}
|
||||||
#endif /* WWW_CONF_RENDERSTATE */
|
#endif /* WWW_CONF_RENDERSTATE */
|
||||||
|
|
||||||
if(y == WWW_CONF_WEBPAGE_HEIGHT) {
|
if(y == WWW_CONF_WEBPAGE_HEIGHT) {
|
||||||
loading = 0;
|
loading = 0;
|
||||||
|
@ -821,7 +822,7 @@ htmlparser_word(char *word, unsigned char wordlen)
|
||||||
if(loading) {
|
if(loading) {
|
||||||
if(pagey == firsty) {
|
if(pagey == firsty) {
|
||||||
memcpy(webpageptr, word, wordlen);
|
memcpy(webpageptr, word, wordlen);
|
||||||
webpageptr += wordlen;
|
webpageptr += wordlen;
|
||||||
*webpageptr = ' ';
|
*webpageptr = ' ';
|
||||||
++webpageptr;
|
++webpageptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue