From 59a1594f21113e4627de7087335fae2d0f1d9ff8 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Mon, 6 Jan 2003 00:04:43 +0000 Subject: [project @ 2003-01-06 00:04:43 by bursa] Remove special case code for file: urls. svn path=/import/netsurf/; revision=85 --- desktop/fetch.c | 160 +++++++++++--------------------------------------------- desktop/fetch.h | 4 +- riscos/gui.c | 52 +++++++++--------- 3 files changed, 58 insertions(+), 158 deletions(-) diff --git a/desktop/fetch.c b/desktop/fetch.c index f6721ade3..3ff8dd09c 100644 --- a/desktop/fetch.c +++ b/desktop/fetch.c @@ -1,5 +1,5 @@ /** - * $Id: fetch.c,v 1.6 2003/01/04 18:51:41 andrew Exp $ + * $Id: fetch.c,v 1.7 2003/01/06 00:04:43 bursa Exp $ */ #include "libxml/HTMLparser.h" @@ -9,30 +9,21 @@ #include "netsurf/desktop/netsurf.h" #include "netsurf/desktop/fetch.h" #include "netsurf/render/utils.h" +#include "netsurf/utils/log.h" #include "curl/curl.h" #include #include #include -void fetch_identify_location(struct fetch* f, char* location, char* previous) -{ - if (f->location != NULL) - xfree(f->location); - - f->location = xstrdup(location); - - if (strspn(location, "file:/") == strlen("file:/")) - f->type = fetch_FILE; - else - /* throw everything else at curl, since it can fetch lots of protocols */ - f->type = fetch_CURL; -} - struct fetch* create_fetch(char* location, char* previous, fetch_flags f, struct fetch_request* r) { struct fetch* fetch = (struct fetch*) xcalloc(1, sizeof(struct fetch)); - fetch_identify_location(fetch, location, previous); + if (fetch->location != NULL) + free(fetch->location); + + fetch->location = xstrdup(location); + fetch->type = fetch_CURL; fetch->flags = f; @@ -125,7 +116,7 @@ size_t fetch_curl_data(void * data, size_t size, size_t nmemb, struct fetch* f) msg.f = f; msg.data.fetch_data.block = data; msg.data.fetch_data.block_size = size * nmemb; - Log("fetch_poll","sending curl's FETCH_DATA to browser"); + LOG(("sending curl's FETCH_DATA to browser")); browser_window_message(f->request->requestor.browser, &msg); return size * nmemb; } @@ -134,20 +125,20 @@ struct fetch* fetch_poll(struct fetch* f) { struct fetch* ret = f; - Log("fetch_poll","polling..."); +/* LOG(("polling...")); */ if (f == NULL) { - Log("fetch_poll","null fetch; returning"); +/* LOG(("null fetch; returning")); */ return f; } - if (f->type == fetch_DELETED) + if (f->status == fetch_DELETED) { ret = f->next; - Log("fetch_poll", "deleting marked fetch"); + LOG(("deleting marked fetch")); fetch_destroy(f); - Log("fetch_poll", "moving on..."); + LOG(("moving on...")); return fetch_poll(ret); } else if (f->type == fetch_CURL && f->status == fetch_STATUS_WAIT) @@ -155,12 +146,12 @@ struct fetch* fetch_poll(struct fetch* f) struct browser_message msg; CURL* curl; - Log("fetch_poll","init curl"); + LOG(("init curl")); curl = curl_easy_init(); - Log("fetch_poll","init curl returned"); + LOG(("init curl returned")); if (curl != 0) { - Log("fetch_poll","init curl OK"); + LOG(("init curl OK")); /* shouldn't assume this! somehow work it out instead. */ msg.type = msg_FETCH_FETCH_INFO; msg.f = f; @@ -169,142 +160,51 @@ struct fetch* fetch_poll(struct fetch* f) if (browser_window_message(f->request->requestor.browser, &msg) == 0) { - Log("fetch_poll","about to set options"); + LOG(("about to set options")); curl_easy_setopt(curl, CURLOPT_URL, f->location); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fetch_curl_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, f); curl_easy_setopt(curl, CURLOPT_USERAGENT, "NetSurf/0.00 (alpha)"); - Log("fetch_poll","about to perform"); + LOG(("about to perform")); curl_easy_perform(curl); - Log("fetch_poll","about to cleanup"); + LOG(("about to cleanup")); curl_easy_cleanup(curl); - Log("fetch_poll","cleanup finished"); + LOG(("cleanup finished")); msg.type = msg_FETCH_FINISHED; msg.f = f; - Log("fetch_poll","sending FETCH_FINISHED to browser"); + LOG(("sending FETCH_FINISHED to browser")); browser_window_message(f->request->requestor.browser, &msg); - Log("fetch_poll","FETCH_FINISHED accepted"); + LOG(("FETCH_FINISHED accepted")); ret = f->next; - Log("fetch_poll","Destroying f"); + LOG(("Destroying f")); fetch_destroy(f); - Log("fetch_poll","Moving on..."); + LOG(("Moving on...")); return fetch_poll(ret); } - Log("fetch_poll","about to cleanup since requestor went funny"); + LOG(("about to cleanup since requestor went funny")); curl_easy_cleanup(curl); - Log("fetch_poll","Requesting browser didn't like something"); + LOG(("Requesting browser didn't like something")); ret = f->next; - Log("fetch_poll","Cancelling fetch"); + LOG(("Cancelling fetch")); f = fetch_cancel(f); return fetch_poll(ret); } - Log("fetch_poll","we are aborting the mission"); + LOG(("we are aborting the mission")); msg.type = msg_FETCH_ABORT; msg.f = f; browser_window_message(f->request->requestor.browser, &msg); - Log("fetch_poll","ABORT message sent to browser"); + LOG(("ABORT message sent to browser")); ret = f->next; fetch_destroy(f); return fetch_poll(ret); /* carry on polling */ } - else if (f->type == fetch_FILE && f->status == fetch_STATUS_WAIT) - { - struct browser_message msg; - char actual_filename[1024]; - FILE* in; - - gui_file_to_filename(f->location, actual_filename, 1024); -/* in = fopen("files","a"); - fprintf(in, "%s\n%s\n\n",f->location, actual_filename); - fclose(in);*/ - in = fopen(actual_filename, "r"); - - if (in == NULL) - { - /* can't open file -- send abort to requestor, then destroy */ - Log("fetch_poll","can't open file"); - msg.type = msg_FETCH_ABORT; - msg.f = f; - browser_window_message(f->request->requestor.browser, &msg); - Log("fetch_poll","ABORT message sent to browser"); - - ret = f->next; - fetch_destroy(f); - Log("fetch_poll","destroyed f; moving on"); - - return fetch_poll(ret); /* carry on polling */ - } - else - { - /* file opened successfully. now to send size and type to requestor, - then the data, then finish. */ - int size; - - /* calculate size */ - Log("fetch_poll","calculating file size"); - fseek(in, 0, SEEK_END); - size = (int) ftell(in); - fclose(in); - - /* send file info. (assuming HTML at the mo, but should work out - what it is, somehow) */ - msg.type = msg_FETCH_FETCH_INFO; - msg.f = f; - msg.data.fetch_info.type = type_HTML; - msg.data.fetch_info.total_size = size; - - Log("fetch_poll","sending FETCH_INFO to browser"); - if (browser_window_message(f->request->requestor.browser, &msg) == 0) - { - /* file info accepted. can now load the data and send it */ - Log("fetch_poll","FETCH_INFO accepted"); - f->status = fetch_STATUS_FETCH; - - /* load and send data */ - msg.type = msg_FETCH_DATA; - msg.f = f; - msg.data.fetch_data.block = load(actual_filename); - msg.data.fetch_data.block_size = size; - Log("fetch_poll","sending FETCH_DATA to browser"); - if (browser_window_message(f->request->requestor.browser, &msg) == 0) - { - xfree(msg.data.fetch_data.block); - /* data accepted. no more data, so finish */ - Log("fetch_poll","FETCH_DATA accepted"); - f->status = fetch_STATUS_FINISH; - - /* send finish */ - msg.type = msg_FETCH_FINISHED; - msg.f = f; - Log("fetch_poll","sending FETCH_FINISHED to browser"); - browser_window_message(f->request->requestor.browser, &msg); - Log("fetch_poll","FETCH_FINISHED accepted"); - - ret = f->next; - Log("fetch_poll","Destroying f"); - fetch_destroy(f); - Log("fetch_poll","Moving on..."); - return fetch_poll(ret); - /* destroy this fetch, then move on to next fetch to poll */ - } - xfree(msg.data.fetch_data.block); - } - - /* requestor didn't like something, and wants the fetch cancelled */ - Log("fetch_poll","Requesting browser didn't like something"); - ret = f->next; - Log("fetch_poll","Cancelling fetch"); - f = fetch_cancel(f); - return fetch_poll(ret); - } - } - Log("fetch_poll","Moving on (at end of function with f->next)"); + LOG(("Moving on (at end of function with f->next)")); f->next = fetch_poll(f->next); return f; } diff --git a/desktop/fetch.h b/desktop/fetch.h index c0c2c06ac..f9366c8fa 100644 --- a/desktop/fetch.h +++ b/desktop/fetch.h @@ -1,5 +1,5 @@ /** - * $Id: fetch.h,v 1.1 2002/09/11 14:24:02 monkeyson Exp $ + * $Id: fetch.h,v 1.2 2003/01/06 00:04:43 bursa Exp $ */ #ifndef _NETSURF_DESKTOP_FETCH_H_ @@ -11,7 +11,7 @@ #include "netsurf/desktop/browser.h" #include -typedef enum {fetch_FILE, fetch_CURL} fetch_type; +typedef enum {fetch_CURL} fetch_type; typedef enum {fetch_STATUS_SEND, fetch_STATUS_WAIT, fetch_STATUS_FETCH, fetch_STATUS_FINISH, fetch_DELETED} fetch_status; typedef int fetch_flags; diff --git a/riscos/gui.c b/riscos/gui.c index cf37e5798..5d9e09f34 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -1,5 +1,5 @@ /** - * $Id: gui.c,v 1.12 2002/12/30 22:56:30 monkeyson Exp $ + * $Id: gui.c,v 1.13 2003/01/06 00:04:43 bursa Exp $ */ #include "netsurf/riscos/font.h" @@ -15,7 +15,7 @@ int gadget_subtract_x; int gadget_subtract_y; #define browser_menu_flags (wimp_ICON_TEXT | wimp_ICON_FILLED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT)) -char* HOME_URL = "file://Resources/intro.html\0"; +char* HOME_URL = "file:////Resources/intro.html\0"; wimp_MENU(2) netsurf_iconbar_menu = { @@ -530,9 +530,9 @@ void ro_gui_window_redraw_box(gui_window* g, struct box * box, signed long x, si switch (box->gadget->type) { case GADGET_TEXTAREA: - icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | - wimp_ICON_VCENTRED | wimp_ICON_FILLED | - wimp_ICON_INDIRECTED | + icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | + wimp_ICON_VCENTRED | wimp_ICON_FILLED | + wimp_ICON_INDIRECTED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT); icon.data.indirected_text.text = box->gadget->data.textarea.text; @@ -544,9 +544,9 @@ void ro_gui_window_redraw_box(gui_window* g, struct box * box, signed long x, si case GADGET_TEXTBOX: - icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | - wimp_ICON_VCENTRED | wimp_ICON_FILLED | - wimp_ICON_INDIRECTED | + icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | + wimp_ICON_VCENTRED | wimp_ICON_FILLED | + wimp_ICON_INDIRECTED | (wimp_COLOUR_DARK_GREY << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT); icon.data.indirected_text.text = box->gadget->data.textbox.text; @@ -557,8 +557,8 @@ void ro_gui_window_redraw_box(gui_window* g, struct box * box, signed long x, si break; case GADGET_ACTIONBUTTON: - icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | - wimp_ICON_VCENTRED | wimp_ICON_FILLED | + icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | + wimp_ICON_VCENTRED | wimp_ICON_FILLED | wimp_ICON_INDIRECTED | wimp_ICON_HCENTRED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT); icon.data.indirected_text.text = box->gadget->data.actionbutt.label; @@ -578,8 +578,8 @@ void ro_gui_window_redraw_box(gui_window* g, struct box * box, signed long x, si break; case GADGET_SELECT: - icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | - wimp_ICON_VCENTRED | wimp_ICON_FILLED | + icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | + wimp_ICON_VCENTRED | wimp_ICON_FILLED | wimp_ICON_INDIRECTED | wimp_ICON_HCENTRED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_VERY_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT); @@ -963,7 +963,7 @@ void gui_init(int argc, char** argv) wimp_icon_create iconbar; wimp_version_no version; - __riscosify_control = __RISCOSIFY_NO_PROCESS; +/* __riscosify_control = __RISCOSIFY_NO_PROCESS; */ task_handle = wimp_initialise(wimp_VERSION_RO38, task_name, (wimp_message_list*) &task_messages, &version); @@ -1766,10 +1766,10 @@ void gui_gadget_combo(struct browser_window* bw, struct gui_gadget* g, int mx, i int count = 0; struct formoption* o; wimp_pointer pointer; - + if (combo_menu != NULL) xfree(combo_menu); - + o = g->data.select.items; while (o != NULL) { @@ -1824,7 +1824,7 @@ void gui_edit_textarea(struct browser_window* bw, struct gui_gadget* g) if (g->data.textarea.text != 0) fprintf(file, "%s", g->data.textarea.text); fclose(file); - + system("settype .NetSurf.TextArea FFF"); system("filer_run .NetSurf.TextArea"); } @@ -1864,7 +1864,7 @@ void ro_msg_datasave(wimp_message* block) wimp_get_window_state(&state); x = browser_x_units(window_x_units(data->pos.x, &state)); y = browser_y_units(window_y_units(data->pos.y, &state)); - + found = 0; click_boxes = NULL; plot_index = 0; @@ -1891,7 +1891,7 @@ void ro_msg_datasave(wimp_message* block) } } } - + xfree(click_boxes); } @@ -1919,7 +1919,7 @@ void ro_msg_dataload(wimp_message* block) wimp_get_window_state(&state); x = browser_x_units(window_x_units(data->pos.x, &state)); y = browser_y_units(window_y_units(data->pos.y, &state)); - + found = 0; click_boxes = NULL; plot_index = 0; @@ -1944,7 +1944,7 @@ void ro_msg_dataload(wimp_message* block) } } } - + xfree(click_boxes); } @@ -1964,7 +1964,7 @@ void gui_set_gadget_extent(struct box* box, int x, int y, os_box* extent, struct extent->x1 = x + box->x * 2 + box->width * 2; extent->y1 = y - box->y * 2; return; - } + } for (c = box->children; c != 0; c = c->next) if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT) gui_set_gadget_extent(c, x + box->x * 2, y - box->y * 2, extent, g); @@ -1984,7 +1984,7 @@ void gui_edit_textbox(struct browser_window* bw, struct gui_gadget* g) int offset; wimp_get_pointer_info(&pointer); - + if (current_textbox != 0) { wimp_delete_icon(current_textbox_w, current_textbox_i); @@ -1997,9 +1997,9 @@ void gui_edit_textbox(struct browser_window* bw, struct gui_gadget* g) icon.w = current_textbox_w; gui_set_gadget_extent(bw->current_content->data.html.layout->children, 0, 0, &icon.icon.extent, g); fprintf(stderr, "ICON EXTENT %d %d %d %d\n", icon.icon.extent.x0, icon.icon.extent.y0, icon.icon.extent.x1, icon.icon.extent.y1); - icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | - wimp_ICON_VCENTRED | wimp_ICON_FILLED | - wimp_ICON_INDIRECTED | + icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_BORDER | + wimp_ICON_VCENTRED | wimp_ICON_FILLED | + wimp_ICON_INDIRECTED | (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) | (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT) | (wimp_BUTTON_WRITABLE << wimp_ICON_BUTTON_TYPE_SHIFT); @@ -2022,7 +2022,7 @@ void gui_edit_textbox(struct browser_window* bw, struct gui_gadget* g) break; offset--; } - + wimp_set_caret_position(current_textbox_w, current_textbox_i, 0,0,-1, offset); } -- cgit v1.2.3