summaryrefslogtreecommitdiff
path: root/beos
diff options
context:
space:
mode:
authorFran├žois Revel <mmu_man@netsurf-browser.org>2010-08-02 23:35:35 +0000
committerFran├žois Revel <mmu_man@netsurf-browser.org>2010-08-02 23:35:35 +0000
commit982dc9e128a773b9db6fae60181db32b03a4b647 (patch)
treecaad3d2162f65a2fc771a5cdd784badcb4bf7359 /beos
parent59f13bbf24d5cae3d00ca3c1bc7d9cbd6f501e4f (diff)
downloadnetsurf-982dc9e128a773b9db6fae60181db32b03a4b647.tar.gz
netsurf-982dc9e128a773b9db6fae60181db32b03a4b647.tar.bz2
Fix BeOS build:
- struct content -> hlcache_handle - login window (though it won't work yet as the message isn't handled, and since we don't have the window pointer anymore we can't add the alert as subset of the window...), - rsrc fetcher, - netsurf_init() args (but the replicant is still broken due to this), - export the realpath() hack as it's needed elsewhere too. svn path=/trunk/netsurf/; revision=10677
Diffstat (limited to 'beos')
-rw-r--r--beos/beos_fetch_rsrc.cpp15
-rw-r--r--beos/beos_gui.cpp51
-rw-r--r--beos/beos_gui.h4
-rw-r--r--beos/beos_login.cpp51
-rw-r--r--beos/beos_scaffolding.cpp9
-rw-r--r--beos/beos_thumbnail.cpp22
-rw-r--r--beos/beos_window.cpp14
7 files changed, 96 insertions, 70 deletions
diff --git a/beos/beos_fetch_rsrc.cpp b/beos/beos_fetch_rsrc.cpp
index 6d7ea4257..24126a271 100644
--- a/beos/beos_fetch_rsrc.cpp
+++ b/beos/beos_fetch_rsrc.cpp
@@ -80,7 +80,7 @@ static void fetch_rsrc_finalise(const char *scheme)
static void *fetch_rsrc_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct fetch_multipart_data *post_multipart,
+ const struct fetch_multipart_data *post_multipart,
const char **headers)
{
struct fetch_rsrc_context *ctx;
@@ -241,20 +241,9 @@ static bool fetch_rsrc_process(struct fetch_rsrc_context *c)
static void fetch_rsrc_poll(const char *scheme)
{
struct fetch_rsrc_context *c, *next;
- struct cache_data cachedata;
if (ring == NULL) return;
- cachedata.req_time = time(NULL);
- cachedata.res_time = time(NULL);
- cachedata.date = 0;
- cachedata.expires = 0;
- cachedata.age = INVALID_AGE;
- cachedata.max_age = 0;
- cachedata.no_cache = true;
- cachedata.etag = NULL;
- cachedata.last_modified = 0;
-
/* Iterate over ring, processing each pending fetch */
c = ring;
do {
@@ -299,7 +288,7 @@ static void fetch_rsrc_poll(const char *scheme)
}
if (!c->aborted) {
fetch_rsrc_send_callback(FETCH_FINISHED,
- c, &cachedata, 0, FETCH_ERROR_NO_ERROR);
+ c, 0, 0, FETCH_ERROR_NO_ERROR);
}
} else {
LOG(("Processing of %s failed!", c->url));
diff --git a/beos/beos_gui.cpp b/beos/beos_gui.cpp
index b0f23b61b..768ae7680 100644
--- a/beos/beos_gui.cpp
+++ b/beos/beos_gui.cpp
@@ -45,6 +45,7 @@ extern "C" {
#include <hubbub/hubbub.h>
#include "content/content.h"
+#include "content/content_protected.h"
#include "content/fetch.h"
#include "content/fetchers/fetch_curl.h"
#include "content/urldb.h"
@@ -82,6 +83,7 @@ extern "C" {
static void *myrealloc(void *ptr, size_t len, void *pw);
+void gui_init(int argc, char** argv);
/* Where to search for shared resources. Must have trailing / */
@@ -121,7 +123,7 @@ static int sEventPipe[2];
#if 0 /* GTK */
static void nsbeos_create_ssl_verify_window(struct browser_window *bw,
- struct content *c, const struct ssl_cert_info *certs,
+ hlcache_handle *c, const struct ssl_cert_info *certs,
unsigned long num);
static void nsbeos_ssl_accept(BButton *w, gpointer data);
static void nsbeos_ssl_reject(BButton *w, gpointer data);
@@ -226,6 +228,7 @@ NSBrowserApplication::QuitRequested()
// XXX doesn't work
+#if 0
static char *generate_default_css()
{
BString text;
@@ -276,9 +279,11 @@ static char *generate_default_css()
return strdup(url);
}
+#endif
/* realpath fallback on R5 */
#if !defined(__HAIKU__) && !defined(B_BEOS_VERSION_DANO)
+extern "C" char *realpath(const char *f, char *buf);
char *realpath(const char *f, char *buf)
{
BPath path(f, NULL, true);
@@ -441,12 +446,23 @@ static void gui_init2(int argc, char** argv)
/** Normal entry point from OS */
int main(int argc, char** argv)
{
+ char buf[PATH_MAX];
setbuf(stderr, NULL);
+ BPath options;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) {
+ options.Append("x-vnd.NetSurf");
+ }
+
+ find_resource(buf, "messages", "./beos/res/messages");
+ LOG(("Using '%s' as Messages file", buf));
+ //messages_load(buf);
+
/* initialise netsurf */
- netsurf_init(argc, argv);
+ netsurf_init(&argc, &argv, options.Path(), buf);
- gui_init2(argc, argv);
+ gui_init(argc, argv);
+ gui_init2(argc, argv);
netsurf_main_loop();
@@ -585,10 +601,6 @@ void gui_init(int argc, char** argv)
option_ca_path = strdup(buf);
}
- find_resource(buf, "messages", "./beos/res/messages");
- LOG(("Using '%s' as Messages file", buf));
- messages_load(buf);
-
//find_resource(buf, "mime.types", "/etc/mime.types");
beos_fetch_filetype_init();
@@ -863,20 +875,22 @@ gui_window_save_link(struct gui_window *g, const char *url, const char *title)
* Send the source of a content to a text editor.
*/
-void nsbeos_gui_view_source(struct content *content, struct selection *selection)
+void nsbeos_gui_view_source(struct hlcache_handle *content, struct selection *selection)
{
char *temp_name;
bool done = false;
BPath path;
status_t err;
+ size_t size;
+ const char *source = content_get_source_data(content, &size);
- if (!content || !content->source_data) {
+ if (!content || !source) {
warn_user("MiscError", "No document source");
return;
}
/* try to load local files directly. */
- temp_name = url_to_path(content->url);
+ temp_name = url_to_path(content_get_url(content));
if (temp_name) {
path.SetTo(temp_name);
BEntry entry;
@@ -904,12 +918,12 @@ void nsbeos_gui_view_source(struct content *content, struct selection *selection
warn_user("IOError", strerror(err));
return;
}
- err = file.Write(content->source_data, content->source_size);
+ err = file.Write(source, size);
if (err < B_OK) {
warn_user("IOError", strerror(err));
return;
}
- const char *mime = content->mime_type;
+ const char *mime = content_get_mime_type(content);
if (mime)
file.WriteAttr("BEOS:TYPE", B_MIME_STRING_TYPE, 0LL,
mime, strlen(mime) + 1);
@@ -926,10 +940,10 @@ void nsbeos_gui_view_source(struct content *content, struct selection *selection
#if 0
if (selection && selection->defined) {
int32 line = -1;
- if (content->type == CONTENT_HTML) {
+ if (content_get_type(content) == CONTENT_HTML) {
// XXX: use selection, find line in source code
}
- if (content->type == CONTENT_TEXTPLAIN) {
+ if (content_get_type(content) == CONTENT_TEXTPLAIN) {
line = MAKELINE_FROM_IDX(start_idx);
}
// not CSS!
@@ -1046,12 +1060,13 @@ void die(const char * const error)
}
-void hotlist_visited(struct content *content)
+void hotlist_visited(hlcache_handle *content)
{
}
-void gui_cert_verify(struct browser_window *bw, struct content *c,
- const struct ssl_cert_info *certs, unsigned long num)
+void gui_cert_verify(const char *url, const struct ssl_cert_info *certs,
+ unsigned long num, nserror (*cb)(bool proceed, void *pw),
+ void *cbpw)
{
CALLED();
#if 0 /* GTK */
@@ -1060,7 +1075,7 @@ void gui_cert_verify(struct browser_window *bw, struct content *c,
}
static void nsbeos_create_ssl_verify_window(struct browser_window *bw,
- struct content *c, const struct ssl_cert_info *certs,
+ hlcache_handle *c, const struct ssl_cert_info *certs,
unsigned long num)
{
CALLED();
diff --git a/beos/beos_gui.h b/beos/beos_gui.h
index 037f9cc79..0efb8e7a0 100644
--- a/beos/beos_gui.h
+++ b/beos/beos_gui.h
@@ -47,6 +47,7 @@ virtual bool QuitRequested();
};
+extern void schedule_run(void);
extern BWindow *wndAbout;
@@ -60,5 +61,6 @@ extern BFilePanel *wndOpenFile;
void nsbeos_pipe_message(BMessage *message, BView *_this, struct gui_window *gui);
void nsbeos_pipe_message_top(BMessage *message, BWindow *_this, struct beos_scaffolding *scaffold);
-void nsbeos_gui_view_source(struct content *content, struct selection *selection);
+void nsbeos_gui_view_source(struct hlcache_handle *content, struct selection *selection);
image_id nsbeos_find_app_path(char *path);
+
diff --git a/beos/beos_login.cpp b/beos/beos_login.cpp
index 2469f3c36..c732cd398 100644
--- a/beos/beos_login.cpp
+++ b/beos/beos_login.cpp
@@ -43,10 +43,11 @@ extern "C" {
class LoginAlert : public BAlert {
public:
- LoginAlert(struct browser_window *bw,
- const char *url,
- const char *host,
- const char *realm,
+ LoginAlert(nserror (*callback)(bool proceed, void *pw),
+ void *callbaclpw,
+ const char *url,
+ const char *host,
+ const char *realm,
const char *text);
virtual ~LoginAlert();
void MessageReceived(BMessage *message);
@@ -55,20 +56,23 @@ private:
BString fUrl; /**< URL being fetched */
BString fHost; /**< Host for user display */
BString fRealm; /**< Authentication realm */
- struct gui_window *fW; /**< GUI window handle */
+ nserror (*fCallback)(bool proceed, void *pw);
+ void *fCallbackPw;
BTextControl *fUserControl;
BTextControl *fPassControl;
};
-static void create_login_window(struct browser_window *bw, const char *host,
- const char *realm, const char *fetchurl);
+static void create_login_window(const char *host,
+ const char *realm, const char *fetchurl,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw);
#define TC_H 25
#define TC_MARGIN 10
-LoginAlert::LoginAlert(struct browser_window *bw,
+LoginAlert::LoginAlert(nserror (*callback)(bool proceed, void *pw),
+ void *callbackpw,
const char *url,
const char *host,
const char *realm,
@@ -76,20 +80,21 @@ LoginAlert::LoginAlert(struct browser_window *bw,
: BAlert("Login", text, "Cancel", "Ok", NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT)
{
+ fCallback = callback;
+ fCallbackPw = callbackpw;
fUrl = url;
fHost = host;
fRealm = realm;
- // dereference now as we can't be sure
- // the main thread won't delete from under our feet
- fW = bw->window;
SetFeel(B_MODAL_SUBSET_WINDOW_FEEL);
+ /*
+ // XXX: can't do that anymore
nsbeos_scaffolding *s = nsbeos_get_scaffold(bw->window);
if (s) {
NSBrowserWindow *w = nsbeos_get_bwindow_for_scaffolding(s);
if (w)
AddToSubset(w);
- }
+ }*/
// make space for controls
ResizeBy(0, 2 * TC_H);
@@ -138,7 +143,8 @@ LoginAlert::MessageReceived(BMessage *message)
m->AddString("URL", fUrl.String());
m->AddString("Host", fHost.String());
m->AddString("Realm", fRealm.String());
- m->AddPointer("gui_window", fW);
+ m->AddPointer("callback", (void *)fCallback);
+ m->AddPointer("callback_pw", (void *)fCallbackPw);
m->AddString("User", fUserControl->Text());
m->AddString("Pass", fPassControl->Text());
BString auth(fUserControl->Text());
@@ -147,7 +153,7 @@ LoginAlert::MessageReceived(BMessage *message)
// notify the main thread
// the event dispatcher will handle it
- nsbeos_pipe_message(m, NULL, fW);
+ nsbeos_pipe_message(m, NULL, NULL);
}
break;
default:
@@ -157,22 +163,25 @@ LoginAlert::MessageReceived(BMessage *message)
}
-void gui_401login_open(struct browser_window *bw, struct content *c,
- const char *realm)
+void gui_401login_open(const char *url, const char *realm,
+ nserror (*cb)(bool proceed, void *pw), void *cbpw)
{
char *host;
url_func_result res;
- res = url_host(c->url, &host);
+ res = url_host(url, &host);
assert(res == URL_FUNC_OK);
- create_login_window(bw, host, realm, c->url);
+ create_login_window(url, host, realm, cb, cbpw);
free(host);
}
-void create_login_window(struct browser_window *bw, const char *host,
- const char *realm, const char *fetchurl)
+//void create_login_window(struct browser_window *bw, const char *host,
+// const char *realm, const char *fetchurl)
+static void create_login_window(const char *url, const char *host,
+ const char *realm, nserror (*cb)(bool proceed, void *pw),
+ void *cbpw)
{
BString r("Secure Area");
if (realm)
@@ -182,7 +191,7 @@ void create_login_window(struct browser_window *bw, const char *host,
text << "Host: " << host << "\n";
//text << "\n";
- LoginAlert *a = new LoginAlert(bw, fetchurl, host, r.String(),
+ LoginAlert *a = new LoginAlert(cb, cbpw, url, host, r.String(),
text.String());
// asynchronously
a->Go(NULL);
diff --git a/beos/beos_scaffolding.cpp b/beos/beos_scaffolding.cpp
index 7b12d433e..a5cc832a7 100644
--- a/beos/beos_scaffolding.cpp
+++ b/beos/beos_scaffolding.cpp
@@ -498,7 +498,10 @@ NSBaseView::Instantiate(BMessage *archive)
replicant_view = view;
replicated = true;
- netsurf_init(2, info->args);
+ //TODO:FIXME: fix replicants
+ // netsurf_init() needs different args now...
+ //netsurf_init(2, info->args);
+ return NULL;
replicant_done_sem = create_sem(0, "NS Replicant created");
thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread,
@@ -2314,7 +2317,7 @@ void gui_window_stop_throbber(struct gui_window* _g)
/**
* add retrieved favicon to the gui
*/
-void gui_window_set_icon(struct gui_window *g, struct content *icon)
+void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
{
}
@@ -2323,7 +2326,7 @@ void gui_window_set_icon(struct gui_window *g, struct content *icon)
* \param ico may be NULL for local calls; then access current cache from
* search_web_ico()
*/
-void gui_window_set_search_ico(struct content *ico)
+void gui_window_set_search_ico(hlcache_handle *ico)
{
}
diff --git a/beos/beos_thumbnail.cpp b/beos/beos_thumbnail.cpp
index 7888999dc..65c6636d3 100644
--- a/beos/beos_thumbnail.cpp
+++ b/beos/beos_thumbnail.cpp
@@ -54,7 +54,7 @@ extern status_t ScaleBitmap(const BBitmap& inBitmap, BBitmap& outBitmap);
* \param bitmap the bitmap to draw to
* \param url the URL the thumnail belongs to, or NULL
*/
-bool thumbnail_create(struct content *content, struct bitmap *bitmap,
+bool thumbnail_create(hlcache_handle *content, struct bitmap *bitmap,
const char *url)
{
BBitmap *thumbnail;
@@ -78,9 +78,11 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap,
LOG(("Trying to create a thumbnail bitmap %d x %d for a content of %d x %d @ %d",
width, height,
- content->width, content->width, depth));
+ content_get_width(content), content_get_width(content), depth));
- BRect contentRect(0, 0, content->width - 1, content->width - 1);
+ BRect contentRect(0, 0,
+ content_get_width(content) - 1,
+ content_get_width(content) - 1);
big = new BBitmap(contentRect,
B_BITMAP_ACCEPTS_VIEWS, B_RGB32);
@@ -118,12 +120,18 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap,
plot = nsbeos_plotters;
nsbeos_plot_set_scale(1.0);
- plot.rectangle(0, 0, content->width, content->width, plot_style_fill_white);
+ plot.rectangle(0, 0,
+ content_get_width(content),
+ content_get_width(content),
+ plot_style_fill_white);
/* render the content */
- content_redraw(content, 0, 0, content->width, content->width,
- 0, 0, content->width, content->width, 1.0, 0xFFFFFF);
-
+ content_redraw(content, 0, 0,
+ content_get_width(content), content_get_width(content),
+ 0, 0,
+ content_get_width(content), content_get_width(content),
+ 1.0, 0xFFFFFF);
+
view->Sync();
view->UnlockLooper();
diff --git a/beos/beos_window.cpp b/beos/beos_window.cpp
index 8708cd2bd..c45b221f6 100644
--- a/beos/beos_window.cpp
+++ b/beos/beos_window.cpp
@@ -911,7 +911,7 @@ void nsbeos_dispatch_event(BMessage *message)
void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message)
{
BRect updateRect;
- struct content *c;
+ hlcache_handle *c;
float scale = g->bw->scale;
assert(g);
@@ -935,7 +935,7 @@ void nsbeos_window_expose_event(BView *view, gui_window *g, BMessage *message)
return;
/* HTML rendering handles scale itself */
- if (c->type == CONTENT_HTML)
+ if (content_get_type(c) == CONTENT_HTML)
scale = 1;
if (!view->LockLooper())
@@ -1196,7 +1196,7 @@ void nsbeos_window_resize_event(BView *view, gui_window *g, BMessage *event)
#if 0
- struct content *content;
+ hlcache_handle *content;
content = g->bw->current_content;
@@ -1393,7 +1393,7 @@ void gui_window_redraw_window(struct gui_window *g)
void gui_window_update_box(struct gui_window *g,
const union content_msg_data *data)
{
- struct content *c = g->bw->current_content;
+ hlcache_handle *c = g->bw->current_content;
if (c == NULL)
return;
@@ -1509,8 +1509,8 @@ void gui_window_update_extent(struct gui_window *g)
if (!g->view->LockLooper())
return;
- float x_max = g->bw->current_content->width * g->bw->scale /* - 1*/;
- float y_max = g->bw->current_content->height * g->bw->scale /* - 1*/;
+ float x_max = content_get_width(g->bw->current_content) * g->bw->scale /* - 1*/;
+ float y_max = content_get_height(g->bw->current_content) * g->bw->scale /* - 1*/;
float x_prop = g->view->Bounds().Width() / x_max;
float y_prop = g->view->Bounds().Height() / y_max;
x_max -= g->view->Bounds().Width() + 1;
@@ -1756,7 +1756,7 @@ bool gui_window_box_scroll_start(struct gui_window *g,
return true;
}
-void gui_drag_save_object(gui_save_type type, struct content *c,
+void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
struct gui_window *g)
{