mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-25 15:59:36 +03:00
Content messages: Remove ERRORCODE, rework ERROR
This reworks CONTENT_MSG_ERROR to be structured data and removes the CONTENT_MSG_ERRORCODE message kind. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
parent
2171f13ab3
commit
6ba199c7d7
@ -173,7 +173,8 @@ nserror content_llcache_callback(llcache_handle *llcache,
|
||||
case LLCACHE_EVENT_ERROR:
|
||||
/** \todo Error page? */
|
||||
c->status = CONTENT_STATUS_ERROR;
|
||||
msg_data.error = event->data.msg;
|
||||
msg_data.errordata.errorcode = NSERROR_UNKNOWN;
|
||||
msg_data.errordata.errormsg = event->data.msg;
|
||||
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
|
||||
break;
|
||||
case LLCACHE_EVENT_PROGRESS:
|
||||
@ -816,12 +817,13 @@ void content_broadcast_errorcode(struct content *c, nserror errorcode)
|
||||
|
||||
assert(c);
|
||||
|
||||
data.errorcode = errorcode;
|
||||
data.errordata.errorcode = errorcode;
|
||||
data.errordata.errormsg = NULL;
|
||||
|
||||
for (user = c->user_list->next; user != 0; user = next) {
|
||||
next = user->next; /* user may be destroyed during callback */
|
||||
if (user->callback != 0) {
|
||||
user->callback(c, CONTENT_MSG_ERRORCODE,
|
||||
user->callback(c, CONTENT_MSG_ERROR,
|
||||
&data, user->pw);
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ typedef enum {
|
||||
CONTENT_MSG_READY, /**< may be displayed */
|
||||
CONTENT_MSG_DONE, /**< finished */
|
||||
CONTENT_MSG_ERROR, /**< error occurred */
|
||||
CONTENT_MSG_ERRORCODE, /**< error occurred return nserror */
|
||||
CONTENT_MSG_REDIRECT, /**< fetch url redirect occured */
|
||||
CONTENT_MSG_STATUS, /**< new status string */
|
||||
CONTENT_MSG_REFORMAT, /**< content_reformat done */
|
||||
@ -112,10 +111,17 @@ union content_msg_data {
|
||||
const struct llcache_query_msg *query_msg;
|
||||
/** CONTENT_MSG_QUERY_FINISHED - Query from underlying object finished */
|
||||
void *query_finished_pw;
|
||||
/** CONTENT_MSG_ERROR - Error message */
|
||||
const char *error;
|
||||
/** CONTENT_MSG_ERRORCODE - Error code */
|
||||
nserror errorcode;
|
||||
/** CONTENT_MSG_ERROR - Error from content or underlying fetch */
|
||||
struct {
|
||||
nserror errorcode; /**< The error code to convey meaning */
|
||||
const char *errormsg; /**< The message.
|
||||
* if NSERROR_UNKNOWN then this is the
|
||||
* direct message, otherwise is some
|
||||
* kind of metadata (e.g. a message name
|
||||
* or somesuch) but always a nul
|
||||
* terminated string.
|
||||
*/
|
||||
} errordata;
|
||||
/** CONTENT_MSG_REDIRECT - Redirect info */
|
||||
struct {
|
||||
struct nsurl *from; /**< Redirect origin */
|
||||
|
@ -634,7 +634,6 @@ nserror nscss_import(hlcache_handle *handle,
|
||||
error = nscss_import_complete(ctx);
|
||||
break;
|
||||
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
case CONTENT_MSG_ERROR:
|
||||
hlcache_handle_release(handle);
|
||||
ctx->css->imports[ctx->index].c = NULL;
|
||||
|
@ -116,10 +116,8 @@ html_convert_css_callback(hlcache_handle *css,
|
||||
case CONTENT_MSG_ERROR:
|
||||
NSLOG(netsurf, INFO, "stylesheet %s failed: %s",
|
||||
nsurl_access(hlcache_handle_get_url(css)),
|
||||
event->data.error);
|
||||
/* fall through */
|
||||
event->data.errordata.errormsg);
|
||||
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
hlcache_handle_release(css);
|
||||
s->sheet = NULL;
|
||||
parent->base.active--;
|
||||
|
@ -137,9 +137,7 @@ html_object_callback(hlcache_handle *object,
|
||||
struct box *box;
|
||||
|
||||
box = o->box;
|
||||
if (box == NULL &&
|
||||
event->type != CONTENT_MSG_ERROR &&
|
||||
event->type != CONTENT_MSG_ERRORCODE) {
|
||||
if (box == NULL && event->type != CONTENT_MSG_ERROR) {
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
@ -195,7 +193,6 @@ html_object_callback(hlcache_handle *object,
|
||||
}
|
||||
break;
|
||||
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
case CONTENT_MSG_ERROR:
|
||||
hlcache_handle_release(object);
|
||||
|
||||
@ -472,8 +469,7 @@ html_object_callback(hlcache_handle *object,
|
||||
c->base.active == 0 &&
|
||||
(event->type == CONTENT_MSG_LOADING ||
|
||||
event->type == CONTENT_MSG_DONE ||
|
||||
event->type == CONTENT_MSG_ERROR ||
|
||||
event->type == CONTENT_MSG_ERRORCODE)) {
|
||||
event->type == CONTENT_MSG_ERROR)) {
|
||||
/* all objects have arrived */
|
||||
content__reformat(&c->base, false, c->base.available_width,
|
||||
c->base.available_height);
|
||||
|
@ -183,10 +183,8 @@ convert_script_async_cb(hlcache_handle *script,
|
||||
case CONTENT_MSG_ERROR:
|
||||
NSLOG(netsurf, INFO, "script %s failed: %s",
|
||||
nsurl_access(hlcache_handle_get_url(script)),
|
||||
event->data.error);
|
||||
/* fall through */
|
||||
event->data.errordata.errormsg);
|
||||
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
hlcache_handle_release(script);
|
||||
s->data.handle = NULL;
|
||||
parent->base.active--;
|
||||
@ -259,10 +257,8 @@ convert_script_defer_cb(hlcache_handle *script,
|
||||
case CONTENT_MSG_ERROR:
|
||||
NSLOG(netsurf, INFO, "script %s failed: %s",
|
||||
nsurl_access(hlcache_handle_get_url(script)),
|
||||
event->data.error);
|
||||
/* fall through */
|
||||
event->data.errordata.errormsg);
|
||||
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
hlcache_handle_release(script);
|
||||
s->data.handle = NULL;
|
||||
parent->base.active--;
|
||||
@ -350,10 +346,8 @@ convert_script_sync_cb(hlcache_handle *script,
|
||||
case CONTENT_MSG_ERROR:
|
||||
NSLOG(netsurf, INFO, "script %s failed: %s",
|
||||
nsurl_access(hlcache_handle_get_url(script)),
|
||||
event->data.error);
|
||||
/* fall through */
|
||||
event->data.errordata.errormsg);
|
||||
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
hlcache_handle_release(script);
|
||||
s->data.handle = NULL;
|
||||
parent->base.active--;
|
||||
|
@ -329,7 +329,8 @@ static bool nsjpeg_convert(struct content *c)
|
||||
if (setjmp(setjmp_buffer)) {
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
|
||||
msg_data.error = nsjpeg_error_buffer;
|
||||
msg_data.errordata.errorcode = NSERROR_UNKNOWN;
|
||||
msg_data.errordata.errormsg = nsjpeg_error_buffer;
|
||||
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
|
||||
return false;
|
||||
}
|
||||
|
@ -361,7 +361,8 @@ static nserror hlcache_migrate_ctx(hlcache_retrieval_ctx *ctx,
|
||||
hlcache_event hlevent;
|
||||
|
||||
hlevent.type = CONTENT_MSG_ERROR;
|
||||
hlevent.data.error = messages_get("MiscError");
|
||||
hlevent.data.errordata.errorcode = NSERROR_UNKNOWN;
|
||||
hlevent.data.errordata.errormsg = messages_get("MiscError");
|
||||
|
||||
ctx->handle->cb(ctx->handle, &hlevent,
|
||||
ctx->handle->pw);
|
||||
@ -393,7 +394,8 @@ static nserror hlcache_migrate_ctx(hlcache_retrieval_ctx *ctx,
|
||||
hlcache_event hlevent;
|
||||
|
||||
hlevent.type = CONTENT_MSG_ERROR;
|
||||
hlevent.data.error = messages_get("UnacceptableType");
|
||||
hlevent.data.errordata.errorcode = NSERROR_UNKNOWN;
|
||||
hlevent.data.errordata.errormsg = messages_get("UnacceptableType");
|
||||
|
||||
ctx->handle->cb(ctx->handle, &hlevent,
|
||||
ctx->handle->pw);
|
||||
@ -489,8 +491,9 @@ static nserror hlcache_llcache_callback(llcache_handle *handle,
|
||||
if (ctx->handle->cb != NULL) {
|
||||
hlcache_event hlevent;
|
||||
|
||||
hlevent.type = CONTENT_MSG_ERRORCODE;
|
||||
hlevent.data.errorcode = error;
|
||||
hlevent.type = CONTENT_MSG_ERROR;
|
||||
hlevent.data.errordata.errorcode = error;
|
||||
hlevent.data.errordata.errormsg = NULL;
|
||||
|
||||
ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
|
||||
}
|
||||
@ -500,7 +503,8 @@ static nserror hlcache_llcache_callback(llcache_handle *handle,
|
||||
hlcache_event hlevent;
|
||||
|
||||
hlevent.type = CONTENT_MSG_ERROR;
|
||||
hlevent.data.error = event->data.msg;
|
||||
hlevent.data.errordata.errorcode = NSERROR_UNKNOWN;
|
||||
hlevent.data.errordata.errormsg = event->data.msg;
|
||||
|
||||
ctx->handle->cb(ctx->handle, &hlevent, ctx->handle->pw);
|
||||
}
|
||||
|
@ -410,7 +410,6 @@ browser_window_favicon_callback(hlcache_handle *c,
|
||||
break;
|
||||
|
||||
case CONTENT_MSG_ERROR:
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
|
||||
/* clean up after ourselves */
|
||||
if (c == bw->favicon.loading) {
|
||||
@ -556,38 +555,6 @@ browser_window_update_favicon(hlcache_handle *c,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* window callback errorcode handling.
|
||||
*/
|
||||
static void
|
||||
browser_window_callback_errorcode(hlcache_handle *c,
|
||||
struct browser_window *bw,
|
||||
nserror code)
|
||||
{
|
||||
const char* message;
|
||||
|
||||
message = messages_get_errorcode(code);
|
||||
|
||||
browser_window_set_status(bw, message);
|
||||
|
||||
/* Only warn the user about errors in top-level windows */
|
||||
if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
|
||||
guit->misc->warning(message, NULL);
|
||||
}
|
||||
|
||||
if (c == bw->loading_content) {
|
||||
bw->loading_content = NULL;
|
||||
} else if (c == bw->current_content) {
|
||||
bw->current_content = NULL;
|
||||
browser_window_remove_caret(bw, false);
|
||||
}
|
||||
|
||||
hlcache_handle_release(c);
|
||||
|
||||
browser_window_stop_throbber(bw);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle meta http-equiv refresh time elapsing by loading a new page.
|
||||
*
|
||||
@ -867,16 +834,16 @@ browser_window_callback(hlcache_handle *c, const hlcache_event *event, void *pw)
|
||||
res = browser_window_content_done(bw);
|
||||
break;
|
||||
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
browser_window_callback_errorcode(c, bw, event->data.errorcode);
|
||||
break;
|
||||
|
||||
case CONTENT_MSG_ERROR:
|
||||
browser_window_set_status(bw, event->data.error);
|
||||
case CONTENT_MSG_ERROR: {
|
||||
const char *message = event->data.errordata.errormsg;
|
||||
if (event->data.errordata.errorcode != NSERROR_UNKNOWN) {
|
||||
message = messages_get_errorcode(event->data.errordata.errorcode);
|
||||
}
|
||||
|
||||
browser_window_set_status(bw, message);
|
||||
/* Only warn the user about errors in top-level windows */
|
||||
if (bw->browser_window_type == BROWSER_WINDOW_NORMAL) {
|
||||
guit->misc->warning(event->data.error, NULL);
|
||||
guit->misc->warning(message, NULL);
|
||||
}
|
||||
|
||||
if (c == bw->loading_content) {
|
||||
@ -890,7 +857,7 @@ browser_window_callback(hlcache_handle *c, const hlcache_event *event, void *pw)
|
||||
|
||||
browser_window_stop_throbber(bw);
|
||||
break;
|
||||
|
||||
}
|
||||
case CONTENT_MSG_REDIRECT:
|
||||
if (urldb_add_url(event->data.redirect.from))
|
||||
urldb_update_url_visit_data(event->data.redirect.from);
|
||||
|
@ -298,10 +298,8 @@ search_web_ico_callback(hlcache_handle *ico,
|
||||
case CONTENT_MSG_ERROR:
|
||||
NSLOG(netsurf, INFO, "icon %s error: %s",
|
||||
nsurl_access(hlcache_handle_get_url(ico)),
|
||||
event->data.error);
|
||||
/* fall through */
|
||||
event->data.errordata.errormsg);
|
||||
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
hlcache_handle_release(ico);
|
||||
/* clear reference to released handle */
|
||||
provider->ico_handle = NULL;
|
||||
@ -468,10 +466,8 @@ default_ico_callback(hlcache_handle *ico,
|
||||
case CONTENT_MSG_ERROR:
|
||||
NSLOG(netsurf, INFO, "icon %s error: %s",
|
||||
nsurl_access(hlcache_handle_get_url(ico)),
|
||||
event->data.error);
|
||||
/* fall through */
|
||||
event->data.errordata.errormsg);
|
||||
|
||||
case CONTENT_MSG_ERRORCODE:
|
||||
hlcache_handle_release(ico);
|
||||
/* clear reference to released handle */
|
||||
ctx->default_ico_handle = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user