r13142 chris_y - /trunk/netsurf/desktop/tree.c
by netsurf@semichrome.net
Author: chris_y
Date: Thu Nov 10 07:47:24 2011
New Revision: 13142
URL: http://source.netsurf-browser.org?rev=13142&view=rev
Log:
Make default folder appear different (redraw seems to be broken at present)
Modified:
trunk/netsurf/desktop/tree.c
Modified: trunk/netsurf/desktop/tree.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/tree.c?rev=13142&...
==============================================================================
--- trunk/netsurf/desktop/tree.c (original)
+++ trunk/netsurf/desktop/tree.c Thu Nov 10 07:47:24 2011
@@ -62,10 +62,24 @@
.flags = FONTF_NONE
};
+static plot_font_style_t plot_fstyle_def_folder = {
+ .family = PLOT_FONT_FAMILY_SANS_SERIF,
+ .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
+ .weight = 700,
+ .flags = FONTF_NONE
+};
+
static plot_font_style_t plot_fstyle_selected = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
.size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
.weight = 400,
+ .flags = FONTF_NONE
+};
+
+static plot_font_style_t plot_fstyle_selected_def_folder = {
+ .family = PLOT_FONT_FAMILY_SANS_SERIF,
+ .size = TREE_TEXT_SIZE_PT * FONT_SIZE_SCALE,
+ .weight = 700,
.flags = FONTF_NONE
};
@@ -190,10 +204,14 @@
/* Text colour */
plot_fstyle.foreground = option_gui_colour_fg_1;
plot_fstyle.background = option_gui_colour_bg_1;
+ plot_fstyle_def_folder.foreground = option_gui_colour_fg_1;
+ plot_fstyle_def_folder.background = option_gui_colour_bg_1;
/* Selected text colour */
plot_fstyle_selected.foreground = option_gui_colour_fg_2;
plot_fstyle_selected.background = option_gui_colour_fg_1;
+ plot_fstyle_selected_def_folder.foreground = option_gui_colour_fg_2;
+ plot_fstyle_selected_def_folder.background = option_gui_colour_fg_1;
}
@@ -277,8 +295,15 @@
int width, height;
static char *cache_text = NULL;
static int cache_size = 0;
+ plot_font_style_t *fstyle;
+ static plot_font_style_t *cache_fstyle = NULL;
assert(element != NULL);
+
+ if (element->parent->def_folder)
+ fstyle = &plot_fstyle_def_folder;
+ else
+ fstyle = &plot_fstyle;
switch (element->type) {
case NODE_ELEMENT_TEXT_PLUS_ICON:
@@ -291,7 +316,8 @@
&element->box.width, NULL);
} else {
if ((cache_text != NULL) &&
- (strcmp(cache_text, element->text) == 0)) {
+ (strcmp(cache_text, element->text) == 0) &&
+ (cache_fstyle == fstyle)) {
element->box.width = cache_size;
#ifdef TREE_NOISY_DEBUG
LOG(("Tree font width cache hit"));
@@ -304,6 +330,7 @@
&cache_size);
element->box.width = cache_size;
cache_text = strdup(element->text);
+ cache_fstyle = fstyle;
}
}
@@ -1598,8 +1625,12 @@
return false;
}
+ tree_clear_default_folder_node(tree);
+
tree->def_folder = sel_node;
sel_node->def_folder = true;
+ tree_handle_node_changed(tree, sel_node, true, false);
+
return true;
}
@@ -1615,6 +1646,7 @@
def_node = tree_get_default_folder_node(tree);
if (def_node != NULL) {
+ tree_handle_node_changed(tree, def_node, true, false);
tree->def_folder = NULL;
def_node->def_folder = false;
}
@@ -1700,6 +1732,7 @@
struct bitmap *bitmap = NULL;
int x, y, width;
bool selected = false;
+ bool def_folder = false;
hlcache_handle *icon;
plot_font_style_t *fstyle;
const int icon_inset = (TREE_LINE_HEIGHT - TREE_ICON_SIZE) / 2;
@@ -1711,9 +1744,12 @@
x = tree_x + element->box.x;
y = tree_y + element->box.y;
width = element->box.width;
- if (&element->parent->data == element)
+ if (&element->parent->data == element) {
if (element->parent->selected)
selected = true;
+ if (element->parent->def_folder)
+ def_folder = true;
+ }
switch (element->type) {
case NODE_ELEMENT_TEXT_PLUS_ICON:
@@ -1770,11 +1806,18 @@
return;
if (selected) {
- fstyle = &plot_fstyle_selected;
+ if (def_folder == true)
+ fstyle = &plot_fstyle_selected_def_folder;
+ else
+ fstyle = &plot_fstyle_selected;
+
plot->rectangle(x, y, x + width,
y + element->box.height,
&plot_style_fill_tree_selected);
} else {
+ if (def_folder == true)
+ fstyle = &plot_fstyle_def_folder;
+ else
fstyle = &plot_fstyle;
}
11 years, 6 months
r13141 chris_y - in /trunk/netsurf/desktop: hotlist.c tree.c tree.h tree_url_node.c
by netsurf@semichrome.net
Author: chris_y
Date: Thu Nov 10 07:07:47 2011
New Revision: 13141
URL: http://source.netsurf-browser.org?rev=13141&view=rev
Log:
Make default hotlist folder persistent across sessions
Modified:
trunk/netsurf/desktop/hotlist.c
trunk/netsurf/desktop/tree.c
trunk/netsurf/desktop/tree.h
trunk/netsurf/desktop/tree_url_node.c
Modified: trunk/netsurf/desktop/hotlist.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/hotlist.c?rev=131...
==============================================================================
--- trunk/netsurf/desktop/hotlist.c (original)
+++ trunk/netsurf/desktop/hotlist.c Thu Nov 10 07:07:47 2011
@@ -479,6 +479,6 @@
tree_clear_default_folder_node(hotlist_tree);
return true;
} else {
- return tree_set_default_folder_node(hotlist_tree);
- }
-}
+ return tree_set_default_folder_node(hotlist_tree, NULL);
+ }
+}
Modified: trunk/netsurf/desktop/tree.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/tree.c?rev=13141&...
==============================================================================
--- trunk/netsurf/desktop/tree.c (original)
+++ trunk/netsurf/desktop/tree.c Thu Nov 10 07:07:47 2011
@@ -118,6 +118,7 @@
bool selected; /**< Whether the node is selected */
bool expanded; /**< Whether the node is expanded */
bool folder; /**< Whether the node is a folder */
+ bool def_folder; /**< Whether the node is the default folder */
bool retain_in_memory; /**< Whether the node remains
in memory after deletion */
bool deleted; /**< Whether the node is currently
@@ -1397,6 +1398,18 @@
/**
+ * Returns true if the node is the default folder for a tree
+ *
+ * \param node the node to be checked
+ * \return true if the node is a default folder, false otherwise
+ */
+bool tree_node_is_default(struct node *node)
+{
+ return node->def_folder;
+}
+
+
+/**
* Update the text of a node element if it has changed.
*
* \param element The node element to update.
@@ -1567,13 +1580,18 @@
* Set the default node of a tree to the selected node
*
* \param tree the tree to set the default node of
+ * \param node the node to set as default (NULL for selected node)
* \return success
*/
-bool tree_set_default_folder_node(struct tree *tree)
+bool tree_set_default_folder_node(struct tree *tree, struct node *node)
{
struct node *sel_node;
- sel_node = tree_get_selected_node(tree->root);
+ if (node == NULL) {
+ sel_node = tree_get_selected_node(tree->root);
+ } else {
+ sel_node = node;
+ }
if((sel_node == NULL) ||
(tree_node_is_folder(sel_node) == false)) {
@@ -1581,6 +1599,7 @@
}
tree->def_folder = sel_node;
+ sel_node->def_folder = true;
return true;
}
@@ -1592,7 +1611,13 @@
*/
void tree_clear_default_folder_node(struct tree *tree)
{
- tree->def_folder = NULL;
+ struct node *def_node = NULL;
+ def_node = tree_get_default_folder_node(tree);
+
+ if (def_node != NULL) {
+ tree->def_folder = NULL;
+ def_node->def_folder = false;
+ }
}
Modified: trunk/netsurf/desktop/tree.h
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/tree.h?rev=13141&...
==============================================================================
--- trunk/netsurf/desktop/tree.h (original)
+++ trunk/netsurf/desktop/tree.h Thu Nov 10 07:07:47 2011
@@ -166,6 +166,7 @@
bool tree_node_has_selection(struct node *node);
bool tree_node_is_deleted(struct node *node);
bool tree_node_is_folder(struct node *node);
+bool tree_node_is_default(struct node *node);
void tree_update_node_element(struct tree *tree, struct node_element *element,
const char *text, void *bitmap);
bool tree_update_element_text(struct tree *tree, struct node_element *element, char *text);
@@ -175,7 +176,7 @@
tree_drag_type tree_drag_status(struct tree *tree);
struct node *tree_get_default_folder_node(struct tree *tree);
-bool tree_set_default_folder_node(struct tree *tree);
+bool tree_set_default_folder_node(struct tree *tree, struct node *node);
void tree_clear_default_folder_node(struct tree *tree);
/* functions for traversing the tree */
Modified: trunk/netsurf/desktop/tree_url_node.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/tree_url_node.c?r...
==============================================================================
--- trunk/netsurf/desktop/tree_url_node.c (original)
+++ trunk/netsurf/desktop/tree_url_node.c Thu Nov 10 07:07:47 2011
@@ -576,6 +576,7 @@
char *title;
struct node *dir;
xmlNode *xmlnode;
+ xmlChar *id;
assert(ul != NULL);
assert(directory != NULL);
@@ -595,6 +596,7 @@
} else if (strcmp((const char *)xmlnode->name, "h4") == 0) {
/* directory */
+ bool dir_is_default = false;
title = (char *) xmlNodeGetContent(xmlnode );
if (!title) {
warn_user("TreeLoadError", "(Empty <h4> "
@@ -613,6 +615,13 @@
warn_user("TreeLoadError", "(Expected "
"<ul> not present.)");
return;
+ } else {
+ id = xmlGetProp(xmlnode, "id");
+ if (id != NULL) {
+ if(strcmp((const char *)id, "default") == 0)
+ dir_is_default = true;
+ xmlFree(id);
+ }
}
dir = tree_create_folder_node(tree, directory, title,
@@ -620,6 +629,10 @@
if (dir == NULL) {
free(title);
return;
+ }
+
+ if(dir_is_default == true) {
+ tree_set_default_folder_node(tree, dir);
}
if (callback != NULL)
@@ -738,6 +751,8 @@
ul = xmlNewChild(node, NULL, (const xmlChar *)"ul", NULL);
if (ul == NULL)
return false;
+ if (tree_node_is_default(directory) == true)
+ xmlSetProp(ul, "id", "default");
for (child = tree_node_get_child(directory); child;
child = tree_node_get_next(child)) {
@@ -767,12 +782,6 @@
}
-
-
-
-
-
-
/**
* Perform a save to a specified file in the form of a html page
*
11 years, 6 months
r13140 chris_y - in /trunk/netsurf: !NetSurf/Resources/de/Messages !NetSurf/Resources/en/Messages !NetSurf/Resources/fr/Messages !NetSurf/Resources/it/Messages !NetSurf/Resources/nl/Messages amiga/gui.h amiga/tree.c
by netsurf@semichrome.net
Author: chris_y
Date: Thu Nov 10 06:23:52 2011
New Revision: 13140
URL: http://source.netsurf-browser.org?rev=13140&view=rev
Log:
Amiga frontend update for r13139
Modified:
trunk/netsurf/!NetSurf/Resources/de/Messages
trunk/netsurf/!NetSurf/Resources/en/Messages
trunk/netsurf/!NetSurf/Resources/fr/Messages
trunk/netsurf/!NetSurf/Resources/it/Messages
trunk/netsurf/!NetSurf/Resources/nl/Messages
trunk/netsurf/amiga/gui.h
trunk/netsurf/amiga/tree.c
Modified: trunk/netsurf/!NetSurf/Resources/de/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/de/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/de/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/de/Messages Thu Nov 10 06:23:52 2011
@@ -343,6 +343,8 @@
TreeNewFolder:Neues Verzeichnis
TreeLaunch:URL ansehen
TreeDelete:Löschen
+TreeDefault:Set as default
+TreeClear:Clear default
# Tree export
#
Modified: trunk/netsurf/!NetSurf/Resources/en/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/en/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/en/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/en/Messages Thu Nov 10 06:23:52 2011
@@ -345,6 +345,8 @@
TreeNewFolder:New directory
TreeLaunch:Visit URL
TreeDelete:Delete
+TreeDefault:Set as default
+TreeClear:Clear default
# Tree export
Modified: trunk/netsurf/!NetSurf/Resources/fr/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/fr/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/fr/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/fr/Messages Thu Nov 10 06:23:52 2011
@@ -343,6 +343,8 @@
TreeNewFolder:Nouv. répertoire
TreeLaunch:Visit URL
TreeDelete:Delete
+TreeDefault:Set as default
+TreeClear:Clear default
# Tree export
#
Modified: trunk/netsurf/!NetSurf/Resources/it/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/it/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/it/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/it/Messages Thu Nov 10 06:23:52 2011
@@ -346,6 +346,8 @@
TreeNewFolder:Nuova cartella
TreeLaunch:Visita URL
TreeDelete:Elimina
+TreeDefault:Set as default
+TreeClear:Clear default
# Tree export
#
Modified: trunk/netsurf/!NetSurf/Resources/nl/Messages
URL: http://source.netsurf-browser.org/trunk/netsurf/%21NetSurf/Resources/nl/M...
==============================================================================
--- trunk/netsurf/!NetSurf/Resources/nl/Messages (original)
+++ trunk/netsurf/!NetSurf/Resources/nl/Messages Thu Nov 10 06:23:52 2011
@@ -343,6 +343,8 @@
TreeNewFolder:Nieuwe map
TreeLaunch:Visit URL
TreeDelete:Delete
+TreeDefault:Set as default
+TreeClear:Clear default
# Tree export
#
Modified: trunk/netsurf/amiga/gui.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.h?rev=13140&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.h (original)
+++ trunk/netsurf/amiga/gui.h Thu Nov 10 06:23:52 2011
@@ -58,10 +58,6 @@
GID_PASS,
GID_LOGIN,
GID_CANCEL,
- GID_OPEN,
- GID_NEWF,
- GID_NEWB,
- GID_DEL,
GID_NEXT,
GID_PREV,
GID_SEARCHSTRING,
Modified: trunk/netsurf/amiga/tree.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/tree.c?rev=13140&r1...
==============================================================================
--- trunk/netsurf/amiga/tree.c (original)
+++ trunk/netsurf/amiga/tree.c Thu Nov 10 06:23:52 2011
@@ -67,10 +67,19 @@
#define AMI_TREE_MENU_DELETE FULLMENUNUM(1,0,0)
#define AMI_TREE_MENU_CLEAR FULLMENUNUM(1,3,0)
+enum {
+ GID_OPEN = GID_LAST,
+ GID_NEWF,
+ GID_NEWB,
+ GID_DEL,
+ GID_DEFAULT,
+ GID_TREE_LAST
+};
+
+
struct treeview_window {
struct Window *win;
- Object *objects[GID_LAST];
-// struct Gadget *gadgets[GID_LAST];
+ Object *objects[GID_TREE_LAST];
struct nsObject *node;
int type;
struct NewMenu *menu;
@@ -446,6 +455,7 @@
void ami_tree_update_buttons(struct treeview_window *twin)
{
BOOL launch_disable = FALSE;
+ BOOL set_default_disable = TRUE;
if(twin->type == AMI_TREE_SSLCERT) return;
@@ -463,7 +473,10 @@
TAG_DONE);
if((selected_node && (tree_node_is_folder(selected_node) == true)))
+ {
launch_disable = TRUE;
+ set_default_disable = FALSE;
+ }
}
else
{
@@ -483,6 +496,14 @@
RefreshSetGadgetAttrs((struct Gadget *)twin->objects[GID_OPEN],
twin->win, NULL,
GA_Disabled, launch_disable,
+ TAG_DONE);
+ }
+
+ if(twin->type == AMI_TREE_HOTLIST)
+ {
+ RefreshSetGadgetAttrs((struct Gadget *)twin->objects[GID_DEFAULT],
+ twin->win, NULL,
+ GA_Disabled, set_default_disable,
TAG_DONE);
}
}
@@ -665,6 +686,12 @@
GA_Text,messages_get("TreeDelete"),
GA_RelVerify,TRUE,
ButtonEnd,
+ LAYOUT_AddChild, twin->objects[GID_DEFAULT] = ButtonObject,
+ GA_ID, GID_DEFAULT,
+ GA_Text, messages_get("TreeDefault"),
+ GA_RelVerify, TRUE,
+ GA_Disabled, TRUE,
+ ButtonEnd,
EndGroup,
CHILD_WeightedHeight,0,
EndGroup,
@@ -784,6 +811,10 @@
case GID_NEWB:
hotlist_add_entry();
+ break;
+
+ case GID_DEFAULT:
+ hotlist_set_default_folder(false);
break;
case GID_DEL:
11 years, 6 months
r13139 chris_y - in /trunk/netsurf/desktop: hotlist.c hotlist.h tree.c tree.h
by netsurf@semichrome.net
Author: chris_y
Date: Thu Nov 10 06:22:48 2011
New Revision: 13139
URL: http://source.netsurf-browser.org?rev=13139&view=rev
Log:
Allow setting a default folder in the tree for hotlist entries to go into. Frontends
will need to be updated to use hotlist_set_default_folder() if they want to use this
functionality.
Modified:
trunk/netsurf/desktop/hotlist.c
trunk/netsurf/desktop/hotlist.h
trunk/netsurf/desktop/tree.c
trunk/netsurf/desktop/tree.h
Modified: trunk/netsurf/desktop/hotlist.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/hotlist.c?rev=131...
==============================================================================
--- trunk/netsurf/desktop/hotlist.c (original)
+++ trunk/netsurf/desktop/hotlist.c Thu Nov 10 06:22:48 2011
@@ -370,7 +370,7 @@
*/
void hotlist_add_folder(void)
{
- struct node *node;
+ struct node *node, *parent;
struct node_element *element;
char *title = strdup("Untitled");
@@ -380,7 +380,9 @@
return;
}
creating_node = true;
- node = tree_create_folder_node(hotlist_tree, hotlist_tree_root, title,
+
+ parent = tree_get_default_folder_node(hotlist_tree);
+ node = tree_create_folder_node(hotlist_tree, parent, title,
true, false, false);
if (node == NULL) {
free(title);
@@ -397,9 +399,11 @@
*/
void hotlist_add_entry(void)
{
- struct node *node;
+ struct node *node, *parent;
creating_node = true;
- node = tree_create_URL_node(hotlist_tree, hotlist_tree_root, "Address",
+
+ parent = tree_get_default_folder_node(hotlist_tree);
+ node = tree_create_URL_node(hotlist_tree, parent, "Address",
"Untitled", hotlist_node_callback, NULL);
if (node == NULL)
@@ -414,7 +418,7 @@
void hotlist_add_page(const char *url)
{
const struct url_data *data;
- struct node *node;
+ struct node *node, *parent;
if (url == NULL)
return;
@@ -422,7 +426,8 @@
if (data == NULL)
return;
- node = tree_create_URL_node(hotlist_tree, hotlist_tree_root, url, NULL,
+ parent = tree_get_default_folder_node(hotlist_tree);
+ node = tree_create_URL_node(hotlist_tree, parent, url, NULL,
hotlist_node_callback, NULL);
tree_update_URL_node(hotlist_tree, node, url, data);
}
@@ -462,3 +467,18 @@
{
tree_launch_selected(hotlist_tree, tabs);
}
+
+/**
+ * Set the hotlist's default folder to the selected node.
+ *
+ * \param clear reset the default to tree root
+ */
+bool hotlist_set_default_folder(bool clear)
+{
+ if (clear == true) {
+ tree_clear_default_folder_node(hotlist_tree);
+ return true;
+ } else {
+ return tree_set_default_folder_node(hotlist_tree);
+ }
+}
Modified: trunk/netsurf/desktop/hotlist.h
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/hotlist.h?rev=131...
==============================================================================
--- trunk/netsurf/desktop/hotlist.h (original)
+++ trunk/netsurf/desktop/hotlist.h Thu Nov 10 06:22:48 2011
@@ -58,5 +58,5 @@
void hotlist_add_page(const char *url);
void hotlist_add_page_xy(const char *url, int x, int y);
void hotlist_launch_selected(bool tabs);
-
+bool hotlist_set_default_folder(bool clear);
#endif
Modified: trunk/netsurf/desktop/tree.c
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/tree.c?rev=13139&...
==============================================================================
--- trunk/netsurf/desktop/tree.c (original)
+++ trunk/netsurf/desktop/tree.c Thu Nov 10 06:22:48 2011
@@ -159,6 +159,7 @@
const struct treeview_table *callbacks;
void *client_data; /* User assigned data for the
callbacks */
+ struct node *def_folder; /* Node to be used for additions by default */
};
void tree_set_icon_dir(char *icon_dir)
@@ -1034,6 +1035,8 @@
parent = node->parent;
if (tree != NULL && parent == tree->root)
parent = NULL;
+ if ((tree != NULL) && (tree->def_folder == node))
+ tree->def_folder = NULL;
tree_delink_node(tree, node);
child = node->child;
node->child = NULL;
@@ -1541,6 +1544,55 @@
tree_drag_type tree_drag_status(struct tree *tree)
{
return tree->drag;
+}
+
+
+/**
+ * Get the default node of a tree for additions
+ *
+ * \param tree the tree to get the default node of
+ * \return the default node
+ */
+struct node *tree_get_default_folder_node(struct tree *tree)
+{
+ if (tree->def_folder != NULL) {
+ return tree->def_folder;
+ } else {
+ return tree_get_root(tree);
+ }
+}
+
+
+/**
+ * Set the default node of a tree to the selected node
+ *
+ * \param tree the tree to set the default node of
+ * \return success
+ */
+bool tree_set_default_folder_node(struct tree *tree)
+{
+ struct node *sel_node;
+
+ sel_node = tree_get_selected_node(tree->root);
+
+ if((sel_node == NULL) ||
+ (tree_node_is_folder(sel_node) == false)) {
+ return false;
+ }
+
+ tree->def_folder = sel_node;
+ return true;
+}
+
+
+/**
+ * Clear the default node of a tree
+ *
+ * \param tree the tree to clear the default node of
+ */
+void tree_clear_default_folder_node(struct tree *tree)
+{
+ tree->def_folder = NULL;
}
Modified: trunk/netsurf/desktop/tree.h
URL: http://source.netsurf-browser.org/trunk/netsurf/desktop/tree.h?rev=13139&...
==============================================================================
--- trunk/netsurf/desktop/tree.h (original)
+++ trunk/netsurf/desktop/tree.h Thu Nov 10 06:22:48 2011
@@ -174,6 +174,10 @@
bool tree_is_edited(struct tree *tree);
tree_drag_type tree_drag_status(struct tree *tree);
+struct node *tree_get_default_folder_node(struct tree *tree);
+bool tree_set_default_folder_node(struct tree *tree);
+void tree_clear_default_folder_node(struct tree *tree);
+
/* functions for traversing the tree */
struct node *tree_node_get_child(struct node *node);
struct node *tree_node_get_next(struct node *node);
11 years, 6 months
r13138 chris_y - /trunk/netsurf/amiga/gui.c
by netsurf@semichrome.net
Author: chris_y
Date: Wed Nov 9 13:22:49 2011
New Revision: 13138
URL: http://source.netsurf-browser.org?rev=13138&view=rev
Log:
Update the title of the initial tab, even when the tab bar is hidden (ensures the
correct title will be present if it is made visible)
Modified:
trunk/netsurf/amiga/gui.c
Modified: trunk/netsurf/amiga/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/gui.c?rev=13138&r1=...
==============================================================================
--- trunk/netsurf/amiga/gui.c (original)
+++ trunk/netsurf/amiga/gui.c Wed Nov 9 13:22:49 2011
@@ -3109,7 +3109,7 @@
utf8title = ami_utf8_easy((char *)title);
- if(g->tab_node && (g->shared->tabs > 1))
+ if(g->tab_node && (g->shared->tabs >= 1))
{
node = g->tab_node;
@@ -3137,8 +3137,9 @@
g->shared->win, NULL, TRUE);
}
- GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS],
- (ULONG *)&cur_tab);
+ if(g->shared->tabs > 1)
+ GetAttr(CLICKTAB_Current, g->shared->objects[GID_TABS],
+ (ULONG *)&cur_tab);
}
if((cur_tab == g->tab) || (g->shared->tabs <= 1))
11 years, 6 months
r13137 jmb - in /trunk/netsurf/content: fetch.c fetch.h fetchers/about.c fetchers/curl.c fetchers/data.c fetchers/file.c fetchers/resource.c llcache.c
by netsurf@semichrome.net
Author: jmb
Date: Tue Nov 8 15:51:42 2011
New Revision: 13137
URL: http://source.netsurf-browser.org?rev=13137&view=rev
Log:
Clean up fetch callback API. Inject some long-needed type safety.
Modified:
trunk/netsurf/content/fetch.c
trunk/netsurf/content/fetch.h
trunk/netsurf/content/fetchers/about.c
trunk/netsurf/content/fetchers/curl.c
trunk/netsurf/content/fetchers/data.c
trunk/netsurf/content/fetchers/file.c
trunk/netsurf/content/fetchers/resource.c
trunk/netsurf/content/llcache.c
Modified: trunk/netsurf/content/fetch.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetch.c?rev=13137...
==============================================================================
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Tue Nov 8 15:51:42 2011
@@ -662,12 +662,9 @@
}
void
-fetch_send_callback(fetch_msg msg, struct fetch *fetch, const void *data,
- unsigned long size, fetch_error_code errorcode)
-{
- /*LOG(("Fetcher sending callback. Fetch %p, fetcher %p data %p size %lu",
- fetch, fetch->fetcher_handle, data, size)); */
- fetch->callback(msg, fetch->p, data, size, errorcode);
+fetch_send_callback(const fetch_msg *msg, struct fetch *fetch)
+{
+ fetch->callback(msg, fetch->p);
}
Modified: trunk/netsurf/content/fetch.h
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetch.h?rev=13137...
==============================================================================
--- trunk/netsurf/content/fetch.h (original)
+++ trunk/netsurf/content/fetch.h Tue Nov 8 15:51:42 2011
@@ -30,33 +30,48 @@
#include "utils/config.h"
#include "utils/nsurl.h"
-typedef enum {
- FETCH_PROGRESS,
- FETCH_HEADER,
- FETCH_DATA,
- FETCH_FINISHED,
- FETCH_ERROR,
- FETCH_REDIRECT,
- FETCH_NOTMODIFIED,
- FETCH_AUTH,
- FETCH_CERT_ERR,
-} fetch_msg;
+struct content;
+struct fetch;
+struct ssl_cert_info;
typedef enum {
- FETCH_ERROR_NO_ERROR,
- FETCH_ERROR_CERT,
- FETCH_ERROR_AUTHENTICATION,
- FETCH_ERROR_HTTP_NOT2,
- FETCH_ERROR_COULDNT_RESOLVE_HOST,
- FETCH_ERROR_PARTIAL_FILE,
- FETCH_ERROR_MEMORY,
- FETCH_ERROR_URL,
- FETCH_ERROR_ENCODING,
- FETCH_ERROR_MISC
-} fetch_error_code;
+ FETCH_PROGRESS,
+ FETCH_HEADER,
+ FETCH_DATA,
+ FETCH_FINISHED,
+ FETCH_ERROR,
+ FETCH_REDIRECT,
+ FETCH_NOTMODIFIED,
+ FETCH_AUTH,
+ FETCH_CERT_ERR
+} fetch_msg_type;
-struct content;
-struct fetch;
+typedef struct fetch_msg {
+ fetch_msg_type type;
+
+ union {
+ const char *progress;
+
+ struct {
+ const uint8_t *buf;
+ size_t len;
+ } header_or_data;
+
+ const char *error;
+
+ /** \todo Use nsurl */
+ const char *redirect;
+
+ struct {
+ const char *realm;
+ } auth;
+
+ struct {
+ const struct ssl_cert_info *certs;
+ size_t num_certs;
+ } cert_err;
+ } data;
+} fetch_msg;
/** Fetch POST multipart data */
struct fetch_multipart_data {
@@ -80,8 +95,7 @@
extern bool fetch_active;
-typedef void (*fetch_callback)(fetch_msg msg, void *p, const void *data,
- unsigned long size, fetch_error_code errorcode);
+typedef void (*fetch_callback)(const fetch_msg *msg, void *p);
void fetch_init(void);
@@ -141,12 +155,11 @@
fetcher_poll_fetcher poll_fetcher,
fetcher_finalise finaliser);
-void fetch_send_callback(fetch_msg msg, struct fetch *fetch,
- const void *data, unsigned long size,
- fetch_error_code errorcode);
+void fetch_send_callback(const fetch_msg *msg, struct fetch *fetch);
void fetch_remove_from_queues(struct fetch *fetch);
void fetch_free(struct fetch *f);
void fetch_set_http_code(struct fetch *fetch, long http_code);
const char *fetch_get_referer_to_send(struct fetch *fetch);
void fetch_set_cookie(struct fetch *fetch, const char *data);
+
#endif
Modified: trunk/netsurf/content/fetchers/about.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/about.c?...
==============================================================================
--- trunk/netsurf/content/fetchers/about.c (original)
+++ trunk/netsurf/content/fetchers/about.c Tue Nov 8 15:51:42 2011
@@ -77,12 +77,11 @@
static struct fetch_about_context *ring = NULL;
/** issue fetch callbacks with locking */
-static inline bool fetch_about_send_callback(fetch_msg msg,
- struct fetch_about_context *ctx, const void *data,
- unsigned long size, fetch_error_code errorcode)
+static inline bool fetch_about_send_callback(const fetch_msg *msg,
+ struct fetch_about_context *ctx)
{
ctx->locked = true;
- fetch_send_callback(msg, ctx->fetchh, data, size, errorcode);
+ fetch_send_callback(msg, ctx->fetchh);
ctx->locked = false;
return ctx->aborted;
@@ -92,6 +91,7 @@
const char *fmt, ...)
{
char header[64];
+ fetch_msg msg;
va_list ap;
va_start(ap, fmt);
@@ -100,8 +100,11 @@
va_end(ap);
- fetch_about_send_callback(FETCH_HEADER, ctx, header, strlen(header),
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_HEADER;
+ msg.data.header_or_data.buf = (const uint8_t *) header;
+ msg.data.header_or_data.len = strlen(header);
+
+ fetch_about_send_callback(&msg, ctx);
return ctx->aborted;
}
@@ -111,24 +114,26 @@
static bool fetch_about_blank_handler(struct fetch_about_context *ctx)
{
- char buffer[2];
- int code = 200;
+ fetch_msg msg;
+ const char buffer[2] = { ' ', '\0' };
/* content is going to return ok */
- fetch_set_http_code(ctx->fetchh, code);
+ fetch_set_http_code(ctx->fetchh, 200);
/* content type */
if (fetch_about_send_header(ctx, "Content-Type: text/html"))
goto fetch_about_blank_handler_aborted;
- buffer[0] = ' ';
- buffer[1] = 0;
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer),
- FETCH_ERROR_NO_ERROR))
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+ msg.data.header_or_data.len = strlen(buffer);
+
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_blank_handler_aborted;
- fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_FINISHED;
+
+ fetch_about_send_callback(&msg, ctx);
return true;
@@ -139,11 +144,15 @@
static bool fetch_about_credits_handler(struct fetch_about_context *ctx)
{
+ fetch_msg msg;
+
/* content is going to return redirect */
fetch_set_http_code(ctx->fetchh, 302);
- fetch_about_send_callback(FETCH_REDIRECT, ctx, "resource:credits.html",
- 0, FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_REDIRECT;
+ msg.data.redirect = "resource:credits.html";
+
+ fetch_about_send_callback(&msg, ctx);
return true;
}
@@ -151,11 +160,15 @@
static bool fetch_about_licence_handler(struct fetch_about_context *ctx)
{
+ fetch_msg msg;
+
/* content is going to return redirect */
fetch_set_http_code(ctx->fetchh, 302);
- fetch_about_send_callback(FETCH_REDIRECT, ctx, "resource:licence.html",
- 0, FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_REDIRECT;
+ msg.data.redirect = "resource:licence.html";
+
+ fetch_about_send_callback(&msg, ctx);
return true;
}
@@ -167,6 +180,7 @@
*/
static bool fetch_about_imagecache_handler(struct fetch_about_context *ctx)
{
+ fetch_msg msg;
char buffer[1024]; /* output buffer */
int code = 200;
int slen;
@@ -179,6 +193,9 @@
/* content type */
if (fetch_about_send_header(ctx, "Content-Type: text/html"))
goto fetch_about_imagecache_handler_aborted;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
/* page head */
slen = snprintf(buffer, sizeof buffer,
@@ -193,8 +210,8 @@
"<img src=\"resource:netsurf.png\" alt=\"NetSurf\"></a>"
"</p>\n"
"<h1>NetSurf Browser Image Cache Status</h1>\n" );
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer,
- slen, FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_imagecache_handler_aborted;
/* image cache summary */
@@ -216,8 +233,8 @@
if (slen >= (int) (sizeof(buffer)))
goto fetch_about_imagecache_handler_aborted; /* overflow */
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer,
- slen, FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_imagecache_handler_aborted;
@@ -240,8 +257,8 @@
if (res >= (int) (sizeof buffer - slen)) {
/* last entry would not fit in buffer, submit buffer */
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer,
- slen, FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_imagecache_handler_aborted;
slen = 0;
} else {
@@ -254,12 +271,12 @@
slen += snprintf(buffer + slen, sizeof buffer - slen,
"</table>\n</body>\n</html>\n");
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_imagecache_handler_aborted;
- fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
return true;
@@ -270,6 +287,7 @@
/** Handler to generate about:config page */
static bool fetch_about_config_handler(struct fetch_about_context *ctx)
{
+ fetch_msg msg;
char buffer[1024];
int code = 200;
int slen;
@@ -282,6 +300,9 @@
/* content type */
if (fetch_about_send_header(ctx, "Content-Type: text/html"))
goto fetch_about_config_handler_aborted;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
slen = snprintf(buffer, sizeof buffer,
"<html>\n<head>\n"
@@ -307,8 +328,8 @@
if (res >= (int) (sizeof buffer - slen)) {
/* last entry would not fit in buffer, submit buffer */
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer,
- slen, FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_config_handler_aborted;
slen = 0;
} else {
@@ -321,12 +342,12 @@
slen += snprintf(buffer + slen, sizeof buffer - slen,
"</table>\n</body>\n</html>\n");
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_config_handler_aborted;
- fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
return true;
@@ -340,6 +361,7 @@
*/
static bool fetch_about_choices_handler(struct fetch_about_context *ctx)
{
+ fetch_msg msg;
char buffer[1024];
int code = 200;
int slen;
@@ -352,6 +374,9 @@
/* content type */
if (fetch_about_send_header(ctx, "Content-Type: text/plain"))
goto fetch_about_choices_handler_aborted;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
slen = snprintf(buffer, sizeof buffer,
"# Automatically generated current NetSurf browser Choices\n");
@@ -366,8 +391,8 @@
if (res >= (int) (sizeof buffer - slen)) {
/* last entry would not fit in buffer, submit buffer */
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer,
- slen, FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_choices_handler_aborted;
slen = 0;
} else {
@@ -377,12 +402,12 @@
}
} while (res > 0);
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_choices_handler_aborted;
- fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
return true;
@@ -397,6 +422,7 @@
static bool fetch_about_testament_handler(struct fetch_about_context *ctx)
{
static modification_t modifications[] = WT_MODIFICATIONS;
+ fetch_msg msg;
char buffer[1024];
int code = 200;
int slen;
@@ -410,11 +436,14 @@
if (fetch_about_send_header(ctx, "Content-Type: text/plain"))
goto fetch_about_testament_handler_aborted;
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+
slen = snprintf(buffer, sizeof buffer,
"# Automatically generated by NetSurf build system\n\n");
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_testament_handler_aborted;
slen = snprintf(buffer, sizeof buffer,
@@ -430,9 +459,9 @@
"# This NetSurf was built from a branch.\n\n"
#endif
);
-
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_testament_handler_aborted;
@@ -440,16 +469,16 @@
"Built by %s (%s) from %s at revision %s\n\n",
GECOS, USERNAME, WT_BRANCHPATH, WT_REVID);
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_testament_handler_aborted;
slen = snprintf(buffer, sizeof buffer,
"Built on %s in %s\n\n",
WT_HOSTNAME, WT_ROOT);
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_testament_handler_aborted;
if (WT_MODIFIED > 0) {
@@ -461,8 +490,8 @@
"Working tree is not modified.\n");
}
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_testament_handler_aborted;
for (i = 0; i < WT_MODIFIED; ++i) {
@@ -470,14 +499,14 @@
" %c %s\n",
modifications[i].modtype,
modifications[i].leaf);
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_testament_handler_aborted;
}
-
- fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
return true;
@@ -487,11 +516,15 @@
static bool fetch_about_logo_handler(struct fetch_about_context *ctx)
{
+ fetch_msg msg;
+
/* content is going to return redirect */
fetch_set_http_code(ctx->fetchh, 302);
- fetch_about_send_callback(FETCH_REDIRECT, ctx, "resource:netsurf.png",
- 0, FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_REDIRECT;
+ msg.data.redirect = "resource:netsurf.png";
+
+ fetch_about_send_callback(&msg, ctx);
return true;
}
@@ -533,6 +566,7 @@
*/
static bool fetch_about_about_handler(struct fetch_about_context *ctx)
{
+ fetch_msg msg;
char buffer[1024];
int code = 200;
int slen;
@@ -545,6 +579,9 @@
/* content type */
if (fetch_about_send_header(ctx, "Content-Type: text/html"))
goto fetch_about_config_handler_aborted;
+
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
slen = snprintf(buffer, sizeof buffer,
"<html>\n<head>\n"
@@ -575,8 +612,8 @@
if (res >= (int)(sizeof buffer - slen)) {
/* last entry would not fit in buffer, submit buffer */
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer,
- slen, FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_config_handler_aborted;
slen = 0;
} else {
@@ -588,12 +625,12 @@
slen += snprintf(buffer + slen, sizeof buffer - slen,
"</ul>\n</body>\n</html>\n");
- if (fetch_about_send_callback(FETCH_DATA, ctx, buffer, slen,
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = slen;
+ if (fetch_about_send_callback(&msg, ctx))
goto fetch_about_config_handler_aborted;
- fetch_about_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_FINISHED;
+ fetch_about_send_callback(&msg, ctx);
return true;
Modified: trunk/netsurf/content/fetchers/curl.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/curl.c?r...
==============================================================================
--- trunk/netsurf/content/fetchers/curl.c (original)
+++ trunk/netsurf/content/fetchers/curl.c Tue Nov 8 15:51:42 2011
@@ -787,9 +787,9 @@
void fetch_curl_done(CURL *curl_handle, CURLcode result)
{
+ fetch_msg msg;
bool finished = false;
bool error = false;
- fetch_error_code errorcode = FETCH_ERROR_NO_ERROR;
bool cert = false;
bool abort_fetch;
struct curl_fetch_info *f;
@@ -830,7 +830,6 @@
; /* redirect with partial body, or similar */
else {
error = true;
- errorcode = FETCH_ERROR_PARTIAL_FILE;
}
} else if (result == CURLE_WRITE_ERROR && f->stopped)
/* CURLE_WRITE_ERROR occurs when fetch_curl_data
@@ -842,23 +841,19 @@
memset(f->cert_data, 0, sizeof(f->cert_data));
cert = true;
}
- else if (result == CURLE_COULDNT_RESOLVE_HOST) {
- error = true;
- errorcode = FETCH_ERROR_COULDNT_RESOLVE_HOST;
- }
else {
LOG(("Unknown cURL response code %d", result));
error = true;
- errorcode = FETCH_ERROR_MISC;
}
fetch_curl_stop(f);
if (abort_fetch)
; /* fetch was aborted: no callback */
- else if (finished)
- fetch_send_callback(FETCH_FINISHED, f->fetch_handle, 0, 0, errorcode);
- else if (cert) {
+ else if (finished) {
+ msg.type = FETCH_FINISHED;
+ fetch_send_callback(&msg, f->fetch_handle);
+ } else if (cert) {
int i;
BIO *mem;
BUF_MEM *buf;
@@ -934,14 +929,17 @@
if (certs[i].cert->references == 0)
X509_free(certs[i].cert);
}
- errorcode = FETCH_ERROR_CERT;
- fetch_send_callback(FETCH_CERT_ERR, f->fetch_handle,
- &ssl_certs, i, errorcode);
-
- }
- else if (error)
- fetch_send_callback(FETCH_ERROR, f->fetch_handle,
- fetch_error_buffer, 0, errorcode);
+
+ msg.type = FETCH_CERT_ERR;
+ msg.data.cert_err.certs = ssl_certs;
+ msg.data.cert_err.num_certs = i;
+ fetch_send_callback(&msg, f->fetch_handle);
+ } else if (error) {
+ msg.type = FETCH_ERROR;
+ msg.data.error = fetch_error_buffer;
+
+ fetch_send_callback(&msg, f->fetch_handle);
+ }
fetch_free(f->fetch_handle);
}
@@ -957,10 +955,13 @@
static char fetch_progress_buffer[256]; /**< Progress buffer for cURL */
struct curl_fetch_info *f = (struct curl_fetch_info *) clientp;
unsigned int time_now_cs;
- double percent;
+ fetch_msg msg;
if (f->abort)
return 0;
+
+ msg.type = FETCH_PROGRESS;
+ msg.data.progress = fetch_progress_buffer;
/* Rate limit each fetch's progress notifications to 2 a second */
#define UPDATES_PER_SECOND 2
@@ -973,22 +974,16 @@
#undef UPDATES_PERS_SECOND
if (dltotal > 0) {
- percent = dlnow * 100.0f / dltotal;
snprintf(fetch_progress_buffer, 255,
messages_get("Progress"),
human_friendly_bytesize(dlnow),
human_friendly_bytesize(dltotal));
- fetch_send_callback(FETCH_PROGRESS, f->fetch_handle,
- fetch_progress_buffer,
- (unsigned long) percent,
- FETCH_ERROR_NO_ERROR);
+ fetch_send_callback(&msg, f->fetch_handle);
} else {
snprintf(fetch_progress_buffer, 255,
messages_get("ProgressU"),
human_friendly_bytesize(dlnow));
- fetch_send_callback(FETCH_PROGRESS, f->fetch_handle,
- fetch_progress_buffer, 0,
- FETCH_ERROR_NO_ERROR);
+ fetch_send_callback(&msg, f->fetch_handle);
}
return 0;
@@ -1021,6 +1016,7 @@
{
struct curl_fetch_info *f = _f;
CURLcode code;
+ fetch_msg msg;
/* ensure we only have to get this information once */
if (!f->http_code)
@@ -1039,17 +1035,16 @@
return size * nmemb;
}
- /*LOG(("fetch %p, size %lu", f, size * nmemb));*/
-
if (f->abort || (!f->had_headers && fetch_curl_process_headers(f))) {
f->stopped = true;
return 0;
}
/* send data to the caller */
- /*LOG(("FETCH_DATA"));*/
- fetch_send_callback(FETCH_DATA, f->fetch_handle, data, size * nmemb,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) data;
+ msg.data.header_or_data.len = size * nmemb;
+ fetch_send_callback(&msg, f->fetch_handle);
if (f->abort) {
f->stopped = true;
@@ -1071,6 +1066,7 @@
{
struct curl_fetch_info *f = _f;
int i;
+ fetch_msg msg;
size *= nmemb;
if (f->abort) {
@@ -1078,8 +1074,10 @@
return 0;
}
- fetch_send_callback(FETCH_HEADER, f->fetch_handle, data, size,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_HEADER;
+ msg.data.header_or_data.buf = (const uint8_t *) data;
+ msg.data.header_or_data.len = size;
+ fetch_send_callback(&msg, f->fetch_handle);
#define SKIP_ST(o) for (i = (o); i < (int) size && (data[i] == ' ' || data[i] == '\t'); i++)
@@ -1152,6 +1150,7 @@
{
long http_code;
CURLcode code;
+ fetch_msg msg;
f->had_headers = true;
@@ -1167,32 +1166,34 @@
if (http_code == 304 && !f->post_urlenc && !f->post_multipart) {
/* Not Modified && GET request */
- fetch_send_callback(FETCH_NOTMODIFIED, f->fetch_handle, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_NOTMODIFIED;
+ fetch_send_callback(&msg, f->fetch_handle);
return true;
}
/* handle HTTP redirects (3xx response codes) */
if (300 <= http_code && http_code < 400 && f->location != 0) {
LOG(("FETCH_REDIRECT, '%s'", f->location));
- fetch_send_callback(FETCH_REDIRECT, f->fetch_handle,
- f->location, 0, FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_REDIRECT;
+ msg.data.redirect = f->location;
+ fetch_send_callback(&msg, f->fetch_handle);
return true;
}
/* handle HTTP 401 (Authentication errors) */
if (http_code == 401) {
- fetch_send_callback(FETCH_AUTH, f->fetch_handle, f->realm, 0,
- FETCH_ERROR_AUTHENTICATION);
+ msg.type = FETCH_AUTH;
+ msg.data.auth.realm = f->realm;
+ fetch_send_callback(&msg, f->fetch_handle);
return true;
}
/* handle HTTP errors (non 2xx response codes) */
if (f->only_2xx && strncmp(nsurl_access(f->url), "http", 4) == 0 &&
(http_code < 200 || 299 < http_code)) {
- fetch_send_callback(FETCH_ERROR, f->fetch_handle,
- messages_get("Not2xx"), 0,
- FETCH_ERROR_HTTP_NOT2);
+ msg.type = FETCH_ERROR;
+ msg.data.error = messages_get("Not2xx");
+ fetch_send_callback(&msg, f->fetch_handle);
return true;
}
Modified: trunk/netsurf/content/fetchers/data.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/data.c?r...
==============================================================================
--- trunk/netsurf/content/fetchers/data.c (original)
+++ trunk/netsurf/content/fetchers/data.c Tue Nov 8 15:51:42 2011
@@ -127,17 +127,17 @@
c->aborted = true;
}
-static void fetch_data_send_callback(fetch_msg msg,
- struct fetch_data_context *c, const void *data,
- unsigned long size, fetch_error_code errorcode)
+static void fetch_data_send_callback(const fetch_msg *msg,
+ struct fetch_data_context *c)
{
c->locked = true;
- fetch_send_callback(msg, c->parent_fetch, data, size, errorcode);
+ fetch_send_callback(msg, c->parent_fetch);
c->locked = false;
}
static bool fetch_data_process(struct fetch_data_context *c)
{
+ fetch_msg msg;
char *params;
char *comma;
char *unescaped;
@@ -153,8 +153,9 @@
if (strlen(c->url) < 6) {
/* 6 is the minimum possible length (data:,) */
- fetch_data_send_callback(FETCH_ERROR, c,
- "Malformed data: URL", 0, FETCH_ERROR_URL);
+ msg.type = FETCH_ERROR;
+ msg.data.error = "Malformed data: URL";
+ fetch_data_send_callback(&msg, c);
return false;
}
@@ -163,8 +164,9 @@
/* find the comma */
if ( (comma = strchr(params, ',')) == NULL) {
- fetch_data_send_callback(FETCH_ERROR, c,
- "Malformed data: URL", 0, FETCH_ERROR_URL);
+ msg.type = FETCH_ERROR;
+ msg.data.error = "Malformed data: URL";
+ fetch_data_send_callback(&msg, c);
return false;
}
@@ -177,9 +179,10 @@
}
if (c->mimetype == NULL) {
- fetch_data_send_callback(FETCH_ERROR, c,
- "Unable to allocate memory for mimetype in data: URL",
- 0, FETCH_ERROR_MEMORY);
+ msg.type = FETCH_ERROR;
+ msg.data.error =
+ "Unable to allocate memory for mimetype in data: URL";
+ fetch_data_send_callback(&msg, c);
return false;
}
@@ -197,9 +200,9 @@
unescaped = curl_easy_unescape(curl, comma + 1, 0, &templen);
c->datalen = templen;
if (unescaped == NULL) {
- fetch_data_send_callback(FETCH_ERROR, c,
- "Unable to URL decode data: URL", 0,
- FETCH_ERROR_ENCODING);
+ msg.type = FETCH_ERROR;
+ msg.data.error = "Unable to URL decode data: URL";
+ fetch_data_send_callback(&msg, c);
return false;
}
@@ -207,18 +210,19 @@
c->data = malloc(c->datalen); /* safe: always gets smaller */
if (base64_decode(unescaped, c->datalen, c->data,
&(c->datalen)) == false) {
- fetch_data_send_callback(FETCH_ERROR, c,
- "Unable to Base64 decode data: URL", 0,
- FETCH_ERROR_ENCODING);
+ msg.type = FETCH_ERROR;
+ msg.data.error = "Unable to Base64 decode data: URL";
+ fetch_data_send_callback(&msg, c);
curl_free(unescaped);
return false;
}
} else {
c->data = malloc(c->datalen);
if (c->data == NULL) {
- fetch_data_send_callback(FETCH_ERROR, c,
- "Unable to allocate memory for data: URL", 0,
- FETCH_ERROR_MEMORY);
+ msg.type = FETCH_ERROR;
+ msg.data.error =
+ "Unable to allocate memory for data: URL";
+ fetch_data_send_callback(&msg, c);
curl_free(unescaped);
return false;
}
@@ -232,6 +236,7 @@
static void fetch_data_poll(lwc_string *scheme)
{
+ fetch_msg msg;
struct fetch_data_context *c, *next;
if (ring == NULL) return;
@@ -263,27 +268,33 @@
*/
snprintf(header, sizeof header, "Content-Type: %s",
c->mimetype);
- fetch_data_send_callback(FETCH_HEADER, c, header,
- strlen(header), FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_HEADER;
+ msg.data.header_or_data.buf = (const uint8_t *) header;
+ msg.data.header_or_data.len = strlen(header);
+ fetch_data_send_callback(&msg, c);
if (c->aborted == false) {
snprintf(header, sizeof header,
"Content-Length: %zd",
c->datalen);
- fetch_data_send_callback(FETCH_HEADER, c,
- header, strlen(header),
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_HEADER;
+ msg.data.header_or_data.buf =
+ (const uint8_t *) header;
+ msg.data.header_or_data.len = strlen(header);
+ fetch_data_send_callback(&msg, c);
}
if (c->aborted == false) {
- fetch_data_send_callback(FETCH_DATA,
- c, c->data, c->datalen,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf =
+ (const uint8_t *) c->data;
+ msg.data.header_or_data.len = c->datalen;
+ fetch_data_send_callback(&msg, c);
}
if (c->aborted == false) {
- fetch_data_send_callback(FETCH_FINISHED,
- c, 0, 0, FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_FINISHED;
+ fetch_data_send_callback(&msg, c);
}
} else {
LOG(("Processing of %s failed!", c->url));
Modified: trunk/netsurf/content/fetchers/file.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/file.c?r...
==============================================================================
--- trunk/netsurf/content/fetchers/file.c (original)
+++ trunk/netsurf/content/fetchers/file.c Tue Nov 8 15:51:42 2011
@@ -70,12 +70,11 @@
static struct fetch_file_context *ring = NULL;
/** issue fetch callbacks with locking */
-static inline bool fetch_file_send_callback(fetch_msg msg,
- struct fetch_file_context *ctx, const void *data,
- unsigned long size, fetch_error_code errorcode)
+static inline bool fetch_file_send_callback(const fetch_msg *msg,
+ struct fetch_file_context *ctx)
{
ctx->locked = true;
- fetch_send_callback(msg, ctx->fetchh, data, size, errorcode);
+ fetch_send_callback(msg, ctx->fetchh);
ctx->locked = false;
return ctx->aborted;
@@ -84,6 +83,7 @@
static bool fetch_file_send_header(struct fetch_file_context *ctx,
const char *fmt, ...)
{
+ fetch_msg msg;
char header[64];
va_list ap;
@@ -93,8 +93,10 @@
va_end(ap);
- fetch_file_send_callback(FETCH_HEADER, ctx, header, strlen(header),
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_HEADER;
+ msg.data.header_or_data.buf = (const uint8_t *) header;
+ msg.data.header_or_data.len = strlen(header);
+ fetch_file_send_callback(&msg, ctx);
return ctx->aborted;
}
@@ -204,6 +206,7 @@
static void fetch_file_process_error(struct fetch_file_context *ctx, int code)
{
+ fetch_msg msg;
char buffer[1024];
const char *title;
char key[8];
@@ -223,12 +226,14 @@
"<p>Error %d while fetching file %s</p></body></html>",
title, title, code, nsurl_access(ctx->url));
- if (fetch_file_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer),
- FETCH_ERROR_NO_ERROR))
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+ msg.data.header_or_data.len = strlen(buffer);
+ if (fetch_file_send_callback(&msg, ctx))
goto fetch_file_process_error_aborted;
- fetch_file_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_FINISHED;
+ fetch_file_send_callback(&msg, ctx);
fetch_file_process_error_aborted:
return;
@@ -239,6 +244,7 @@
static void fetch_file_process_plain(struct fetch_file_context *ctx,
struct stat *fdstat)
{
+ fetch_msg msg;
char *buf;
size_t buf_size;
@@ -250,8 +256,8 @@
/* Check if we can just return not modified */
if (ctx->file_etag != 0 && ctx->file_etag == fdstat->st_mtime) {
fetch_set_http_code(ctx->fetchh, 304);
- fetch_file_send_callback(FETCH_NOTMODIFIED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_NOTMODIFIED;
+ fetch_file_send_callback(&msg, ctx);
return;
}
@@ -271,9 +277,10 @@
/* allocate the buffer storage */
buf = malloc(buf_size);
if (buf == NULL) {
- fetch_file_send_callback(FETCH_ERROR, ctx,
- "Unable to allocate memory for file data buffer",
- 0, FETCH_ERROR_MEMORY);
+ msg.type = FETCH_ERROR;
+ msg.data.error =
+ "Unable to allocate memory for file data buffer";
+ fetch_file_send_callback(&msg, ctx);
close(fd);
return;
}
@@ -304,29 +311,32 @@
while (tot_read < fdstat->st_size) {
res = read(fd, buf, buf_size);
if (res == -1) {
- fetch_file_send_callback(FETCH_ERROR, ctx,
- "Error reading file", 0,
- FETCH_ERROR_PARTIAL_FILE);
+ msg.type = FETCH_ERROR;
+ msg.data.error = "Error reading file";
+ fetch_file_send_callback(&msg, ctx);
goto fetch_file_process_aborted;
}
if (res == 0) {
- fetch_file_send_callback(FETCH_ERROR, ctx,
- "Unexpected EOF reading file", 0,
- FETCH_ERROR_PARTIAL_FILE);
+ msg.type = FETCH_ERROR;
+ msg.data.error = "Unexpected EOF reading file";
+ fetch_file_send_callback(&msg, ctx);
goto fetch_file_process_aborted;
}
tot_read += res;
- if (fetch_file_send_callback(FETCH_DATA, ctx, buf, res,
- FETCH_ERROR_NO_ERROR))
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buf;
+ msg.data.header_or_data.len = res;
+ if (fetch_file_send_callback(&msg, ctx))
break;
}
- if (ctx->aborted == false)
- fetch_file_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ if (ctx->aborted == false) {
+ msg.type = FETCH_FINISHED;
+ fetch_file_send_callback(&msg, ctx);
+ }
fetch_file_process_aborted:
@@ -392,6 +402,7 @@
static void fetch_file_process_dir(struct fetch_file_context *ctx,
struct stat *fdstat)
{
+ fetch_msg msg;
char buffer[1024]; /* Output buffer */
bool even = false; /* formatting flag */
char *title; /* pretty printed title */
@@ -425,18 +436,21 @@
if (fetch_file_send_header(ctx, "Content-Type: text/html"))
goto fetch_file_process_dir_aborted;
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+
/* directory listing top */
dirlist_generate_top(buffer, sizeof buffer);
- if (fetch_file_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer),
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = strlen(buffer);
+ if (fetch_file_send_callback(&msg, ctx))
goto fetch_file_process_dir_aborted;
/* directory listing title */
title = gen_nice_title(ctx->path);
dirlist_generate_title(title, buffer, sizeof buffer);
free(title);
- if (fetch_file_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer),
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = strlen(buffer);
+ if (fetch_file_send_callback(&msg, ctx))
goto fetch_file_process_dir_aborted;
/* Print parent directory link */
@@ -446,11 +460,8 @@
if ((res == URL_FUNC_OK) && compare == false) {
dirlist_generate_parent_link(up, buffer, sizeof buffer);
- fetch_file_send_callback(FETCH_DATA, ctx,
- buffer,
- strlen(buffer),
- FETCH_ERROR_NO_ERROR);
-
+ msg.data.header_or_data.len = strlen(buffer);
+ fetch_file_send_callback(&msg, ctx);
}
free(up);
@@ -461,8 +472,8 @@
/* directory list headings */
dirlist_generate_headings(buffer, sizeof buffer);
- if (fetch_file_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer),
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = strlen(buffer);
+ if (fetch_file_send_callback(&msg, ctx))
goto fetch_file_process_dir_aborted;
while ((ent = readdir(scandir)) != NULL) {
@@ -532,10 +543,8 @@
free(path);
- if (fetch_file_send_callback(FETCH_DATA, ctx,
- buffer,
- strlen(buffer),
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = strlen(buffer);
+ if (fetch_file_send_callback(&msg, ctx))
goto fetch_file_process_dir_aborted;
even = !even;
@@ -543,13 +552,12 @@
/* directory listing bottom */
dirlist_generate_bottom(buffer, sizeof buffer);
- if (fetch_file_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer),
- FETCH_ERROR_NO_ERROR))
+ msg.data.header_or_data.len = strlen(buffer);
+ if (fetch_file_send_callback(&msg, ctx))
goto fetch_file_process_dir_aborted;
-
- fetch_file_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_FINISHED;
+ fetch_file_send_callback(&msg, ctx);
fetch_file_process_dir_aborted:
Modified: trunk/netsurf/content/fetchers/resource.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/fetchers/resource...
==============================================================================
--- trunk/netsurf/content/fetchers/resource.c (original)
+++ trunk/netsurf/content/fetchers/resource.c Tue Nov 8 15:51:42 2011
@@ -89,12 +89,11 @@
static uint32_t fetch_resource_path_count;
/** issue fetch callbacks with locking */
-static inline bool fetch_resource_send_callback(fetch_msg msg,
- struct fetch_resource_context *ctx, const void *data,
- unsigned long size, fetch_error_code errorcode)
+static inline bool fetch_resource_send_callback(const fetch_msg *msg,
+ struct fetch_resource_context *ctx)
{
ctx->locked = true;
- fetch_send_callback(msg, ctx->fetchh, data, size, errorcode);
+ fetch_send_callback(msg, ctx->fetchh);
ctx->locked = false;
return ctx->aborted;
@@ -103,6 +102,7 @@
static bool fetch_resource_send_header(struct fetch_resource_context *ctx,
const char *fmt, ...)
{
+ fetch_msg msg;
char header[64];
va_list ap;
@@ -112,8 +112,10 @@
va_end(ap);
- fetch_resource_send_callback(FETCH_HEADER, ctx, header, strlen(header),
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_HEADER;
+ msg.data.header_or_data.buf = (const uint8_t *) header;
+ msg.data.header_or_data.len = strlen(header);
+ fetch_resource_send_callback(&msg, ctx);
return ctx->aborted;
}
@@ -123,12 +125,14 @@
static bool fetch_resource_redirect_handler(struct fetch_resource_context *ctx)
{
+ fetch_msg msg;
+
/* content is going to return redirect */
fetch_set_http_code(ctx->fetchh, 302);
- fetch_resource_send_callback(FETCH_REDIRECT, ctx,
- nsurl_access(ctx->redirect_url), 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_REDIRECT;
+ msg.data.redirect = nsurl_access(ctx->redirect_url);
+ fetch_resource_send_callback(&msg, ctx);
return true;
}
@@ -136,6 +140,7 @@
static bool fetch_resource_notfound_handler(struct fetch_resource_context *ctx)
{
+ fetch_msg msg;
int code = 404;
char buffer[1024];
const char *title;
@@ -156,12 +161,14 @@
"<p>Error %d while fetching file %s</p></body></html>",
title, title, code, nsurl_access(ctx->url));
- if (fetch_resource_send_callback(FETCH_DATA, ctx, buffer, strlen(buffer),
- FETCH_ERROR_NO_ERROR))
+ msg.type = FETCH_DATA;
+ msg.data.header_or_data.buf = (const uint8_t *) buffer;
+ msg.data.header_or_data.len = strlen(buffer);
+ if (fetch_resource_send_callback(&msg, ctx))
goto fetch_resource_notfound_handler_aborted;
- fetch_resource_send_callback(FETCH_FINISHED, ctx, 0, 0,
- FETCH_ERROR_NO_ERROR);
+ msg.type = FETCH_FINISHED;
+ fetch_resource_send_callback(&msg, ctx);
fetch_resource_notfound_handler_aborted:
return false;
Modified: trunk/netsurf/content/llcache.c
URL: http://source.netsurf-browser.org/trunk/netsurf/content/llcache.c?rev=131...
==============================================================================
--- trunk/netsurf/content/llcache.c (original)
+++ trunk/netsurf/content/llcache.c Tue Nov 8 15:51:42 2011
@@ -211,18 +211,17 @@
static nserror llcache_query_handle_response(bool proceed, void *cbpw);
-static void llcache_fetch_callback(fetch_msg msg, void *p, const void *data,
- unsigned long size, fetch_error_code errorcode);
+static void llcache_fetch_callback(const fetch_msg *msg, void *p);
static nserror llcache_fetch_redirect(llcache_object *object,
const char *target, llcache_object **replacement);
static nserror llcache_fetch_notmodified(llcache_object *object,
llcache_object **replacement);
-static nserror llcache_fetch_split_header(const char *data, size_t len,
+static nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
char **name, char **value);
static nserror llcache_fetch_parse_header(llcache_object *object,
- const char *data, size_t len, char **name, char **value);
+ const uint8_t *data, size_t len, char **name, char **value);
static nserror llcache_fetch_process_header(llcache_object *object,
- const char *data, size_t len);
+ const uint8_t *data, size_t len);
static nserror llcache_fetch_process_data(llcache_object *object,
const uint8_t *data, size_t len);
static nserror llcache_fetch_auth(llcache_object *object,
@@ -1814,29 +1813,27 @@
/**
* Handler for fetch events
*
- * \param msg Type of fetch event
+ * \param msg Fetch event
* \param p Our private data
- * \param data Event data
- * \param size Length of data in bytes
- * \param errorcode Reason for fetch error
- */
-void llcache_fetch_callback(fetch_msg msg, void *p, const void *data,
- unsigned long size, fetch_error_code errorcode)
+ */
+void llcache_fetch_callback(const fetch_msg *msg, void *p)
{
nserror error = NSERROR_OK;
llcache_object *object = p;
llcache_event event;
#ifdef LLCACHE_TRACE
- LOG(("Fetch event %d for %p", msg, object));
+ LOG(("Fetch event %d for %p", msg->type, object));
#endif
- switch (msg) {
+ switch (msg->type) {
case FETCH_HEADER:
/* Received a fetch header */
object->fetch.state = LLCACHE_FETCH_HEADERS;
- error = llcache_fetch_process_header(object, data, size);
+ error = llcache_fetch_process_header(object,
+ msg->data.header_or_data.buf,
+ msg->data.header_or_data.len);
break;
/* 3xx responses */
@@ -1849,7 +1846,8 @@
object->candidate = NULL;
}
- error = llcache_fetch_redirect(object, data, &object);
+ error = llcache_fetch_redirect(object,
+ msg->data.redirect, &object);
break;
case FETCH_NOTMODIFIED:
/* Conditional request determined that cached object is fresh */
@@ -1891,7 +1889,9 @@
object->fetch.state = LLCACHE_FETCH_DATA;
- error = llcache_fetch_process_data(object, data, size);
+ error = llcache_fetch_process_data(object,
+ msg->data.header_or_data.buf,
+ msg->data.header_or_data.len);
break;
case FETCH_FINISHED:
/* Finished fetching */
@@ -1933,7 +1933,7 @@
/** \todo Consider using errorcode for something */
event.type = LLCACHE_EVENT_ERROR;
- event.data.msg = data;
+ event.data.msg = msg->data.error;
error = llcache_send_event_to_users(object, &event);
@@ -1941,8 +1941,8 @@
case FETCH_PROGRESS:
/* Progress update */
event.type = LLCACHE_EVENT_PROGRESS;
- event.data.msg = data;
-
+ event.data.msg = msg->data.progress;
+
error = llcache_send_event_to_users(object, &event);
break;
@@ -1957,7 +1957,7 @@
object->candidate = NULL;
}
- error = llcache_fetch_auth(object, data);
+ error = llcache_fetch_auth(object, msg->data.auth.realm);
break;
case FETCH_CERT_ERR:
/* Something went wrong when validating TLS certificates */
@@ -1968,7 +1968,9 @@
object->candidate = NULL;
}
- error = llcache_fetch_cert_error(object, data, size);
+ error = llcache_fetch_cert_error(object,
+ msg->data.cert_err.certs,
+ msg->data.cert_err.num_certs);
break;
}
@@ -2179,17 +2181,17 @@
* \param value Pointer to location to receive header value
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror llcache_fetch_split_header(const char *data, size_t len, char **name,
- char **value)
+nserror llcache_fetch_split_header(const uint8_t *data, size_t len,
+ char **name, char **value)
{
char *n, *v;
- const char *colon;
+ const uint8_t *colon;
/* Find colon */
- colon = strchr(data, ':');
+ colon = (const uint8_t *) strchr((const char *) data, ':');
if (colon == NULL) {
/* Failed, assume a key with no value */
- n = strdup(data);
+ n = strdup((const char *) data);
if (n == NULL)
return NSERROR_NOMEM;
@@ -2213,7 +2215,7 @@
colon[-1] == '\n'))
colon--;
- n = strndup(data, colon - data);
+ n = strndup((const char *) data, colon - data);
if (n == NULL)
return NSERROR_NOMEM;
@@ -2236,7 +2238,7 @@
len--;
}
- v = strndup(colon, len - (colon - data));
+ v = strndup((const char *) colon, len - (colon - data));
if (v == NULL) {
free(n);
return NSERROR_NOMEM;
@@ -2263,8 +2265,8 @@
* the cache control data for the object if an interesting
* header is encountered
*/
-nserror llcache_fetch_parse_header(llcache_object *object, const char *data,
- size_t len, char **name, char **value)
+nserror llcache_fetch_parse_header(llcache_object *object,
+ const uint8_t *data, size_t len, char **name, char **value)
{
nserror error;
@@ -2355,8 +2357,8 @@
* \param len Byte length of header
* \return NSERROR_OK on success, appropriate error otherwise
*/
-nserror llcache_fetch_process_header(llcache_object *object, const char *data,
- size_t len)
+nserror llcache_fetch_process_header(llcache_object *object,
+ const uint8_t *data, size_t len)
{
nserror error;
char *name, *value;
@@ -2374,7 +2376,7 @@
* that we might have computed, and start again.
*/
/** \todo Properly parse the response line */
- if (strncmp(data, "HTTP/", SLEN("HTTP/")) == 0) {
+ if (strncmp((const char *) data, "HTTP/", SLEN("HTTP/")) == 0) {
time_t req_time = object->cache.req_time;
llcache_invalidate_cache_control_data(object);
11 years, 7 months
r13136 mono - in /trunk/netsurf/atari: browser.c gui.c
by netsurf@semichrome.net
Author: mono
Date: Tue Nov 8 13:13:34 2011
New Revision: 13136
URL: http://source.netsurf-browser.org?rev=13136&view=rev
Log:
Removed calls to FrameInit/FrameExit ( was used for window components ).
Modified:
trunk/netsurf/atari/browser.c
trunk/netsurf/atari/gui.c
Modified: trunk/netsurf/atari/browser.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/browser.c?rev=13136...
==============================================================================
--- trunk/netsurf/atari/browser.c (original)
+++ trunk/netsurf/atari/browser.c Tue Nov 8 13:13:34 2011
@@ -70,12 +70,6 @@
static void __CDECL browser_evnt_wdestroy( WINDOW * c, short buff[8], void * data);
COMPONENT *comp_widget_create( APPvar *app, WINDOW *win, int size, int flex );
-/*
-The component window interface needs frame API init,
-keep track of frame API init:
-*/
-static bool frameinit = true;
-
/*
Create an browser component.
@@ -93,11 +87,6 @@
{
LGRECT cwork;
COMPONENT * scrollv, * scrollh, * drawable;
-
- if( frameinit ) {
- mt_FrameInit( &app );
- frameinit = false;
- }
CMP_BROWSER bnew = (CMP_BROWSER)malloc( sizeof(struct s_browser) );
if( bnew )
Modified: trunk/netsurf/atari/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/gui.c?rev=13136&r1=...
==============================================================================
--- trunk/netsurf/atari/gui.c (original)
+++ trunk/netsurf/atari/gui.c Tue Nov 8 13:13:34 2011
@@ -884,8 +884,6 @@
}
LOG(("Shutting down plotter"));
atari_plotter_finalise();
- LOG(("FrameExit"));
- mt_FrameExit( &app );
if( tmp_clipboard != NULL ){
free( tmp_clipboard );
tmp_clipboard = NULL;
11 years, 7 months
r13135 chris_y - in /trunk/netsurf/amiga: menu.c options.h
by netsurf@semichrome.net
Author: chris_y
Date: Mon Nov 7 12:51:08 2011
New Revision: 13135
URL: http://source.netsurf-browser.org?rev=13135&view=rev
Log:
Reimplement the previous hotlist menu refresh code, as the bug causing the previous
problems was fixed ages ago. Make the timing configurable for now but default to off.
Modified:
trunk/netsurf/amiga/menu.c
trunk/netsurf/amiga/options.h
Modified: trunk/netsurf/amiga/menu.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/menu.c?rev=13135&r1...
==============================================================================
--- trunk/netsurf/amiga/menu.c (original)
+++ trunk/netsurf/amiga/menu.c Mon Nov 7 12:51:08 2011
@@ -63,6 +63,7 @@
#include "desktop/selection.h"
#include "desktop/textinput.h"
#include "utils/messages.h"
+#include "utils/schedule.h"
#define IMAGE_MENU_ITEM(n, i, t) \
gwin->menulab[n] = LabelObject, \
@@ -254,7 +255,7 @@
gwin->menutype[AMI_MENU_AREXX_MAX] = NM_END;
}
-/* Menu refresh for hotlist - disabled, see below.
+/* Menu refresh for hotlist */
void ami_menu_refresh(struct gui_window_2 *gwin)
{
SetAttrs(gwin->objects[OID_MAIN],
@@ -267,10 +268,7 @@
SetAttrs(gwin->objects[OID_MAIN],
WINDOW_NewMenu, gwin->menu,
TAG_DONE);
-
- schedule(6000,(void *)ami_menu_refresh,gwin);
-}
-*/
+}
struct NewMenu *ami_create_menu(struct gui_window_2 *gwin)
{
@@ -299,11 +297,9 @@
ami_menu_scan(ami_tree_get_tree(hotlist_window), false, gwin);
ami_menu_arexx_scan(gwin);
-/* Set up scheduler to refresh the hotlist menu
- Disabled as it causes everything to slow down to a halt after
- several iterations
- schedule(6000,(void *)ami_menu_refresh,gwin);
-*/
+/* Set up scheduler to refresh the hotlist menu */
+ if(option_menu_refresh > 0)
+ schedule(option_menu_refresh, (void *)ami_menu_refresh, gwin);
return(gwin->menu);
}
Modified: trunk/netsurf/amiga/options.h
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/options.h?rev=13135...
==============================================================================
--- trunk/netsurf/amiga/options.h (original)
+++ trunk/netsurf/amiga/options.h Mon Nov 7 12:51:08 2011
@@ -67,6 +67,7 @@
extern int option_monitor_aspect_x;
extern int option_monitor_aspect_y;
extern bool option_accept_lang_locale;
+extern int option_menu_refresh;
#define EXTRA_OPTION_DEFINE \
char *option_url_file = 0; \
@@ -116,6 +117,7 @@
int option_monitor_aspect_x = 4; \
int option_monitor_aspect_y = 3; \
bool option_accept_lang_locale = true; \
+int option_menu_refresh = 0; \
#define EXTRA_OPTION_TABLE \
{ "url_file", OPTION_STRING, &option_url_file }, \
@@ -164,5 +166,6 @@
{ "amiga_ydpi", OPTION_INTEGER, &option_amiga_ydpi}, \
{ "monitor_aspect_x", OPTION_INTEGER, &option_monitor_aspect_x}, \
{ "monitor_aspect_y", OPTION_INTEGER, &option_monitor_aspect_y}, \
-{ "accept_lang_locale", OPTION_BOOL, &option_accept_lang_locale},
+{ "accept_lang_locale", OPTION_BOOL, &option_accept_lang_locale}, \
+{ "menu_refresh", OPTION_INTEGER, &option_menu_refresh},
#endif
11 years, 7 months
r13134 tlsa - /trunk/libcss/src/select/select.c
by netsurf@semichrome.net
Author: tlsa
Date: Mon Nov 7 11:14:02 2011
New Revision: 13134
URL: http://source.netsurf-browser.org?rev=13134&view=rev
Log:
Simplify cache loop criterion.
Modified:
trunk/libcss/src/select/select.c
Modified: trunk/libcss/src/select/select.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/select/select.c?rev=13...
==============================================================================
--- trunk/libcss/src/select/select.c (original)
+++ trunk/libcss/src/select/select.c Mon Nov 7 11:14:02 2011
@@ -1347,10 +1347,11 @@
(next_detail->type == CSS_SELECTOR_CLASS ||
next_detail->type == CSS_SELECTOR_ID)) {
reject_item *reject = state->next_reject + 1;
+ reject_item *last = state->reject_cache +
+ N_ELEMENTS(state->reject_cache) - 1;
bool match = false;
- while (reject < state->reject_cache +
- N_ELEMENTS(state->reject_cache)) {
+ while (reject <= last) {
/* Perform pessimistic matching (may hurt quirks) */
if (reject->type == next_detail->type &&
lwc_string_isequal(reject->value,
11 years, 7 months
r13133 tlsa - in /trunk/libcss/src/select: select.c select.h
by netsurf@semichrome.net
Author: tlsa
Date: Mon Nov 7 08:04:49 2011
New Revision: 13133
URL: http://source.netsurf-browser.org?rev=13133&view=rev
Log:
Fill reject cache backwards from end.
Modified:
trunk/libcss/src/select/select.c
trunk/libcss/src/select/select.h
Modified: trunk/libcss/src/select/select.c
URL: http://source.netsurf-browser.org/trunk/libcss/src/select/select.c?rev=13...
==============================================================================
--- trunk/libcss/src/select/select.c (original)
+++ trunk/libcss/src/select/select.c Mon Nov 7 08:04:49 2011
@@ -350,7 +350,8 @@
state.media = media;
state.handler = handler;
state.pw = pw;
- state.next_reject = state.reject_cache;
+ state.next_reject = state.reject_cache +
+ (N_ELEMENTS(state.reject_cache) - 1);
/* Allocate the result set */
state.results = ctx->alloc(NULL, sizeof(css_select_results), ctx->pw);
@@ -1139,8 +1140,7 @@
if (detail->next)
next_detail = detail + 1;
- if (state->next_reject >= state->reject_cache +
- N_ELEMENTS(state->reject_cache) ||
+ if (state->next_reject < state->reject_cache ||
comb != CSS_COMBINATOR_ANCESTOR ||
next_detail == NULL ||
next_detail->next != 0 ||
@@ -1151,7 +1151,7 @@
/* Insert */
state->next_reject->type = next_detail->type;
state->next_reject->value = next_detail->qname.name;
- state->next_reject++;
+ state->next_reject--;
}
css_error match_selector_chain(css_select_ctx *ctx,
@@ -1346,10 +1346,11 @@
next_detail != NULL &&
(next_detail->type == CSS_SELECTOR_CLASS ||
next_detail->type == CSS_SELECTOR_ID)) {
- reject_item *reject = state->reject_cache;
+ reject_item *reject = state->next_reject + 1;
bool match = false;
- while (reject != state->next_reject) {
+ while (reject < state->reject_cache +
+ N_ELEMENTS(state->reject_cache)) {
/* Perform pessimistic matching (may hurt quirks) */
if (reject->type == next_detail->type &&
lwc_string_isequal(reject->value,
Modified: trunk/libcss/src/select/select.h
URL: http://source.netsurf-browser.org/trunk/libcss/src/select/select.h?rev=13...
==============================================================================
--- trunk/libcss/src/select/select.h (original)
+++ trunk/libcss/src/select/select.h Mon Nov 7 08:04:49 2011
@@ -55,7 +55,7 @@
lwc_string **classes; /* Node classes, if any */
uint32_t n_classes; /* Number of classes */
- reject_item reject_cache[128]; /* Reject cache */
+ reject_item reject_cache[128]; /* Reject cache (filled from end) */
reject_item *next_reject; /* Next free slot in reject cache */
prop_state props[CSS_N_PROPERTIES][CSS_PSEUDO_ELEMENT_COUNT];
11 years, 7 months