summaryrefslogtreecommitdiff
path: root/atari
diff options
context:
space:
mode:
Diffstat (limited to 'atari')
-rw-r--r--atari/Makefile.defaults79
-rw-r--r--atari/Makefile.target8
-rw-r--r--atari/about.c21
-rw-r--r--atari/certview.c568
-rw-r--r--atari/clipboard.c130
-rw-r--r--atari/cookies.c55
-rw-r--r--atari/ctxmenu.c493
-rw-r--r--atari/deskmenu.c637
-rwxr-xr-xatari/download.c414
-rwxr-xr-xatari/download.h2
-rw-r--r--atari/encoding.c22
-rw-r--r--atari/encoding.h47
-rwxr-xr-xatari/filetype.c121
-rw-r--r--atari/filetype.h24
-rwxr-xr-xatari/findfile.c53
-rwxr-xr-xatari/findfile.h3
-rw-r--r--atari/gemtk/guiwin.c6
-rw-r--r--atari/gemtk/objc.c3
-rw-r--r--atari/gemtk/utils.c33
-rw-r--r--atari/gui.c298
-rwxr-xr-xatari/gui.h9
-rw-r--r--atari/history.c45
-rw-r--r--atari/hotlist.c42
-rw-r--r--atari/hotlist.h7
-rwxr-xr-xatari/login.c4
-rwxr-xr-xatari/misc.c512
-rw-r--r--atari/osspec.c227
-rwxr-xr-xatari/plot/font_freetype.c1
-rw-r--r--atari/plot/font_internal.c2
-rwxr-xr-xatari/plot/font_vdi.c460
-rwxr-xr-xatari/plot/plot.c21
-rwxr-xr-xatari/rootwin.c41
-rwxr-xr-xatari/rootwin.h2
-rwxr-xr-xatari/schedule.c126
-rwxr-xr-xatari/schedule.h28
-rw-r--r--atari/search.c414
-rw-r--r--atari/search.h3
-rw-r--r--atari/settings.c10
-rwxr-xr-xatari/statusbar.c426
-rw-r--r--atari/toolbar.c619
-rw-r--r--atari/toolbar.h3
-rw-r--r--atari/treeview.c39
-rwxr-xr-xatari/verify_ssl.c541
43 files changed, 3216 insertions, 3383 deletions
diff --git a/atari/Makefile.defaults b/atari/Makefile.defaults
index ccc9b49ce..dcdc1d661 100644
--- a/atari/Makefile.defaults
+++ b/atari/Makefile.defaults
@@ -2,59 +2,56 @@
# Atari-specific options
# ----------------------------------------------------------------------------
- # Force using glibc internal iconv implementation instead of external libiconv
- # Valid options: YES, NO
- NETSURF_USE_LIBICONV_PLUG := NO
+# Force using glibc internal iconv implementation instead of external libiconv
+# Valid options: YES, NO
+NETSURF_USE_LIBICONV_PLUG := NO
- # Enable NetSurf's use of librosprite for displaying RISC OS Sprites
- # Valid options: YES, NO, AUTO
- NETSURF_USE_ROSPRITE := NO
+# Enable NetSurf's use of librosprite for displaying RISC OS Sprites
+# Valid options: YES, NO, AUTO
+NETSURF_USE_ROSPRITE := NO
- # Enable NetSurf's use of libwebp for displaying WebPs
- # Valid options: YES, NO
- NETSURF_USE_WEBP := NO
+# Enable NetSurf's use of libwebp for displaying WebPs
+# Valid options: YES, NO
+NETSURF_USE_WEBP := NO
- # Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_RSVG := AUTO
+# Enable NetSurf's use of librsvg in conjunction with Cairo to display SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_RSVG := AUTO
- # Enable NetSurf's use of libsvgtiny for displaying SVGs
- # Valid options: YES, NO, AUTO
- NETSURF_USE_NSSVG := AUTO
+# Enable NetSurf's use of libsvgtiny for displaying SVGs
+# Valid options: YES, NO, AUTO
+NETSURF_USE_NSSVG := AUTO
- NETSURF_USE_MNG := NO
+# Enable Spidermonkey JavaScript engine
+# Valid options: YES, NO
+NETSURF_USE_MOZJS := NO
- # Enable Spidermonkey JavaScript engine
- # Valid options: YES, NO
- NETSURF_USE_MOZJS := NO
+# enable true type fonts via freetype2
+# Valid options: YES, NO
+NETSURF_USE_ATARI_FREETYPE_FONT := YES
- # enable true type fonts via freetype2
- # Valid options: YES, NO
- NETSURF_USE_ATARI_FREETYPE_FONT := YES
+# Enable use of netsurf embedded font
+# Valid options: YES, NO
+NETSURF_USE_ATARI_NETSURF_FONT := YES
- # Enable use of netsurf embedded font
- # Valid options: YES, NO
- NETSURF_USE_ATARI_NETSURF_FONT := YES
+# Enable VDI Font rendering
+# Valid options: YES, NO
+NETSURF_USE_ATARI_VDI_FONT := NO
- # Enable VDI Font rendering
- # Valid options: YES, NO
- NETSURF_USE_ATARI_VDI_FONT := NO
+# Configure support for screen drivers with no true colour mode
+# Valid options: YES, NO
+NETSURF_USE_ATARI_8BPP_SUPPORT := NO
- # Configure support for screen drivers with no true colour mode
- # Valid options: YES, NO
- NETSURF_USE_ATARI_8BPP_SUPPORT := NO
+# Configure the CPU target
+# Valid options: 68000, 68020-60, 5475 (coldfire)
+ATARIARCH = 68020-60
- # Configure the CPU target
- # Valid options: 68000, 68020-60, 5475 (coldfire)
- ATARIARCH = 68020-60
+# enable optimizations
+# -O2 is currently broken with m68000 / m68020-60 builds
+CFLAGS += -O3
- # enable optimizations
- # -O2 is currently broken with m68000 / m68020-60 builds
- CFLAGS += -O3
-
- # override warning flags removing -Wall
- WARNFLAGS = -W -Wundef -Wpointer-arith \
+# override warning flags removing -Wall
+WARNFLAGS = -W -Wundef -Wpointer-arith \
-Wcast-align -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
-Wnested-externs -Wuninitialized -Wl,-t
-
diff --git a/atari/Makefile.target b/atari/Makefile.target
index 283361355..c9b2046f2 100644
--- a/atari/Makefile.target
+++ b/atari/Makefile.target
@@ -10,6 +10,7 @@
# the netsurf environment!
STRIP := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*strip)
STACK := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*stack)
+FT2CF := $(GCCSDK_INSTALL_ENV)/bin/freetype-config
ifeq ($(ATARIARCH),68000)
PRGSUFFIX := 000.app
@@ -32,10 +33,9 @@ endif
# non-pkgconfig components
-FREETYPE_FONT_CFLAGS := $(shell freetype-config --cflags) -DWITH_FREETYPE_FONT_DRIVER
+FREETYPE_FONT_CFLAGS := $(shell $(FT2CF) --cflags) -DWITH_FREETYPE_FONT_DRIVER
SPIDERMONKEY_CFLAGS := -DWITH_MOZJS -DXP_UNIX -DJS_HAS_FILE_OBJECT=0 -DJSOPTION_JIT=0 -DPOSIX_SOURCE -D_BSD_SOURCE
-$(eval $(call feature_enabled,MNG,-DWITH_MNG,-lmng,PNG/MNG/JNG (libmng)))
$(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng)))
$(eval $(call feature_enabled,MOZJS,$(SPIDERMONKEY_CFLAGS),-ljs,JavaScript (Spidermonkey)))
$(eval $(call feature_enabled,ATARI_FREETYPE_FONT,$(FREETYPE_FONT_CFLAGS),-lfreetype,(Freetype)))
@@ -59,7 +59,7 @@ endif
$(eval $(call pkg_config_find_and_add_enabled,BMP,libnsbmp,BMP))
$(eval $(call pkg_config_find_and_add_enabled,GIF,libnsgif,GIF))
-CFLAGS += -U__STRICT_ANSI__ -std=c99 -Dsmall $(WARNFLAGS) -Dnsatari \
+CFLAGS += -U__STRICT_ANSI__ -std=c99 -Dsmall -Dnsatari \
-D_BSD_SOURCE \
-D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L \
@@ -69,7 +69,7 @@ CFLAGS += -U__STRICT_ANSI__ -std=c99 -Dsmall $(WARNFLAGS) -Dnsatari \
LDFLAGS += -lcflib -lcurl
LDFLAGS += -lcss -lparserutils -ldom -lwapcaplet -lhubbub
LDFLAGS += -lssl -lcrypto
-LDFLAGS += -lz -liconv -lcares -lHermes -lgem -lm
+LDFLAGS += -lz -lcares -lHermes -lgem -lm
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib
diff --git a/atari/about.c b/atari/about.c
index f09dfb358..174e27b20 100644
--- a/atari/about.c
+++ b/atari/about.c
@@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <limits.h>
-#include <unistd.h>
-#include <string.h>
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
@@ -28,16 +28,16 @@
#include "atari/plot/plot.h"
#include "atari/gemtk/gemtk.h"
#include "atari/res/netsurf.rsh"
-#include "atari/about.h"
+#include "atari/about.h"
-#include "utils/testament.h"
+#include "testament.h"
#include "utils/useragent.h"
#include "desktop/netsurf.h"
#include "utils/nsurl.h"
#include "utils/messages.h"
-#include "curl/curlver.h"
+#include "curl/curlver.h"
static OBJECT * about_form = NULL;
@@ -50,9 +50,6 @@ static short __CDECL about_userdraw(PARMBLK *parmblock)
{
short pxy[8];
short dummy;
- int content_len;
- char *content;
- short cur_x, cur_y;
short cheight = 8, cwidth = gl_wchar;
char c[2] = {0,0};
@@ -73,6 +70,9 @@ static short __CDECL about_userdraw(PARMBLK *parmblock)
};
if(parmblock->pb_currstate == parmblock->pb_prevstate){
+ short cur_x, cur_y;
+ char *content;
+ int content_len;
content = (char*)parmblock->pb_parm;
content_len = strlen(content);
@@ -170,8 +170,7 @@ void atari_about_show(void)
if (goto_url != NULL) {
nserr = nsurl_create(goto_url, &url);
if (nserr == NSERROR_OK) {
- nserr = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ nserr = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/atari/certview.c b/atari/certview.c
index 6877529d8..b6b752224 100644
--- a/atari/certview.c
+++ b/atari/certview.c
@@ -14,293 +14,287 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <ctype.h>
-#include <string.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-
-#include "desktop/browser.h"
-#include "content/urldb.h"
-#include "desktop/sslcert_viewer.h"
-#include "desktop/gui.h"
-#include "desktop/core_window.h"
-#include "utils/nsoption.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-
-#include "atari/gui.h"
-#include "atari/misc.h"
-#include "atari/treeview.h"
-#include "atari/certview.h"
-#include "atari/findfile.h"
-#include "atari/gemtk/gemtk.h"
-#include "atari/res/netsurf.rsh"
-
-extern GRECT desk_area;
-
-
-/* Setup Atari Treeview Callbacks: */
-static nserror atari_sslcert_viewer_init_phase2(struct core_window *cw,
- struct core_window_callback_table * default_callbacks);
-static void atari_sslcert_viewer_finish(struct core_window *cw);
-static void atari_sslcert_viewer_keypress(struct core_window *cw,
- uint32_t ucs4);
-static void atari_sslcert_viewer_mouse_action(struct core_window *cw,
- browser_mouse_state mouse,
- int x, int y);
-static void atari_sslcert_viewer_draw(struct core_window *cw, int x,
- int y, struct rect *clip,
- const struct redraw_context *ctx);
-static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]);
-
-static struct atari_treeview_callbacks atari_sslcert_viewer_treeview_callbacks = {
- .init_phase2 = atari_sslcert_viewer_init_phase2,
- .finish = atari_sslcert_viewer_finish,
- .draw = atari_sslcert_viewer_draw,
- .keypress = atari_sslcert_viewer_keypress,
- .mouse_action = atari_sslcert_viewer_mouse_action,
- .gemtk_user_func = handle_event
-};
-
-/* static functions */
-static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin);
-
-
-static nserror atari_sslcert_viewer_init_phase2(struct core_window *cw,
- struct core_window_callback_table *cb_t)
-{
- struct atari_sslcert_viewer_s *cvwin;
- struct sslcert_session_data *ssl_d;
-
- cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
-
- assert(cvwin);
-
- ssl_d = cvwin->ssl_session_data;
-
- assert(ssl_d);
-
- LOG((""));
-
- return(sslcert_viewer_init(cb_t, cw, ssl_d));
-}
-
-static void atari_sslcert_viewer_finish(struct core_window *cw)
-{
- struct atari_sslcert_viewer_s *cvwin;
-
- assert(cw);
-
- cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
-
- /* This will also free the session data: */
- sslcert_viewer_fini(cvwin->ssl_session_data);
-
- LOG((""));
-}
-
-static void atari_sslcert_viewer_draw(struct core_window *cw, int x,
- int y, struct rect *clip,
- const struct redraw_context *ctx)
-{
- struct atari_sslcert_viewer_s *cvwin;
-
- assert(cw);
-
- cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
-
- assert(cvwin);
-
- sslcert_viewer_redraw(cvwin->ssl_session_data, x, y, clip, ctx);
-}
-
-static void atari_sslcert_viewer_keypress(struct core_window *cw, uint32_t ucs4)
-{
- struct atari_sslcert_viewer_s *cvwin;
-
- assert(cw);
-
- cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
-
- LOG(("ucs4: %lu\n", ucs4));
- sslcert_viewer_keypress(cvwin->ssl_session_data, ucs4);
-}
-
-static void atari_sslcert_viewer_mouse_action(struct core_window *cw,
- browser_mouse_state mouse,
- int x, int y)
-{
- struct atari_sslcert_viewer_s *cvwin;
-
- assert(cw);
-
- cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
-
- if ((mouse & BROWSER_MOUSE_HOVER)) {
- sslcert_viewer_mouse_action(cvwin->ssl_session_data, mouse, x, y);
- } else {
- sslcert_viewer_mouse_action(cvwin->ssl_session_data, mouse, x, y);
- }
-}
-
-
-static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
-{
- struct core_window *tv=NULL;
- GRECT tb_area;
- GUIWIN * gemtk_win;
- struct gui_window * gw;
- struct atari_sslcert_viewer_s *cvwin = NULL;
- char *cur_url = NULL;
- char *cur_title = NULL;
- short retval = 0;
- OBJECT *toolbar;
-
- LOG((""));
-
- if(ev_out->emo_events & MU_MESAG){
- switch (msg[0]) {
-
- case WM_TOOLBAR:
- toolbar = gemtk_obj_get_tree(TOOLBAR_SSL_CERT);
- LOG(("CERTVIEWER WM_TOOLBAR"));
- tv = (struct core_window*) gemtk_wm_get_user_data(win);
- assert(tv);
- cvwin = (struct atari_sslcert_viewer_s *)
- atari_treeview_get_user_data(tv);
- switch (msg[4]) {
-
- case TOOLBAR_SSL_CERT_TRUSTED:
-
- if (toolbar[msg[4]].ob_state & OS_SELECTED) {
-
- } else {
-
- }
- break;
- }
-
-
- gemtk_win = atari_treeview_get_gemtk_window(tv);
- assert(gemtk_win);
- //gemtk_obj_get_tree(TOOLBAR_HOTLIST)[msg[4]].ob_state &= ~OS_SELECTED;
- atari_treeview_get_grect(tv, TREEVIEW_AREA_TOOLBAR, &tb_area);
- evnt_timer(150);
- gemtk_wm_exec_redraw(gemtk_win, &tb_area);
- retval = 1;
- break;
-
- case WM_CLOSED:
- // TODO set perrmissions
- toolbar = gemtk_obj_get_tree(TOOLBAR_SSL_CERT);
- tv = (struct core_window*) gemtk_wm_get_user_data(win);
- assert(tv);
- cvwin = (struct atari_sslcert_viewer_s *)
- atari_treeview_get_user_data(tv);
- if (toolbar[TOOLBAR_SSL_CERT_TRUSTED].ob_state & OS_SELECTED) {
- sslcert_viewer_accept(cvwin->ssl_session_data);
- } else {
- sslcert_viewer_reject(cvwin->ssl_session_data);
- }
- atari_sslcert_viewer_destroy(cvwin);
- retval = 1;
- break;
-
- default: break;
- }
- }
-
- return(retval);
+ */
+
+#include <ctype.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "desktop/browser.h"
+#include "content/urldb.h"
+#include "content/hlcache.h"
+#include "desktop/sslcert_viewer.h"
+#include "desktop/gui.h"
+#include "desktop/core_window.h"
+#include "utils/nsoption.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+
+#include "atari/gui.h"
+#include "atari/misc.h"
+#include "atari/treeview.h"
+#include "atari/certview.h"
+#include "atari/findfile.h"
+#include "atari/gemtk/gemtk.h"
+#include "atari/res/netsurf.rsh"
+
+extern GRECT desk_area;
+
+
+/* Setup Atari Treeview Callbacks: */
+static nserror atari_sslcert_viewer_init_phase2(struct core_window *cw,
+ struct core_window_callback_table * default_callbacks);
+static void atari_sslcert_viewer_finish(struct core_window *cw);
+static void atari_sslcert_viewer_keypress(struct core_window *cw,
+ uint32_t ucs4);
+static void atari_sslcert_viewer_mouse_action(struct core_window *cw,
+ browser_mouse_state mouse,
+ int x, int y);
+static void atari_sslcert_viewer_draw(struct core_window *cw, int x,
+ int y, struct rect *clip,
+ const struct redraw_context *ctx);
+static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8]);
+
+static struct atari_treeview_callbacks atari_sslcert_viewer_treeview_callbacks = {
+ .init_phase2 = atari_sslcert_viewer_init_phase2,
+ .finish = atari_sslcert_viewer_finish,
+ .draw = atari_sslcert_viewer_draw,
+ .keypress = atari_sslcert_viewer_keypress,
+ .mouse_action = atari_sslcert_viewer_mouse_action,
+ .gemtk_user_func = handle_event
+};
+
+/* static functions */
+static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin);
+
+
+static nserror atari_sslcert_viewer_init_phase2(struct core_window *cw,
+ struct core_window_callback_table *cb_t)
+{
+ struct atari_sslcert_viewer_s *cvwin;
+ struct sslcert_session_data *ssl_d;
+
+ cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
+
+ assert(cvwin);
+
+ ssl_d = cvwin->ssl_session_data;
+
+ assert(ssl_d);
+
+ LOG((""));
+
+ return(sslcert_viewer_init(cb_t, cw, ssl_d));
+}
+
+static void atari_sslcert_viewer_finish(struct core_window *cw)
+{
+ struct atari_sslcert_viewer_s *cvwin;
+
+ assert(cw);
+
+ cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
+
+ /* This will also free the session data: */
+ sslcert_viewer_fini(cvwin->ssl_session_data);
+
+ LOG((""));
+}
+
+static void atari_sslcert_viewer_draw(struct core_window *cw, int x,
+ int y, struct rect *clip,
+ const struct redraw_context *ctx)
+{
+ struct atari_sslcert_viewer_s *cvwin;
+
+ assert(cw);
+
+ cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
+
+ assert(cvwin);
+
+ sslcert_viewer_redraw(cvwin->ssl_session_data, x, y, clip, ctx);
+}
+
+static void atari_sslcert_viewer_keypress(struct core_window *cw, uint32_t ucs4)
+{
+ struct atari_sslcert_viewer_s *cvwin;
+
+ assert(cw);
+
+ cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
+
+ LOG(("ucs4: %lu\n", ucs4));
+ sslcert_viewer_keypress(cvwin->ssl_session_data, ucs4);
+}
+
+static void atari_sslcert_viewer_mouse_action(struct core_window *cw,
+ browser_mouse_state mouse,
+ int x, int y)
+{
+ struct atari_sslcert_viewer_s *cvwin;
+
+ assert(cw);
+
+ cvwin = (struct atari_sslcert_viewer_s *)atari_treeview_get_user_data(cw);
+
+ sslcert_viewer_mouse_action(cvwin->ssl_session_data, mouse, x, y);
}
-static void atari_sslcert_viewer_init(struct atari_sslcert_viewer_s * cvwin,
- struct sslcert_session_data *ssl_d)
-{
- assert(cvwin->init == false);
- assert(cvwin->window == NULL);
- assert(cvwin->tv == NULL);
-
- int flags = ATARI_TREEVIEW_WIDGETS;
- short handle = -1;
- GRECT desk;
- OBJECT * tree = gemtk_obj_get_tree(TOOLBAR_SSL_CERT);
- assert( tree );
-
- handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
- cvwin->window = gemtk_wm_add(handle,
- GEMTK_WM_FLAG_DEFAULTS, NULL);
- if (cvwin->window == NULL ) {
- gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
- "Failed to allocate Treeview:\nCertviewer");
- return;
- }
- wind_set_str(handle, WF_NAME, (char*)"SSL Certificate");
- gemtk_wm_set_toolbar(cvwin->window, tree, 0, 0);
- gemtk_wm_unlink(cvwin->window);
-
- cvwin->ssl_session_data = ssl_d;
- cvwin->tv = atari_treeview_create(cvwin->window,
- &atari_sslcert_viewer_treeview_callbacks,
- cvwin, flags);
-
- if (cvwin->tv == NULL) {
- /* handle it properly, clean up previous allocs */
- LOG(("Failed to allocate treeview"));
- return;
- }
-
- cvwin->init = true;
-}
-
-/*
-* documented in certview.h
+
+static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
+{
+ struct core_window *tv=NULL;
+ GRECT tb_area;
+ GUIWIN * gemtk_win;
+ struct atari_sslcert_viewer_s *cvwin = NULL;
+ short retval = 0;
+ OBJECT *toolbar;
+
+ LOG((""));
+
+ if(ev_out->emo_events & MU_MESAG){
+ switch (msg[0]) {
+
+ case WM_TOOLBAR:
+ toolbar = gemtk_obj_get_tree(TOOLBAR_SSL_CERT);
+ LOG(("CERTVIEWER WM_TOOLBAR"));
+ tv = (struct core_window*) gemtk_wm_get_user_data(win);
+ assert(tv);
+ cvwin = (struct atari_sslcert_viewer_s *)
+ atari_treeview_get_user_data(tv);
+ switch (msg[4]) {
+
+ case TOOLBAR_SSL_CERT_TRUSTED:
+
+ if (toolbar[msg[4]].ob_state & OS_SELECTED) {
+
+ } else {
+
+ }
+ break;
+ }
+
+
+ gemtk_win = atari_treeview_get_gemtk_window(tv);
+ assert(gemtk_win);
+ //gemtk_obj_get_tree(TOOLBAR_HOTLIST)[msg[4]].ob_state &= ~OS_SELECTED;
+ atari_treeview_get_grect(tv, TREEVIEW_AREA_TOOLBAR, &tb_area);
+ evnt_timer(150);
+ gemtk_wm_exec_redraw(gemtk_win, &tb_area);
+ retval = 1;
+ break;
+
+ case WM_CLOSED:
+ // TODO set perrmissions
+ toolbar = gemtk_obj_get_tree(TOOLBAR_SSL_CERT);
+ tv = (struct core_window*) gemtk_wm_get_user_data(win);
+ assert(tv);
+ cvwin = (struct atari_sslcert_viewer_s *)
+ atari_treeview_get_user_data(tv);
+ if (toolbar[TOOLBAR_SSL_CERT_TRUSTED].ob_state & OS_SELECTED) {
+ sslcert_viewer_accept(cvwin->ssl_session_data);
+ } else {
+ sslcert_viewer_reject(cvwin->ssl_session_data);
+ }
+ atari_sslcert_viewer_destroy(cvwin);
+ retval = 1;
+ break;
+
+ default: break;
+ }
+ }
+
+ return(retval);
+}
+
+static void atari_sslcert_viewer_init(struct atari_sslcert_viewer_s * cvwin,
+ struct sslcert_session_data *ssl_d)
+{
+ assert(cvwin->init == false);
+ assert(cvwin->window == NULL);
+ assert(cvwin->tv == NULL);
+
+ int flags = ATARI_TREEVIEW_WIDGETS;
+ short handle = -1;
+ GRECT desk;
+ OBJECT * tree = gemtk_obj_get_tree(TOOLBAR_SSL_CERT);
+ assert( tree );
+
+ handle = wind_create(flags, 0, 0, desk_area.g_w, desk_area.g_h);
+ cvwin->window = gemtk_wm_add(handle,
+ GEMTK_WM_FLAG_DEFAULTS, NULL);
+ if (cvwin->window == NULL ) {
+ gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT,
+ "Failed to allocate Treeview:\nCertviewer");
+ return;
+ }
+ wind_set_str(handle, WF_NAME, (char*)"SSL Certificate");
+ gemtk_wm_set_toolbar(cvwin->window, tree, 0, 0);
+ gemtk_wm_unlink(cvwin->window);
+
+ cvwin->ssl_session_data = ssl_d;
+ cvwin->tv = atari_treeview_create(cvwin->window,
+ &atari_sslcert_viewer_treeview_callbacks,
+ cvwin, flags);
+
+ if (cvwin->tv == NULL) {
+ /* handle it properly, clean up previous allocs */
+ LOG(("Failed to allocate treeview"));
+ return;
+ }
+
+ cvwin->init = true;
+}
+
+/*
+* documented in certview.h
*/
-void atari_sslcert_viewer_open(struct sslcert_session_data *ssl_d)
-{
- struct atari_sslcert_viewer_s * cvwin;
-
- cvwin = calloc(1, sizeof(struct atari_sslcert_viewer_s));
-
- assert(cvwin);
-
- atari_sslcert_viewer_init(cvwin, ssl_d);
-
- if (atari_treeview_is_open(cvwin->tv) == false) {
-
- GRECT pos;
- pos.g_x = desk_area.g_w - desk_area.g_w / 4;
- pos.g_y = desk_area.g_y;
- pos.g_w = desk_area.g_w / 4;
- pos.g_h = desk_area.g_h;
-
- atari_treeview_open(cvwin->tv, &pos);
- } else {
- wind_set(gemtk_wm_get_handle(cvwin->window), WF_TOP, 1, 0,
- 0, 0);
- }
-}
-
-
-static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin)
-{
- assert(cvwin);
- assert(cvwin->init);
- assert(cvwin->window);
-
- LOG((""));
-
- if (atari_treeview_is_open(cvwin->tv))
- atari_treeview_close(cvwin->tv);
- wind_delete(gemtk_wm_get_handle(cvwin->window));
- gemtk_wm_remove(cvwin->window);
- cvwin->window = NULL;
- atari_treeview_delete(cvwin->tv);
- free(cvwin);
- LOG(("done"));
-}
-
+void atari_sslcert_viewer_open(struct sslcert_session_data *ssl_d)
+{
+ struct atari_sslcert_viewer_s * cvwin;
+
+ cvwin = calloc(1, sizeof(struct atari_sslcert_viewer_s));
+
+ assert(cvwin);
+
+ atari_sslcert_viewer_init(cvwin, ssl_d);
+
+ if (atari_treeview_is_open(cvwin->tv) == false) {
+
+ GRECT pos;
+ pos.g_x = desk_area.g_w - desk_area.g_w / 4;
+ pos.g_y = desk_area.g_y;
+ pos.g_w = desk_area.g_w / 4;
+ pos.g_h = desk_area.g_h;
+
+ atari_treeview_open(cvwin->tv, &pos);
+ } else {
+ wind_set(gemtk_wm_get_handle(cvwin->window), WF_TOP, 1, 0,
+ 0, 0);
+ }
+}
+
+
+static void atari_sslcert_viewer_destroy(struct atari_sslcert_viewer_s * cvwin)
+{
+ assert(cvwin);
+ assert(cvwin->init);
+ assert(cvwin->window);
+
+ LOG((""));
+
+ if (atari_treeview_is_open(cvwin->tv))
+ atari_treeview_close(cvwin->tv);
+ wind_delete(gemtk_wm_get_handle(cvwin->window));
+ gemtk_wm_remove(cvwin->window);
+ cvwin->window = NULL;
+ atari_treeview_delete(cvwin->tv);
+ free(cvwin);
+ LOG(("done"));
+}
+
diff --git a/atari/clipboard.c b/atari/clipboard.c
index 254579bba..d80599e2b 100644
--- a/atari/clipboard.c
+++ b/atari/clipboard.c
@@ -20,69 +20,69 @@
*
*
*/
-
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <stdio.h>
-#include <mint/osbind.h>
-#include <cflib.h>
-#include "atari/clipboard.h"
-#include "atari/gemtk/gemtk.h"
-
-
-static int filesize(char * path)
-{
- FILE *f;
- int fs;
-
- f = fopen( path, "r+b");
- if(!f)
- return(-1);
-
- fseek(f, 0L, SEEK_END);
- fs = ftell(f);
- fclose(f);
-
- return(fs);
-}
-
-int scrap_txt_write(char *str)
-{
- scrap_wtxt(str);
-
-
- // Send SC_CHANGED message:
- gemtk_send_msg(SC_CHANGED, 0, 2, 0, 0, 0, 0);
-
- return(0);
-
-}
-char *scrap_txt_read(void)
-{
- char * buf = NULL;
- char path[80];
- int file;
- int len;
-
- if (get_scrapdir (path))
- {
- strcat (path, "scrap.txt");
- len = filesize(path);
- if(len > 0){
- if ((file = (int) Fopen (path, 0)) >= 0)
- {
- buf = malloc(len);
- if(buf){
- len = Fread (file, len, buf);
- Fclose (file);
- buf[len] = '\0';
- return buf;
- }
- }
- }
- }
-
-}
-
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include <mint/osbind.h>
+#include <cflib.h>
+#include "atari/clipboard.h"
+#include "atari/gemtk/gemtk.h"
+
+
+static int filesize(char * path)
+{
+ FILE *f;
+ int fs;
+
+ f = fopen( path, "r+b");
+ if(!f)
+ return(-1);
+
+ fseek(f, 0L, SEEK_END);
+ fs = ftell(f);
+ fclose(f);
+
+ return(fs);
+}
+
+int scrap_txt_write(char *str)
+{
+ scrap_wtxt(str);
+
+
+ // Send SC_CHANGED message:
+ gemtk_send_msg(SC_CHANGED, 0, 2, 0, 0, 0, 0);
+
+ return(0);
+
+}
+
+char *scrap_txt_read(void)
+{
+ char * buf = NULL;
+ char path[80];
+
+ if (get_scrapdir (path))
+ {
+ int len;
+ strcat (path, "scrap.txt");
+ len = filesize(path);
+ if(len > 0){
+ int file;
+ if ((file = (int) Fopen (path, 0)) >= 0)
+ {
+ buf = malloc(len);
+ if(buf){
+ len = Fread (file, len, buf);
+ Fclose (file);
+ buf[len] = '\0';
+ return buf;
+ }
+ }
+ }
+ }
+
+}
+
diff --git a/atari/cookies.c b/atari/cookies.c
index d05707559..9082da2b7 100644
--- a/atari/cookies.c
+++ b/atari/cookies.c
@@ -1,19 +1,19 @@
-/*
- * Copyright 2013 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/*
+ * Copyright 2013 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <ctype.h>
@@ -35,7 +35,6 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
-#include "utils/url.h"
#include "atari/gui.h"
#include "atari/misc.h"
#include "atari/treeview.h"
@@ -103,24 +102,14 @@ static void atari_cookie_manager_mouse_action(struct core_window *cw,
browser_mouse_state mouse,
int x, int y)
{
- if((mouse & BROWSER_MOUSE_HOVER) && cookie_manager_has_selection()){
- cookie_manager_mouse_action(mouse, x, y);
- } else {
- cookie_manager_mouse_action(mouse, x, y);
- }
-
+ cookie_manager_mouse_action(mouse, x, y);
}
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
- struct atari_treeview_window *tv=NULL;
GRECT tb_area;
- GUIWIN * gemtk_win;
- struct gui_window * gw;
- char *cur_url = NULL;
- char *cur_title = NULL;
short retval = 0;
LOG((""));
@@ -159,8 +148,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
return(retval);
-}
-
+}
+
void atari_cookie_manager_init(void)
{
if (atari_cookie_manager.init == false) {
@@ -200,7 +189,7 @@ void atari_cookie_manager_init(void)
}
}
atari_cookie_manager.init = true;
-}
+}
void atari_cookie_manager_open(void)
{
assert(atari_cookie_manager.init);
@@ -220,13 +209,13 @@ void atari_cookie_manager_open(void)
}
}
-
+
void atari_cookie_manager_close(void)
{
atari_treeview_close(atari_cookie_manager.tv);
}
-
+
void atari_cookie_manager_destroy(void)
{
if( atari_cookie_manager.init == false) {
diff --git a/atari/ctxmenu.c b/atari/ctxmenu.c
index fb687b809..f782c6e19 100644
--- a/atari/ctxmenu.c
+++ b/atari/ctxmenu.c
@@ -1,116 +1,116 @@
-/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdbool.h>
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdbool.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <mint/osbind.h>
-#include <cflib.h>
-
-#include "desktop/gui.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/textinput.h"
-#include "content/content.h"
-#include "content/hlcache.h"
-#include "content/urldb.h"
-#include "css/css.h"
-#include "utils/log.h"
+#include <cflib.h>
+
+#include "desktop/gui.h"
+#include "desktop/netsurf.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/mouse.h"
+#include "desktop/textinput.h"
+#include "content/content.h"
+#include "content/hlcache.h"
+#include "content/urldb.h"
+#include "css/css.h"
+#include "utils/log.h"
#include "utils/messages.h"
-#include "utils/utils.h"
-
-#include "atari/gui.h"
-#include "atari/rootwin.h"
-#include "atari/misc.h"
-#include "atari/clipboard.h"
-#include "utils/nsoption.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/ctxmenu.h"
-
-
-#define CNT_INVALID 0
-#define CNT_BROWSER 64
-#define CNT_HREF 128
-#define CNT_SELECTION 256
-#define CNT_INTERACTIVE 512
-#define CNT_IMG 1024
-
-
-struct s_context_info {
- unsigned long flags;
- struct contextual_content ccdata;
-};
-
-struct s_context_info ctxinfo;
-
-static struct s_context_info * get_context_info( struct gui_window * gw, short mx, short my )
-{
- hlcache_handle *h;
- GRECT area;
- struct contextual_content ccdata;
+#include "utils/utils.h"
+
+#include "atari/gui.h"
+#include "atari/rootwin.h"
+#include "atari/misc.h"
+#include "atari/clipboard.h"
+#include "utils/nsoption.h"
+#include "atari/res/netsurf.rsh"
+#include "atari/ctxmenu.h"
+
+
+#define CNT_INVALID 0
+#define CNT_BROWSER 64
+#define CNT_HREF 128
+#define CNT_SELECTION 256
+#define CNT_INTERACTIVE 512
+#define CNT_IMG 1024
+
+bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
+
+struct s_context_info {
+ unsigned long flags;
+ struct contextual_content ccdata;
+};
+
+struct s_context_info ctxinfo;
+
+static struct s_context_info * get_context_info( struct gui_window * gw, short mx, short my )
+{
+ hlcache_handle *h;
+ GRECT area;
struct browser_window * bw = gw->browser->bw;
- int sx, sy;
-
- h = bw->current_content;
+ int sx, sy;
+
+ h = bw->current_content;
ctxinfo.flags = 0;
window_get_grect(gw->root, BROWSER_AREA_CONTENT, &area);
if (POINT_WITHIN(mx, my, area)) {
- mx -= area.g_x;
+ mx -= area.g_x;
my -= area.g_y;
- if (!bw->current_content || content_get_type(h) != CONTENT_HTML){
- return(&ctxinfo);
- }
-
- ctxinfo.flags |= CNT_BROWSER;
+ if (!bw->current_content || content_get_type(h) != CONTENT_HTML){
+ return(&ctxinfo);
+ }
+
+ ctxinfo.flags |= CNT_BROWSER;
memset( &ctxinfo.ccdata, sizeof(struct contextual_content), 0 );
gui_window_get_scroll(gw, &sx, &sy);
-
- browser_window_get_contextual_content( gw->browser->bw, mx+sx, my+sy,
+
+ browser_window_get_contextual_content( gw->browser->bw, mx+sx, my+sy,
(struct contextual_content*)&ctxinfo.ccdata);
-
- if( ctxinfo.ccdata.link_url ){
- ctxinfo.flags |= CNT_HREF;
- }
- if( ctxinfo.ccdata.object) {
- if( content_get_type(ctxinfo.ccdata.object) == CONTENT_IMAGE ){
- ctxinfo.flags |= CNT_IMG;
- }
- }
- if ( ctxinfo.ccdata.form_features == CTX_FORM_TEXT )
+
+ if( ctxinfo.ccdata.link_url ){
+ ctxinfo.flags |= CNT_HREF;
+ }
+ if( ctxinfo.ccdata.object) {
+ if( content_get_type(ctxinfo.ccdata.object) == CONTENT_IMAGE ){
+ ctxinfo.flags |= CNT_IMG;
+ }
+ }
+ if ( ctxinfo.ccdata.form_features == CTX_FORM_TEXT )
ctxinfo.flags |= (CNT_INTERACTIVE | CNT_SELECTION);
}
return(&ctxinfo);
-
-
+
+
}
/***
@@ -147,60 +147,59 @@ static char * get_tmpfilename(const char * prefix, const char * suffix)
} while(file_exists(tmpfilename));
return(tmpfilename);
-}
-
-//TODO: do not open popup for gui_window, but for a rootwin?
-void context_popup(struct gui_window * gw, short x, short y)
-{
-
-#define POP_FIRST_ITEM POP_CTX_CUT_SEL
-#define POP_LAST_ITEM POP_CTX_SAVE_LINK_AS
-
- OBJECT * pop;
- int choice;
- struct s_context_info * ctx;
- unsigned long size;
- const char * data;
- FILE * fp_tmpfile;
+}
+
+//TODO: do not open popup for gui_window, but for a rootwin?
+void context_popup(struct gui_window * gw, short x, short y)
+{
+
+#define POP_FIRST_ITEM POP_CTX_CUT_SEL
+#define POP_LAST_ITEM POP_CTX_SAVE_LINK_AS
+
+ OBJECT * pop;
+ int choice;
+ struct s_context_info * ctx;
+ unsigned long size;
+ const char * data;
+ FILE * fp_tmpfile;
char cmdline[128];
/* skip first byte, which must hold length of commandline: */
- char * tempfile = &cmdline[1];
- int err = 0;
- char * editor, *lastslash;
- MENU pop_menu, me_data;
-
- pop = gemtk_obj_get_tree( POP_CTX );
- if (pop == NULL)
- return;
- ctx = get_context_info(gw, x, y);
-
- /*
- Disable all items by default:
- */
- for( choice = POP_FIRST_ITEM; choice<=POP_LAST_ITEM; choice++ ){
- SET_BIT(pop[ choice ].ob_state, OS_DISABLED, 1);
- }
-
- if( ctx->flags & CNT_INTERACTIVE ){
- SET_BIT(pop[ POP_CTX_PASTE_SEL ].ob_state, OS_DISABLED, 0);
- }
-
- if( (ctx->flags & CNT_BROWSER) ){
- SET_BIT(pop[ POP_CTX_SELECT_ALL ].ob_state, OS_DISABLED, 0);
- SET_BIT(pop[ POP_CTX_COPY_SEL ].ob_state, OS_DISABLED, 0);
- SET_BIT(pop[ POP_CTX_VIEW_SOURCE ].ob_state, OS_DISABLED, 0);
+ char * tempfile = &cmdline[1];
+ char * editor;
+ MENU pop_menu, me_data;
+
+ pop = gemtk_obj_get_tree( POP_CTX );
+ if (pop == NULL)
+ return;
+ ctx = get_context_info(gw, x, y);
+
+ /*
+ Disable all items by default:
+ */
+ for( choice = POP_FIRST_ITEM; choice<=POP_LAST_ITEM; choice++ ){
+ SET_BIT(pop[ choice ].ob_state, OS_DISABLED, 1);
}
-
- if( ctx->flags & CNT_HREF ){
- SET_BIT(pop[ POP_CTX_COPY_LINK ].ob_state, OS_DISABLED, 0);
- SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, OS_DISABLED, 0);
- SET_BIT(pop[ POP_CTX_SAVE_LINK_AS ].ob_state, OS_DISABLED, 0);
- }
-
- if( ctx->flags & CNT_IMG ){
- SET_BIT(pop[ POP_CTX_SAVE_AS ].ob_state, OS_DISABLED, 0);
- SET_BIT(pop[ POP_CTX_COPY_URL ].ob_state, OS_DISABLED, 0);
- SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, OS_DISABLED, 0);
+
+ if( ctx->flags & CNT_INTERACTIVE ){
+ SET_BIT(pop[ POP_CTX_PASTE_SEL ].ob_state, OS_DISABLED, 0);
+ }
+
+ if( (ctx->flags & CNT_BROWSER) ){
+ SET_BIT(pop[ POP_CTX_SELECT_ALL ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_COPY_SEL ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_VIEW_SOURCE ].ob_state, OS_DISABLED, 0);
+ }
+
+ if( ctx->flags & CNT_HREF ){
+ SET_BIT(pop[ POP_CTX_COPY_LINK ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_SAVE_LINK_AS ].ob_state, OS_DISABLED, 0);
+ }
+
+ if( ctx->flags & CNT_IMG ){
+ SET_BIT(pop[ POP_CTX_SAVE_AS ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_COPY_URL ].ob_state, OS_DISABLED, 0);
+ SET_BIT(pop[ POP_CTX_OPEN_NEW ].ob_state, OS_DISABLED, 0);
}
// point mn_tree tree to states popup:
@@ -208,121 +207,119 @@ void context_popup(struct gui_window * gw, short x, short y)
pop_menu.mn_menu = 0;
pop_menu.mn_item = POP_CTX_CUT_SEL;
pop_menu.mn_scroll = SCROLL_NO;
- pop_menu.mn_keystate = 0;
+ pop_menu.mn_keystate = 0;
menu_popup(&pop_menu, x, y, &me_data);
- choice = me_data.mn_item;
-
- switch( choice ){
- case POP_CTX_COPY_SEL:
- browser_window_key_press(gw->browser->bw, KEY_COPY_SELECTION);
- break;
-
- case POP_CTX_CUT_SEL:
- browser_window_key_press(gw->browser->bw, KEY_CUT_SELECTION);
- break;
-
+ choice = me_data.mn_item;
+
+ switch( choice ){
+ case POP_CTX_COPY_SEL:
+ browser_window_key_press(gw->browser->bw, KEY_COPY_SELECTION);
+ break;
+
+ case POP_CTX_CUT_SEL:
+ browser_window_key_press(gw->browser->bw, KEY_CUT_SELECTION);
+ break;
+
case POP_CTX_PASTE_SEL:
- browser_window_key_press(gw->browser->bw, KEY_PASTE);
- break;
-
- case POP_CTX_SELECT_ALL:
- browser_window_key_press(gw->browser->bw, KEY_SELECT_ALL);
- break;
-
- case POP_CTX_SAVE_AS:
- if (ctx->ccdata.object != NULL) {
- if( hlcache_handle_get_url(ctx->ccdata.object) != NULL ) {
- browser_window_navigate(
- gw->browser->bw,
- hlcache_handle_get_url(ctx->ccdata.object),
- hlcache_handle_get_url(gw->browser->bw->current_content),
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- NULL
- );
- }
- }
-
- case POP_CTX_SAVE_LINK_AS:
- if (ctx->ccdata.link_url != NULL) {
- nsurl *url;
+ browser_window_key_press(gw->browser->bw, KEY_PASTE);
+ break;
+
+ case POP_CTX_SELECT_ALL:
+ browser_window_key_press(gw->browser->bw, KEY_SELECT_ALL);
+ break;
+
+ case POP_CTX_SAVE_AS:
+ if (ctx->ccdata.object != NULL) {
+ if( hlcache_handle_get_url(ctx->ccdata.object) != NULL ) {
+ browser_window_navigate(
+ gw->browser->bw,
+ hlcache_handle_get_url(ctx->ccdata.object),
+ hlcache_handle_get_url(gw->browser->bw->current_content),
+ BW_NAVIGATE_DOWNLOAD,
+ NULL,
+ NULL,
+ NULL
+ );
+ }
+ }
+
+ case POP_CTX_SAVE_LINK_AS:
+ if (ctx->ccdata.link_url != NULL) {
+ nsurl *url;
nserror error;
error = nsurl_create(ctx->ccdata.link_url, &url);
- if (error == NSERROR_OK) {
- error = browser_window_navigate(
- gw->browser->bw,
- url,
- hlcache_handle_get_url(gw->browser->bw->current_content),
- BROWSER_WINDOW_DOWNLOAD |
- BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- NULL
- );
- nsurl_unref(url);
- }
+ if (error == NSERROR_OK) {
+ error = browser_window_navigate(
+ gw->browser->bw,
+ url,
+ hlcache_handle_get_url(gw->browser->bw->current_content),
+ BW_NAVIGATE_DOWNLOAD,
+ NULL,
+ NULL,
+ NULL
+ );
+ nsurl_unref(url);
+ }
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
}
- }
-
- break;
-
- case POP_CTX_COPY_URL:
- if ((ctx->flags & CNT_IMG) && (ctx->ccdata.object != NULL)) {
- if( hlcache_handle_get_url(ctx->ccdata.object) != NULL ){
+ }
+
+ break;
+
+ case POP_CTX_COPY_URL:
+ if ((ctx->flags & CNT_IMG) && (ctx->ccdata.object != NULL)) {
+ if( hlcache_handle_get_url(ctx->ccdata.object) != NULL ){
scrap_txt_write((char*)nsurl_access(
- hlcache_handle_get_url(ctx->ccdata.object)));
- }
- }
- break;
-
- case POP_CTX_COPY_LINK:
- if ((ctx->flags & CNT_HREF) && ctx->ccdata.link_url != NULL) {
- scrap_txt_write((char*)ctx->ccdata.link_url);
- }
- break;
-
- case POP_CTX_OPEN_NEW:
- if ((ctx->flags & CNT_HREF) && ctx->ccdata.link_url) {
+ hlcache_handle_get_url(ctx->ccdata.object)));
+ }
+ }
+ break;
+
+ case POP_CTX_COPY_LINK:
+ if ((ctx->flags & CNT_HREF) && ctx->ccdata.link_url != NULL) {
+ scrap_txt_write((char*)ctx->ccdata.link_url);
+ }
+ break;
+
+ case POP_CTX_OPEN_NEW:
+ if ((ctx->flags & CNT_HREF) && ctx->ccdata.link_url) {
nsurl *url;
nserror error;
error = nsurl_create(ctx->ccdata.link_url, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(
+ BW_CREATE_HISTORY | BW_CREATE_CLONE,
url,
- hlcache_handle_get_url(gw->browser->bw->current_content),
- gw->browser->bw,
+ hlcache_handle_get_url(gw->browser->bw->current_content),
+ gw->browser->bw,
NULL
- );
+ );
nsurl_unref(url);
}
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
}
- }
- break;
-
- case POP_CTX_VIEW_SOURCE:
- editor = nsoption_charp(atari_editor);
- if (editor != NULL && strlen(editor)>0) {
- data = content_get_source_data(gw->browser->bw->current_content,
+ }
+ break;
+
+ case POP_CTX_VIEW_SOURCE:
+ editor = nsoption_charp(atari_editor);
+ if (editor != NULL && strlen(editor)>0) {
+ data = content_get_source_data(gw->browser->bw->current_content,
&size);
if (size > 0 && data != NULL){
snprintf(tempfile, 127, "%s", get_tmpfilename("ns-", ".html"));
/* the GEMDOS cmdline contains the length of the commandline
in the first byte: */
cmdline[0] = (unsigned char)strlen(tempfile);
- LOG(("Creating temporay source file: %s\n", tempfile));
- fp_tmpfile = fopen(tempfile, "w");
- if (fp_tmpfile != NULL){
- fwrite(data, size, 1, fp_tmpfile);
+ LOG(("Creating temporay source file: %s\n", tempfile));
+ fp_tmpfile = fopen(tempfile, "w");
+ if (fp_tmpfile != NULL){
+ fwrite(data, size, 1, fp_tmpfile);
fclose(fp_tmpfile);
// Send SH_WDRAW to notify files changed:
@@ -332,22 +329,22 @@ void context_popup(struct gui_window * gw, short x, short y)
if(strlen(tempfile)<=125){
shel_write(1, 1, 1, editor, cmdline);
}
- } else {
- printf("Could not open temp file: %s!\n", tempfile );
- }
-
- } else {
- LOG(("Invalid content!"));
- }
- } else {
- form_alert(0, "[1][Set option \"atari_editor\".][OK]");
- }
- break;
-
- default: break;
- }
-
-#undef POP_FIRST_ITEM
-#undef POP_LAST_ITEM
-
-}
+ } else {
+ printf("Could not open temp file: %s!\n", tempfile );
+ }
+
+ } else {
+ LOG(("Invalid content!"));
+ }
+ } else {
+ form_alert(0, "[1][Set option \"atari_editor\".][OK]");
+ }
+ break;
+
+ default: break;
+ }
+
+#undef POP_FIRST_ITEM
+#undef POP_LAST_ITEM
+
+}
diff --git a/atari/deskmenu.c b/atari/deskmenu.c
index ee8855cb0..96b2d02ce 100644
--- a/atari/deskmenu.c
+++ b/atari/deskmenu.c
@@ -1,13 +1,30 @@
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#include <stdlib.h>
#include <cflib.h>
#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/url.h"
+#include "utils/messages.h"
#include "desktop/browser.h"
#include "desktop/browser_private.h"
#include "utils/nsoption.h"
-#include "desktop/save_complete.h"
+#include "desktop/save_complete.h"
#include "atari/res/netsurf.rsh"
#include "atari/gemtk/gemtk.h"
#include "atari/deskmenu.h"
@@ -27,19 +44,19 @@
typedef void __CDECL (*menu_evnt_func)(short item, short title, void * data);
-struct s_accelerator
-{
- char ascii; /* either ascii or */
- long keycode; /* normalised keycode is valid */
- short mod; /* shift / ctrl etc */
-};
-
-struct s_menu_item_evnt {
- short title; /* to which menu this item belongs */
- short rid; /* resource ID */
- menu_evnt_func menu_func; /* click handler */
- struct s_accelerator accel; /* accelerator info */
- char * menustr;
+struct s_accelerator
+{
+ char ascii; /* either ascii or */
+ long keycode; /* normalised keycode is valid */
+ short mod; /* shift / ctrl etc */
+};
+
+struct s_menu_item_evnt {
+ short title; /* to which menu this item belongs */
+ short rid; /* resource ID */
+ menu_evnt_func menu_func; /* click handler */
+ struct s_accelerator accel; /* accelerator info */
+ char * menustr;
};
static void register_menu_str(struct s_menu_item_evnt * mi);
@@ -50,23 +67,23 @@ extern bool html_redraw_debug;
extern struct gui_window * input_window;
extern char options[PATH_MAX];
extern const char * option_homepage_url;
-extern int option_window_width;
+extern int option_window_width;
extern int option_window_height;
extern int option_window_x;
extern int option_window_y;
static OBJECT * h_gem_menu;
-
-/* Zero based resource tree ids: */
-#define T_ABOUT 0
-#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
-#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
-#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
-#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
-#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
-/* Count of the above defines: */
+
+/* Zero based resource tree ids: */
+#define T_ABOUT 0
+#define T_FILE MAINMENU_T_FILE - MAINMENU_T_FILE + 1
+#define T_EDIT MAINMENU_T_EDIT - MAINMENU_T_FILE + 1
+#define T_VIEW MAINMENU_T_VIEW - MAINMENU_T_FILE + 1
+#define T_NAV MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
+#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
+/* Count of the above defines: */
#define NUM_MENU_TITLES 7
@@ -102,50 +119,50 @@ static void __CDECL menu_cookies(short item, short title, void *data);
static void __CDECL menu_vlog(short item, short title, void *data);
static void __CDECL menu_help_content(short item, short title, void *data);
-struct s_menu_item_evnt menu_evnt_tbl[] =
-{
- {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+struct s_menu_item_evnt menu_evnt_tbl[] =
+{
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
{T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
{T_VIEW, MAINMENU_INC_SCALE, menu_inc_scale, {'+',0,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_DEC_SCALE, menu_dec_scale, {'-',0,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_DEC_SCALE, menu_dec_scale, {'-',0,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
{T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
{T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, menu_home, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
{T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_COOKIES, menu_cookies, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
- {-1, -1, NULL,{0,0,0}, NULL }
+ {T_UTIL, MAINMENU_M_COOKIES, menu_cookies, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {-1, -1, NULL,{0,0,0}, NULL }
};
/*
-static void __CDECL evnt_menu(WINDOW * win, short buff[8])
-{
- int title = buff[3];
- INT16 x,y;
- char *str;
- struct gui_window * gw = window_list;
+static void __CDECL evnt_menu(WINDOW * win, short buff[8])
+{
+ int title = buff[3];
+ INT16 x,y;
+ char *str;
+ struct gui_window * gw = window_list;
int i=0;
deskmenu_dispatch_item(buff[3], buff[4]);
@@ -155,23 +172,22 @@ static void __CDECL evnt_menu(WINDOW * win, short buff[8])
/*
Menu item event handlers:
*/
-
-static void __CDECL menu_about(short item, short title, void *data)
+
+static void __CDECL menu_about(short item, short title, void *data)
{
- /*
+ /*
nsurl *url;
nserror error;
- char buf[PATH_MAX];
+ char buf[PATH_MAX];
- LOG(("%s", __FUNCTION__));
- strcpy((char*)&buf, "file://");
+ LOG(("%s", __FUNCTION__));
+ strcpy((char*)&buf, "file://");
strncat((char*)&buf, (char*)"./doc/README.TXT",
- PATH_MAX - (strlen("file://")+1) );
+ PATH_MAX - (strlen("file://")+1) );
error = nsurl_create(buf, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -183,15 +199,15 @@ static void __CDECL menu_about(short item, short title, void *data)
}
*/
atari_about_show();
-}
-
-static void __CDECL menu_new_win(short item, short title, void *data)
-{
+}
+
+static void __CDECL menu_new_win(short item, short title, void *data)
+{
nsurl *url;
nserror error;
const char *addr;
- LOG(("%s", __FUNCTION__));
+ LOG(("%s", __FUNCTION__));
if (nsoption_charp(homepage_url) != NULL) {
addr = nsoption_charp(homepage_url);
@@ -202,8 +218,7 @@ static void __CDECL menu_new_win(short item, short title, void *data)
/* create an initial browser window */
error = nsurl_create(addr, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -214,18 +229,17 @@ static void __CDECL menu_new_win(short item, short title, void *data)
if (error != NSERROR_OK) {
warn_user(messages_get_errorcode(error), 0);
}
-}
-
-static void __CDECL menu_open_url(short item, short title, void *data)
-{
- struct gui_window * gw;
- struct browser_window * bw ;
+}
+
+static void __CDECL menu_open_url(short item, short title, void *data)
+{
+ struct gui_window * gw;
+ struct browser_window * bw ;
LOG(("%s", __FUNCTION__));
-
- gw = input_window;
- if( gw == NULL ) {
- browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+
+ gw = input_window;
+ if( gw == NULL ) {
+ browser_window_create(BW_CREATE_HISTORY,
NULL,
NULL,
NULL,
@@ -239,12 +253,12 @@ static void __CDECL menu_open_url(short item, short title, void *data)
window_set_focus(gw->root, URL_WIDGET, NULL);
/* delete selection: */
- toolbar_key_input(gw->root->toolbar, NK_DEL);
-}
-
-static void __CDECL menu_open_file(short item, short title, void *data)
+ toolbar_key_input(gw->root->toolbar, NK_DEL);
+}
+
+static void __CDECL menu_open_file(short item, short title, void *data)
{
-
+
LOG(("%s", __FUNCTION__));
const char * filename = file_select(messages_get("OpenFile"), "");
@@ -256,8 +270,7 @@ static void __CDECL menu_open_file(short item, short title, void *data)
error = nsurl_create(urltxt, &url);
if (error == NSERROR_OK) {
- error = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ error = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
@@ -271,18 +284,18 @@ static void __CDECL menu_open_file(short item, short title, void *data)
free( urltxt );
}
}
-}
-
-static void __CDECL menu_close_win(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- gui_window_destroy( input_window );
-}
-
-static void __CDECL menu_save_page(short item, short title, void *data)
-{
+}
+
+static void __CDECL menu_close_win(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ gui_window_destroy( input_window );
+}
+
+static void __CDECL menu_save_page(short item, short title, void *data)
+{
LOG(("%s", __FUNCTION__));
static bool init = true;
bool is_folder=false;
@@ -306,41 +319,40 @@ static void __CDECL menu_save_page(short item, short title, void *data)
if( path != NULL ){
save_complete(input_window->browser->bw->current_content, path, NULL);
}
-
-}
-
-static void __CDECL menu_quit(short item, short title, void *data)
-{
- short buff[8];
- memset( &buff, 0, sizeof(short)*8 );
+
+}
+
+static void __CDECL menu_quit(short item, short title, void *data)
+{
+ short buff[8];
+ memset( &buff, 0, sizeof(short)*8 );
+ LOG(("%s", __FUNCTION__));
+ gemtk_wm_send_msg(NULL, AP_TERM, 0, 0, 0, 0);
+}
+
+static void __CDECL menu_cut(short item, short title, void *data)
+{
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
+}
+
+static void __CDECL menu_copy(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
+}
+
+static void __CDECL menu_paste(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window != NULL )
+ browser_window_key_press( input_window->browser->bw, KEY_PASTE);
+}
+
+static void __CDECL menu_find(short item, short title, void *data)
+{
LOG(("%s", __FUNCTION__));
- gemtk_wm_send_msg(NULL, AP_TERM, 0, 0, 0, 0);
-}
-
-static void __CDECL menu_cut(short item, short title, void *data)
-{
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_CUT_SELECTION);
-}
-
-static void __CDECL menu_copy(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_COPY_SELECTION);
-}
-
-static void __CDECL menu_paste(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window != NULL )
- browser_window_key_press( input_window->browser->bw, KEY_PASTE);
-}
-
-static void __CDECL menu_find(short item, short title, void *data)
-{
- static bool visible = false;
- LOG(("%s", __FUNCTION__));
if (input_window != NULL) {
if (input_window->search) {
window_close_search(input_window->root);
@@ -348,72 +360,76 @@ static void __CDECL menu_find(short item, short title, void *data)
else {
window_open_search(input_window->root, true);
}
- }
-}
-
-static void __CDECL menu_choices(short item, short title, void *data)
+ }
+}
+
+static void __CDECL menu_choices(short item, short title, void *data)
{
LOG(("%s", __FUNCTION__));
- open_settings();
-}
-
-static void __CDECL menu_stop(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
+ open_settings();
+}
+
+static void __CDECL menu_stop(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
return;
- assert(input_window && input_window->root);
- toolbar_stop_click(input_window->root->toolbar);
-
-}
-
-static void __CDECL menu_reload(short item, short title, void *data)
-{
- if(input_window == NULL)
- return;
- toolbar_reload_click(input_window->root->toolbar);
- LOG(("%s", __FUNCTION__));
+ assert(input_window && input_window->root);
+ toolbar_stop_click(input_window->root->toolbar);
+
}
+static void __CDECL menu_reload(short item, short title, void *data)
+{
+ if(input_window == NULL)
+ return;
+ toolbar_reload_click(input_window->root->toolbar);
+ LOG(("%s", __FUNCTION__));
+}
-static void __CDECL menu_inc_scale(short item, short title, void *data)
+
+static void __CDECL menu_inc_scale(short item, short title, void *data)
{
- if(input_window == NULL)
- return;
+ if(input_window == NULL)
+ return;
- gui_window_set_scale(input_window, gui_window_get_scale(input_window)+0.25);
+ browser_window_set_scale(input_window->browser->bw,
+ browser_window_get_scale(input_window->browser->bw) + 0.25,
+ true);
}
-static void __CDECL menu_dec_scale(short item, short title, void *data)
+static void __CDECL menu_dec_scale(short item, short title, void *data)
{
- if(input_window == NULL)
+ if(input_window == NULL)
return;
- gui_window_set_scale(input_window, gui_window_get_scale(input_window)-0.25);
+ browser_window_set_scale(input_window->browser->bw,
+ browser_window_get_scale(input_window->browser->bw) - 0.25,
+ true);
}
-
-
-static void __CDECL menu_toolbars(short item, short title, void *data)
+
+
+static void __CDECL menu_toolbars(short item, short title, void *data)
{
- static int state = 0;
+ static int state = 0;
LOG(("%s", __FUNCTION__));
if( input_window != null && input_window->root->toolbar != null ){
state = !state;
// TODO: implement toolbar hide
//toolbar_hide(input_window->root->toolbar, state );
- }
-}
-
-static void __CDECL menu_savewin(short item, short title, void *data)
-{
+ }
+}
+
+static void __CDECL menu_savewin(short item, short title, void *data)
+{
LOG(("%s", __FUNCTION__));
if (input_window && input_window->browser) {
GRECT rect;
wind_get_grect(gemtk_wm_get_handle(input_window->root->win), WF_CURRXYWH,
- &rect);
+ &rect);
option_window_width = rect.g_w;
option_window_height = rect.g_h;
option_window_x = rect.g_x;
@@ -424,112 +440,112 @@ static void __CDECL menu_savewin(short item, short title, void *data)
nsoption_set_int(window_y, rect.g_y);
nsoption_write((const char*)&options, NULL, NULL);
}
-
-}
-
-static void __CDECL menu_debug_render(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- html_redraw_debug = !html_redraw_debug;
- if( input_window != NULL ) {
+
+}
+
+static void __CDECL menu_debug_render(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ html_redraw_debug = !html_redraw_debug;
+ if( input_window != NULL ) {
if ( input_window->browser != NULL
- && input_window->browser->bw != NULL) {
+ && input_window->browser->bw != NULL) {
GRECT rect;
- window_get_grect(input_window->root, BROWSER_AREA_CONTENT, &rect);
+ window_get_grect(input_window->root, BROWSER_AREA_CONTENT, &rect);
browser_window_reformat(input_window->browser->bw, false,
rect.g_w, rect.g_h );
menu_icheck(h_gem_menu, MAINMENU_M_DEBUG_RENDER,
- (html_redraw_debug) ? 1 : 0);
- }
- }
+ (html_redraw_debug) ? 1 : 0);
+ }
+ }
}
-static void __CDECL menu_fg_images(short item, short title, void *data)
-{
+static void __CDECL menu_fg_images(short item, short title, void *data)
+{
nsoption_set_bool(foreground_images, !nsoption_bool(foreground_images));
menu_icheck(h_gem_menu, MAINMENU_M_FG_IMAGES,
- (nsoption_bool(foreground_images)) ? 1 : 0);
+ (nsoption_bool(foreground_images)) ? 1 : 0);
}
-static void __CDECL menu_bg_images(short item, short title, void *data)
-{
+static void __CDECL menu_bg_images(short item, short title, void *data)
+{
nsoption_set_bool(background_images, !nsoption_bool(background_images));
menu_icheck(h_gem_menu, MAINMENU_M_BG_IMAGES,
- (nsoption_bool(background_images)) ? 1 : 0);
-}
-
-static void __CDECL menu_back(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- toolbar_back_click(input_window->root->toolbar);
-}
-
-static void __CDECL menu_forward(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- toolbar_forward_click(input_window->root->toolbar);
-}
-
-static void __CDECL menu_home(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
- toolbar_home_click(input_window->root->toolbar);
-}
-
-static void __CDECL menu_lhistory(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if( input_window == NULL )
- return;
-}
-
-static void __CDECL menu_ghistory(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- atari_global_history_open();
-}
-
-static void __CDECL menu_add_bookmark(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- if (input_window) {
- if( input_window->browser->bw->current_content != NULL ){
- atari_hotlist_add_page(
- nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
- NULL
- );
- }
- }
-}
-
-static void __CDECL menu_bookmarks(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- atari_hotlist_open();
-}
-
-static void __CDECL menu_cookies(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
- atari_cookie_manager_open();
-}
-
-static void __CDECL menu_vlog(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
+ (nsoption_bool(background_images)) ? 1 : 0);
+}
+
+static void __CDECL menu_back(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ toolbar_back_click(input_window->root->toolbar);
+}
+
+static void __CDECL menu_forward(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ toolbar_forward_click(input_window->root->toolbar);
+}
+
+static void __CDECL menu_home(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+ toolbar_home_click(input_window->root->toolbar);
+}
+
+static void __CDECL menu_lhistory(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if( input_window == NULL )
+ return;
+}
+
+static void __CDECL menu_ghistory(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ atari_global_history_open();
+}
+
+static void __CDECL menu_add_bookmark(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ if (input_window) {
+ if( input_window->browser->bw->current_content != NULL ){
+ atari_hotlist_add_page(
+ nsurl_access(hlcache_handle_get_url(input_window->browser->bw->current_content)),
+ NULL
+ );
+ }
+ }
+}
+
+static void __CDECL menu_bookmarks(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ atari_hotlist_open();
+}
+
+static void __CDECL menu_cookies(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
+ atari_cookie_manager_open();
+}
+
+static void __CDECL menu_vlog(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
verbose_log = !verbose_log;
- menu_icheck(h_gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0);
-}
-
-static void __CDECL menu_help_content(short item, short title, void *data)
-{
- LOG(("%s", __FUNCTION__));
+ menu_icheck(h_gem_menu, MAINMENU_M_VLOG, (verbose_log) ? 1 : 0);
+}
+
+static void __CDECL menu_help_content(short item, short title, void *data)
+{
+ LOG(("%s", __FUNCTION__));
}
/*
@@ -618,7 +634,6 @@ static void register_menu_str( struct s_menu_item_evnt * mi )
// find keycodes / chracters:
if( str[x] <= 28 ){
// parse symbol
- unsigned short keycode=0;
switch( str[x] ){
case 0x03:
accel->keycode = NK_RIGHT;
@@ -674,8 +689,8 @@ void deskmenu_init(void)
/* Install menu: */
menu_bar(h_gem_menu, MENU_INSTALL);
- /* parse and update menu items: */
- i = 0;
+ /* parse and update menu items: */
+ i = 0;
while (menu_evnt_tbl[i].rid != -1) {
if(menu_evnt_tbl[i].rid > 0 && menu_evnt_tbl[i].title > 0){
register_menu_str( &menu_evnt_tbl[i] );
@@ -685,7 +700,7 @@ void deskmenu_init(void)
menu_evnt_tbl[i].menustr);
}
}
- i++;
+ i++;
}
deskmenu_update();
/* Redraw menu: */
@@ -700,14 +715,14 @@ void deskmenu_destroy(void)
int i;
/* Remove menu from desktop: */
- menu_bar(h_gem_menu, MENU_REMOVE);
+ menu_bar(h_gem_menu, MENU_REMOVE);
/* Free modified menu titles: */
- i=0;
- while(menu_evnt_tbl[i].rid != -1) {
- if( menu_evnt_tbl[i].menustr != NULL )
- free(menu_evnt_tbl[i].menustr);
- i++;
+ i=0;
+ while(menu_evnt_tbl[i].rid != -1) {
+ if( menu_evnt_tbl[i].menustr != NULL )
+ free(menu_evnt_tbl[i].menustr);
+ i++;
}
}
@@ -734,21 +749,21 @@ int deskmenu_dispatch_item(short title, short item)
// legacy code, is this sensible?:
/*
- while( gw ) {
- window_set_focus( gw, WIDGET_NONE, NULL );
- gw = gw->next;
+ while( gw ) {
+ window_set_focus( gw, WIDGET_NONE, NULL );
+ gw = gw->next;
}
*/
- while (menu_evnt_tbl[i].rid != -1) {
+ while (menu_evnt_tbl[i].rid != -1) {
if (menu_evnt_tbl[i].rid == item) {
- if (menu_evnt_tbl[i].menu_func != NULL) {
+ if (menu_evnt_tbl[i].menu_func != NULL) {
menu_evnt_tbl[i].menu_func(item, title, NULL);
- }
- break;
- }
- i++;
+ }
+ break;
+ }
+ i++;
}
return(retval);
@@ -769,10 +784,10 @@ int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
sascii = gemtk_keybd2ascii(kcode, K_LSHIFT);
}
- /* Iterate through the menu function table: */
- while( menu_evnt_tbl[i].rid != -1 && done == false) {
+ /* Iterate through the menu function table: */
+ while( menu_evnt_tbl[i].rid != -1 && done == false) {
if( kstate == menu_evnt_tbl[i].accel.mod
- && menu_evnt_tbl[i].accel.ascii != 0) {
+ && menu_evnt_tbl[i].accel.ascii != 0) {
if( menu_evnt_tbl[i].accel.ascii == sascii) {
if (menu_evnt_tbl[i].title > 0 && menu_evnt_tbl[i].rid > 0) {
deskmenu_dispatch_item(menu_evnt_tbl[i].title,
@@ -781,15 +796,15 @@ int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
else {
/* Keyboard shortcut not displayed within menu: */
menu_evnt_tbl[i].menu_func(0, 0, NULL);
- }
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod) {
+ }
+ done = true;
+ break;
+ }
+ } else {
+ /* the accel code hides in the keycode: */
+ if( menu_evnt_tbl[i].accel.keycode != 0) {
+ if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
+ kstate == menu_evnt_tbl[i].accel.mod) {
if (menu_evnt_tbl[i].title > 0 && menu_evnt_tbl[i].rid > 0) {
deskmenu_dispatch_item(menu_evnt_tbl[i].title,
menu_evnt_tbl[i].rid);
@@ -797,13 +812,13 @@ int deskmenu_dispatch_keypress(unsigned short kcode, unsigned short kstate,
else {
/* Keyboard shortcut not displayed within menu: */
menu_evnt_tbl[i].menu_func(0, 0, NULL);
- }
- done = true;
- break;
- }
- }
- }
- i++;
+ }
+ done = true;
+ break;
+ }
+ }
+ }
+ i++;
}
return((done==true) ? 1 : 0);
}
diff --git a/atari/download.c b/atari/download.c
index e4a45e82e..7e44cda89 100755
--- a/atari/download.c
+++ b/atari/download.c
@@ -1,49 +1,47 @@
-/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
#include <stdbool.h>
-
-#include "content/urldb.h"
-#include "content/fetch.h"
-#include "desktop/gui.h"
-#include "desktop/local_history.h"
-#include "desktop/netsurf.h"
-#include "utils/nsoption.h"
-#include "desktop/save_complete.h"
-#include "desktop/textinput.h"
-#include "desktop/download.h"
-#include "render/html.h"
-#include "utils/url.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "atari/gui.h"
-#include "atari/misc.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/download.h"
-#include "atari/osspec.h"
+
+#include "content/urldb.h"
+#include "content/fetch.h"
+#include "desktop/gui.h"
+#include "desktop/netsurf.h"
+#include "utils/nsoption.h"
+#include "desktop/save_complete.h"
+#include "desktop/textinput.h"
+#include "desktop/download.h"
+#include "render/html.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "atari/gui.h"
+#include "atari/misc.h"
+#include "atari/res/netsurf.rsh"
+#include "atari/download.h"
+#include "atari/osspec.h"
extern struct gui_window * input_window;
extern GRECT desk_area;
@@ -124,7 +122,7 @@ static short on_aes_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
}
return(retval);
-}
+}
static void on_redraw(struct gui_download_window *dw, GRECT *clip)
{
@@ -148,8 +146,8 @@ static void on_redraw(struct gui_download_window *dw, GRECT *clip)
((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_PERCENT))->te_ptext = dw->lbl_percent;
((TEDINFO *)get_obspec(tree, DOWNLOAD_LBL_SPEED))->te_ptext = dw->lbl_speed;
- if (dw->size_total > 0 ) {
- p = ((double)dw->size_downloaded / (double)dw->size_total * 100);
+ if (dw->size_total > 0 ) {
+ p = ((double)dw->size_downloaded / (double)dw->size_total * 100);
}
tree[DOWNLOAD_PROGRESS_DONE].ob_width = MAX( MIN( p*(DOWNLOAD_BAR_MAX/100),
DOWNLOAD_BAR_MAX ), 1);
@@ -169,58 +167,58 @@ static void on_redraw(struct gui_download_window *dw, GRECT *clip)
wind_get_grect(dw->aes_handle, WF_NEXTXYWH, &visible);
}
}
-
-static void on_abort_click(struct gui_download_window *dw)
-{
+
+static void on_abort_click(struct gui_download_window *dw)
+{
if( dw->status == NSATARI_DOWNLOAD_COMPLETE
|| dw->status == NSATARI_DOWNLOAD_ERROR ) {
gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0,0,0,0);
- }
- else if( dw->status != NSATARI_DOWNLOAD_CANCELED ){
- dw->abort = true;
- }
-}
-
-static void on_cbrdy_click(struct gui_download_window *dw)
+ }
+ else if( dw->status != NSATARI_DOWNLOAD_CANCELED ){
+ dw->abort = true;
+ }
+}
+
+static void on_cbrdy_click(struct gui_download_window *dw)
{
- dw->close_on_finish = !dw->close_on_finish;
+ dw->close_on_finish = !dw->close_on_finish;
if (dw->close_on_finish && dw->status == NSATARI_DOWNLOAD_COMPLETE) {
gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0,0,0,0);
}
gemtk_wm_exec_redraw(dw->guiwin, NULL);
- evnt_timer(250);
-}
-
-static void on_close(struct gui_download_window * dw)
-{
- gui_download_window_destroy(dw);
-}
-
-static void gui_download_window_destroy( struct gui_download_window * gdw)
-{
-
-
- LOG((""));
- if (gdw->status == NSATARI_DOWNLOAD_WORKING) {
- download_context_abort(gdw->ctx);
- }
-
- download_context_destroy(gdw->ctx);
-
- if (gdw->destination) {
- free( gdw->destination );
- }
- if (gdw->fd != NULL) {
- fclose(gdw->fd);
- gdw->fd = NULL;
- }
- if (gdw->fbuf != NULL) {
- free( gdw->fbuf );
- }
+ evnt_timer(250);
+}
+
+static void on_close(struct gui_download_window * dw)
+{
+ gui_download_window_destroy(dw);
+}
+
+static void gui_download_window_destroy( struct gui_download_window * gdw)
+{
+
+
+ LOG((""));
+ if (gdw->status == NSATARI_DOWNLOAD_WORKING) {
+ download_context_abort(gdw->ctx);
+ }
+
+ download_context_destroy(gdw->ctx);
+
+ if (gdw->destination) {
+ free( gdw->destination );
+ }
+ if (gdw->fd != NULL) {
+ fclose(gdw->fd);
+ gdw->fd = NULL;
+ }
+ if (gdw->fbuf != NULL) {
+ free( gdw->fbuf );
+ }
gemtk_wm_remove(gdw->guiwin);
wind_close(gdw->aes_handle);
- wind_delete(gdw->aes_handle);
- free(gdw);
+ wind_delete(gdw->aes_handle);
+ free(gdw);
}
static char * select_filepath( const char * path, const char * filename )
@@ -244,15 +242,14 @@ static char * select_filepath( const char * path, const char * filename )
printf("download file: %s\n", ret);
return(ret);
-}
+}
-struct gui_download_window * gui_download_window_create(download_context *ctx,
- struct gui_window *parent)
+static struct gui_download_window *
+gui_download_window_create(download_context *ctx, struct gui_window *parent)
{
- const char *filename;
- char *destination;
- char gdos_path[PATH_MAX];
- const char * url;
+ const char *filename;
+ char *destination;
+ char gdos_path[PATH_MAX];
struct gui_download_window * gdw;
int dlgres = 0;
OBJECT * tree = gemtk_obj_get_tree(DOWNLOAD);
@@ -261,19 +258,19 @@ struct gui_download_window * gui_download_window_create(download_context *ctx,
LOG(("Creating download window for gui window: %p", parent));
- /* TODO: Implement real form and use messages file strings! */
-
+ /* TODO: Implement real form and use messages file strings! */
+
if (tree == NULL){
die("Couldn't find AES Object tree for download window!");
return(NULL);
}
-
+
filename = download_context_get_filename((const download_context*)ctx);
snprintf(alert, 200, "[2][Accept download?|%.*s][Yes|Save as...|No]",
40,filename);
- dlgres = form_alert(2, alert);
- if( dlgres == 3){
- return( NULL );
+ dlgres = form_alert(2, alert);
+ if( dlgres == 3){
+ return( NULL );
}
else if( dlgres == 2 ){
gemdos_realpath(nsoption_charp(downloads_path), gdos_path);
@@ -288,39 +285,38 @@ struct gui_download_window * gui_download_window_create(download_context *ctx,
destination = malloc( dstsize );
snprintf(destination, dstsize, "%s/%s", gdos_path, filename);
}
-
- gdw = calloc(1, sizeof(struct gui_download_window));
+
+ gdw = calloc(1, sizeof(struct gui_download_window));
if( gdw == NULL ){
warn_user(NULL, "Out of memory!");
- free( destination );
+ free( destination );
return( NULL );
}
-
- gdw->ctx = ctx;
- gdw->abort = false;
- gdw->start = clock() / CLOCKS_PER_SEC;
- gdw->lastrdw = 0;
- gdw->status = NSATARI_DOWNLOAD_WORKING;
- gdw->parent = parent;
- gdw->fbufsize = MAX(BUFSIZ, 48000);
- gdw->size_downloaded = 0;
+
+ gdw->ctx = ctx;
+ gdw->abort = false;
+ gdw->start = clock() / CLOCKS_PER_SEC;
+ gdw->lastrdw = 0;
+ gdw->status = NSATARI_DOWNLOAD_WORKING;
+ gdw->parent = parent;
+ gdw->fbufsize = MAX(BUFSIZ, 48000);
+ gdw->size_downloaded = 0;
gdw->size_total = download_context_get_total_length(ctx);
gdw->destination = destination;
- gdw->tree = tree;
- url = download_context_get_url(ctx);
-
- gdw->fd = fopen(gdw->destination, "wb");
+ gdw->tree = tree;
+
+ gdw->fd = fopen(gdw->destination, "wb");
if( gdw->fd == NULL ){
char spare[200];
snprintf(spare, 200, "Couldn't open %s for writing!", gdw->destination);
- gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, spare);
- gui_download_window_destroy(gdw);
- return( NULL );
+ gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, spare);
+ gui_download_window_destroy(gdw);
+ return( NULL );
}
-
- gdw->fbuf = malloc( gdw->fbufsize+1 );
- if( gdw->fbuf != NULL ){
- setvbuf( gdw->fd, gdw->fbuf, _IOFBF, gdw->fbufsize );
+
+ gdw->fbuf = malloc( gdw->fbufsize+1 );
+ if( gdw->fbuf != NULL ){
+ setvbuf( gdw->fd, gdw->fbuf, _IOFBF, gdw->fbufsize );
}
gdw->aes_handle = wind_create_grect(CLOSER | NAME | MOVER, &desk_area);
@@ -328,17 +324,17 @@ struct gui_download_window * gui_download_window_create(download_context *ctx,
unsigned long gwflags = GEMTK_WM_FLAG_DEFAULTS;
gdw->guiwin = gemtk_wm_add(gdw->aes_handle, gwflags, on_aes_event);
if( gdw->guiwin == NULL || gdw->fd == NULL ){
- die("could not create guiwin");
- gui_download_window_destroy(gdw);
- return( NULL );
+ die("could not create guiwin");
+ gui_download_window_destroy(gdw);
+ return( NULL );
}
gemtk_wm_set_user_data(gdw->guiwin, gdw);
gemtk_wm_set_toolbar(gdw->guiwin, tree, 0, 0);
- gemtk_wm_set_toolbar_redraw_func(gdw->guiwin, toolbar_redraw_cb);
-
- strncpy((char*)&gdw->lbl_file, filename, MAX_SLEN_LBL_FILE-1);
- LOG(("created download: %s (total size: %d)",
- gdw->destination, gdw->size_total
+ gemtk_wm_set_toolbar_redraw_func(gdw->guiwin, toolbar_redraw_cb);
+
+ strncpy((char*)&gdw->lbl_file, filename, MAX_SLEN_LBL_FILE-1);
+ LOG(("created download: %s (total size: %d)",
+ gdw->destination, gdw->size_total
));
GRECT work, curr;
@@ -357,100 +353,104 @@ struct gui_download_window * gui_download_window_create(download_context *ctx,
return(gdw);
}
-
-
-nserror gui_download_window_data(struct gui_download_window *dw,
- const char *data, unsigned int size)
-{
-
- uint32_t clck = clock();
- uint32_t tnow = clck / (CLOCKS_PER_SEC>>3);
+
+
+static nserror gui_download_window_data(struct gui_download_window *dw,
+ const char *data, unsigned int size)
+{
+
+ uint32_t clck = clock();
+ uint32_t tnow = clck / (CLOCKS_PER_SEC>>3);
uint32_t sdiff = (clck / (CLOCKS_PER_SEC)) - dw->start;
- uint32_t p = 0;
- float speed;
- float pf = 0;
LOG((""));
- OBJECT * tree = dw->tree;
-
if(dw->abort == true){
- dw->status = NSATARI_DOWNLOAD_CANCELED;
- dw->abort = false;
+ dw->status = NSATARI_DOWNLOAD_CANCELED;
+ dw->abort = false;
download_context_abort(dw->ctx);
- gemtk_wm_exec_redraw(dw->guiwin, NULL);
- return(NSERROR_OK);
- }
-
- /* save data */
- fwrite( data , size, sizeof(unsigned char),dw->fd );
+ gemtk_wm_exec_redraw(dw->guiwin, NULL);
+ return(NSERROR_OK);
+ }
+
+ /* save data */
+ fwrite( data , size, sizeof(unsigned char),dw->fd );
dw->size_downloaded += size;
- /* Update GUI */
+ /* Update GUI */
if ((tnow - dw->lastrdw) > 1) {
+ float speed;
+
+ dw->lastrdw = tnow;
+ speed = dw->size_downloaded / sdiff;
- dw->lastrdw = tnow;
- speed = dw->size_downloaded / sdiff;
-
if( dw->size_total > 0 ){
- p = ((double)dw->size_downloaded / (double)dw->size_total * 100);
- snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
- "%lu%s", p, "%"
- );
- } else {
- snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
- "%s", "?%"
- );
- }
- snprintf( (char*)&dw->lbl_speed, MAX_SLEN_LBL_SPEED, "%s/s",
- human_friendly_bytesize(speed)
- );
- snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
- human_friendly_bytesize(dw->size_downloaded),
- (dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : "?"
+ uint32_t p = 0;
+ p = ((double)dw->size_downloaded / (double)dw->size_total * 100);
+ snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
+ "%lu%s", p, "%"
+ );
+ } else {
+ snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
+ "%s", "?%"
+ );
+ }
+ snprintf( (char*)&dw->lbl_speed, MAX_SLEN_LBL_SPEED, "%s/s",
+ human_friendly_bytesize(speed)
+ );
+ snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
+ human_friendly_bytesize(dw->size_downloaded),
+ (dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : "?"
);
- gemtk_wm_exec_redraw(dw->guiwin, NULL);
- }
- return NSERROR_OK;
-}
-
-void gui_download_window_error(struct gui_download_window *dw,
- const char *error_msg)
-{
- LOG(("%s", error_msg));
- strncpy((char*)&dw->lbl_file, error_msg, MAX_SLEN_LBL_FILE-1);
- dw->status = NSATARI_DOWNLOAD_ERROR;
+ gemtk_wm_exec_redraw(dw->guiwin, NULL);
+ }
+ return NSERROR_OK;
+}
+
+static void gui_download_window_error(struct gui_download_window *dw,
+ const char *error_msg)
+{
+ LOG(("%s", error_msg));
+ strncpy((char*)&dw->lbl_file, error_msg, MAX_SLEN_LBL_FILE-1);
+ dw->status = NSATARI_DOWNLOAD_ERROR;
gemtk_wm_exec_redraw(dw->guiwin, NULL);
gui_window_set_status(input_window, messages_get("Done") );
- // TODO: change abort to close
-}
-
-void gui_download_window_done(struct gui_download_window *dw)
+ // TODO: change abort to close
+}
+
+static void gui_download_window_done(struct gui_download_window *dw)
{
- OBJECT * tree;
LOG((""));
-// TODO: change abort to close
+// TODO: change abort to close
dw->status = NSATARI_DOWNLOAD_COMPLETE;
-
- if( dw->fd != NULL ) {
- fclose( dw->fd );
- dw->fd = NULL;
- }
- tree = dw->tree;
+ if( dw->fd != NULL ) {
+ fclose( dw->fd );
+ dw->fd = NULL;
+ }
+
if (dw->close_on_finish) {
- gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0, 0, 0, 0);
+ gemtk_wm_send_msg(dw->guiwin, WM_CLOSED, 0, 0, 0, 0);
} else {
- snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
- "%lu%s", 100, "%"
- );
- snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
- human_friendly_bytesize(dw->size_downloaded),
- (dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : human_friendly_bytesize(dw->size_downloaded)
- );
+ snprintf( (char*)&dw->lbl_percent, MAX_SLEN_LBL_PERCENT,
+ "%lu%s", 100, "%"
+ );
+ snprintf( (char*)&dw->lbl_done, MAX_SLEN_LBL_DONE, "%s / %s",
+ human_friendly_bytesize(dw->size_downloaded),
+ (dw->size_total>0) ? human_friendly_bytesize(dw->size_total) : human_friendly_bytesize(dw->size_downloaded)
+ );
gemtk_wm_exec_redraw(dw->guiwin, NULL);
}
- gui_window_set_status(input_window, messages_get("Done") );
-}
+ gui_window_set_status(input_window, messages_get("Done") );
+}
+
+static struct gui_download_table download_table = {
+ .create = gui_download_window_create,
+ .data = gui_download_window_data,
+ .error = gui_download_window_error,
+ .done = gui_download_window_done,
+};
+
+struct gui_download_table *atari_download_table = &download_table;
diff --git a/atari/download.h b/atari/download.h
index e25893d4a..82f89c050 100755
--- a/atari/download.h
+++ b/atari/download.h
@@ -19,6 +19,8 @@
#ifndef NS_ATARI_DOWNLOAD_H
#define NS_ATARI_DOWNLOAD_H
+extern struct gui_download_table *atari_download_table;
+
#define MAX_SLEN_LBL_DONE 64
#define MAX_SLEN_LBL_PERCENT 5
#define MAX_SLEN_LBL_SPEED 13
diff --git a/atari/encoding.c b/atari/encoding.c
index 0212d51c4..7a60eeeb9 100644
--- a/atari/encoding.c
+++ b/atari/encoding.c
@@ -16,28 +16,30 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
+
+#include "desktop/gui.h"
+
#include "atari/encoding.h"
/* TODO: this need a rework..., encoding to atari st doesn|t always work.
( gui_add_to_clipboard...) */
-utf8_convert_ret utf8_to_local_encoding(const char *string,
+nserror utf8_to_local_encoding(const char *string,
size_t len,
char **result)
{
- utf8_convert_ret r;
+ nserror r;
r = utf8_to_enc(string, "ATARIST", len, result);
- if(r != UTF8_CONVERT_OK) {
+ if(r != NSERROR_OK) {
r = utf8_to_enc(string, "UTF-8", len, result);
- assert( r == UTF8_CONVERT_OK );
+ assert( r == NSERROR_OK );
}
return r;
}
-utf8_convert_ret utf8_from_local_encoding(const char *string,
- size_t len,
- char **result)
+nserror utf8_from_local_encoding(const char *string, size_t len, char **result)
{
return utf8_from_enc(string, "ATARIST", len, result, NULL);
}
@@ -69,3 +71,9 @@ int atari_to_ucs4(unsigned char atari)
}
+static struct gui_utf8_table utf8_table = {
+ .utf8_to_local = utf8_to_local_encoding,
+ .local_to_utf8 = utf8_from_local_encoding,
+};
+
+struct gui_utf8_table *atari_utf8_table = &utf8_table;
diff --git a/atari/encoding.h b/atari/encoding.h
index c85bac9fc..d0289b613 100644
--- a/atari/encoding.h
+++ b/atari/encoding.h
@@ -1,32 +1,37 @@
-/*
- * Copyright 2012 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/*
+ * Copyright 2012 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NS_ATARI_ENCODING_H
#define NS_ATARI_ENCODING_H
-#include <inttypes.h>
-#include <assert.h>
+#include <inttypes.h>
+#include <assert.h>
#include <stdbool.h>
-#include "css/css.h"
+#include "css/css.h"
#include "render/font.h"
-#include "utils/utf8.h"
-
+#include "utils/utf8.h"
+
+struct gui_utf8_table *atari_utf8_table;
+
+nserror utf8_to_local_encoding(const char *string, size_t len, char **result);
+nserror utf8_from_local_encoding(const char *string, size_t len, char **result);
+
int atari_to_ucs4( unsigned char atarichar);
#endif
diff --git a/atari/filetype.c b/atari/filetype.c
index 99daf470c..251abc6b3 100755
--- a/atari/filetype.c
+++ b/atari/filetype.c
@@ -1,70 +1,71 @@
-/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "utils/url.h"
-#include "utils/log.h"
-#include "content/fetch.h"
-
-/**
- * filetype -- determine the MIME type of a local file
- */
-const char *fetch_filetype(const char *unix_path)
-{
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "utils/log.h"
+#include "content/fetch.h"
+
+#include "atari/filetype.h"
+
+/**
+ * filetype -- determine the MIME type of a local file
+ */
+const char *fetch_filetype(const char *unix_path)
+{
int l;
char * res = (char*)"text/html";
l = strlen(unix_path);
LOG(("unix path: %s", unix_path));
-
+
/* This line is added for devlopment versions running from the root dir: */
- if( strchr( unix_path, (int)'.' ) ){
- if (2 < l && strcasecmp(unix_path + l - 3, "f79") == 0)
- res = (char*)"text/css";
- else if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
- res = (char*)"text/css";
- else if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
- res = (char*)"image/jpeg";
- else if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
- res = (char*)"image/jpeg";
- else if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
- res = (char*)"image/gif";
- else if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
- res = (char*)"image/png";
- else if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
- res = (char*)"image/jng";
- else if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
- res = (char*)"image/svg";
- else if (2 < l && strcasecmp(unix_path + l - 3, "txt") == 0)
+ if( strchr( unix_path, (int)'.' ) ){
+ if (2 < l && strcasecmp(unix_path + l - 3, "f79") == 0)
+ res = (char*)"text/css";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "css") == 0)
+ res = (char*)"text/css";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "jpg") == 0)
+ res = (char*)"image/jpeg";
+ else if (3 < l && strcasecmp(unix_path + l - 4, "jpeg") == 0)
+ res = (char*)"image/jpeg";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "gif") == 0)
+ res = (char*)"image/gif";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "png") == 0)
+ res = (char*)"image/png";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "jng") == 0)
+ res = (char*)"image/jng";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "svg") == 0)
+ res = (char*)"image/svg";
+ else if (2 < l && strcasecmp(unix_path + l - 3, "txt") == 0)
res = (char*)"text/plain";
} else {
- int n=0;
- int c;
FILE * fp;
char buffer[16];
fp = fopen( unix_path, "r" );
if( fp ){
+ int n=0;
+ int c;
do {
c = fgetc (fp);
if( c != EOF )
@@ -84,14 +85,8 @@ const char *fetch_filetype(const char *unix_path)
}
}
}
-
+
error:
LOG(("mime type: %s", res ));
- return( res );
-}
-
-
-char *fetch_mimetype(const char *ro_path)
-{
- return strdup("text/plain");
+ return( res );
}
diff --git a/atari/filetype.h b/atari/filetype.h
new file mode 100644
index 000000000..97ba75b80
--- /dev/null
+++ b/atari/filetype.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NS_ATARI_FILETYPE_H_
+#define NS_ATARI_FILETYPE_H_
+
+const char *fetch_filetype(const char *unix_path);
+
+#endif
diff --git a/atari/findfile.c b/atari/findfile.c
index 7badc7149..356a9333f 100755
--- a/atari/findfile.c
+++ b/atari/findfile.c
@@ -68,59 +68,6 @@ char * local_file_to_url( const char * filename )
#undef BACKSLASH
}
-/* convert an local path to an URL, memory for URL is allocated. */
-char *path_to_url(const char *path_in)
-{
- #define BACKSLASH 0x5C
- char * path;
-
- LOG(("path2url in: %s\n", path_in));
-
- path = (char*)path_in;
-
- int urllen = strlen(path) + FILE_SCHEME_PREFIX_LEN + 1;
- char *url = malloc(urllen);
-
- snprintf(url, urllen, "%s%s", FILE_SCHEME_PREFIX, path);
-
- int i=0;
- while( url[i] != 0 ){
- if( url[i] == BACKSLASH ){
- url[i] = '/';
- }
- i++;
- }
-
- LOG(("path2url out: %s\n", url));
- return url;
- #undef BACKSLASH
-}
-
-
-char *url_to_path(const char *url)
-{
- char *url_path = curl_unescape(url, 0);
- char *path;
- char abspath[PATH_MAX+1];
-
- LOG(( "url2path in: %s (%s)\n", url, url_path ));
-
- // is the URL relative?
- if (url_path[7] == '.') {
- // yes, make it absolute...
- gemdos_realpath(url_path + (FILE_SCHEME_PREFIX_LEN-1), abspath);
- path = strdup(abspath);
- } else {
- path = strdup(url_path + (FILE_SCHEME_PREFIX_LEN));
- }
-
- curl_free(url_path);
-
- LOG(( "url2path out: %s\n", path ));
-
- return path;
-}
-
/**
* Locate a shared resource file by searching known places in order.
diff --git a/atari/findfile.h b/atari/findfile.h
index e87f7cff7..9a6f7848a 100755
--- a/atari/findfile.h
+++ b/atari/findfile.h
@@ -21,6 +21,7 @@
#define NS_ATARI_FINDFILE_H
extern char *atari_find_resource(char *buf, const char *filename, const char *def);
-char * local_file_to_url( const char * filename );
+char *local_file_to_url(const char *filename);
+
#endif /* NETSURF_ATARI_FINDFILE_H */
diff --git a/atari/gemtk/guiwin.c b/atari/gemtk/guiwin.c
index 9a5c93d9b..afb3cd790 100644
--- a/atari/gemtk/guiwin.c
+++ b/atari/gemtk/guiwin.c
@@ -129,7 +129,7 @@ static short preproc_wm(GUIWIN * gw, EVMULT_OUT *ev_out, short msg[8])
{
GRECT g, g_ro, g2;
short retval = 1;
- int val = 1, old_val;
+ int val = 1;
struct gemtk_wm_scroll_info_s *slid;
switch(msg[0]) {
@@ -1338,7 +1338,7 @@ bool gemtk_wm_has_intersection(GUIWIN *win, GRECT *work)
}
wind_get_grect(win->handle, WF_FIRSTXYWH, &area);
- while (area.g_w && area.g_w) {
+ while (area.g_w) {
//GRECT * ptr = &area;
if (RC_WITHIN(work, &area)) {
retval = false;
@@ -1375,10 +1375,8 @@ void gemtk_wm_toolbar_redraw(GUIWIN *gw, uint16_t msg, GRECT *clip)
void gemtk_wm_form_redraw(GUIWIN *gw, GRECT *clip)
{
GRECT area, area_ro, g;
- int scroll_px_x, scroll_px_y;
struct gemtk_wm_scroll_info_s *slid;
//int new_x, new_y, old_x, old_y;
- short edit_idx;
DEBUG_PRINT(("gemtk_wm_form_redraw\n"));
diff --git a/atari/gemtk/objc.c b/atari/gemtk/objc.c
index 514f6b544..855413e0b 100644
--- a/atari/gemtk/objc.c
+++ b/atari/gemtk/objc.c
@@ -27,8 +27,6 @@
char *gemtk_obj_get_text(OBJECT * tree, short idx)
{
static char p[]="";
- USERBLK *user;
- char *retval;
switch (tree[idx].ob_type & 0x00FF) {
case G_BUTTON:
@@ -71,7 +69,6 @@ char gemtk_obj_set_str_safe(OBJECT * tree, short idx, const char *txt)
char spare[204];
short type = 0;
short maxlen = 0;
- TEDINFO *ted;
type = (tree[idx].ob_type & 0xFF);
diff --git a/atari/gemtk/utils.c b/atari/gemtk/utils.c
index aac293d21..63e6330ec 100644
--- a/atari/gemtk/utils.c
+++ b/atari/gemtk/utils.c
@@ -1,19 +1,19 @@
-/*
- * Copyright 2013 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/*
+ * Copyright 2013 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
@@ -123,7 +123,6 @@ void gemtk_send_msg(short msg_type, short data2, short data3, short data4,
void gemtk_wind_get_str(short aes_handle, short mode, char *str, int len)
{
- char tmp_str[255];
// TODO: remove or implement function
diff --git a/atari/gui.c b/atari/gui.c
index e52a6589c..f267b69a8 100644
--- a/atari/gui.c
+++ b/atari/gui.c
@@ -16,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/*
- This File provides all the mandatory functions prefixed with gui_
-*/
+/**
+ * \file Provides all the mandatory functions prefixed with gui_ for atari
+ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -30,17 +30,17 @@
#include <stdbool.h>
#include <hubbub/hubbub.h>
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "utils/nsoption.h"
#include "content/urldb.h"
#include "content/fetch.h"
#include "content/fetchers/resource.h"
#include "css/utils.h"
#include "desktop/gui.h"
-#include "desktop/local_history.h"
#include "desktop/plotters.h"
#include "desktop/netsurf.h"
-#include "desktop/401login.h"
-
-#include "utils/nsoption.h"
#include "desktop/save_complete.h"
#include "desktop/textinput.h"
#include "desktop/treeview.h"
@@ -48,11 +48,6 @@
#include "desktop/browser_private.h"
#include "desktop/mouse.h"
#include "render/font.h"
-#include "utils/schedule.h"
-#include "utils/url.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
#include "atari/gemtk/gemtk.h"
#include "atari/gui.h"
@@ -74,6 +69,8 @@
#include "atari/osspec.h"
#include "atari/search.h"
#include "atari/deskmenu.h"
+#include "atari/download.h"
+#include "atari/filetype.h"
#include "cflib.h"
#define TODO() (0)/*printf("%s Unimplemented!\n", __FUNCTION__)*/
@@ -113,18 +110,18 @@ EVMULT_IN aes_event_in = {
EVMULT_OUT aes_event_out;
short aes_msg_out[8];
+bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
+static void gui_window_set_url(struct gui_window *w, const char *url);
-
-void gui_poll(bool active)
+static void gui_poll(bool active)
{
struct gui_window *tmp;
short mx, my, dummy;
- unsigned short nkc = 0;
aes_event_in.emi_tlow = schedule_run();
- if(active || rendering){
+ if(rendering){
aes_event_in.emi_tlow = nsoption_int(atari_gui_poll_timeout);
}
@@ -133,13 +130,10 @@ void gui_poll(bool active)
printf("long poll!\n");
}
- struct gui_window * g;
-
- if( !active ) {
if(input_window && input_window->root->redraw_slots.areas_used > 0) {
window_process_redraws(input_window->root);
}
- }
+
graf_mkstate(&mx, &my, &dummy, &dummy);
aes_event_in.emi_m1.g_x = mx;
@@ -186,13 +180,13 @@ void gui_poll(bool active)
}
-struct gui_window *
-gui_create_browser_window(struct browser_window *bw,
- struct browser_window *clone,
- bool new_tab) {
+static struct gui_window *
+gui_window_create(struct browser_window *bw,
+ struct gui_window *existing,
+ gui_window_create_flags flags) {
struct gui_window *gw=NULL;
- LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw, bw, clone,
- (int)new_tab
+ LOG(( "gw: %p, BW: %p, existing %p, flags: %d\n" , gw, bw, existing,
+ (int)flags
));
gw = calloc(1, sizeof(struct gui_window));
@@ -200,14 +194,13 @@ gui_create_browser_window(struct browser_window *bw,
return NULL;
LOG(("new window: %p, bw: %p\n", gw, bw));
- window_create(gw, bw, clone, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\
+ window_create(gw, bw, existing, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\
|WIDGET_SCROLL);
if (gw->root->win) {
GRECT pos = {
option_window_x, option_window_y,
option_window_width, option_window_height
};
- gui_window_set_scale(gw, 1.0);
gui_window_set_url(gw, "");
gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT);
gui_set_input_gui_window(gw);
@@ -277,8 +270,11 @@ void gui_window_destroy(struct gui_window *w)
}
}
-void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
- bool scaled)
+static void
+gui_window_get_dimensions(struct gui_window *w,
+ int *width,
+ int *height,
+ bool scaled)
{
if (w == NULL)
return;
@@ -288,7 +284,7 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height,
*height = rect.g_h;
}
-void gui_window_set_title(struct gui_window *gw, const char *title)
+static void gui_window_set_title(struct gui_window *gw, const char *title)
{
if (gw == NULL)
@@ -299,7 +295,7 @@ void gui_window_set_title(struct gui_window *gw, const char *title)
int l;
char * conv;
l = strlen(title)+1;
- if (utf8_to_local_encoding(title, l-1, &conv) == UTF8_CONVERT_OK ) {
+ if (utf8_to_local_encoding(title, l-1, &conv) == NSERROR_OK ) {
l = MIN((uint32_t)atari_sysinfo.aes_max_win_title_len, strlen(conv));
if(gw->title == NULL)
gw->title = malloc(l);
@@ -346,24 +342,17 @@ void gui_window_set_status(struct gui_window *w, const char *text)
window_set_stauts(w->root, (char*)text);
}
-float gui_window_get_scale(struct gui_window *gw)
+static void atari_window_reformat(struct gui_window *gw)
{
- return(gw->scale);
-}
+ int width = 0, height = 0;
-void gui_window_set_scale(struct gui_window *gw, float scale)
-{
- int width = 0, heigth = 0;
-
- LOG(("scale: %f", scale));
-
- gw->scale = MAX(scale, 0.25);
-
- gui_window_get_dimensions(gw, &width, &heigth, true);
- browser_window_reformat(gw->browser->bw, false, width, heigth);
+ if (gw != NULL) {
+ gui_window_get_dimensions(gw, &width, &height, true);
+ browser_window_reformat(gw->browser->bw, false, width, height);
+ }
}
-void gui_window_redraw_window(struct gui_window *gw)
+static void gui_window_redraw_window(struct gui_window *gw)
{
CMP_BROWSER b;
GRECT rect;
@@ -374,7 +363,7 @@ void gui_window_redraw_window(struct gui_window *gw)
window_schedule_redraw_grect(gw->root, &rect);
}
-void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
+static void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
{
GRECT area;
struct gemtk_wm_scroll_info_s *slid;
@@ -395,7 +384,6 @@ void gui_window_update_box(struct gui_window *gw, const struct rect *rect)
bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
{
- int x,y;
if (w == NULL)
return false;
@@ -404,13 +392,12 @@ bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy)
return( true );
}
-void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
+static void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
{
- int units = 0;
- if ((w == NULL)
- || (w->browser->bw == NULL)
- || (w->browser->bw->current_content == NULL))
- return;
+ if ( (w == NULL)
+ || (w->browser->bw == NULL)
+ || (!browser_window_has_content(w->browser->bw)))
+ return;
LOG(("scroll (gui_window: %p) %d, %d\n", w, sx, sy));
window_scroll_by(w->root, sx, sy);
@@ -418,21 +405,14 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy)
}
-void gui_window_scroll_visible(struct gui_window *w, int x0, int y0, int x1, int y1)
-{
- LOG(("%s:(%p, %d, %d, %d, %d)", __func__, w, x0, y0, x1, y1));
- gui_window_set_scroll(w,x0,y0);
-}
-
-
/* It seems this method is called when content size got adjusted,
so that we can adjust scroll info. We also have to call it when tab
change occurs.
*/
-void gui_window_update_extent(struct gui_window *gw)
+static void gui_window_update_extent(struct gui_window *gw)
{
- if( gw->browser->bw->current_content != NULL ) {
+ if(browser_window_has_content(gw->browser->bw)) {
// TODO: store content size!
if(window_get_active_gui_window(gw->root) == gw) {
window_set_content_size( gw->root,
@@ -448,13 +428,6 @@ void gui_window_update_extent(struct gui_window *gw)
}
-void gui_clear_selection(struct gui_window *g)
-{
-
-}
-
-
-
/**
* set the pointer shape
*/
@@ -534,13 +507,8 @@ void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape)
}
}
-void gui_window_hide_pointer(struct gui_window *w)
-{
- TODO();
-}
-
-void gui_window_set_url(struct gui_window *w, const char *url)
+static void gui_window_set_url(struct gui_window *w, const char *url)
{
int l;
@@ -591,28 +559,28 @@ static void throbber_advance( void * data )
return;
toolbar_throbber_progress(gw->root->toolbar);
- schedule(100, throbber_advance, gw );
+ atari_schedule(1000, throbber_advance, gw );
}
-void gui_window_start_throbber(struct gui_window *w)
+static void gui_window_start_throbber(struct gui_window *w)
{
GRECT work;
if (w == NULL)
return;
toolbar_set_throbber_state(w->root->toolbar, true);
- schedule(100, throbber_advance, w );
+ atari_schedule(1000, throbber_advance, w );
rendering = true;
}
-void gui_window_stop_throbber(struct gui_window *w)
+static void gui_window_stop_throbber(struct gui_window *w)
{
if (w == NULL)
return;
if (w->root->toolbar->throbber.running == false)
return;
- schedule_remove(throbber_advance, w);
+ atari_schedule(-1, throbber_advance, w);
toolbar_set_throbber_state(w->root->toolbar, false);
@@ -620,7 +588,7 @@ void gui_window_stop_throbber(struct gui_window *w)
}
/* Place caret in window */
-void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
+static void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
const struct rect *clip)
{
window_place_caret(w->root, 1, x, y, height, NULL);
@@ -632,7 +600,7 @@ void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
/**
* clear window caret
*/
-void
+static void
gui_window_remove_caret(struct gui_window *w)
{
if (w == NULL)
@@ -646,7 +614,7 @@ gui_window_remove_caret(struct gui_window *w)
return;
}
-void
+static void
gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
{
struct bitmap *bmp_icon;
@@ -658,13 +626,7 @@ gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
}
}
-void
-gui_window_set_search_ico(hlcache_handle *ico)
-{
- TODO();
-}
-
-void gui_window_new_content(struct gui_window *w)
+static void gui_window_new_content(struct gui_window *w)
{
struct gemtk_wm_scroll_info_s *slid = gemtk_wm_get_scroll_info(w->root->win);
slid->x_pos = 0;
@@ -673,44 +635,6 @@ void gui_window_new_content(struct gui_window *w)
gui_window_redraw_window(w);
}
-bool gui_window_scroll_start(struct gui_window *w)
-{
- TODO();
- return true;
-}
-
-bool gui_window_drag_start(struct gui_window *g, gui_drag_type type,
- const struct rect *rect)
-{
- TODO();
- return true;
-}
-
-void gui_window_save_link(struct gui_window *g, const char *url,
- const char *title)
-{
- LOG(("%s -> %s", title, url ));
- TODO();
-}
-
-void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
- struct gui_window *w)
-{
- LOG((""));
- TODO();
-}
-
-void gui_drag_save_selection(struct gui_window *g, const char *selection)
-{
- LOG((""));
- TODO();
-}
-
-void gui_start_selection(struct gui_window *w)
-{
-
-}
-
/**
* Core asks front end for clipboard contents.
@@ -718,10 +642,9 @@ void gui_start_selection(struct gui_window *w)
* \param buffer UTF-8 text, allocated by front end, ownership yeilded to core
* \param length Byte length of UTF-8 text in buffer
*/
-void gui_get_clipboard(char **buffer, size_t *length)
+static void gui_get_clipboard(char **buffer, size_t *length)
{
char *clip;
- size_t clip_len;
*length = 0;
*buffer = 0;
@@ -734,17 +657,18 @@ void gui_get_clipboard(char **buffer, size_t *length)
// clipboard is in atari encoding, convert it to utf8:
+ size_t clip_len;
char *utf8 = NULL;
- utf8_convert_ret ret;
clip_len = strlen(clip);
if (clip_len > 0) {
+ nserror ret;
ret = utf8_to_local_encoding(clip, clip_len, &utf8);
- if (ret == UTF8_CONVERT_OK && utf8 != NULL) {
+ if (ret == NSERROR_OK && utf8 != NULL) {
*buffer = utf8;
*length = strlen(utf8);
} else {
- assert(ret == UTF8_CONVERT_OK && utf8 != NULL);
+ assert(ret == NSERROR_OK && utf8 != NULL);
}
}
@@ -760,43 +684,27 @@ void gui_get_clipboard(char **buffer, size_t *length)
* \param styles Array of styles given to text runs, owned by core, or NULL
* \param n_styles Number of text run styles in array
*/
-void gui_set_clipboard(const char *buffer, size_t length,
+static void gui_set_clipboard(const char *buffer, size_t length,
nsclipboard_styles styles[], int n_styles)
{
if (length > 0 && buffer != NULL) {
// convert utf8 input to atari encoding:
- utf8_convert_ret ret;
+ nserror ret;
char *clip = NULL;
ret = utf8_to_local_encoding(buffer,length, &clip);
- if (ret == UTF8_CONVERT_OK) {
+ if (ret == NSERROR_OK) {
scrap_txt_write(clip);
} else {
- assert(ret == UTF8_CONVERT_OK);
+ assert(ret == NSERROR_OK);
}
free(clip);
}
}
-
-void gui_create_form_select_menu(struct browser_window *bw,
- struct form_control *control)
-{
- TODO();
-}
-
-/**
- * Broadcast an URL that we can't handle.
- */
-void gui_launch_url(const char *url)
-{
- TODO();
- LOG(("launch file: %s\n", url));
-}
-
-void gui_401login_open(nsurl *url, const char *realm,
+static void gui_401login_open(nsurl *url, const char *realm,
nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
bool bres;
@@ -815,15 +723,13 @@ void gui_401login_open(nsurl *url, const char *realm,
}
-void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
+static void gui_cert_verify(nsurl *url, const struct ssl_cert_info *certs,
unsigned long num, nserror (*cb)(bool proceed, void *pw),
void *cbpw)
{
struct sslcert_session_data *data;
LOG((""));
- bool bres;
-
// TODO: localize string
int b = form_alert(1, "[2][SSL Verify failed, continue?][Continue|Abort|Details...]");
if(b == 1){
@@ -854,7 +760,7 @@ struct gui_window * gui_get_input_window(void)
return(input_window);
}
-void gui_quit(void)
+static void gui_quit(void)
{
LOG((""));
@@ -972,18 +878,14 @@ static inline void create_cursor(int flags, short mode, void * form,
}
}
-nsurl *gui_get_resource_url(const char *path)
+static nsurl *gui_get_resource_url(const char *path)
{
char buf[PATH_MAX];
- char *raw;
nsurl *url = NULL;
atari_find_resource((char*)&buf, path, path);
- raw = path_to_url((char*)&buf);
- if (raw != NULL) {
- nsurl_create(raw, &url);
- free(raw);
- }
+
+ netsurf_path_to_nsurl(buf, &url);
return url;
}
@@ -1098,6 +1000,49 @@ static void gui_init2(int argc, char** argv)
toolbar_init();
}
+static struct gui_window_table atari_window_table = {
+ .create = gui_window_create,
+ .destroy = gui_window_destroy,
+ .redraw = gui_window_redraw_window,
+ .update = gui_window_update_box,
+ .get_scroll = gui_window_get_scroll,
+ .set_scroll = gui_window_set_scroll,
+ .get_dimensions = gui_window_get_dimensions,
+ .update_extent = gui_window_update_extent,
+ .reformat = atari_window_reformat,
+
+ .set_title = gui_window_set_title,
+ .set_url = gui_window_set_url,
+ .set_icon = gui_window_set_icon,
+ .set_status = gui_window_set_status,
+ .set_pointer = gui_window_set_pointer,
+ .place_caret = gui_window_place_caret,
+ .remove_caret = gui_window_remove_caret,
+ .new_content = gui_window_new_content,
+ .start_throbber = gui_window_start_throbber,
+ .stop_throbber = gui_window_stop_throbber,
+};
+
+static struct gui_clipboard_table atari_clipboard_table = {
+ .get = gui_get_clipboard,
+ .set = gui_set_clipboard,
+};
+
+static struct gui_fetch_table atari_fetch_table = {
+ .filetype = fetch_filetype,
+
+ .get_resource_url = gui_get_resource_url,
+};
+
+static struct gui_browser_table atari_browser_table = {
+ .poll = gui_poll,
+ .schedule = atari_schedule,
+
+ .quit = gui_quit,
+ .cert_verify = gui_cert_verify,
+ .login = gui_401login_open,
+};
+
/* #define WITH_DBG_LOGFILE 1 */
/** Entry point from OS.
*
@@ -1113,8 +1058,22 @@ int main(int argc, char** argv)
struct stat stat_buf;
nsurl *url;
nserror ret;
+ struct netsurf_table atari_table = {
+ .browser = &atari_browser_table,
+ .window = &atari_window_table,
+ .clipboard = &atari_clipboard_table,
+ .download = atari_download_table,
+ .fetch = &atari_fetch_table,
+ .utf8 = atari_utf8_table,
+ .search = atari_search_table,
+ };
+
+ ret = netsurf_register(&atari_table);
+ if (ret != NSERROR_OK) {
+ die("NetSurf operation table failed registration");
+ }
- /* @todo logging file descriptor update belongs in a nslog_init callback */
+ /** @todo logging file descriptor update belongs in a nslog_init callback */
setbuf(stderr, NULL);
setbuf(stdout, NULL);
#ifdef WITH_DBG_LOGFILE
@@ -1146,7 +1105,7 @@ int main(int argc, char** argv)
/* common initialisation */
LOG(("Initialising core..."));
- ret = netsurf_init(messages);
+ ret = netsurf_init(messages, NULL);
if (ret != NSERROR_OK) {
die("NetSurf failed to initialise");
}
@@ -1171,8 +1130,7 @@ int main(int argc, char** argv)
/* create an initial browser window */
ret = nsurl_create(addr, &url);
if (ret == NSERROR_OK) {
- ret = browser_window_create(BROWSER_WINDOW_VERIFIABLE |
- BROWSER_WINDOW_HISTORY,
+ ret = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
NULL,
diff --git a/atari/gui.h b/atari/gui.h
index 6c43ec6fe..10736c5f8 100755
--- a/atari/gui.h
+++ b/atari/gui.h
@@ -149,7 +149,6 @@ struct gui_window {
char * title;
char * url;
struct bitmap * icon;
- float scale;
struct s_caret caret;
struct s_search_form_session *search;
struct gui_window *next, *prev;
@@ -163,8 +162,10 @@ extern struct gui_window *window_list;
void gui_set_input_gui_window(struct gui_window *gw);
struct gui_window *gui_get_input_window(void);
char *gui_window_get_url(struct gui_window *gw);
-char * gui_window_get_title(struct gui_window *gw);
-void gui_window_set_scale(struct gui_window *gw, float scale);
-float gui_window_get_scale(struct gui_window *gw);
+char *gui_window_get_title(struct gui_window *gw);
+
+void gui_window_set_status(struct gui_window *w, const char *text);
+void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape);
+void gui_window_destroy(struct gui_window *w);
#endif
diff --git a/atari/history.c b/atari/history.c
index 90ed0b8ae..6fe510825 100644
--- a/atari/history.c
+++ b/atari/history.c
@@ -1,19 +1,19 @@
-/*
- * Copyright 2013 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/*
+ * Copyright 2013 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -37,7 +37,6 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
-#include "utils/url.h"
#include "atari/gui.h"
#include "atari/misc.h"
#include "atari/treeview.h"
@@ -104,11 +103,8 @@ static void atari_global_history_mouse_action(struct core_window *cw,
int x, int y)
{
LOG(("x: %d, y: %d\n", x, y));
- if((mouse & BROWSER_MOUSE_HOVER) && global_history_has_selection()){
- global_history_mouse_action(mouse, x, y);
- } else {
- global_history_mouse_action(mouse, x, y);
- }
+
+ global_history_mouse_action(mouse, x, y);
}
@@ -116,12 +112,7 @@ static void atari_global_history_mouse_action(struct core_window *cw,
static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
- struct atari_treeview_window *tv=NULL;
GRECT tb_area;
- GUIWIN * gemtk_win;
- struct gui_window * gw;
- char *cur_url = NULL;
- char *cur_title = NULL;
short retval = 0;
LOG((""));
diff --git a/atari/hotlist.c b/atari/hotlist.c
index b4e36ae1a..62ca0cf08 100644
--- a/atari/hotlist.c
+++ b/atari/hotlist.c
@@ -1,19 +1,19 @@
-/*
- * Copyright 2013 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/*
+ * Copyright 2013 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@@ -36,7 +36,6 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
-#include "utils/url.h"
#include "atari/gui.h"
#include "atari/misc.h"
#include "atari/treeview.h"
@@ -108,12 +107,8 @@ static void atari_hotlist_mouse_action(struct core_window *cw,
int x, int y)
{
LOG(("x: %d, y: %d\n", x, y));
- if((mouse & BROWSER_MOUSE_HOVER) && hotlist_has_selection()){
- hotlist_mouse_action(mouse, x, y);
- } else {
- hotlist_mouse_action(mouse, x, y);
- }
+ hotlist_mouse_action(mouse, x, y);
}
@@ -295,9 +290,6 @@ struct node;
void atari_hotlist_add_page( const char * url, const char * title )
{
- struct node * root;
- struct node * selected = NULL;
- struct node * folder = NULL;
nsurl *nsurl;
if(hl.tv == NULL)
diff --git a/atari/hotlist.h b/atari/hotlist.h
index d3ef02292..52598f27a 100644
--- a/atari/hotlist.h
+++ b/atari/hotlist.h
@@ -18,10 +18,17 @@
#ifndef NS_ATARI_HOTLIST_H
#define NS_ATARI_HOTLIST_H
+
#include <stdbool.h>
+
#include "desktop/tree.h"
#include "atari/gemtk/gemtk.h"
#include "atari/treeview.h"
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
/* The hotlist window, toolbar and treeview data. */
struct atari_hotlist {
diff --git a/atari/login.c b/atari/login.c
index 461a2f985..687512ed1 100755
--- a/atari/login.c
+++ b/atari/login.c
@@ -16,24 +16,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "desktop/401login.h"
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <cflib.h>
+
#include "utils/config.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
#include "desktop/browser.h"
-#include "desktop/401login.h"
#include "desktop/gui.h"
#include "utils/errors.h"
#include "utils/utils.h"
#include "utils/messages.h"
#include "utils/log.h"
-#include "utils/url.h"
#include "content/urldb.h"
#include "content/fetch.h"
#include "atari/misc.h"
diff --git a/atari/misc.c b/atari/misc.c
index d330859b9..bd3158406 100755
--- a/atari/misc.c
+++ b/atari/misc.c
@@ -1,138 +1,97 @@
-/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include <assert.h>
-#include <stdlib.h>
+#include <stdlib.h>
#include <stdio.h>
-#include <stdbool.h>
-#include <string.h>
+#include <stdbool.h>
+#include <string.h>
-#include <sys/types.h>
+#include <sys/types.h>
#include <mint/osbind.h>
#include "content/content.h"
-#include "content/hlcache.h"
-#include "desktop/cookie_manager.h"
+#include "content/hlcache.h"
+#include "desktop/cookie_manager.h"
#include "desktop/mouse.h"
#include "desktop/tree.h"
-#include "utils/nsoption.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "utils/url.h"
-#include "utils/log.h"
+#include "utils/nsoption.h"
+#include "utils/messages.h"
+#include "utils/utils.h"
+#include "utils/log.h"
#include "content/fetch.h"
-
-#include "atari/gui.h"
-#include "atari/toolbar.h"
-
+
+#include "atari/gui.h"
+#include "atari/toolbar.h"
+
#include "atari/misc.h"
#include "atari/encoding.h"
#include "atari/gemtk/gemtk.h"
-#include "cflib.h"
-
-extern void * h_gem_rsrc;
+#include "cflib.h"
+
+extern void * h_gem_rsrc;
struct is_process_running_callback_data {
const char * fname;
bool found;
};
-
-void warn_user(const char *warning, const char *detail)
-{
- size_t len = 1 + ((warning != NULL) ? strlen(messages_get(warning)) :
- 0) + ((detail != 0) ? strlen(detail) : 0);
- char message[len];
- snprintf(message, len, messages_get(warning), detail);
+
+void warn_user(const char *warning, const char *detail)
+{
+ size_t len = 1 + ((warning != NULL) ? strlen(messages_get(warning)) :
+ 0) + ((detail != 0) ? strlen(detail) : 0);
+ char message[len];
+ snprintf(message, len, messages_get(warning), detail);
printf("%s\n", message);
- gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, message);
-}
-
-void die(const char *error)
+ gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, message);
+}
+
+void die(const char *error)
{
- printf("%s\n", error);
+ printf("%s\n", error);
gemtk_msg_box_show(GEMTK_MSG_BOX_ALERT, error);
- exit(1);
-}
-
-/**
- * Return the filename part of a full path
- *
- * \param path full path and filename
- * \return filename (will be freed with free())
- */
-
-char *filename_from_path(char *path)
-{
- char *leafname;
-
- leafname = strrchr(path, '\\');
- if( !leafname )
- leafname = strrchr(path, '/');
- if (!leafname)
- leafname = path;
- else
- leafname += 1;
-
- return strdup(leafname);
-}
-
-/**
- * Add a path component/filename to an existing path
- *
- * \param path buffer containing path + free space
- * \param length length of buffer "path"
- * \param newpart string containing path component to add to path
- * \return true on success
- */
-
-bool path_add_part(char *path, int length, const char *newpart)
-{
- if(path[strlen(path) - 1] != '/')
- strncat(path, "/", length);
-
- strncat(path, newpart, length);
-
- return true;
+ exit(1);
}
-struct gui_window * find_guiwin_by_aes_handle(short handle){
-
- struct gui_window * gw;
- gw = window_list;
-
- if( handle == 0 ){
+
+struct gui_window * find_guiwin_by_aes_handle(short handle){
+
+ struct gui_window * gw;
+ gw = window_list;
+
+ if( handle == 0 ){
return( NULL );
}
- while(gw != NULL) {
+ while(gw != NULL) {
if(gw->root->win != NULL
- && gemtk_wm_get_handle(gw->root->win) == handle) {
- return(gw);
- }
- else
- gw = gw->next;
- }
-
- return( NULL );
+ && gemtk_wm_get_handle(gw->root->win) == handle) {
+ return(gw);
+ }
+ else
+ gw = gw->next;
+ }
+
+ return( NULL );
}
-
-
+
+
static int scan_process_list(scan_process_callback cb, void *data)
{
int pid, count = 0;
@@ -227,9 +186,9 @@ bool is_process_running(const char * name)
scan_process_list(proc_running_callback, &data);
return( (data.found==1) ? true : false );
-}
-
-
+}
+
+
/**
* Callback for load_icon(). Should be removed once bitmaps get loaded directly
* from disc
@@ -244,16 +203,16 @@ static nserror load_icon_callback(hlcache_handle *handle,
/**
* utility function. Copied from NetSurf tree API.
*
- * \param name the name of the loaded icon, if it's not a full path the icon is
- * looked for in the directory specified by icons_dir
+ * \param name the name of the loaded icon, if it's not a full path
+ * the icon is looked for in the directory specified by
+ * icons_dir.
+ * \param cb callback function to deal with hlcache callback.
+ * \param pw Context pointer to be passed to callback.
* \return the icon in form of a content or NULL on failure
*/
-hlcache_handle *load_icon(const char *name, hlcache_handle_callback cb,
- void * pw )
+hlcache_handle *
+load_icon(const char *name, hlcache_handle_callback cb, void *pw)
{
- char *url = NULL;
- const char *icon_url = NULL;
- int len;
hlcache_handle *c;
nserror err;
nsurl *icon_nsurl;
@@ -262,38 +221,23 @@ hlcache_handle *load_icon(const char *name, hlcache_handle_callback cb,
/** @todo something like bitmap_from_disc is needed here */
if (!strncmp(name, "file://", 7)) {
- icon_url = name;
+ err = nsurl_create(name, &icon_nsurl);
} else {
- char *native_path;
+ char *native_path = NULL;
if (icons_dir == NULL)
return NULL;
- /* path + separator + leafname + '\0' */
- len = strlen(icons_dir) + 1 + strlen(name) + 1;
- native_path = malloc(len);
- if (native_path == NULL) {
- LOG(("malloc failed"));
- warn_user("NoMemory", 0);
- return NULL;
+ err = netsurf_mkpath(&native_path, NULL, 2, icons_dir, name);
+ if (err == NSERROR_OK) {
+ /* Convert native path to URL */
+ err = netsurf_path_to_nsurl(native_path, &icon_nsurl);
+ free(native_path);
}
-
- /* Build native path */
- memcpy(native_path, icons_dir,
- strlen(icons_dir) + 1);
- path_add_part(native_path, len, name);
-
- /* Convert native path to URL */
- url = path_to_url(native_path);
-
- free(native_path);
- icon_url = url;
}
- err = nsurl_create(icon_url, &icon_nsurl);
if (err != NSERROR_OK) {
- if (url != NULL)
- free(url);
+ warn_user(messages_get_errorcode(err), 0);
return NULL;
}
@@ -304,30 +248,26 @@ hlcache_handle *load_icon(const char *name, hlcache_handle_callback cb,
nsurl_unref(icon_nsurl);
- /* If we built the URL here, free it */
- if (url != NULL)
- free(url);
-
if (err != NSERROR_OK) {
return NULL;
}
return c;
-}
-
-void gem_set_cursor( MFORM_EX * cursor )
-{
- static unsigned char flags = 255;
- static int number = 255;
- if( flags == cursor->flags && number == cursor->number )
- return;
+}
+
+void gem_set_cursor( MFORM_EX * cursor )
+{
+ static unsigned char flags = 255;
+ static int number = 255;
+ if( flags == cursor->flags && number == cursor->number )
+ return;
if( cursor->flags & MFORM_EX_FLAG_USERFORM ) {
- gemtk_obj_mouse_sprite(cursor->tree, cursor->number);
- } else {
- graf_mouse(cursor->number, NULL );
- }
- number = cursor->number;
- flags = cursor->flags;
+ gemtk_obj_mouse_sprite(cursor->tree, cursor->number);
+ } else {
+ graf_mouse(cursor->number, NULL );
+ }
+ number = cursor->number;
+ flags = cursor->flags;
}
/**
@@ -339,7 +279,7 @@ void gem_set_cursor( MFORM_EX * cursor )
*/
long nkc_to_input_key(short nkc, long * ucs4_out)
{
- unsigned char ascii = (nkc & 0xFF);
+ unsigned char ascii = (nkc & 0xFF);
long ik = 0;
// initialize result:
@@ -352,131 +292,131 @@ long nkc_to_input_key(short nkc, long * ucs4_out)
if( ((nkc & NKF_CTRL) == NKF_CTRL) && ((nkc & (NKF_SHIFT))!=0) ) {
}
- /* cntrl key only: */
- else if( (nkc & NKF_CTRL) == NKF_CTRL ) {
- switch ( ascii ) {
- case 'A':
- ik = KEY_SELECT_ALL;
- break;
-
- case 'C':
- ik = KEY_COPY_SELECTION;
- break;
-
- case 'X':
- ik = KEY_CUT_SELECTION;
- break;
-
- case 'V':
- ik = KEY_PASTE;
- break;
-
- default:
- break;
- }
+ /* cntrl key only: */
+ else if( (nkc & NKF_CTRL) == NKF_CTRL ) {
+ switch ( ascii ) {
+ case 'A':
+ ik = KEY_SELECT_ALL;
+ break;
+
+ case 'C':
+ ik = KEY_COPY_SELECTION;
+ break;
+
+ case 'X':
+ ik = KEY_CUT_SELECTION;
+ break;
+
+ case 'V':
+ ik = KEY_PASTE;
+ break;
+
+ default:
+ break;
+ }
}
- /* shift key only: */
+ /* shift key only: */
else if( (nkc & NKF_SHIFT) != 0 ) {
- switch( ascii ) {
- case NK_TAB:
- ik = KEY_SHIFT_TAB;
- break;
-
- case NK_LEFT:
- ik = KEY_LINE_START;
- break;
-
- case NK_RIGHT:
- ik = KEY_LINE_END;
- break;
-
- case NK_UP:
- ik = KEY_PAGE_UP;
- break;
-
- case NK_DOWN:
- ik = KEY_PAGE_DOWN;
- break;
-
- default:
- break;
- }
+ switch( ascii ) {
+ case NK_TAB:
+ ik = KEY_SHIFT_TAB;
+ break;
+
+ case NK_LEFT:
+ ik = KEY_LINE_START;
+ break;
+
+ case NK_RIGHT:
+ ik = KEY_LINE_END;
+ break;
+
+ case NK_UP:
+ ik = KEY_PAGE_UP;
+ break;
+
+ case NK_DOWN:
+ ik = KEY_PAGE_DOWN;
+ break;
+
+ default:
+ break;
+ }
}
- /* No modifier keys: */
- else {
+ /* No modifier keys: */
+ else {
switch( ascii ) {
case NK_INS:
ik = KEY_PASTE;
break;
-
- case NK_BS:
- ik = KEY_DELETE_LEFT;
- break;
-
- case NK_DEL:
- ik = KEY_DELETE_RIGHT;
- break;
-
- case NK_TAB:
- ik = KEY_TAB;
- break;
-
-
- case NK_ENTER:
- ik = KEY_NL;
- break;
-
- case NK_RET:
- ik = KEY_CR;
- break;
-
- case NK_ESC:
- ik = KEY_ESCAPE;
- break;
-
- case NK_CLRHOME:
- ik = KEY_TEXT_START;
- break;
-
- case NK_RIGHT:
- ik = KEY_RIGHT;
- break;
-
- case NK_LEFT:
- ik = KEY_LEFT;
- break;
-
- case NK_UP:
- ik = KEY_UP;
+
+ case NK_BS:
+ ik = KEY_DELETE_LEFT;
+ break;
+
+ case NK_DEL:
+ ik = KEY_DELETE_RIGHT;
+ break;
+
+ case NK_TAB:
+ ik = KEY_TAB;
+ break;
+
+
+ case NK_ENTER:
+ ik = KEY_NL;
+ break;
+
+ case NK_RET:
+ ik = KEY_CR;
+ break;
+
+ case NK_ESC:
+ ik = KEY_ESCAPE;
+ break;
+
+ case NK_CLRHOME:
+ ik = KEY_TEXT_START;
+ break;
+
+ case NK_RIGHT:
+ ik = KEY_RIGHT;
+ break;
+
+ case NK_LEFT:
+ ik = KEY_LEFT;
+ break;
+
+ case NK_UP:
+ ik = KEY_UP;
break;
case NK_UNDO:
ik = KEY_UNDO;
- break;
-
- case NK_DOWN:
- ik = KEY_DOWN;
- break;
-
- case NK_M_PGUP:
- ik = KEY_PAGE_UP;
- break;
-
- case NK_M_PGDOWN:
- ik = KEY_PAGE_DOWN;
- break;
-
- default:
- break;
- }
+ break;
+
+ case NK_DOWN:
+ ik = KEY_DOWN;
+ break;
+
+ case NK_M_PGUP:
+ ik = KEY_PAGE_UP;
+ break;
+
+ case NK_M_PGDOWN:
+ ik = KEY_PAGE_DOWN;
+ break;
+
+ default:
+ break;
+ }
}
-
- if( ik == 0 && ( (nkc & NKF_CTRL)==0) ) {
+
+ if( ik == 0 && ( (nkc & NKF_CTRL)==0) ) {
if (ascii >= 9 ) {
*ucs4_out = atari_to_ucs4(ascii);
- }
- }
+ }
+ }
return ( ik );
}
@@ -510,25 +450,25 @@ const char * file_select(const char * title, const char * name) {
return( NULL );
}
-
-
-void dbg_grect(const char * str, GRECT * r)
-{
- printf("%s: x: %d, y: %d, w: %d, h: %d (x2: %d, y2: %d)\n", str,
- r->g_x, r->g_y, r->g_w, r->g_h, r->g_x + r->g_w, r->g_y + r->g_h);
-}
-
-void dbg_pxy(const char * str, short * pxy )
-{
- printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
- pxy[0], pxy[1], pxy[2], pxy[3] );
+
+
+void dbg_grect(const char * str, GRECT * r)
+{
+ printf("%s: x: %d, y: %d, w: %d, h: %d (x2: %d, y2: %d)\n", str,
+ r->g_x, r->g_y, r->g_w, r->g_h, r->g_x + r->g_w, r->g_y + r->g_h);
+}
+
+void dbg_pxy(const char * str, short * pxy )
+{
+ printf("%s: x: %d, y: %d, w: %d, h: %d\n", str,
+ pxy[0], pxy[1], pxy[2], pxy[3] );
}
-void dbg_rect(const char * str, int * pxy)
-{
- printf("%s: x0: %d, y0: %d, x1: %d, y1: %d (w: %d, h: %d)\n", str,
+void dbg_rect(const char * str, int * pxy)
+{
+ printf("%s: x0: %d, y0: %d, x1: %d, y1: %d (w: %d, h: %d)\n", str,
pxy[0], pxy[1], pxy[2], pxy[3],
pxy[2] - pxy[0],
- pxy[3] - pxy[1] );
-}
-
+ pxy[3] - pxy[1] );
+}
+
diff --git a/atari/osspec.c b/atari/osspec.c
index 5bd7320dc..11bdee112 100644
--- a/atari/osspec.c
+++ b/atari/osspec.c
@@ -1,134 +1,133 @@
-/*
- * Copyright 2010 <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <stdio.h>
+/*
+ * Copyright 2010 <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <stdio.h>
#include <string.h>
-#include <support.h>
-#include <mint/osbind.h>
-#include <mint/cookie.h>
-
-#include "utils/log.h"
+#include <support.h>
+#include <mint/osbind.h>
+#include <mint/cookie.h>
+
+#include "utils/log.h"
#include "atari/osspec.h"
-#include "atari/gemtk/gemtk.h"
-
-#ifndef PATH_MAX
-#define PATH_MAX 1024
-#endif
-
-NS_ATARI_SYSINFO atari_sysinfo;
-
-void init_os_info(void)
-{
- int16_t out[4];
- unsigned long cookie_FSMC = 0;
-
- atari_sysinfo.gemdos_version = Sversion();
-
- if( tos_getcookie (C_FSMC, &cookie_FSMC ) == C_FOUND ) {
- atari_sysinfo.gdos_FSMC = 1;
- } else {
- atari_sysinfo.gdos_FSMC = 0;
- }
- atari_sysinfo.large_sfont_pxh = 13;
- atari_sysinfo.medium_sfont_pxh = 6;
- atari_sysinfo.small_sfont_pxh = 4;
- /* todo: detect if system font is monospaced */
- atari_sysinfo.sfont_monospaced = true;
- if( appl_xgetinfo(AES_LARGEFONT, &out[0], &out[1], &out[2], &out[3] ) > 0 ){
- atari_sysinfo.large_sfont_pxh = out[0];
- }
- if( appl_xgetinfo(AES_SMALLFONT, &out[0], &out[1], &out[2], &out[3] ) > 0 ){
- atari_sysinfo.small_sfont_pxh = out[0];
- }
- atari_sysinfo.aes_max_win_title_len = 79;
- if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
- if (sys_NAES()) {
- atari_sysinfo.aes_max_win_title_len = 127;
- }
- if (sys_XAAES()) {
- atari_sysinfo.aes_max_win_title_len = 200;
- }
- }
-}
-
-int tos_getcookie(long tag, long * value)
-{
- COOKIE * cptr;
- long oldsp;
-
- if( atari_sysinfo.gemdos_version > TOS4VER ){
- return( Getcookie(tag, value) );
- }
-
- cptr = (COOKIE*)Setexc(0x0168, -1L);
- if(cptr != NULL) {
- do {
- if( cptr->c == tag ){
- if(cptr->v != 0 ){
- if( value != NULL ){
- *value = cptr->v;
- }
- return( C_FOUND );
- }
- }
- } while( (cptr++)->c != 0L );
- }
- return( C_NOTFOUND );
-}
-
-/*
-
- a fixed version of realpath() which returns valid
- paths for TOS which have no U: drive
-
-*/
-
-char * gemdos_realpath(const char * path, char * rpath)
-{
- char work[PATH_MAX+1];
+#include "atari/gemtk/gemtk.h"
+
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+NS_ATARI_SYSINFO atari_sysinfo;
+
+void init_os_info(void)
+{
+ int16_t out[4];
+ unsigned long cookie_FSMC = 0;
+
+ atari_sysinfo.gemdos_version = Sversion();
+
+ if( tos_getcookie (C_FSMC, &cookie_FSMC ) == C_FOUND ) {
+ atari_sysinfo.gdos_FSMC = 1;
+ } else {
+ atari_sysinfo.gdos_FSMC = 0;
+ }
+ atari_sysinfo.large_sfont_pxh = 13;
+ atari_sysinfo.medium_sfont_pxh = 6;
+ atari_sysinfo.small_sfont_pxh = 4;
+ /* todo: detect if system font is monospaced */
+ atari_sysinfo.sfont_monospaced = true;
+ if( appl_xgetinfo(AES_LARGEFONT, &out[0], &out[1], &out[2], &out[3] ) > 0 ){
+ atari_sysinfo.large_sfont_pxh = out[0];
+ }
+ if( appl_xgetinfo(AES_SMALLFONT, &out[0], &out[1], &out[2], &out[3] ) > 0 ){
+ atari_sysinfo.small_sfont_pxh = out[0];
+ }
+ atari_sysinfo.aes_max_win_title_len = 79;
+ if (sys_type() & (SYS_MAGIC|SYS_NAES|SYS_XAAES)) {
+ if (sys_NAES()) {
+ atari_sysinfo.aes_max_win_title_len = 127;
+ }
+ if (sys_XAAES()) {
+ atari_sysinfo.aes_max_win_title_len = 200;
+ }
+ }
+}
+
+int tos_getcookie(long tag, long * value)
+{
+ COOKIE * cptr;
+
+ if( atari_sysinfo.gemdos_version > TOS4VER ){
+ return( Getcookie(tag, value) );
+ }
+
+ cptr = (COOKIE*)Setexc(0x0168, -1L);
+ if(cptr != NULL) {
+ do {
+ if( cptr->c == tag ){
+ if(cptr->v != 0 ){
+ if( value != NULL ){
+ *value = cptr->v;
+ }
+ return( C_FOUND );
+ }
+ }
+ } while( (cptr++)->c != 0L );
+ }
+ return( C_NOTFOUND );
+}
+
+/*
+
+ a fixed version of realpath() which returns valid
+ paths for TOS which have no U: drive
+
+*/
+
+char * gemdos_realpath(const char * path, char * rpath)
+{
+ char work[PATH_MAX+1];
char * r;
-
- if (rpath == NULL) {
- return (NULL);
+
+ if (rpath == NULL) {
+ return (NULL);
}
// Check if the path is already absolute:
if(path[1] == ':'){
strcpy(rpath, path);
return(rpath);
- }
+ }
LOG(("realpath in: %s\n", path));
r = realpath(path, work);
if (r != NULL) {
int e = unx2dos((const char *)r, rpath);
- LOG(("realpath out: %s\n", rpath));
+ LOG(("realpath out: %s\n", rpath));
return(rpath);
}
else {
LOG(("realpath out: NULL!\n"));
}
- return (NULL);
-}
-
+ return (NULL);
+}
+
diff --git a/atari/plot/font_freetype.c b/atari/plot/font_freetype.c
index 49e46c857..7ca2d8aba 100755
--- a/atari/plot/font_freetype.c
+++ b/atari/plot/font_freetype.c
@@ -23,6 +23,7 @@
#include FT_CACHE_H
#include "utils/nsoption.h"
+#include "css/css.h"
#include "atari/plot/plot.h"
#include "atari/plot/font_freetype.h"
#include "atari/findfile.h"
diff --git a/atari/plot/font_internal.c b/atari/plot/font_internal.c
index 2b0025a71..e3c806cfe 100644
--- a/atari/plot/font_internal.c
+++ b/atari/plot/font_internal.c
@@ -72,7 +72,7 @@ fb_get_font(const plot_font_style_t *fstyle)
}
}
-static utf8_convert_ret utf8_to_font_encoding(const struct fb_font_desc* font,
+static nserror utf8_to_font_encoding(const struct fb_font_desc* font,
const char *string,
size_t len,
char **result)
diff --git a/atari/plot/font_vdi.c b/atari/plot/font_vdi.c
index 340759f02..7f3dacf63 100755
--- a/atari/plot/font_vdi.c
+++ b/atari/plot/font_vdi.c
@@ -1,49 +1,51 @@
-/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
#ifdef WITH_VDI_FONT_DRIVER
#include <mt_gemx.h>
-#include "atari/plot/plot.h"
-#include "atari/plot/font_vdi.h"
-
-#include "utils/utf8.h"
+#include "atari/plot/plot.h"
+#include "atari/plot/font_vdi.h"
+
+#include "utils/utf8.h"
#include "utils/log.h"
-
-
-
-//static char * lstr = NULL;
-
-
-static int dtor( FONT_PLOTTER self );
-static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const char * str, size_t length, int * width );
-static int str_split( FONT_PLOTTER self, const plot_font_style_t *fstyle,const char *string,
- size_t length,int x, size_t *char_offset, int *actual_x );
-static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t *fstyle,const char *string,
- size_t length,int x, size_t *char_offset, int *actual_x );
-static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle );
-
-static bool init = false;
-static int vdih;
-
-extern struct s_vdi_sysinfo vdi_sysinfo;
+#include "atari/encoding.h"
+
+
+
+
+//static char * lstr = NULL;
+
+
+static int dtor( FONT_PLOTTER self );
+static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const char * str, size_t length, int * width );
+static int str_split( FONT_PLOTTER self, const plot_font_style_t *fstyle,const char *string,
+ size_t length,int x, size_t *char_offset, int *actual_x );
+static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t *fstyle,const char *string,
+ size_t length,int x, size_t *char_offset, int *actual_x );
+static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle );
+
+static bool init = false;
+static int vdih;
+
+extern struct s_vdi_sysinfo vdi_sysinfo;
static inline void atari_to_vdi_str(char *lstr, int length)
{
@@ -63,53 +65,53 @@ static inline void atari_to_vdi_str(char *lstr, int length)
}
}
}
-
-int ctor_font_plotter_vdi( FONT_PLOTTER self )
-{
- self->dtor = dtor;
- self->str_width = str_width;
- self->str_split = str_split;
- self->pixel_pos = pixel_pos;
- self->text = text;
- LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
- if( !init ) {
- vdih = self->vdi_handle;
- }
- init = true;
- return( 1 );
-}
-
-static int dtor( FONT_PLOTTER self )
-{
- return( 1 );
-}
-
-static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const char * str,
- size_t length, int * width )
-{
- short cw, ch, cellw, cellh;
- short pxsize;
+
+int ctor_font_plotter_vdi( FONT_PLOTTER self )
+{
+ self->dtor = dtor;
+ self->str_width = str_width;
+ self->str_split = str_split;
+ self->pixel_pos = pixel_pos;
+ self->text = text;
+ LOG(("%s: %s\n", (char*)__FILE__, __FUNCTION__));
+ if( !init ) {
+ vdih = self->vdi_handle;
+ }
+ init = true;
+ return( 1 );
+}
+
+static int dtor( FONT_PLOTTER self )
+{
+ return( 1 );
+}
+
+static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const char * str,
+ size_t length, int * width )
+{
+ short cw, ch, cellw, cellh;
+ short pxsize;
short fx=0;
char * lstr = NULL;
-
- utf8_to_local_encoding(str, length, &lstr);
- assert( lstr != NULL );
+
+ utf8_to_local_encoding(str, length, &lstr);
+ assert( lstr != NULL );
int slen = strlen(lstr);
- atari_to_vdi_str(lstr, slen);
-
- if( fstyle->flags & FONTF_ITALIC )
- fx |= 4;
- if( fstyle->flags & FONTF_OBLIQUE )
- fx |= 16;
- if( fstyle->weight > 450 )
- fx |= 1;
- vst_effects( self->vdi_handle, fx );
- /* TODO: replace 90 with global dpi setting */
+ atari_to_vdi_str(lstr, slen);
+
+ if( fstyle->flags & FONTF_ITALIC )
+ fx |= 4;
+ if( fstyle->flags & FONTF_OBLIQUE )
+ fx |= 16;
+ if( fstyle->weight > 450 )
+ fx |= 1;
+ vst_effects( self->vdi_handle, fx );
+ /* TODO: replace 90 with global dpi setting */
//pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
//vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
/*
if(slen != utf8_bounded_length(str, length)){
@@ -117,51 +119,49 @@ static int str_width( FONT_PLOTTER self,const plot_font_style_t *fstyle, const c
printf("s: %s // %s\n", str, lstr );
}*/
-
- *width = slen * cellw;
- free((void*)lstr);
- return( 0 );
-}
-
-static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const char *string,
- size_t length,int x, size_t *char_offset, int *actual_x )
-{
- short cw, ch, cellw, cellh;
- short pxsize;
- short fx=0;
- int i;
- char *lstr = NULL;
- size_t slen = 0;
- int last_space_x = 0;
+
+ *width = slen * cellw;
+ free((void*)lstr);
+ return( 0 );
+}
+
+static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const char *string,
+ size_t length,int x, size_t *char_offset, int *actual_x )
+{
+ short cw, ch, cellw, cellh;
+ short pxsize;
+ short fx=0;
+ char *lstr = NULL;
+ size_t slen = 0;
+ int last_space_x = 0;
int last_space_idx = 0;
- size_t nxtchr = 0;
-
- utf8_to_local_encoding(string, length, &lstr );
- assert( lstr != NULL );
+ size_t nxtchr = 0;
+
+ utf8_to_local_encoding(string, length, &lstr );
+ assert( lstr != NULL );
slen = strlen(lstr);
atari_to_vdi_str(lstr, slen);
-
- if( fstyle->flags & FONTF_ITALIC )
- fx |= 4;
- if( fstyle->flags & FONTF_OBLIQUE )
- fx |= 16;
- if( fstyle->weight > 450 )
- fx |= 1;
- vst_effects( self->vdi_handle, fx );
- //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+
+ if( fstyle->flags & FONTF_ITALIC )
+ fx |= 4;
+ if( fstyle->flags & FONTF_OBLIQUE )
+ fx |= 16;
+ if( fstyle->weight > 450 )
+ fx |= 1;
+ vst_effects( self->vdi_handle, fx );
+ //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
//vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
- vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
- *actual_x = 0;
- //*char_offset = 0;
- int cpos=0;
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 );
+ vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
+ *actual_x = 0;
+ //*char_offset = 0;
while (nxtchr < slen) {
- if( lstr[nxtchr] == ' ' ) {
- last_space_x = *actual_x;
- last_space_idx = nxtchr;
+ if( lstr[nxtchr] == ' ' ) {
+ last_space_x = *actual_x;
+ last_space_idx = nxtchr;
}
*actual_x += cellw;
if (*actual_x > x && last_space_idx != 0) {
@@ -178,138 +178,136 @@ static int str_split( FONT_PLOTTER self, const plot_font_style_t * fstyle, const
}
*char_offset = nxtchr;
-
-// for( i=0; i<slen; i++) {
-// if( lstr[i] == ' ' ) {
-// last_space_x = *actual_x;
-// last_space_idx = cpos;
-// }
-// if( *actual_x > x ) {
-// *actual_x = last_space_x;
-// *char_offset = last_space_idx;
-// return true;
-// }
-// *actual_x += cellw;
-// cpos++;
-// }
-// *char_offset = cpos;
- free( (void*)lstr );
- return( 0 );
-}
-
-static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t * fstyle,const char *string,
- size_t length,int x, size_t *char_offset, int *actual_x )
-{
- short cw, ch, cellw, cellh;
- short pxsize=0;
- short fx=0;
-
- char *lstr = NULL;
- int i=0;
- int curpx=0;
- utf8_to_local_encoding(string, length, &lstr );
- assert( lstr != NULL );
+
+// for( i=0; i<slen; i++) {
+// if( lstr[i] == ' ' ) {
+// last_space_x = *actual_x;
+// last_space_idx = cpos;
+// }
+// if( *actual_x > x ) {
+// *actual_x = last_space_x;
+// *char_offset = last_space_idx;
+// return true;
+// }
+// *actual_x += cellw;
+// cpos++;
+// }
+// *char_offset = cpos;
+ free( (void*)lstr );
+ return( 0 );
+}
+
+static int pixel_pos( FONT_PLOTTER self, const plot_font_style_t * fstyle,const char *string,
+ size_t length,int x, size_t *char_offset, int *actual_x )
+{
+ short cw, ch, cellw, cellh;
+ short pxsize=0;
+ short fx=0;
+
+ char *lstr = NULL;
+ int i=0;
+ utf8_to_local_encoding(string, length, &lstr );
+ assert( lstr != NULL );
int slen = strlen(lstr);
atari_to_vdi_str(lstr, slen);
-
- if( fstyle->flags & FONTF_ITALIC )
- fx |= 4;
- if( fstyle->flags & FONTF_OBLIQUE )
- fx |= 16;
- if( fstyle->weight > 450 )
- fx |= 1;
- vst_effects(self->vdi_handle, fx);
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
- *actual_x = 0;
- *char_offset = 0;
- for( i=0; i<slen; i++) {
- *actual_x += cellw;
- if( *actual_x > x) {
- *actual_x -= cellw;
- *char_offset = i;
- break;
- }
- }
- free((void*)lstr);
- lstr = NULL;
- return( 0 );
-}
-
-static inline void vst_rgbcolor( short vdih, uint32_t cin )
-{
+
+ if( fstyle->flags & FONTF_ITALIC )
+ fx |= 4;
+ if( fstyle->flags & FONTF_OBLIQUE )
+ fx |= 16;
+ if( fstyle->weight > 450 )
+ fx |= 1;
+ vst_effects(self->vdi_handle, fx);
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ vst_height( self->vdi_handle, pxsize ,&cw, &ch, &cellw, &cellh);
+ *actual_x = 0;
+ *char_offset = 0;
+ for( i=0; i<slen; i++) {
+ *actual_x += cellw;
+ if( *actual_x > x) {
+ *actual_x -= cellw;
+ *char_offset = i;
+ break;
+ }
+ }
+ free((void*)lstr);
+ lstr = NULL;
+ return( 0 );
+}
+
+static inline void vst_rgbcolor( short vdih, uint32_t cin )
+{
#ifdef WITH_8BPP_SUPPORT
if( vdi_sysinfo.scr_bpp > 8 ) {
-#endif
+#endif
//unsigned short c[4];
RGB1000 c;
-
- rgb_to_vdi1000( (unsigned char*)&cin, &c );
- vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
- vst_color( vdih, OFFSET_CUSTOM_COLOR );
+
+ rgb_to_vdi1000( (unsigned char*)&cin, &c );
+ vs_color( vdih, OFFSET_CUSTOM_COLOR, (unsigned short*)&c);
+ vst_color( vdih, OFFSET_CUSTOM_COLOR );
#ifdef WITH_8BPP_SUPPORT
- } else {
- if( vdi_sysinfo.scr_bpp >= 4 )
- vst_color( vdih, RGB_TO_VDI(cin) );
- else
- vst_color( vdih, BLACK );
+ } else {
+ if( vdi_sysinfo.scr_bpp >= 4 )
+ vst_color( vdih, RGB_TO_VDI(cin) );
+ else
+ vst_color( vdih, BLACK );
}
-#endif
-}
-
-static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length,
- const plot_font_style_t *fstyle )
-{
- /* todo: either limit the string to max 80 chars, or use v_ftext instead of v_gtext */
- short cw, ch, cellw, cellh;
- short pxsize=8;
+#endif
+}
+
+static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length,
+ const plot_font_style_t *fstyle )
+{
+ /* todo: either limit the string to max 80 chars, or use v_ftext instead of v_gtext */
+ short cw, ch, cellw, cellh;
+ short pxsize=8;
short fx=0;
- GRECT canvas;
+ GRECT canvas;
char *lstr = NULL;
- assert( utf8_to_local_encoding(text, length, &lstr) == UTF8_CONVERT_OK);
+ assert( utf8_to_local_encoding(text, length, &lstr) == NSERROR_OK);
assert( lstr != NULL );
-
+
int slen = strlen(lstr);
if(slen > 800){
lstr[800]=0;
}
- atari_to_vdi_str(lstr, slen);
-
- if( fstyle != NULL){
- if( fstyle->flags & FONTF_ITALIC )
- fx |= 4;
- if( fstyle->flags & FONTF_OBLIQUE )
- fx |= 4;
- if( fstyle->weight > 450 )
- fx |= 1;
-
- /* TODO: netsurf uses 90 as default dpi ( somewhere defined in libcss),
- use that value or pass it as arg, to reduce netsurf dependency */
- //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
- }
- plot_get_dimensions(&canvas);
- x += canvas.g_x;
- y += canvas.g_y;
- vst_effects( self->vdi_handle, fx );
+ atari_to_vdi_str(lstr, slen);
+
+ if( fstyle->flags & FONTF_ITALIC )
+ fx |= 4;
+ if( fstyle->flags & FONTF_OBLIQUE )
+ fx |= 4;
+ if( fstyle->weight > 450 )
+ fx |= 1;
+
+ /* TODO: netsurf uses 90 as default dpi ( somewhere defined in libcss),
+ use that value or pass it as arg, to reduce netsurf dependency */
+ //pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+ pxsize = ceil( (fstyle->size/FONT_SIZE_SCALE) * 90 / 72 );
+
+ plot_get_dimensions(&canvas);
+ x += canvas.g_x;
+ y += canvas.g_y;
+ vst_effects( self->vdi_handle, fx );
vst_alignment(vdih, 0, 0, &cw, &ch );
- vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
- //vst_height( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
- vswr_mode( self->vdi_handle, MD_TRANS );
- vst_rgbcolor(self->vdi_handle, fstyle->foreground);
-
+ vst_point( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
+ //vst_height( self->vdi_handle, pxsize, &cw, &ch, &cellw, &cellh);
+ vswr_mode( self->vdi_handle, MD_TRANS );
+ vst_rgbcolor(self->vdi_handle, fstyle->foreground);
+
if( atari_sysinfo.gdos_FSMC ){
- //printf("\nftext\n");
- v_ftext( self->vdi_handle, x, y, (char*)lstr );
+ //printf("\nftext\n");
+ v_ftext( self->vdi_handle, x, y, (char*)lstr );
} else {
- //printf("\ngtext\n");
- v_gtext( self->vdi_handle, x, y, (char*)lstr );
- }
- free( lstr );
- return( 0 );
-}
-
-#endif
+ //printf("\ngtext\n");
+ v_gtext( self->vdi_handle, x, y, (char*)lstr );
+ }
+ free( lstr );
+ return( 0 );
+}
+
+#endif
diff --git a/atari/plot/plot.c b/atari/plot/plot.c
index 2c75db335..cfec7b424 100755
--- a/atari/plot/plot.c
+++ b/atari/plot/plot.c
@@ -625,7 +625,6 @@ inline static unsigned char get_stdpx(MFDB * dst, int wdplanesz, int x, int y)
*/
inline short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b)
{
- short ret = 0;
short i;
unsigned char rgb[3] = {r,g,b};
unsigned char tval[3];
@@ -635,7 +634,7 @@ inline short rgb_to_666_index(unsigned char r, unsigned char g, unsigned char b)
diff_b = abs(r-b);
diff_c = abs(r-b);
if( diff_a < 2 && diff_b < 2 && diff_c < 2 ) {
- if( (r!=0XFF) && (g!=0XFF) && (g!=0XFF) ) {
+ if( (r!=0XFF) && (g!=0XFF) && (b!=0XFF) ) {
if( ((r&0xF0)>>4) != 0 )
//printf("conv gray: %x -> %d\n", ((r&0xF0)>>4) , (OFFSET_CUST_PAL) + ((r&0xF0)>>4) );
return( (OFFSET_CUST_PAL - OFFSET_WEB_PAL) + ((r&0xF0)>>4) );
@@ -1016,11 +1015,8 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
MFDB stdform;
int dststride; /* stride of dest. image */
int dstsize; /* size of dest. in byte */
- int err;
int bw, bh;
- int process_w, process_h;
struct bitmap * scrbuf = NULL;
- struct bitmap * source;
bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
bool opaque = bitmap_get_opaque( img );
@@ -1035,8 +1031,8 @@ static bool bitmap_convert_8(struct bitmap * img, int x,
assert( clip->g_h > 0 );
assert( clip->g_w > 0 );
- process_w = bw = bitmap_get_width( img );
- process_h = bh = bitmap_get_height( img );
+ bw = bitmap_get_width( img );
+ bh = bitmap_get_height( img );
// The converted bitmap can be saved for subsequent blits, when
// the bitmap is fully opaque
@@ -1526,7 +1522,7 @@ int plot_init(char * fdrvrname)
{
GRECT loc_pos= {0,0,360,400};
- int err=0,i;
+ int err=0;
if( nsoption_int(atari_dither) == 1)
atari_plot_flags |= PLOT_FLAG_DITHER;
@@ -1589,11 +1585,10 @@ int plot_init(char * fdrvrname)
bitmap_convert = (vdi_sysinfo.scr_bpp > 8) ? bitmap_convert_tc : bitmap_convert_8;
/* Setup color lookup tables and palette */
- i = 0;
- unsigned char * col;
unsigned char rgbcol[4];
- unsigned char graytone=0;
if( vdi_sysinfo.scr_bpp <= 8 ){
+ unsigned char graytone=0;
+ int i;
for( i=0; i<=255; i++ ) {
// get the current color and save it for restore:
@@ -1659,12 +1654,12 @@ int plot_init(char * fdrvrname)
int plot_finalise( void )
{
- int i=0;
delete_font_plotter(fplotter);
#ifdef WITH_8BPP_SUPPORT
if (vfmt.indexed) {
+ int i;
for (i=OFFSET_WEB_PAL; i<OFFSET_CUST_PAL+16; i++) {
vs_color(atari_plot_vdi_handle, i, &sys_pal[i][0]);
}
@@ -1857,7 +1852,6 @@ static bool plot_polygon(const int *p, unsigned int n,
{
short pxy[n*2];
unsigned int i=0;
- short d[4];
if (vdi_sysinfo.maxpolycoords > 0)
assert( (signed int)n < vdi_sysinfo.maxpolycoords);
@@ -1894,7 +1888,6 @@ bool plot_set_dimensions(int x, int y, int w, int h)
GRECT absclip = {x, y, w, h};
if (!(w == view.w && h == view.h)) {
- struct rect newclip = { 0, 0, w-1, h-1 };
view.w = (short)w;
view.h = (short)h;
doupdate = true;
diff --git a/atari/rootwin.c b/atari/rootwin.c
index 3c89e6d55..a9c958e04 100755
--- a/atari/rootwin.c
+++ b/atari/rootwin.c
@@ -38,7 +38,6 @@
#include "utils/log.h"
#include "desktop/gui.h"
-#include "desktop/local_history.h"
#include "desktop/netsurf.h"
#include "desktop/browser.h"
#include "desktop/browser_private.h"
@@ -85,6 +84,8 @@ static bool on_content_mouse_click(ROOTWIN *rootwin);
static bool on_content_mouse_move(ROOTWIN *rootwin, GRECT *content_area);
static void toolbar_redraw_cb(GUIWIN *win, uint16_t msg, GRECT *clip);
+bool gui_window_get_scroll(struct gui_window *w, int *sx, int *sy);
+
static bool redraw_active = false;
static const struct redraw_context rootwin_rdrw_ctx = {
@@ -98,11 +99,8 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
short retval = 0;
GRECT area;
static bool prev_url = false;
- static short prev_x=0;
- static short prev_y=0;
struct rootwin_data_s * data = gemtk_wm_get_user_data(win);
struct gui_window *tmp;
- OBJECT *obj;
if ((ev_out->emo_events & MU_MESAG) != 0) {
@@ -228,7 +226,7 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
int window_create(struct gui_window * gw,
struct browser_window * bw,
- struct browser_window * clone,
+ struct gui_window * existing,
unsigned long inflags)
{
int err = 0;
@@ -292,8 +290,8 @@ int window_create(struct gui_window * gw,
assert(gw->browser);
gw->browser->bw = bw;
- if(clone)
- gw->browser->bw->scale = clone->scale;
+ if(existing)
+ gw->browser->bw->scale = existing->browser->bw->scale;
else
gw->browser->bw->scale = 1;
@@ -467,7 +465,6 @@ void window_set_title(struct s_gui_win_root * rootwin, char *title)
void window_scroll_by(ROOTWIN *root, int sx, int sy)
{
- int units;
GRECT content_area;
struct gemtk_wm_scroll_info_s *slid = gemtk_wm_get_scroll_info(root->win);
@@ -509,8 +506,6 @@ void window_set_content_size(ROOTWIN *rootwin, int width, int height)
void window_set_focus(struct s_gui_win_root *rootwin,
enum focus_element_type type, void * element)
{
- struct textarea * ta;
-
assert(rootwin != NULL);
if (rootwin->focus.type != type || rootwin->focus.element != element) {
@@ -568,7 +563,6 @@ void window_set_icon(ROOTWIN *rootwin, struct bitmap * bmp )
rootwin->icon = bmp;
/* redraw window when it is iconyfied: */
if (rootwin->icon != NULL) {
- short info, dummy;
if (gemtk_wm_get_state(rootwin->win) & GEMTK_WM_STATUS_ICONIFIED) {
window_redraw_favicon(rootwin, NULL);
}
@@ -767,7 +761,6 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip_ro)
} else {
//printf("window_redraw_favicon image %p\n", rootwin->icon);
VdiHdl plot_vdi_handle = plot_get_vdi_handle();
- struct rect work_clip = { 0,0,work.g_w,work.g_h };
short pxy[4];
int xoff=0;
@@ -777,7 +770,6 @@ void window_redraw_favicon(ROOTWIN *rootwin, GRECT *clip_ro)
}
plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w,
work.g_h);
- //plot_clip(&work_clip);
wind_get_grect(rootwin->aes_handle, WF_FIRSTXYWH, &visible);
while (visible.g_h > 0 && visible.g_w > 0) {
@@ -842,7 +834,7 @@ static void window_redraw_content(ROOTWIN *rootwin, GRECT *content_area,
plot_set_dimensions(content_area->g_x, content_area->g_y,
content_area->g_w, content_area->g_h);
- oldscale = plot_set_scale(gui_window_get_scale(rootwin->active_gui_window));
+ oldscale = plot_set_scale(browser_window_get_scale(rootwin->active_gui_window->browser->bw));
/* first, we make the coords relative to the content area: */
content_area_rel.g_x = clip->g_x - content_area->g_x;
@@ -886,7 +878,7 @@ void window_place_caret(ROOTWIN *rootwin, short mode, int content_x,
short pxy[8];
GRECT mywork, caret_pos;
MFDB screen;
- int i, scroll_x, scroll_y;
+ int scroll_x, scroll_y;
uint16_t *fd_addr;
struct gemtk_wm_scroll_info_s *slid;
short colors[2] = {G_BLACK, G_WHITE};
@@ -972,6 +964,7 @@ void window_place_caret(ROOTWIN *rootwin, short mode, int content_x,
// draw the caret into the mfdb buffer:
if (render_required) {
+ int i;
assert(caret->symbol.fd_nplanes == 1);
assert(caret->symbol.fd_w == 16);
@@ -1022,7 +1015,6 @@ void window_process_redraws(ROOTWIN * rootwin)
GRECT work, visible_ro, tb_area, content_area;
short i;
short scroll_x=0, scroll_y=0;
- bool toolbar_rdrw_required;
bool caret_rdrw_required = false;
struct gemtk_wm_scroll_info_s *slid =NULL;
int caret_h = 0;
@@ -1366,7 +1358,6 @@ static short on_window_key_input(ROOTWIN *rootwin, unsigned short nkc)
{
bool done = false;
struct gui_window * gw = window_get_active_gui_window(rootwin);
- struct gui_window * gw_tmp;
if( gw == NULL )
return(false);
@@ -1396,8 +1387,6 @@ static short on_window_key_input(ROOTWIN *rootwin, unsigned short nkc)
static void on_redraw(ROOTWIN *rootwin, short msg[8])
{
- short handle;
-
GRECT clip = {msg[4], msg[5], msg[6], msg[7]};
//dbg_grect("on_redraw", &clip);
@@ -1414,7 +1403,6 @@ static void on_redraw(ROOTWIN *rootwin, short msg[8])
static void on_resized(ROOTWIN *rootwin)
{
GRECT g, work;
- OBJECT *toolbar;
struct gui_window *gw;
gw = window_get_active_gui_window(rootwin);
@@ -1497,6 +1485,8 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8])
size, mx, my
));
+ gui_window_get_scroll(gw, &sx, &sy);
+
window_get_grect(rootwin, BROWSER_AREA_CONTENT, &content_area);
mx = mx - content_area.g_x;
my = my - content_area.g_y;
@@ -1508,19 +1498,18 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8])
mx+sx, my+sy,
NULL);
if(processed == true) {
- utf8_convert_ret ret;
+ nserror ret;
char *utf8_fn;
ret = utf8_from_local_encoding(buff, 0, &utf8_fn);
- if (ret != UTF8_CONVERT_OK) {
+ if (ret != NSERROR_OK) {
free(buff);
/* A bad encoding should never happen */
LOG(("utf8_from_local_encoding failed"));
- assert(ret != UTF8_CONVERT_BADENC);
+ assert(ret != NSERROR_BAD_ENCODING);
/* no memory */
goto error;
}
- gui_window_get_scroll(gw, &sx, &sy);
processed = browser_window_drop_file_at_point(gw->browser->bw,
mx+sx, my+sy,
utf8_fn);
@@ -1534,8 +1523,8 @@ static void on_file_dropped(ROOTWIN *rootwin, short msg[8])
char * tmp_url = local_file_to_url(buff);
if ((tmp_url != NULL)
&& nsurl_create(tmp_url, &ns_url) == NSERROR_OK) {
- browser_window_navigate(gw->browser->bw, ns_url, NULL,
- BROWSER_WINDOW_HISTORY | BROWSER_WINDOW_VERIFIABLE,
+ browser_window_navigate(gw->browser->bw, ns_url, NULL,
+ BW_NAVIGATE_HISTORY,
NULL, NULL, NULL);
nsurl_unref(ns_url);
}
diff --git a/atari/rootwin.h b/atari/rootwin.h
index d2cd04a35..a5b22c968 100755
--- a/atari/rootwin.h
+++ b/atari/rootwin.h
@@ -46,7 +46,7 @@ enum browser_area_e {
/* Creates an normal Browser window with [toolbar], [statusbar] */
int window_create(struct gui_window * gw,
struct browser_window * bw,
- struct browser_window * clone,
+ struct gui_window * existing,
unsigned long flags );
/* Destroys WinDom part of gui_window */
int window_destroy(ROOTWIN *rootwin);
diff --git a/atari/schedule.c b/atari/schedule.c
index a91c510b3..3bef573a5 100755
--- a/atari/schedule.c
+++ b/atari/schedule.c
@@ -22,12 +22,17 @@
#include <sys/time.h>
#include <time.h>
-#include "utils/schedule.h"
+#include "utils/errors.h"
+
#include "atari/schedule.h"
+#ifdef DEBUG_SCHEDULER
#include "utils/log.h"
+#else
+#define LOG(X)
+#endif
-#define CS_NOW() ((clock() * 100) / CLOCKS_PER_SEC)
+#define MS_NOW() ((clock() * 1000) / CLOCKS_PER_SEC)
/* linked list of scheduled callbacks */
static struct nscallback *schedule_list = NULL;
@@ -47,45 +52,6 @@ static int max_scheduled;
static int cur_scheduled;
/**
- * Schedule a callback.
- *
- * \param tival interval before the callback should be made / cs
- * \param callback callback function
- * \param p user parameter, passed to callback function
- *
- * The callback function will be called as soon as possible after t cs have
- * passed.
- */
-void schedule( int cs_ival, void (*callback)(void *p), void *p)
-{
- struct nscallback *nscb;
-
- /*
- remove any callback of this kind,
- other frontend do this, too. framebuffer frontend doesn't do it.
- */
- schedule_remove(callback, p);
-
- nscb = calloc(1, sizeof(struct nscallback));
-
- nscb->timeout = CS_NOW() + cs_ival;
-#ifdef DEBUG_SCHEDULER
- LOG(("adding callback %p for %p(%p) at %d cs", nscb, callback, p, nscb->timeout ));
-#endif
- nscb->callback = callback;
- nscb->p = p;
-
- /* add to list front */
- nscb->next = schedule_list;
- schedule_list = nscb;
- cur_scheduled++;
- if( cur_scheduled > max_scheduled )
- max_scheduled = cur_scheduled;
-}
-
-
-
-/**
* Unschedule a callback.
*
* \param callback callback function
@@ -94,18 +60,18 @@ void schedule( int cs_ival, void (*callback)(void *p), void *p)
* All scheduled callbacks matching both callback and p are removed.
*/
-void schedule_remove(void (*callback)(void *p), void *p)
+static nserror schedule_remove(void (*callback)(void *p), void *p)
{
struct nscallback *cur_nscb;
struct nscallback *prev_nscb;
struct nscallback *unlnk_nscb;
- if (schedule_list == NULL)
- return;
+ /* check there is something on the list to remove */
+ if (schedule_list == NULL) {
+ return NSERROR_OK;
+ }
-#ifdef DEBUG_SCHEDULER
LOG(("removing %p, %p", callback, p));
-#endif
cur_nscb = schedule_list;
prev_nscb = NULL;
@@ -114,9 +80,8 @@ void schedule_remove(void (*callback)(void *p), void *p)
if ((cur_nscb->callback == callback) &&
(cur_nscb->p == p)) {
/* item to remove */
-#ifdef DEBUG_SCHEDULER
- LOG(("callback entry %p removing %p(%p)", cur_nscb, cur_nscb->callback, cur_nscb->p));
-#endif
+ LOG(("callback entry %p removing %p(%p)",
+ cur_nscb, cur_nscb->callback, cur_nscb->p));
/* remove callback */
unlnk_nscb = cur_nscb;
@@ -135,20 +100,51 @@ void schedule_remove(void (*callback)(void *p), void *p)
cur_nscb = prev_nscb->next;
}
}
+ return NSERROR_OK;
+}
+
+/* exported function documented in atari/schedule.h */
+nserror atari_schedule(int ival, void (*callback)(void *p), void *p)
+{
+ struct nscallback *nscb;
+ nserror ret;
+
+ /* remove any existing callback of this kind */
+ ret = schedule_remove(callback, p);
+ if ((ival < 0) || (ret != NSERROR_OK)) {
+ return ret;
+ }
+
+ nscb = calloc(1, sizeof(struct nscallback));
+
+ nscb->timeout = MS_NOW() + ival;
+
+ LOG(("adding callback %p for %p(%p) at %d ms",
+ nscb, callback, p, nscb->timeout ));
+
+ nscb->callback = callback;
+ nscb->p = p;
+
+ /* add to list front */
+ nscb->next = schedule_list;
+ schedule_list = nscb;
+ cur_scheduled++;
+ if( cur_scheduled > max_scheduled ) {
+ max_scheduled = cur_scheduled;
+ }
+
+ return NSERROR_OK;
}
-/**
- * Process events up to current time.
- */
-int
-schedule_run(void)
+/* exported function documented in atari/schedule.h */
+int schedule_run(void)
{
unsigned long nexttime;
struct nscallback *cur_nscb;
struct nscallback *prev_nscb;
struct nscallback *unlnk_nscb;
- unsigned long now = CS_NOW();
+ unsigned long now = MS_NOW();
if (schedule_list == NULL)
return -1;
@@ -170,9 +166,9 @@ schedule_run(void)
prev_nscb->next = unlnk_nscb->next;
}
-#ifdef DEBUG_SCHEDULER
- LOG(("callback entry %p running %p(%p)", unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p));
-#endif
+ LOG(("callback entry %p running %p(%p)",
+ unlnk_nscb, unlnk_nscb->callback, unlnk_nscb->p));
+
/* call callback */
unlnk_nscb->callback(unlnk_nscb->p);
free(unlnk_nscb);
@@ -180,9 +176,8 @@ schedule_run(void)
/* need to deal with callback modifying the list. */
if (schedule_list == NULL) {
-#ifdef DEBUG_SCHEDULER
LOG(("schedule_list == NULL"));
-#endif
+
return -1; /* no more callbacks scheduled */
}
@@ -204,21 +199,22 @@ schedule_run(void)
}
/* make rettime relative to now and convert to ms */
- nexttime = (nexttime - now)*10;
-#ifdef DEBUG_SCHEDULER
+ nexttime = nexttime - now;
+
LOG(("returning time to next event as %ldms", nexttime ));
-#endif
+
/*return next event time in milliseconds (24days max wait) */
- return ( nexttime );
+ return nexttime;
}
+/* exported function documented in atari/schedule.h */
void list_schedule(void)
{
struct timeval tv;
struct nscallback *cur_nscb;
- LOG(("schedule list at cs clock %ld", CS_NOW() ));
+ LOG(("schedule list at ms clock %ld", MS_NOW() ));
cur_nscb = schedule_list;
while (cur_nscb != NULL) {
diff --git a/atari/schedule.h b/atari/schedule.h
index e21b759a0..05eebb2d7 100755
--- a/atari/schedule.h
+++ b/atari/schedule.h
@@ -17,10 +17,32 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NS_SCHEDULE_H
-#define NS_SCHEDULE_H
+#ifndef NS_ATARI_SCHEDULE_H
+#define NS_ATARI_SCHEDULE_H
-void list_schedule(void);
+/**
+ * Process events up to current time.
+ *
+ * \return The number of miliseconds until the next scheduled event.
+ */
int schedule_run(void);
+/**
+ * Schedule a callback.
+ *
+ * \param ival interval before the callback should be made in miliseconds.
+ * \param callback callback function.
+ * \param p user parameter, passed to callback function.
+ * \return NSERROR_OK on success or appropriate error code.
+ *
+ * The callback function will be called as soon as possible after \a ival
+ * ms have passed.
+ */
+nserror atari_schedule(int ival, void (*callback)(void *p), void *p);
+
+/**
+ * LOG all current scheduled events.
+ */
+void list_schedule(void);
+
#endif
diff --git a/atari/search.c b/atari/search.c
index 6d8f53bec..f79891aa5 100644
--- a/atari/search.c
+++ b/atari/search.c
@@ -1,124 +1,127 @@
-/*
- * Copyright 2013 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Module Description:
- *
- *
- *
- */
-
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdbool.h>
-#include <assert.h>
-
-#include "desktop/gui.h"
-#include "desktop/browser.h"
-#include "desktop/browser_private.h"
-#include "desktop/search.h"
-#include "utils/log.h"
-#include "utils/messages.h"
+/*
+ * Copyright 2013 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Module Description:
+ *
+ *
+ *
+ */
+
+
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdbool.h>
+#include <assert.h>
+
+#include "desktop/gui.h"
+#include "desktop/browser.h"
+#include "desktop/browser_private.h"
+#include "desktop/search.h"
+#include "utils/log.h"
+#include "utils/messages.h"
#include "atari/gui.h"
-#include "atari/rootwin.h"
-#include "atari/misc.h"
+#include "atari/rootwin.h"
+#include "atari/misc.h"
#include "atari/toolbar.h"
#include "atari/search.h"
-#include "atari/gemtk/gemtk.h"
-#include "atari/res/netsurf.rsh"
-
-extern struct gui_window * input_window;
-
-
-static void nsatari_search_set_status(bool found, void *p);
-static void nsatari_search_set_hourglass(bool active, void *p);
-static void nsatari_search_add_recent(const char *string, void *p);
-void nsatari_search_set_forward_state(bool active, void *p);
-void nsatari_search_set_back_state(bool active, void *p);
-
-static struct gui_search_callbacks nsatari_search_callbacks = {
- nsatari_search_set_forward_state,
- nsatari_search_set_back_state,
- nsatari_search_set_status,
- nsatari_search_set_hourglass,
- nsatari_search_add_recent
-};
-
-
-/**
-* Change the displayed search status.
-* \param found search pattern matched in text
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
-
-void nsatari_search_set_status(bool found, void *p)
-{
+#include "atari/gemtk/gemtk.h"
+#include "atari/res/netsurf.rsh"
+
+extern struct gui_window * input_window;
+
+
+static void nsatari_search_set_status(bool found, void *p);
+static void nsatari_search_set_hourglass(bool active, void *p);
+static void nsatari_search_add_recent(const char *string, void *p);
+void nsatari_search_set_forward_state(bool active, void *p);
+void nsatari_search_set_back_state(bool active, void *p);
+
+static struct gui_search_table search_table = {
+ nsatari_search_set_status,
+ nsatari_search_set_hourglass,
+ nsatari_search_add_recent,
+ nsatari_search_set_forward_state,
+ nsatari_search_set_back_state,
+};
+
+struct gui_search_table *atari_search_table = &search_table;
+
+
+
+/**
+* Change the displayed search status.
+* \param found search pattern matched in text
+* \param p the pointer sent to search_verify_new() / search_create_context()
+*/
+
+void nsatari_search_set_status(bool found, void *p)
+{
LOG(("%p set status: %d\n", p, found));
- // TODO: maybe update GUI
-}
-
-/**
-* display hourglass while searching
-* \param active start/stop indicator
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
-
-void nsatari_search_set_hourglass(bool active, void *p)
-{
- SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
- LOG(("active: %d, session: %p", active, p));
- if (active)
- gui_window_set_pointer(s->bw->window, GUI_POINTER_PROGRESS);
- else
- gui_window_set_pointer(s->bw->window, GUI_POINTER_DEFAULT);
-}
-
-/**
-* add search string to recent searches list
-* front is at liberty how to implement the bare notification
-* should normally store a strdup() of the string;
-* core gives no guarantee of the integrity of the const char *
-* \param string search pattern
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
-
-void nsatari_search_add_recent(const char *string, void *p)
-{
- LOG(("%p add recent: %s\n", p, string));
-}
-
-/**
-* activate search forwards button in gui
-* \param active activate/inactivate
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
-
-void nsatari_search_set_forward_state(bool active, void *p)
+ // TODO: maybe update GUI
+}
+
+/**
+* display hourglass while searching
+* \param active start/stop indicator
+* \param p the pointer sent to search_verify_new() / search_create_context()
+*/
+
+void nsatari_search_set_hourglass(bool active, void *p)
+{
+ SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
+ LOG(("active: %d, session: %p", active, p));
+ if (active)
+ gui_window_set_pointer(s->bw->window, GUI_POINTER_PROGRESS);
+ else
+ gui_window_set_pointer(s->bw->window, GUI_POINTER_DEFAULT);
+}
+
+/**
+* add search string to recent searches list
+* front is at liberty how to implement the bare notification
+* should normally store a strdup() of the string;
+* core gives no guarantee of the integrity of the const char *
+* \param string search pattern
+* \param p the pointer sent to search_verify_new() / search_create_context()
+*/
+
+void nsatari_search_add_recent(const char *string, void *p)
+{
+ LOG(("%p add recent: %s\n", p, string));
+}
+
+/**
+* activate search forwards button in gui
+* \param active activate/inactivate
+* \param p the pointer sent to search_verify_new() / search_create_context()
+*/
+
+void nsatari_search_set_forward_state(bool active, void *p)
{
struct gui_window *gw;
OBJECT *toolbar;
- GRECT area;
- SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
- /* deactivate back cb */
+ GRECT area;
+ SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
+ /* deactivate back cb */
LOG(("%p: set forward state: %d\n", p, active));
-
+
gw = s->bw->window;
toolbar = toolbar_get_form(gw->root->toolbar);
@@ -128,22 +131,22 @@ void nsatari_search_set_forward_state(bool active, void *p)
toolbar[TOOLBAR_BT_SEARCH_FWD].ob_state |= OS_DISABLED;
window_get_grect(gw->root, BROWSER_AREA_SEARCH, &area);
window_schedule_redraw_grect(gw->root, &area);
-
-}
-
-/**
-* activate search back button in gui
-* \param active activate/inactivate
-* \param p the pointer sent to search_verify_new() / search_create_context()
-*/
-
-void nsatari_search_set_back_state(bool active, void *p)
-{
+
+}
+
+/**
+* activate search back button in gui
+* \param active activate/inactivate
+* \param p the pointer sent to search_verify_new() / search_create_context()
+*/
+
+void nsatari_search_set_back_state(bool active, void *p)
+{
struct gui_window *gw;
OBJECT *toolbar;
GRECT area;
- SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
- /* deactivate back cb */
+ SEARCH_FORM_SESSION s = (SEARCH_FORM_SESSION)p;
+ /* deactivate back cb */
LOG(("%p: set back state: %d\n", p, active));
s->state.back_avail = active;
@@ -155,42 +158,42 @@ void nsatari_search_set_back_state(bool active, void *p)
else
toolbar[TOOLBAR_BT_SEARCH_BACK].ob_state |= OS_DISABLED;
window_get_grect(gw->root, BROWSER_AREA_SEARCH, &area);
- window_schedule_redraw_grect(gw->root, &area);
+ window_schedule_redraw_grect(gw->root, &area);
}
-
-static int apply_form(OBJECT *obj, struct s_search_form_state *s)
-{
+
+static int apply_form(OBJECT *obj, struct s_search_form_state *s)
+{
char * cstr;
assert(s != NULL);
-
+
s->flags = 0;
-
- if( (obj[TOOLBAR_CB_CASESENSE].ob_state & OS_SELECTED) != 0 )
- s->flags |= SEARCH_FLAG_CASE_SENSITIVE;
- if( (obj[TOOLBAR_CB_SHOWALL].ob_state & OS_SELECTED) != 0 )
- s->flags |= SEARCH_FLAG_SHOWALL;
+
+ if( (obj[TOOLBAR_CB_CASESENSE].ob_state & OS_SELECTED) != 0 )
+ s->flags |= SEARCH_FLAG_CASE_SENSITIVE;
+ if( (obj[TOOLBAR_CB_SHOWALL].ob_state & OS_SELECTED) != 0 )
+ s->flags |= SEARCH_FLAG_SHOWALL;
cstr = gemtk_obj_get_text(obj, TOOLBAR_TB_SRCH);
snprintf(s->text, 32, "%s", cstr);
- return ( 0 );
-
-}
-
-static void set_text(OBJECT *obj, short idx, char * text, int len)
-{
- char spare[255];
-
- if( len > 254 )
- len = 254;
- if( text != NULL ){
- strncpy(spare, text, 254);
- } else {
- strcpy(spare, "");
+ return ( 0 );
+
+}
+
+static void set_text(OBJECT *obj, short idx, char * text, int len)
+{
+ char spare[255];
+
+ if( len > 254 )
+ len = 254;
+ if( text != NULL ){
+ strncpy(spare, text, 254);
+ } else {
+ strcpy(spare, "");
}
-
- set_string(obj, idx, spare);
+
+ set_string(obj, idx, spare);
}
void nsatari_search_restore_form( struct s_search_form_session *s, OBJECT *obj)
@@ -219,75 +222,70 @@ void nsatari_search_restore_form( struct s_search_form_session *s, OBJECT *obj)
set_text(obj, TOOLBAR_TB_SRCH, s->state.text, t->te_txtlen);
}
-
-void nsatari_search_session_destroy(struct s_search_form_session *s)
-{
- if (s != NULL) {
+
+void nsatari_search_session_destroy(struct s_search_form_session *s)
+{
+ if (s != NULL) {
LOG((""));
- browser_window_search_clear(s->bw);
- free(s);
- }
-}
-
-/** checks for search parameters changes */
-static bool search_session_compare(struct s_search_form_session *s, OBJECT *obj)
-{
- bool check;
- uint32_t flags_old;
+ browser_window_search_clear(s->bw);
+ free(s);
+ }
+}
+
+/** checks for search parameters changes */
+static bool search_session_compare(struct s_search_form_session *s, OBJECT *obj)
+{
+ uint32_t flags_old;
uint32_t flags_mask = SEARCH_FLAG_SHOWALL | SEARCH_FLAG_CASE_SENSITIVE;
- struct s_search_form_state cur;
+ struct s_search_form_state cur;
assert(s != NULL && obj != NULL);
-
+
flags_old = s->state.flags;
-
- apply_form(obj, &cur);
- if ((cur.flags&flags_mask) != (flags_old&flags_mask)) {
- return( true );
- }
-
+
+ apply_form(obj, &cur);
+ if ((cur.flags&flags_mask) != (flags_old&flags_mask)) {
+ return( true );
+ }
+
char * cstr;
- cstr = gemtk_obj_get_text(obj, TOOLBAR_TB_SRCH);
- if (cstr != NULL){
- if (strcmp(cstr, (char*)&s->state.text) != 0) {
- return (true);
- }
- }
-
- return( false );
-}
-
-
-void nsatari_search_perform(struct s_search_form_session *s, OBJECT *obj,
- search_flags_t f)
-{
-
- bool fwd;
- search_flags_t flags = f;
+ cstr = gemtk_obj_get_text(obj, TOOLBAR_TB_SRCH);
+ if (cstr != NULL){
+ if (strcmp(cstr, (char*)&s->state.text) != 0) {
+ return (true);
+ }
+ }
+
+ return( false );
+}
+
+void nsatari_search_perform(struct s_search_form_session *s, OBJECT *obj,
+ search_flags_t f)
+{
assert(s!=null);
assert(input_window->browser->bw == s->bw);
-
-
+
+
if(search_session_compare(s, obj)){
- browser_window_search_clear(s->bw);
- apply_form(obj, &s->state);
- } else {
-
+ browser_window_search_clear(s->bw);
+ apply_form(obj, &s->state);
+ } else {
+
}
- /* get search direction manually: */
- if ( (f&SEARCH_FLAG_FORWARDS) != 0 )
- s->state.flags |= SEARCH_FLAG_FORWARDS;
- else
+ /* get search direction manually: */
+ if ( (f&SEARCH_FLAG_FORWARDS) != 0 )
+ s->state.flags |= SEARCH_FLAG_FORWARDS;
+ else
s->state.flags &= (~SEARCH_FLAG_FORWARDS);
-
- browser_window_search(s->bw, &nsatari_search_callbacks, s,
- s->state.flags,
- gemtk_obj_get_text(obj, TOOLBAR_TB_SRCH));
-
-}
-
+
+ browser_window_search(s->bw, s,
+ s->state.flags,
+ gemtk_obj_get_text(obj, TOOLBAR_TB_SRCH));
+
+}
+
struct s_search_form_session * nsatari_search_session_create(OBJECT * obj,
struct browser_window *bw)
diff --git a/atari/search.h b/atari/search.h
index 00671e4a7..984fd3704 100644
--- a/atari/search.h
+++ b/atari/search.h
@@ -49,6 +49,9 @@ typedef struct s_search_form_session * SEARCH_FORM_SESSION;
struct s_search_form_session * nsatari_search_session_create(OBJECT * obj,
struct browser_window *bw);
+
+struct gui_search_table *atari_search_table;
+
void nsatari_search_session_destroy(struct s_search_form_session *s);
void nsatari_search_perform(struct s_search_form_session *s, OBJECT *obj,
search_flags_t f);
diff --git a/atari/settings.c b/atari/settings.c
index fa835bfbf..000ad7d19 100644
--- a/atari/settings.c
+++ b/atari/settings.c
@@ -404,7 +404,7 @@ static void form_event(int index, int external)
MENU pop_menu, me_data;
short x, y;
- int choice, i;
+ int choice;
switch(index) {
@@ -560,9 +560,9 @@ static void form_event(int index, int external)
break;
case SETTINGS_BT_SEL_DOWNLOAD_DIR:
- case SETTINGS_BT_SEL_HOTLIST:
- case SETTINGS_BT_SEL_CA_BUNDLE:
- case SETTINGS_BT_SEL_CA_CERTS:
+ case SETTINGS_BT_SEL_HOTLIST:
+ case SETTINGS_BT_SEL_CA_BUNDLE:
+ case SETTINGS_BT_SEL_CA_CERTS:
case SETTINGS_BT_SEL_EDITOR:
handle_filesystem_select_button(index);
break;
@@ -814,8 +814,6 @@ static short on_aes_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
{
short retval = 0;
GRECT clip, work;
- static short edit_idx = 0;
- struct gemtk_wm_scroll_info_s *slid;
if ((ev_out->emo_events & MU_MESAG) != 0) {
// handle message
diff --git a/atari/statusbar.c b/atari/statusbar.c
index 3bf186c02..121762bc4 100755
--- a/atari/statusbar.c
+++ b/atari/statusbar.c
@@ -1,238 +1,236 @@
-/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <assert.h>
-#include <math.h>
-
-#include "utils/log.h"
-#include "desktop/gui.h"
-#include "desktop/local_history.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
-#include "desktop/mouse.h"
-#include "desktop/plotters.h"
-
-#include "atari/gui.h"
-#include "atari/statusbar.h"
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <assert.h>
+#include <math.h>
+
+#include "utils/log.h"
+#include "desktop/gui.h"
+#include "desktop/netsurf.h"
+#include "desktop/browser.h"
+#include "desktop/mouse.h"
+#include "desktop/plotters.h"
+
+#include "atari/gui.h"
+#include "atari/statusbar.h"
#include "atari/rootwin.h"
-#include "atari/misc.h"
-
-#include "atari/res/netsurf.rsh"
-#include "atari/plot/plot.h"
-#include "atari/osspec.h"
-
-#ifdef WITH_CUSTOM_STATUSBAR
-extern int atari_plot_vdi_handle;
-
-static
-void __CDECL evnt_sb_redraw( COMPONENT *c, long buff[8] )
-{
- size_t i;
- struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app, c, CDT_OWNER);
- assert(gw != NULL);
- CMP_STATUSBAR sb = gw->root->statusbar;
- assert( sb != NULL );
- if( sb == NULL )
- return;
-
- if( sb->attached == false )
- return;
-
- LGRECT work, lclip;
- short pxy[8], d, pxyclip[4];
-
- mt_CompGetLGrect(&app, sb->comp, WF_WORKXYWH, &work);
- lclip = work;
- if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) {
- return;
- }
- vsf_interior(atari_plot_vdi_handle, FIS_SOLID );
- vsl_color(atari_plot_vdi_handle, BLACK );
- vsl_type(atari_plot_vdi_handle, 1);
- vsl_width(atari_plot_vdi_handle, 1 );
- vst_color(atari_plot_vdi_handle, BLACK);
-
- vst_height(atari_plot_vdi_handle, atari_sysinfo.medium_sfont_pxh, &pxy[0], &pxy[1], &pxy[2], &pxy[3] );
- vst_alignment(atari_plot_vdi_handle, 0, 5, &d, &d );
- vst_effects(atari_plot_vdi_handle, 0 );
- pxyclip[0] = lclip.g_x;
- pxyclip[1] = lclip.g_y;
- pxyclip[2] = lclip.g_x + lclip.g_w-1;
- pxyclip[3] = lclip.g_y + lclip.g_h-1;
-
+#include "atari/misc.h"
+
+#include "atari/res/netsurf.rsh"
+#include "atari/plot/plot.h"
+#include "atari/osspec.h"
+
+#ifdef WITH_CUSTOM_STATUSBAR
+extern int atari_plot_vdi_handle;
+
+static
+void __CDECL evnt_sb_redraw( COMPONENT *c, long buff[8] )
+{
+ struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app, c, CDT_OWNER);
+ assert(gw != NULL);
+ CMP_STATUSBAR sb = gw->root->statusbar;
+ assert( sb != NULL );
+ if( sb == NULL )
+ return;
+
+ if( sb->attached == false )
+ return;
+
+ LGRECT work, lclip;
+ short pxy[8], d, pxyclip[4];
+
+ mt_CompGetLGrect(&app, sb->comp, WF_WORKXYWH, &work);
+ lclip = work;
+ if ( !rc_lintersect( (LGRECT*)&buff[4], &lclip ) ) {
+ return;
+ }
+ vsf_interior(atari_plot_vdi_handle, FIS_SOLID );
+ vsl_color(atari_plot_vdi_handle, BLACK );
+ vsl_type(atari_plot_vdi_handle, 1);
+ vsl_width(atari_plot_vdi_handle, 1 );
+ vst_color(atari_plot_vdi_handle, BLACK);
+
+ vst_height(atari_plot_vdi_handle, atari_sysinfo.medium_sfont_pxh, &pxy[0], &pxy[1], &pxy[2], &pxy[3] );
+ vst_alignment(atari_plot_vdi_handle, 0, 5, &d, &d );
+ vst_effects(atari_plot_vdi_handle, 0 );
+ pxyclip[0] = lclip.g_x;
+ pxyclip[1] = lclip.g_y;
+ pxyclip[2] = lclip.g_x + lclip.g_w-1;
+ pxyclip[3] = lclip.g_y + lclip.g_h-1;
+
vs_clip(atari_plot_vdi_handle, 1, (short*)&pxyclip );
- vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
-
- if( lclip.g_y <= work.g_y ) {
- pxy[0] = work.g_x;
- pxy[1] = work.g_y;
- pxy[2] = MIN( work.g_x + work.g_w, lclip.g_x + lclip.g_w );
- pxy[3] = work.g_y;
- v_pline(atari_plot_vdi_handle, 2, (short*)&pxy );
- }
-
- if(app.nplanes > 2) {
- vsf_color(atari_plot_vdi_handle, LWHITE);
- } else {
- vsf_color(atari_plot_vdi_handle, WHITE );
- }
-
- pxy[0] = work.g_x;
- pxy[1] = work.g_y+1;
- pxy[2] = work.g_x + work.g_w-1;
- pxy[3] = work.g_y + work.g_h-1;
+ vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
+
+ if( lclip.g_y <= work.g_y ) {
+ pxy[0] = work.g_x;
+ pxy[1] = work.g_y;
+ pxy[2] = MIN( work.g_x + work.g_w, lclip.g_x + lclip.g_w );
+ pxy[3] = work.g_y;
+ v_pline(atari_plot_vdi_handle, 2, (short*)&pxy );
+ }
+
+ if(app.nplanes > 2) {
+ vsf_color(atari_plot_vdi_handle, LWHITE);
+ } else {
+ vsf_color(atari_plot_vdi_handle, WHITE );
+ }
+
+ pxy[0] = work.g_x;
+ pxy[1] = work.g_y+1;
+ pxy[2] = work.g_x + work.g_w-1;
+ pxy[3] = work.g_y + work.g_h-1;
v_bar(atari_plot_vdi_handle, pxy );
-
-
- if( sb->textlen > 0 ) {
- short curx;
- short vqw[4];
- char t[2];
- short cw = 8;
- t[1]=0;
- if( atari_sysinfo.sfont_monospaced ) {
- t[0]='A';
- int r = vqt_width(atari_plot_vdi_handle, t[0], &vqw[0], &vqw[1], &vqw[2] );
- cw = vqw[0];
- }
- vswr_mode(atari_plot_vdi_handle, MD_TRANS );
- for( curx = work.g_x + 2, i=0 ; (curx+cw < work.g_x+work.g_w ) && i < sb->textlen; i++ ){
- t[0] = sb->text[i];
- if( !atari_sysinfo.sfont_monospaced ) {
- vqt_width(atari_plot_vdi_handle, t[0], &vqw[0], &vqw[1], &vqw[2] );
- cw = vqw[0];
- }
- if( curx >= lclip.g_x - cw ) {
- v_gtext(atari_plot_vdi_handle, curx, work.g_y + 5, (char*)&t );
- }
- curx += cw;
- if( curx >= lclip.g_x + lclip.g_w )
- break;
- }
- }
+
+
+ if( sb->textlen > 0 ) {
+ size_t i;
+ short curx;
+ short vqw[4];
+ char t[2];
+ short cw = 8;
+ t[1]=0;
+ if( atari_sysinfo.sfont_monospaced ) {
+ t[0]='A';
+ int r = vqt_width(atari_plot_vdi_handle, t[0], &vqw[0], &vqw[1], &vqw[2] );
+ cw = vqw[0];
+ }
+ vswr_mode(atari_plot_vdi_handle, MD_TRANS );
+ for( curx = work.g_x + 2, i=0 ; (curx+cw < work.g_x+work.g_w ) && i < sb->textlen; i++ ){
+ t[0] = sb->text[i];
+ if( !atari_sysinfo.sfont_monospaced ) {
+ vqt_width(atari_plot_vdi_handle, t[0], &vqw[0], &vqw[1], &vqw[2] );
+ cw = vqw[0];
+ }
+ if( curx >= lclip.g_x - cw ) {
+ v_gtext(atari_plot_vdi_handle, curx, work.g_y + 5, (char*)&t );
+ }
+ curx += cw;
+ if( curx >= lclip.g_x + lclip.g_w )
+ break;
+ }
+ }
vswr_mode(atari_plot_vdi_handle, MD_REPLACE );
pxy[0] = work.g_x + work.g_w;
pxy[1] = work.g_y + work.g_h;
pxy[2] = work.g_x + work.g_w;
pxy[3] = work.g_y + work.g_h-work.g_h;
v_pline(atari_plot_vdi_handle, 2, (short*)&pxy );
-
- vs_clip(atari_plot_vdi_handle, 0, (short*)&pxyclip );
- return;
-}
-
-static void __CDECL evnt_sb_click( COMPONENT *c, long buff[8] )
-{
- static bool prevstate;
- short sbuff[8], mx, my;
- LGRECT work;
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- if( evnt.mx >= work.g_x + (work.g_w) && evnt.mx <= work.g_x + work.g_w &&
- evnt.my >= work.g_y + (work.g_h) && evnt.my <= work.g_y + work.g_h ) {
- // click within sb button
- }
-}
-
-CMP_STATUSBAR sb_create( struct gui_window * gw )
-{
- CMP_STATUSBAR s = malloc( sizeof(struct s_statusbar) );
- s->attached = false;
- s->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, STATUSBAR_HEIGHT, 0);
- s->comp->rect.g_h = STATUSBAR_HEIGHT;
- s->comp->bounds.max_height = STATUSBAR_HEIGHT;
- mt_CompDataAttach( &app, s->comp, CDT_OWNER, gw );
- mt_CompEvntAttach( &app, s->comp, WM_REDRAW, evnt_sb_redraw );
- mt_CompEvntAttach( &app, s->comp, WM_XBUTTON, evnt_sb_click );
- sb_set_text( s, (char*)"" );
- return( s );
-}
-
-void sb_destroy( CMP_STATUSBAR s )
-{
- LOG(("%s\n", __FUNCTION__ ));
- if( s ) {
- if( s->comp ){
- mt_CompDelete( &app, s->comp );
- }
- free( s );
- }
-}
-
-void sb_set_text(CMP_STATUSBAR sb , const char * text)
+
+ vs_clip(atari_plot_vdi_handle, 0, (short*)&pxyclip );
+ return;
+}
+
+static void __CDECL evnt_sb_click( COMPONENT *c, long buff[8] )
+{
+ static bool prevstate;
+ LGRECT work;
+ mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
+ if( evnt.mx >= work.g_x + (work.g_w) && evnt.mx <= work.g_x + work.g_w &&
+ evnt.my >= work.g_y + (work.g_h) && evnt.my <= work.g_y + work.g_h ) {
+ // click within sb button
+ }
+}
+
+CMP_STATUSBAR sb_create( struct gui_window * gw )
{
-
- LGRECT work;
- assert( sb != NULL );
- assert( sb->comp != NULL );
- strncpy( (char*)&sb->text, text, STATUSBAR_MAX_SLEN );
- sb->text[STATUSBAR_MAX_SLEN]=0;
- sb->textlen = strlen( (char*)&sb->text );
- if( sb->attached ){
- struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app, sb->comp, CDT_OWNER);
- if( gw != NULL ){
- mt_CompGetLGrect(&app, sb->comp, WF_WORKXYWH, &work);
- ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
- work.g_x, work.g_y, work.g_w, work.g_h );
- }
- }
+ CMP_STATUSBAR s = malloc( sizeof(struct s_statusbar) );
+ s->attached = false;
+ s->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, STATUSBAR_HEIGHT, 0);
+ s->comp->rect.g_h = STATUSBAR_HEIGHT;
+ s->comp->bounds.max_height = STATUSBAR_HEIGHT;
+ mt_CompDataAttach( &app, s->comp, CDT_OWNER, gw );
+ mt_CompEvntAttach( &app, s->comp, WM_REDRAW, evnt_sb_redraw );
+ mt_CompEvntAttach( &app, s->comp, WM_XBUTTON, evnt_sb_click );
+ sb_set_text( s, (char*)"" );
+ return( s );
+}
+
+void sb_destroy( CMP_STATUSBAR s )
+{
+ LOG(("%s\n", __FUNCTION__ ));
+ if( s ) {
+ if( s->comp ){
+ mt_CompDelete( &app, s->comp );
+ }
+ free( s );
+ }
+}
+
+void sb_set_text(CMP_STATUSBAR sb , const char * text)
+{
+
+ LGRECT work;
+ assert( sb != NULL );
+ assert( sb->comp != NULL );
+ strncpy( (char*)&sb->text, text, STATUSBAR_MAX_SLEN );
+ sb->text[STATUSBAR_MAX_SLEN]=0;
+ sb->textlen = strlen( (char*)&sb->text );
+ if( sb->attached ){
+ struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app, sb->comp, CDT_OWNER);
+ if( gw != NULL ){
+ mt_CompGetLGrect(&app, sb->comp, WF_WORKXYWH, &work);
+ ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
+ work.g_x, work.g_y, work.g_w, work.g_h );
+ }
+ }
}
#else
-CMP_STATUSBAR sb_create( struct gui_window * gw )
-{
- CMP_STATUSBAR s = malloc( sizeof(struct s_statusbar) );
- s->attached = false;
- sb_set_text( s, (char*)"" );
- return( s );
-}
-
-void sb_destroy( CMP_STATUSBAR s )
-{
- LOG(("%s\n", __FUNCTION__ ));
- if( s ) {
- free( s );
- }
+CMP_STATUSBAR sb_create( struct gui_window * gw )
+{
+ CMP_STATUSBAR s = malloc( sizeof(struct s_statusbar) );
+ s->attached = false;
+ sb_set_text( s, (char*)"" );
+ return( s );
+}
+
+void sb_destroy( CMP_STATUSBAR s )
+{
+ LOG(("%s\n", __FUNCTION__ ));
+ if( s ) {
+ free( s );
+ }
}
void sb_attach(CMP_STATUSBAR sb, struct gui_window * gw)
{
sb->aes_win = gemtk_wm_get_handle(gw->root->win);
sb->attached = true;
-}
-
-void sb_set_text(CMP_STATUSBAR sb, const char * text )
-{
- assert( sb != NULL );
- strncpy(sb->text, text, STATUSBAR_MAX_SLEN);
- sb->text[STATUSBAR_MAX_SLEN]=0;
- sb->textlen = strlen(sb->text);
+}
+
+void sb_set_text(CMP_STATUSBAR sb, const char * text )
+{
+ assert( sb != NULL );
+ strncpy(sb->text, text, STATUSBAR_MAX_SLEN);
+ sb->text[STATUSBAR_MAX_SLEN]=0;
+ sb->textlen = strlen(sb->text);
if(sb->attached){
- wind_set_str(sb->aes_win, WF_INFO, sb->text);
- }
+ wind_set_str(sb->aes_win, WF_INFO, sb->text);
+ }
}
#endif
diff --git a/atari/toolbar.c b/atari/toolbar.c
index fd9051dd9..8cdad4af6 100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -1,90 +1,91 @@
-/*
- * Copyright 2012 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <assert.h>
-#include <math.h>
-
-#include "utils/log.h"
-#include "desktop/gui.h"
-#include "desktop/local_history.h"
-#include "desktop/netsurf.h"
-#include "desktop/browser.h"
+/*
+ * Copyright 2012 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <assert.h>
+#include <math.h>
+
+#include "utils/log.h"
+#include "desktop/gui.h"
+#include "desktop/netsurf.h"
+#include "desktop/browser.h"
+#include "desktop/browser_history.h"
#include "desktop/browser_private.h"
-#include "desktop/mouse.h"
-#include "desktop/plot_style.h"
+#include "desktop/mouse.h"
+#include "desktop/plot_style.h"
#include "desktop/plotters.h"
#include "desktop/tree.h"
#include "desktop/hotlist.h"
#include "utils/nsoption.h"
#include "utils/nsurl.h"
-#include "utils/utf8.h"
-#include "atari/clipboard.h"
-#include "atari/gui.h"
-#include "atari/toolbar.h"
-#include "atari/rootwin.h"
-
-#include "atari/clipboard.h"
-#include "atari/misc.h"
-#include "atari/plot/plot.h"
-#include "cflib.h"
+#include "utils/utf8.h"
+#include "atari/clipboard.h"
+#include "atari/gui.h"
+#include "atari/toolbar.h"
+#include "atari/rootwin.h"
+
+#include "atari/clipboard.h"
+#include "atari/misc.h"
+#include "atari/plot/plot.h"
+#include "cflib.h"
#include "atari/res/netsurf.rsh"
#include "desktop/textarea.h"
#include "desktop/textinput.h"
#include "content/hlcache.h"
+#include "atari/encoding.h"
-
-#define TB_BUTTON_WIDTH 32
-#define THROBBER_WIDTH 32
-#define THROBBER_MIN_INDEX 1
-#define THROBBER_MAX_INDEX 12
-#define THROBBER_INACTIVE_INDEX 13
-enum e_toolbar_button_states {
- button_on = 0,
- button_off = 1
-};
-#define TOOLBAR_BUTTON_NUM_STATES 2
+#define TB_BUTTON_WIDTH 32
+#define THROBBER_WIDTH 32
+#define THROBBER_MIN_INDEX 1
+#define THROBBER_MAX_INDEX 12
+#define THROBBER_INACTIVE_INDEX 13
+
+enum e_toolbar_button_states {
+ button_on = 0,
+ button_off = 1
+};
+#define TOOLBAR_BUTTON_NUM_STATES 2
struct s_toolbar;
-
-struct s_tb_button
-{
- short rsc_id;
+
+struct s_tb_button
+{
+ short rsc_id;
void (*cb_click)(struct s_toolbar *tb);
hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
struct s_toolbar *owner;
- enum e_toolbar_button_states state;
+ enum e_toolbar_button_states state;
short index;
- GRECT area;
-};
-
-
-extern char * option_homepage_url;
-extern void * h_gem_rsrc;
+ GRECT area;
+};
+
+
+extern char * option_homepage_url;
+extern void * h_gem_rsrc;
extern struct gui_window * input_window;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
@@ -97,53 +98,53 @@ static int area_navigation_height = 0;
static int area_search_height = 0;
static int area_full_height = 0;
static float toolbar_url_scale = 1.0;
-
-static plot_font_style_t font_style_url = {
- .family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = 14*FONT_SIZE_SCALE,
- .weight = 400,
- .flags = FONTF_NONE,
- .background = 0xffffff,
- .foreground = 0x0
- };
-
-
+
+static plot_font_style_t font_style_url = {
+ .family = PLOT_FONT_FAMILY_SANS_SERIF,
+ .size = 14*FONT_SIZE_SCALE,
+ .weight = 400,
+ .flags = FONTF_NONE,
+ .background = 0xffffff,
+ .foreground = 0x0
+ };
+
+
/* prototypes & order for button widgets: */
-
-static struct s_tb_button tb_buttons[] =
-{
- {
- TOOLBAR_BT_BACK,
- toolbar_back_click,
- {0,0},
- 0, 0, 0, {0,0,0,0}
- },
- {
- TOOLBAR_BT_HOME,
- toolbar_home_click,
+
+static struct s_tb_button tb_buttons[] =
+{
+ {
+ TOOLBAR_BT_BACK,
+ toolbar_back_click,
{0,0},
- 0, 0, 0, {0,0,0,0}
- },
- {
- TOOLBAR_BT_FORWARD,
- toolbar_forward_click,
+ 0, 0, 0, {0,0,0,0}
+ },
+ {
+ TOOLBAR_BT_HOME,
+ toolbar_home_click,
{0,0},
- 0, 0, 0, {0,0,0,0}
- },
- {
- TOOLBAR_BT_STOP,
- toolbar_stop_click,
+ 0, 0, 0, {0,0,0,0}
+ },
+ {
+ TOOLBAR_BT_FORWARD,
+ toolbar_forward_click,
{0,0},
- 0, 0, 0, {0,0,0,0}
- },
- {
- TOOLBAR_BT_RELOAD,
- toolbar_reload_click,
+ 0, 0, 0, {0,0,0,0}
+ },
+ {
+ TOOLBAR_BT_STOP,
+ toolbar_stop_click,
{0,0},
- 0, 0, 0, {0,0,0,0}
+ 0, 0, 0, {0,0,0,0}
},
- { 0, 0, {0,0}, 0, -1, 0, {0,0,0,0}}
+ {
+ TOOLBAR_BT_RELOAD,
+ toolbar_reload_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
+ },
+ { 0, 0, {0,0}, 0, -1, 0, {0,0,0,0}}
};
struct s_toolbar_style {
@@ -162,12 +163,12 @@ static struct s_toolbar_style toolbar_styles[] =
{18}
};
-static const struct redraw_context toolbar_rdrw_ctx = {
- .interactive = true,
- .background_images = true,
- .plot = &atari_plotters
- };
-
+static const struct redraw_context toolbar_rdrw_ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &atari_plotters
+ };
+
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h );
static nserror toolbar_icon_callback( hlcache_handle *handle,
const hlcache_event *event, void *pw );
@@ -175,22 +176,22 @@ static nserror toolbar_icon_callback( hlcache_handle *handle,
/**
* Find a button for a specific resource ID
*/
-static struct s_tb_button *find_button(struct s_toolbar *tb, int rsc_id)
-{
- int i = 0;
- while (i < tb->btcnt) {
- if (tb->buttons[i].rsc_id == rsc_id) {
- return(&tb->buttons[i]);
- }
- i++;
+static struct s_tb_button *find_button(struct s_toolbar *tb, int rsc_id)
+{
+ int i = 0;
+ while (i < tb->btcnt) {
+ if (tb->buttons[i].rsc_id == rsc_id) {
+ return(&tb->buttons[i]);
+ }
+ i++;
}
- return(NULL);
+ return(NULL);
}
/**
* Callback for textarea redraw
*/
-static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
+static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
{
GRECT area;
@@ -207,7 +208,7 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
area.g_h = h;
//dbg_grect("tb_txt_request_redraw", &area);
window_schedule_redraw_grect(tb->owner, &area);
- return;
+ return;
}
static void tb_txt_callback(void *data, struct textarea_msg *msg)
@@ -230,12 +231,12 @@ static void tb_txt_callback(void *data, struct textarea_msg *msg)
}
static struct s_tb_button *button_init(struct s_toolbar *tb, OBJECT * tree, int index,
- struct s_tb_button * instance)
+ struct s_tb_button * instance)
{
*instance = tb_buttons[index];
instance->owner = tb;
- return(instance);
+ return(instance);
}
@@ -265,7 +266,7 @@ void toolbar_init( void )
area_search_height = aes_toolbar[TOOLBAR_AREA_SEARCH].ob_height;
area_navigation_height = aes_toolbar[TOOLBAR_AREA_NAVIGATION].ob_height;
- init = true;
+ init = true;
}
@@ -275,20 +276,20 @@ void toolbar_exit(void)
}
-struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
-{
+struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
+{
int i;
struct s_toolbar *t;
LOG((""));
- assert(init == true);
-
- t = calloc(1, sizeof(struct s_toolbar));
+ assert(init == true);
- assert(t);
+ t = calloc(1, sizeof(struct s_toolbar));
- /* initialize the toolbar values: */
+ assert(t);
+
+ /* initialize the toolbar values: */
t->owner = owner;
t->style = 1;
t->search_visible = false;
@@ -297,20 +298,20 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
/* dublicate the form template: */
t->form = gemtk_obj_tree_copy(aes_toolbar);
-
-
- /* count buttons and add them as components: */
- i = 0;
- while(tb_buttons[i].rsc_id > 0) {
- i++;
- }
- t->btcnt = i;
+
+
+ /* count buttons and add them as components: */
+ i = 0;
+ while(tb_buttons[i].rsc_id > 0) {
+ i++;
+ }
+ t->btcnt = i;
t->buttons = malloc(t->btcnt * sizeof(struct s_tb_button));
- memset(t->buttons, 0, t->btcnt * sizeof(struct s_tb_button));
- for (i=0; i < t->btcnt; i++) {
- button_init(t, aes_toolbar, i, &t->buttons[i]);
- }
-
+ memset(t->buttons, 0, t->btcnt * sizeof(struct s_tb_button));
+ for (i=0; i < t->btcnt; i++) {
+ button_init(t, aes_toolbar, i, &t->buttons[i]);
+ }
+
/* create the url widget: */
font_style_url.size =
toolbar_styles[t->style].font_height_pt * FONT_SIZE_SCALE;
@@ -329,27 +330,27 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
ta_setup.selected_bg = 0x000000;
ta_setup.text = font_style_url;
ta_setup.text.foreground = 0x000000;
- ta_setup.text.background = 0xffffff;
- t->url.textarea = textarea_create(ta_flags, &ta_setup,
- tb_txt_callback, t);
+ ta_setup.text.background = 0xffffff;
+ t->url.textarea = textarea_create(ta_flags, &ta_setup,
+ tb_txt_callback, t);
- /* create the throbber widget: */
- t->throbber.index = THROBBER_INACTIVE_INDEX;
- t->throbber.max_index = THROBBER_MAX_INDEX;
+ /* create the throbber widget: */
+ t->throbber.index = THROBBER_INACTIVE_INDEX;
+ t->throbber.max_index = THROBBER_MAX_INDEX;
t->throbber.running = false;
LOG(("created toolbar: %p, root: %p, textarea: %p, throbber: %p", t,
- owner, t->url.textarea, t->throbber));
- return( t );
+ owner, t->url.textarea, t->throbber));
+ return( t );
}
void toolbar_destroy(struct s_toolbar *tb)
{
- free(tb->buttons);
+ free(tb->buttons);
free(tb->form);
- textarea_destroy(tb->url.textarea);
+ textarea_destroy(tb->url.textarea);
free(tb);
}
@@ -418,7 +419,7 @@ static void toolbar_reflow(struct s_toolbar *tb)
}
else if (tb->buttons[i].state == button_on) {
tb->form[tb->buttons[i].rsc_id].ob_state &= ~OS_DISABLED;
- }
+ }
}
tb->reflow = false;
// TODO: iterate through all other toolbars and set reflow = true
@@ -427,7 +428,6 @@ static void toolbar_reflow(struct s_toolbar *tb)
void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
{
GRECT area, area_ro;
- float old_scale;
if (tb->attached == false) {
return;
@@ -446,13 +446,14 @@ void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
area = area_ro;
if (rc_intersect(clip, &area)) {
+ float old_scale;
plot_set_dimensions(area_ro.g_x, area_ro.g_y, area_ro.g_w, area_ro.g_h);
- struct rect r = {
+ struct rect r = {
.x0 = MAX(0,area.g_x - area_ro.g_x),
- .y0 = MAX(0,area.g_y - area_ro.g_y),
+ .y0 = MAX(0,area.g_y - area_ro.g_y),
.x1 = MAX(0,area.g_x - area_ro.g_x) + area.g_w,
- .y1 = MAX(0,area.g_y - area_ro.g_y) + area.g_h
+ .y1 = MAX(0,area.g_y - area_ro.g_y) + area.g_h
};
//dbg_rect("tb textarea clip: ", &r);
// TODO: let this be handled by an userdef object redraw function:
@@ -470,56 +471,53 @@ void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
{
LOG((""));
- struct s_tb_button * bt;
+ struct s_tb_button * bt;
bool enable = false;
GRECT area;
- nsurl * ns_url;
- char * c_url;
- size_t c_url_len;
assert(bw != NULL);
if (button == TOOLBAR_BT_BACK || button <= 0 ) {
bt = find_button(tb, TOOLBAR_BT_BACK);
- enable = browser_window_back_available(bw);
- if (enable) {
- bt->state = button_on;
- } else {
- bt->state = button_off;
+ enable = browser_window_back_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
}
}
- if (button == TOOLBAR_BT_HOME || button <= 0 ) {
+ if (button == TOOLBAR_BT_HOME || button <= 0 ) {
- }
+ }
if (button == TOOLBAR_BT_FORWARD || button <= 0 ) {
bt = find_button(tb, TOOLBAR_BT_FORWARD);
- enable = browser_window_forward_available(bw);
- if (enable) {
- bt->state = button_on;
- } else {
- bt->state = button_off;
- }
- }
+ enable = browser_window_forward_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
+ }
+ }
if (button == TOOLBAR_BT_RELOAD || button <= 0 ) {
bt = find_button(tb, TOOLBAR_BT_RELOAD);
- enable = browser_window_reload_available(bw);
- if (enable) {
- bt->state = button_on;
- } else {
- bt->state = button_off;
+ enable = browser_window_reload_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
}
- }
+ }
if (button == TOOLBAR_BT_STOP || button <= 0) {
bt = find_button(tb, TOOLBAR_BT_STOP);
- enable = browser_window_stop_available(bw);
- if (enable) {
- bt->state = button_on;
- } else {
- bt->state = button_off;
+ enable = browser_window_stop_available(bw);
+ if (enable) {
+ bt->state = button_on;
+ } else {
+ bt->state = button_off;
}
}
@@ -690,65 +688,65 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
{
assert(tb!=NULL);
-
+
GRECT work;
bool ret = false;
- struct gui_window *gw = window_get_active_gui_window(tb->owner);
-
- assert( gw != NULL );
-
- long ucs4;
- long ik = nkc_to_input_key(nkc, &ucs4);
-
- if (ik == 0) {
- if ((nkc&0xFF) >= 9) {
- ret = textarea_keypress(tb->url.textarea, ucs4);
- }
- }
- else if (ik == KEY_CR || ik == KEY_NL) {
- nsurl *url;
- char tmp_url[PATH_MAX];
- if ( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
- window_set_focus(tb->owner, BROWSER, gw->browser);
- if (nsurl_create((const char*)&tmp_url, &url) != NSERROR_OK) {
- warn_user("NoMemory", 0);
- } else {
- browser_window_navigate(gw->browser->bw, url, NULL,
- BROWSER_WINDOW_HISTORY | BROWSER_WINDOW_VERIFIABLE,
- NULL, NULL, NULL);
- nsurl_unref(url);
- }
-
- ret = true;
- }
- }
- else if (ik == KEY_COPY_SELECTION) {
- // copy whole text
- char * text;
- int len;
- len = textarea_get_text( tb->url.textarea, NULL, 0 );
- text = malloc( len+1 );
- if (text){
- textarea_get_text( tb->url.textarea, text, len+1 );
- scrap_txt_write(text);
- free( text );
- }
+ struct gui_window *gw = window_get_active_gui_window(tb->owner);
+
+ assert( gw != NULL );
+
+ long ucs4;
+ long ik = nkc_to_input_key(nkc, &ucs4);
+
+ if (ik == 0) {
+ if ((nkc&0xFF) >= 9) {
+ ret = textarea_keypress(tb->url.textarea, ucs4);
+ }
+ }
+ else if (ik == KEY_CR || ik == KEY_NL) {
+ nsurl *url;
+ char tmp_url[PATH_MAX];
+ if ( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
+ window_set_focus(tb->owner, BROWSER, gw->browser);
+ if (nsurl_create((const char*)&tmp_url, &url) != NSERROR_OK) {
+ warn_user("NoMemory", 0);
+ } else {
+ browser_window_navigate(gw->browser->bw, url, NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL, NULL, NULL);
+ nsurl_unref(url);
+ }
+
+ ret = true;
+ }
+ }
+ else if (ik == KEY_COPY_SELECTION) {
+ // copy whole text
+ char * text;
+ int len;
+ len = textarea_get_text( tb->url.textarea, NULL, 0 );
+ text = malloc( len+1 );
+ if (text){
+ textarea_get_text( tb->url.textarea, text, len+1 );
+ scrap_txt_write(text);
+ free( text );
+ }
}
else if ( ik == KEY_PASTE) {
- char * clip = scrap_txt_read();
+ char * clip = scrap_txt_read();
if ( clip != NULL ){
- int clip_length = strlen( clip );
- if ( clip_length > 0 ) {
- char *utf8;
- utf8_convert_ret res;
- /* Clipboard is in local encoding so
- * convert to UTF8 */
- res = utf8_from_local_encoding( clip, clip_length, &utf8 );
- if ( res == UTF8_CONVERT_OK ) {
- toolbar_set_url(tb, utf8);
+ int clip_length = strlen( clip );
+ if ( clip_length > 0 ) {
+ char *utf8;
+ nserror res;
+ /* Clipboard is in local encoding so
+ * convert to UTF8 */
+ res = utf8_from_local_encoding( clip, clip_length, &utf8 );
+ if ( res == NSERROR_OK ) {
+ toolbar_set_url(tb, utf8);
free(utf8);
- ret = true;
- }
+ ret = true;
+ }
}
free( clip );
}
@@ -756,11 +754,11 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
else if (ik == KEY_ESCAPE) {
textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
- }
- else {
- ret = textarea_keypress( tb->url.textarea, ik );
- }
-
+ }
+ else {
+ ret = textarea_keypress( tb->url.textarea, ik );
+ }
+
return( ret );
}
@@ -768,10 +766,8 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
{
LOG((""));
- GRECT work;
- short mx, my, mb, kstat;
- int old;
- OBJECT * toolbar_tree;
+ GRECT work;
+ short mx, my, mb, kstat;
struct gui_window * gw;
@@ -779,10 +775,10 @@ void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
graf_mkstate(&mx, &my, &mb, &kstat);
toolbar_get_grect(tb, TOOLBAR_AREA_URL, &work);
- mx -= work.g_x;
+ mx -= work.g_x;
my -= work.g_y;
-
- /* TODO: reset mouse state of browser window? */
+
+ /* TODO: reset mouse state of browser window? */
/* select whole text when newly focused, otherwise set caret to
end of text */
if (!window_url_widget_has_focus(tb->owner)) {
@@ -791,21 +787,21 @@ void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
/* url widget has focus and mouse button is still pressed... */
else if (mb & 1) {
- textarea_mouse_action(tb->url.textarea, BROWSER_MOUSE_DRAG_1,
- mx, my );
- short prev_x = mx;
- short prev_y = my;
- do {
- if (abs(prev_x-mx) > 5 || abs(prev_y-my) > 5) {
- textarea_mouse_action( tb->url.textarea,
- BROWSER_MOUSE_HOLDING_1, mx, my );
- prev_x = mx;
+ textarea_mouse_action(tb->url.textarea, BROWSER_MOUSE_DRAG_1,
+ mx, my );
+ short prev_x = mx;
+ short prev_y = my;
+ do {
+ if (abs(prev_x-mx) > 5 || abs(prev_y-my) > 5) {
+ textarea_mouse_action( tb->url.textarea,
+ BROWSER_MOUSE_HOLDING_1, mx, my );
+ prev_x = mx;
prev_y = my;
window_schedule_redraw_grect(tb->owner, &work);
- window_process_redraws(tb->owner);
- }
- graf_mkstate( &mx, &my, &mb, &kstat );
- mx = mx - (work.g_x);
+ window_process_redraws(tb->owner);
+ }
+ graf_mkstate( &mx, &my, &mb, &kstat );
+ mx = mx - (work.g_x);
my = my - (work.g_y);
} while (mb & 1);
@@ -817,19 +813,15 @@ void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
}
else {
/* when execution reaches here, mouse input is a click or dclick */
- /* TODO: recognize click + shitoolbar_update_buttonsft key */
- int mstate = BROWSER_MOUSE_PRESS_1;
- if ((kstat & (K_LSHIFT|K_RSHIFT)) != 0) {
- mstate = BROWSER_MOUSE_MOD_1;
- }
+ /* TODO: recognize click + shitoolbar_update_buttonsft key */
if (aes_event_out.emo_mclicks == 2 ) {
- textarea_mouse_action( tb->url.textarea,
+ textarea_mouse_action( tb->url.textarea,
BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1, mx,
my);
toolbar_get_grect(tb, TOOLBAR_AREA_URL, &work);
window_schedule_redraw_grect(tb->owner, &work);
} else {
- textarea_mouse_action(tb->url.textarea,
+ textarea_mouse_action(tb->url.textarea,
BROWSER_MOUSE_PRESS_1, mx, my );
}
}
@@ -935,8 +927,8 @@ OBJECT *toolbar_get_form(struct s_toolbar *tb)
}
-/* public event handler */
-void toolbar_back_click(struct s_toolbar *tb)
+/* public event handler */
+void toolbar_back_click(struct s_toolbar *tb)
{
struct browser_window * bw;
struct gui_window * gw;
@@ -946,11 +938,11 @@ void toolbar_back_click(struct s_toolbar *tb)
bw = gw->browser->bw;
assert(bw != NULL);
- if( history_back_available(bw->history) )
- history_back(bw, bw->history);
-}
-
-void toolbar_reload_click(struct s_toolbar *tb)
+ if( browser_window_back_available(bw) )
+ browser_window_history_back(bw, false);
+}
+
+void toolbar_reload_click(struct s_toolbar *tb)
{
struct browser_window * bw;
struct gui_window * gw;
@@ -960,10 +952,10 @@ void toolbar_reload_click(struct s_toolbar *tb)
bw = gw->browser->bw;
assert(bw != NULL);
- browser_window_reload(bw, true);
-}
-
-void toolbar_forward_click(struct s_toolbar *tb)
+ browser_window_reload(bw, true);
+}
+
+void toolbar_forward_click(struct s_toolbar *tb)
{
struct browser_window * bw;
struct gui_window * gw;
@@ -972,12 +964,12 @@ void toolbar_forward_click(struct s_toolbar *tb)
assert(gw != NULL);
bw = gw->browser->bw;
assert(bw != NULL);
-
- if (history_forward_available(bw->history))
- history_forward(bw, bw->history);
-}
-
-void toolbar_home_click(struct s_toolbar *tb)
+
+ if (browser_window_forward_available(bw))
+ browser_window_history_forward(bw, false);
+}
+
+void toolbar_home_click(struct s_toolbar *tb)
{
struct browser_window * bw;
struct gui_window * gw;
@@ -994,23 +986,22 @@ void toolbar_home_click(struct s_toolbar *tb)
use_url = (char*)"about:welcome";
}
- if (nsurl_create(use_url, &url) != NSERROR_OK) {
- warn_user("NoMemory", 0);
- } else {
- browser_window_navigate(bw,
- url,
- NULL,
- BROWSER_WINDOW_HISTORY |
- BROWSER_WINDOW_VERIFIABLE,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
-}
-
-
-void toolbar_stop_click(struct s_toolbar *tb)
+ if (nsurl_create(use_url, &url) != NSERROR_OK) {
+ warn_user("NoMemory", 0);
+ } else {
+ browser_window_navigate(bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+}
+
+
+void toolbar_stop_click(struct s_toolbar *tb)
{
struct browser_window * bw;
struct gui_window * gw;
@@ -1023,10 +1014,10 @@ void toolbar_stop_click(struct s_toolbar *tb)
assert(bw != NULL);
- browser_window_stop(bw);
+ browser_window_stop(bw);
}
-void toolbar_favorite_click(struct s_toolbar *tb)
+void toolbar_favorite_click(struct s_toolbar *tb)
{
nsurl * ns_url = NULL;
char * c_url;
@@ -1053,7 +1044,7 @@ void toolbar_favorite_click(struct s_toolbar *tb)
free(c_url);
}
-void toolbar_crypto_click(struct s_toolbar *tb)
+void toolbar_crypto_click(struct s_toolbar *tb)
{
}
diff --git a/atari/toolbar.h b/atari/toolbar.h
index be4bd038e..284376fcb 100644
--- a/atari/toolbar.h
+++ b/atari/toolbar.h
@@ -26,6 +26,7 @@
#include "desktop/browser.h"
struct s_toolbar;
+struct nsurl;
enum toolbar_textarea {
URL_INPUT_TEXT_AREA = 1
@@ -76,7 +77,7 @@ OBJECT *toolbar_get_form(struct s_toolbar *tb);
struct textarea *toolbar_get_textarea(struct s_toolbar *tb,
enum toolbar_textarea which);
char *toolbar_get_url(struct s_toolbar *tb);
-nsurl * toolbar_get_nsurl(struct s_toolbar * tb);
+struct nsurl * toolbar_get_nsurl(struct s_toolbar * tb);
void toolbar_set_throbber_state(struct s_toolbar *tb, bool active);
void toolbar_set_attached(struct s_toolbar *tb, bool attached);
void toolbar_set_visible(struct s_toolbar *tb, short area, bool visible);
diff --git a/atari/treeview.c b/atari/treeview.c
index 8c7330640..005465c47 100644
--- a/atari/treeview.c
+++ b/atari/treeview.c
@@ -1,19 +1,19 @@
-/*
- * Copyright 2013 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+/*
+ * Copyright 2013 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <inttypes.h>
@@ -342,13 +342,11 @@ static short handle_event(GUIWIN *win, EVMULT_OUT *ev_out, short msg[8])
static void __CDECL on_keybd_event(struct core_window *cw, EVMULT_OUT *ev_out,
short msg[8])
{
- bool r=false;
long kstate = 0;
long kcode = 0;
long ucs4;
long ik;
unsigned short nkc = 0;
- unsigned short nks = 0;
unsigned char ascii;
struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
@@ -434,8 +432,6 @@ static void __CDECL on_mbutton_event(struct core_window *cw, EVMULT_OUT *ev_out,
struct gemtk_wm_scroll_info_s *slid;
GRECT work;
short mx, my;
- int bms;
- bool ignore=false;
short cur_rel_x, cur_rel_y, dummy, mbut;
assert(tv);
@@ -467,6 +463,7 @@ static void __CDECL on_mbutton_event(struct core_window *cw, EVMULT_OUT *ev_out,
graf_mkstate(&cur_rel_x, &cur_rel_y, &mbut, &dummy);
/* check for click or hold: */
if( (mbut&1) == 0 ){
+ int bms;
bms = BROWSER_MOUSE_CLICK_1 | BROWSER_MOUSE_PRESS_1;
if(ev_out->emo_mclicks == 2 ) {
bms = BROWSER_MOUSE_DOUBLE_CLICK;
@@ -636,7 +633,6 @@ void atari_treeview_close(struct core_window *cw)
wind_close(gemtk_wm_get_handle(tv->window));
gemtk_wm_unlink(tv->window);
/* unlink the window: */
- struct atari_treeview_window *tmp = treeviews_open;
if (tv->prev_open != NULL) {
tv->prev_open->next_open = tv->next_open;
} else {
@@ -753,7 +749,6 @@ void atari_treeview_get_window_dimensions(struct core_window *cw,
{
if (cw != NULL && (width != NULL || height != NULL)) {
GRECT work;
- struct atari_treeview_window *tv = (struct atari_treeview_window *)cw;
atari_treeview_get_grect(cw, TREEVIEW_AREA_CONTENT, &work);
*width = work.g_w;
*height = work.g_h;
diff --git a/atari/verify_ssl.c b/atari/verify_ssl.c
index e6a57b7b2..5d3f86856 100755
--- a/atari/verify_ssl.c
+++ b/atari/verify_ssl.c
@@ -1,272 +1,269 @@
-/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
- *
- * This file is part of NetSurf, http://www.netsurf-browser.org/
- *
- * NetSurf is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * NetSurf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <windom.h>
-
-#include "utils/errors.h"
-#include "utils/utils.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "content/urldb.h"
-#include "content/fetch.h"
-#include "atari/res/netsurf.rsh"
-#include "atari/verify_ssl.h"
-
-/*
- todo: this file need to use the treeview api - complete rework,
- current implementation is not used in any way.
-*/
-
-extern void * h_gem_rsrc;
-extern short atari_plot_vdi_handle;
-
-
-#define CERT_INF_LINES 8
-
-static struct ssl_info_draw_param
-{
- struct ssl_cert_info * cert_infos_n;
- unsigned long num_certs;
- int current;
- int scrollx;
- int cols;
- int scrolly;
- int rows; /* assumed to be 8 */
- OBJECT * tree;
-} dp;
-
-
-static int cert_display_width( struct ssl_cert_info * cert_info )
-{
- int l1, l2;
- int max=0;
- int i;
- int add = 16; /* strlen("Issuer: "); */
-
- l1 = strlen(cert_info->issuer) + add;
- l2 = strlen(cert_info->subject) + add;
- return( MAX(l1, l2) );
-}
-
-
-static void __CDECL cert_info_draw( WINDOW * win, short buf[8], void * data)
-{
- struct ssl_info_draw_param * dp = (struct ssl_info_draw_param *)data;
- GRECT work;
- short pxy[4];
- int maxchars;
- short d, cbh, cbw;
- int i = 0;
- short x,y,w,h;
- int px_ypos, px_xpos;
- char * line = malloc(512);
- if( line == NULL )
- return;
-
- LOG(("Cert info draw, win: %p, data: %p, scrollx: %d", win, data, dp->scrollx ));
-
- WindGet( win, WF_WORKXYWH, &x, &y, &w, &h );
- /*using static values here, as RsrcUserDraw has mem leaks & a very small stack */
- pxy[0] = work.g_x = x + 8;
- pxy[1] = work.g_y = y + 80;
- pxy[2] = x + 8 + 272;
- pxy[3] = y + 80 + 176;
- work.g_w = 272;
- work.g_h = 176;
-
- maxchars = (work.g_w / 8)+1;
- vs_clip( atari_plot_vdi_handle, 1,(short*) &pxy );
- vswr_mode( atari_plot_vdi_handle, MD_REPLACE );
- vsf_interior( atari_plot_vdi_handle, 1 );
- vsf_color( atari_plot_vdi_handle, LWHITE );
- v_bar( atari_plot_vdi_handle, (short*)&pxy );
- vst_height( atari_plot_vdi_handle, 16, &d, &d, &cbw, &cbh );
- vst_alignment(atari_plot_vdi_handle, 0, 5, &d, &d );
- vst_color( atari_plot_vdi_handle, BLACK );
- vst_effects( atari_plot_vdi_handle, 0 );
- px_ypos = px_xpos = 0;
- for(i=0; i<CERT_INF_LINES; i++ ) {
- switch( i ) {
- case 0:
- sprintf(line, "Cert Version: %d", dp->cert_infos_n[dp->current].version );
- break;
-
- case 1:
- sprintf(line, "Invalid before: %s", &dp->cert_infos_n[dp->current].not_before );
- break;
-
- case 2:
- sprintf(line, "Invalid after: %s", &dp->cert_infos_n[dp->current].not_after );
- break;
-
- case 3:
- sprintf(line, "Signature type: %d", dp->cert_infos_n[dp->current].sig_type );
- break;
-
- case 4:
- sprintf(line, "Serial: %d", dp->cert_infos_n[dp->current].serial );
- break;
-
- case 5:
- sprintf(line, "Issuer: %s", &dp->cert_infos_n[dp->current].issuer );
- break;
-
- case 6:
- sprintf(line, "Subject: %s", &dp->cert_infos_n[dp->current].subject );
- break;
-
- case 7:
- sprintf(line, "Cert type: %d", dp->cert_infos_n[dp->current].cert_type );
- break;
-
- default:
- break;
- }
- if( (int)strlen(line) > dp->scrollx ) {
- if( dp->scrollx + maxchars < 511 && ( (signed int)strlen(line) - dp->scrollx) > maxchars )
- line[dp->scrollx + maxchars] = 0;
- v_gtext(atari_plot_vdi_handle, work.g_x + 1, work.g_y + px_ypos, &line[dp->scrollx]);
- }
- px_ypos += cbh;
- }
- vst_alignment(atari_plot_vdi_handle, 0, 0, &d, &d );
- vs_clip( atari_plot_vdi_handle, 0, (short*)&pxy );
- free( line );
-}
-
-
-static void do_popup( WINDOW *win, int index, int mode, void *data)
-{
- struct ssl_info_draw_param * dp = (struct ssl_info_draw_param *)data;
- char * items[dp->num_certs];
- short x, y;
- unsigned int i;
- int dispw;
- LOG(("do_popup: num certs: %d", dp->num_certs));
- for( i = 0; i<dp->num_certs; i++) {
- items[i] = malloc( 48 );
- strncpy(items[i], (char*)&dp->cert_infos_n[i].issuer, 46 );
- }
- objc_offset( FORM(win), index, &x, &y );
- dp->current = MenuPopUp( items, x, y,
- dp->num_certs, MIN( 3, dp->num_certs), 0,
- P_LIST + P_WNDW + P_CHCK );
- ObjcChange( OC_FORM, win, index, NORMAL, TRUE );
- dp->cols = cert_display_width( &dp->cert_infos_n[dp->current] );
- dp->rows = 8;
- dp->scrollx = 0;
- dp->scrolly = 0;
-
- /* Send (!) redraw ( OC_MSG ) */
- ObjcDrawParent( OC_FORM, FORM(win), VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
- for( i = 0; i<dp->num_certs; i++) {
- free( items[i] );
- }
-}
-
-
-
-bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_infos_n ,
- unsigned long num_certs )
-{
- OBJECT *tree;
- WINDOW * form;
-
- bool bres = false;
- bool cont = true;
- int res = 0;
- dp.cert_infos_n = (struct ssl_cert_info *)cert_infos_n;
- dp.num_certs = num_certs;
- dp.scrollx = 0;
- dp.scrolly = 0;
- dp.current = 0;
- dp.cols = cert_display_width( &dp.cert_infos_n[dp.current] );
- dp.rows = 8;
- dp.tree = tree;
-
- RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree);
- ObjcString( tree, VERIFY_LBL_HOST, (char*)url );
- ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 );
- ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 );
- form = FormWindBegin( tree, (char*)"SSL Verify failed" );
- EvntDataAdd( form, WM_REDRAW, cert_info_draw, (void*)&dp, EV_BOT );
- /* this results in some extended objects which can not be freed: :( */
- /* RsrcUserDraw( OC_FORM, tree, VERIFY_BOX_DETAILS, cert_info_draw,(void*)&dp ) ; */
- ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp );
- /*
- ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp );
- ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp );
- */
- while( cont ) {
- res = FormWindDo( MU_MESAG );
- cont = false;
- switch( res ){
- case VERIFY_BT_ACCEPT:
- bres = true;
- break;
-
- case VERIFY_BT_NEXT_CERT:
- /* select box clicked or dragged... */
- cont = true;
- break;
-
- case VERIFY_BT_REJECT:
- bres = false;
- break;
-
- case VERIFY_BT_SCROLL_D:
- cont = true;
- dp.scrolly += 1;
- ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
- break;
-
- case VERIFY_BT_SCROLL_U:
- cont = true;
- dp.scrolly -= 1;
- ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
- break;
-
- case VERIFY_BT_SCROLL_R:
- LOG(( "scroll r!" ));
- cont = true;
- dp.scrollx += 1;
- if( dp.scrollx > (dp.cols - (272 / 8 )) )
- dp.scrollx -= 1;
- ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG);
- break;
-
- case VERIFY_BT_SCROLL_L:
- cont = true;
- dp.scrollx -= 1;
- if( dp.scrollx < 0 )
- dp.scrollx = 0;
- ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
- break;
-
- default:
- break;
- }
- }
- FormWindEnd( );
- return( bres );
-}
+/*
+ * Copyright 2010 Ole Loots <ole@monochrom.net>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <windom.h>
+
+#include "utils/errors.h"
+#include "utils/utils.h"
+#include "utils/log.h"
+#include "utils/messages.h"
+#include "content/urldb.h"
+#include "content/fetch.h"
+#include "atari/res/netsurf.rsh"
+#include "atari/verify_ssl.h"
+
+/*
+ todo: this file need to use the treeview api - complete rework,
+ current implementation is not used in any way.
+*/
+
+extern void * h_gem_rsrc;
+extern short atari_plot_vdi_handle;
+
+
+#define CERT_INF_LINES 8
+
+static struct ssl_info_draw_param
+{
+ struct ssl_cert_info * cert_infos_n;
+ unsigned long num_certs;
+ int current;
+ int scrollx;
+ int cols;
+ int scrolly;
+ int rows; /* assumed to be 8 */
+ OBJECT * tree;
+} dp;
+
+
+static int cert_display_width( struct ssl_cert_info * cert_info )
+{
+ int l1, l2;
+ int add = 16; /* strlen("Issuer: "); */
+
+ l1 = strlen(cert_info->issuer) + add;
+ l2 = strlen(cert_info->subject) + add;
+ return( MAX(l1, l2) );
+}
+
+
+static void __CDECL cert_info_draw( WINDOW * win, short buf[8], void * data)
+{
+ struct ssl_info_draw_param * dp = (struct ssl_info_draw_param *)data;
+ GRECT work;
+ short pxy[4];
+ int maxchars;
+ short d, cbh, cbw;
+ int i = 0;
+ short x,y,w,h;
+ int px_ypos;
+ char * line = malloc(512);
+ if( line == NULL )
+ return;
+
+ LOG(("Cert info draw, win: %p, data: %p, scrollx: %d", win, data, dp->scrollx ));
+
+ WindGet( win, WF_WORKXYWH, &x, &y, &w, &h );
+ /*using static values here, as RsrcUserDraw has mem leaks & a very small stack */
+ pxy[0] = work.g_x = x + 8;
+ pxy[1] = work.g_y = y + 80;
+ pxy[2] = x + 8 + 272;
+ pxy[3] = y + 80 + 176;
+ work.g_w = 272;
+ work.g_h = 176;
+
+ maxchars = (work.g_w / 8)+1;
+ vs_clip( atari_plot_vdi_handle, 1,(short*) &pxy );
+ vswr_mode( atari_plot_vdi_handle, MD_REPLACE );
+ vsf_interior( atari_plot_vdi_handle, 1 );
+ vsf_color( atari_plot_vdi_handle, LWHITE );
+ v_bar( atari_plot_vdi_handle, (short*)&pxy );
+ vst_height( atari_plot_vdi_handle, 16, &d, &d, &cbw, &cbh );
+ vst_alignment(atari_plot_vdi_handle, 0, 5, &d, &d );
+ vst_color( atari_plot_vdi_handle, BLACK );
+ vst_effects( atari_plot_vdi_handle, 0 );
+ px_ypos = 0;
+ for(i=0; i<CERT_INF_LINES; i++ ) {
+ switch( i ) {
+ case 0:
+ sprintf(line, "Cert Version: %d", dp->cert_infos_n[dp->current].version );
+ break;
+
+ case 1:
+ sprintf(line, "Invalid before: %s", &dp->cert_infos_n[dp->current].not_before );
+ break;
+
+ case 2:
+ sprintf(line, "Invalid after: %s", &dp->cert_infos_n[dp->current].not_after );
+ break;
+
+ case 3:
+ sprintf(line, "Signature type: %d", dp->cert_infos_n[dp->current].sig_type );
+ break;
+
+ case 4:
+ sprintf(line, "Serial: %d", dp->cert_infos_n[dp->current].serial );
+ break;
+
+ case 5:
+ sprintf(line, "Issuer: %s", &dp->cert_infos_n[dp->current].issuer );
+ break;
+
+ case 6:
+ sprintf(line, "Subject: %s", &dp->cert_infos_n[dp->current].subject );
+ break;
+
+ case 7:
+ sprintf(line, "Cert type: %d", dp->cert_infos_n[dp->current].cert_type );
+ break;
+
+ default:
+ break;
+ }
+ if( (int)strlen(line) > dp->scrollx ) {
+ if( dp->scrollx + maxchars < 511 && ( (signed int)strlen(line) - dp->scrollx) > maxchars )
+ line[dp->scrollx + maxchars] = 0;
+ v_gtext(atari_plot_vdi_handle, work.g_x + 1, work.g_y + px_ypos, &line[dp->scrollx]);
+ }
+ px_ypos += cbh;
+ }
+ vst_alignment(atari_plot_vdi_handle, 0, 0, &d, &d );
+ vs_clip( atari_plot_vdi_handle, 0, (short*)&pxy );
+ free( line );
+}
+
+
+static void do_popup( WINDOW *win, int index, int mode, void *data)
+{
+ struct ssl_info_draw_param * dp = (struct ssl_info_draw_param *)data;
+ char * items[dp->num_certs];
+ short x, y;
+ unsigned int i;
+ LOG(("do_popup: num certs: %d", dp->num_certs));
+ for( i = 0; i<dp->num_certs; i++) {
+ items[i] = malloc( 48 );
+ strncpy(items[i], (char*)&dp->cert_infos_n[i].issuer, 46 );
+ }
+ objc_offset( FORM(win), index, &x, &y );
+ dp->current = MenuPopUp( items, x, y,
+ dp->num_certs, MIN( 3, dp->num_certs), 0,
+ P_LIST + P_WNDW + P_CHCK );
+ ObjcChange( OC_FORM, win, index, NORMAL, TRUE );
+ dp->cols = cert_display_width( &dp->cert_infos_n[dp->current] );
+ dp->rows = 8;
+ dp->scrollx = 0;
+ dp->scrolly = 0;
+
+ /* Send (!) redraw ( OC_MSG ) */
+ ObjcDrawParent( OC_FORM, FORM(win), VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
+ for( i = 0; i<dp->num_certs; i++) {
+ free( items[i] );
+ }
+}
+
+
+
+bool verify_ssl_form_do( const char * url, const struct ssl_cert_info * cert_infos_n ,
+ unsigned long num_certs )
+{
+ OBJECT *tree;
+ WINDOW * form;
+
+ bool bres = false;
+ bool cont = true;
+ int res = 0;
+ dp.cert_infos_n = (struct ssl_cert_info *)cert_infos_n;
+ dp.num_certs = num_certs;
+ dp.scrollx = 0;
+ dp.scrolly = 0;
+ dp.current = 0;
+ dp.cols = cert_display_width( &dp.cert_infos_n[dp.current] );
+ dp.rows = 8;
+ dp.tree = tree;
+
+ RsrcGaddr (h_gem_rsrc , R_TREE, VERIFY, &tree);
+ ObjcString( tree, VERIFY_LBL_HOST, (char*)url );
+ ObjcChange( OC_OBJC, tree, VERIFY_BT_ACCEPT, 0, 0 );
+ ObjcChange( OC_OBJC, tree, VERIFY_BT_REJECT, 0, 0 );
+ form = FormWindBegin( tree, (char*)"SSL Verify failed" );
+ EvntDataAdd( form, WM_REDRAW, cert_info_draw, (void*)&dp, EV_BOT );
+ /* this results in some extended objects which can not be freed: :( */
+ /* RsrcUserDraw( OC_FORM, tree, VERIFY_BOX_DETAILS, cert_info_draw,(void*)&dp ) ; */
+ ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp );
+ /*
+ ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp );
+ ObjcAttachFormFunc( form, VERIFY_BT_NEXT_CERT, do_popup, &dp );
+ */
+ while( cont ) {
+ res = FormWindDo( MU_MESAG );
+ cont = false;
+ switch( res ){
+ case VERIFY_BT_ACCEPT:
+ bres = true;
+ break;
+
+ case VERIFY_BT_NEXT_CERT:
+ /* select box clicked or dragged... */
+ cont = true;
+ break;
+
+ case VERIFY_BT_REJECT:
+ bres = false;
+ break;
+
+ case VERIFY_BT_SCROLL_D:
+ cont = true;
+ dp.scrolly += 1;
+ ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
+ break;
+
+ case VERIFY_BT_SCROLL_U:
+ cont = true;
+ dp.scrolly -= 1;
+ ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
+ break;
+
+ case VERIFY_BT_SCROLL_R:
+ LOG(( "scroll r!" ));
+ cont = true;
+ dp.scrollx += 1;
+ if( dp.scrollx > (dp.cols - (272 / 8 )) )
+ dp.scrollx -= 1;
+ ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG);
+ break;
+
+ case VERIFY_BT_SCROLL_L:
+ cont = true;
+ dp.scrollx -= 1;
+ if( dp.scrollx < 0 )
+ dp.scrollx = 0;
+ ObjcDrawParent( OC_FORM, form, VERIFY_BOX_DETAILS, 1, 7 | OC_MSG );
+ break;
+
+ default:
+ break;
+ }
+ }
+ FormWindEnd( );
+ return( bres );
+}