Esempio n. 1
0
bool sslcert_load_tree(struct tree *tree, 
		       const struct ssl_cert_info *certs,
		       struct sslcert_session_data *data)
{
	struct node *tree_root;
	struct node *node;
	unsigned long cert_loop;

	assert(data != NULL && certs != NULL && tree != NULL);

	tree_root = tree_get_root(tree);

	for (cert_loop = 0; cert_loop < data->num; cert_loop++) {
		node = sslcert_create_node(&(certs[cert_loop]));
		if (node != NULL) {
			/* There is no problem creating the node
			 * add an entry for it in the root of the
			 * treeview .
			 */
			tree_link_node(tree, tree_root, node, false);
		}
	}

	data->tree = tree;

	return tree;

}
Esempio n. 2
0
bool ro_treeview_has_selection(ro_treeview *tv)
{
	if (tv != NULL)
		return tree_node_has_selection(tree_get_root(tv->tree));
	else
		return false;
}
Esempio n. 3
0
/**
 * Add an entry node.
 *
 * \param selected add the entry in the currently-selected node
 */
void hotlist_add_entry(bool selected)
{
	struct node *node;
	struct node *parent = NULL;
	creating_node = true;

	if (selected == true) {
		parent = tree_get_selected_node(tree_get_root(hotlist_tree));
		if (parent && (tree_node_is_folder(parent) == false)) {
			parent = tree_node_get_parent(parent);
		}
	}

	if (parent == NULL) {
		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)
		return;
	tree_set_node_user_callback(node, hotlist_node_callback, NULL);
	tree_url_node_edit_title(hotlist_tree, node);
}
Esempio n. 4
0
/**
 * Add a folder node.
 *
 * \param selected create the folder in the currently-selected node
 */
void hotlist_add_folder(bool selected)
{
	struct node *node, *parent = NULL;
	struct node_element *element;
	char *title = strdup("Untitled");

	if (title == NULL) {
		LOG(("malloc failed"));
		warn_user("NoMemory", 0);
		return;
	}
	creating_node = true;

	if (selected == true) {
		parent = tree_get_selected_node(tree_get_root(hotlist_tree));
		if (parent && (tree_node_is_folder(parent) == false)) {
			parent = tree_node_get_parent(parent);
		}
	}

	if (parent == NULL) {
		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);
		return;
	}
	tree_set_node_user_callback(node, hotlist_node_callback, NULL);
	tree_set_node_icon(hotlist_tree, node, folder_icon);
 	element = tree_node_find_element(node, TREE_ELEMENT_TITLE, NULL);
 	tree_start_edit(hotlist_tree, element);
}
Esempio n. 5
0
void RTFConcatenator::CollectAll(struct wintree_t *pWinTree)
{
	ASSERT(pWinTree);

	// set top node
	m_pTopNode = tree_get_root(wintree_get_tree(pWinTree));

	// make headings
	m_HeadingCounter.CollectAll(pWinTree);

	wintree_traverse(pWinTree, CollectCallback, this);
}
Esempio n. 6
0
/**
 * Loads an url tree from a specified file.
 *
 * \param  filename  	name of file to read
 * \param  tree		empty tree which data will be read into
 * \return the file represented as a tree, or NULL on failure
 */
bool tree_urlfile_load(const char *filename, struct tree *tree,
		       tree_node_user_callback callback, void *callback_data)
{
	xmlDoc *doc;
	xmlNode *html, *body, *ul;
	struct node *root;
	FILE *fp = NULL;

	if (filename == NULL) {
		return false;
	}

	fp = fopen(filename, "r");
	if (fp == NULL) {
		return false;
	}
	fclose(fp);

	doc = htmlParseFile(filename, "iso-8859-1");
	if (doc == NULL) {
		warn_user("TreeLoadError", messages_get("ParsingFail"));
		return false;
	}

	html = tree_url_find_xml_element((xmlNode *) doc, "html");
	body = tree_url_find_xml_element(html, "body");
	ul = tree_url_find_xml_element(body, "ul");
	if (ul == NULL) {
		xmlFreeDoc(doc);
		warn_user("TreeLoadError",
			  "(<html>...<body>...<ul> not found.)");
		return false;
	}

	root = tree_get_root(tree);
	tree_url_load_directory(ul, tree, root, callback, callback_data);
	tree_set_node_expanded(tree, root, true, false, false);

	xmlFreeDoc(doc);
	return true;
}
Esempio n. 7
0
/**
 * Perform a save to a specified file in the form of a html page
 *
 * \param filename	the file to save to
 * \param page_title 	title of the page
 */
bool tree_urlfile_save(struct tree *tree, const char *filename,
		       const char *page_title)
{
	int res;
	xmlDoc *doc;
	xmlNode *html, *head, *title, *body;

	/* Unfortunately the Browse Hotlist format is invalid HTML,
	 * so this is a lie. 
	 */
	doc = htmlNewDoc(
		(const xmlChar *) "http://www.w3.org/TR/html4/strict.dtd",
		(const xmlChar *) "-//W3C//DTD HTML 4.01//EN");
	if (doc == NULL) {
		warn_user("NoMemory", 0);
		return false;
	}

	html = xmlNewNode(NULL, (const xmlChar *) "html");
	if (html == NULL) {
		warn_user("NoMemory", 0);
		xmlFreeDoc(doc);
		return false;
	}
	xmlDocSetRootElement(doc, html);

	head = xmlNewChild(html, NULL, (const xmlChar *) "head", NULL);
	if (head == NULL) {
		warn_user("NoMemory", 0);
		xmlFreeDoc(doc);
		return false;
	}

	title  = xmlNewTextChild(head, NULL, (const xmlChar *) "title",
				 (const xmlChar *) page_title);
	if (title == NULL) {
		warn_user("NoMemory", 0);
		xmlFreeDoc(doc);
		return false;
	}

	body = xmlNewChild(html, NULL, (const xmlChar *) "body", NULL);
	if (body == NULL) {
		warn_user("NoMemory", 0);
		xmlFreeDoc(doc);
		return false;
	}

	if (!tree_url_save_directory(tree_get_root(tree), body)) {
 		warn_user("NoMemory", 0);
 		xmlFreeDoc(doc);
 		return false;
 	}

	doc->charset = XML_CHAR_ENCODING_UTF8;
	res = htmlSaveFileEnc(filename, doc, "iso-8859-1");
	if (res == -1) {
		warn_user("HotlistSaveError", 0);
		xmlFreeDoc(doc);
		return false;
	}

	xmlFreeDoc(doc);
	return true;
}
Esempio n. 8
0
static bool ro_treeview_mouse_click(wimp_pointer *pointer)
{
	os_error		*error;
	ro_treeview		*tv;
	wimp_window_state	state;
	int			xpos, ypos;
	browser_mouse_state	mouse;
	bool			handled = false;

	tv = (ro_treeview *) ro_gui_wimp_event_get_user_data(pointer->w);
	if (tv == NULL) {
		LOG(("NULL treeview block for window: 0x%x",
				(unsigned int) pointer->w));
		return false;
	}

	state.w = tv->w;
	error = xwimp_get_window_state(&state);
	if (error) {
		LOG(("xwimp_get_window_state: 0x%x: %s",
				error->errnum, error->errmess));
		warn_user("WimpError", error->errmess);
		return false;
	}

	/* Convert the returned mouse coordinates into NetSurf's internal
	 * units.
	 */

	xpos = ((pointer->pos.x - state.visible.x0) +
			state.xscroll - tv->origin.x) / 2;
	ypos = ((state.visible.y1 - pointer->pos.y) -
			state.yscroll + tv->origin.y) / 2;

	/* Start to process the mouse click.
	 *
	 * Select and Adjust are processed normally. To get filer-like operation
	 * with selections, Menu clicks are passed to the treeview first as
	 * Select if there are no selected nodes in the tree.
	 */

	mouse = 0;

	if (pointer->buttons == wimp_CLICK_MENU) {
		if (!tree_node_has_selection(tree_get_root(tv->tree)))
			mouse |= BROWSER_MOUSE_CLICK_1;
	} else {
		mouse = ro_gui_mouse_click_state(pointer->buttons,
				wimp_BUTTON_DOUBLE_CLICK_DRAG);

		/* Give the window input focus on Select-clicks.  This wouldn't
		 * be necessary if the core used the RISC OS caret.
		 */

		if (mouse & BROWSER_MOUSE_CLICK_1)
			xwimp_set_caret_position(tv->w, -1, -100, -100, 32, -1);
	}

	if (mouse != 0) {
		handled = tree_mouse_action(tv->tree, mouse, xpos, ypos);

		tv->drag = tree_drag_status(tv->tree);
		if (tv->drag != TREE_NO_DRAG) {
			tv->drag_start.x = xpos;
			tv->drag_start.y = ypos;
		}

		/* If it's a visible drag, start the RO side of the visible
		 * effects.
		 */

		if (tv->drag == TREE_SELECT_DRAG ||
				tv->drag == TREE_MOVE_DRAG)
			ro_treeview_drag_start(tv, pointer, &state);


		if (tv->callbacks != NULL &&
				tv->callbacks->toolbar_button_update != NULL)
			tv->callbacks->toolbar_button_update();
	}

	/* Special actions for some mouse buttons.  Adjust closes the dialog;
	 * Menu opens a menu.  For the latter, we assume that the owning module
	 * will have attached a window menu to our parent window with the auto
	 * flag unset (so that we can fudge the selection above).  If it hasn't,
	 * the call will quietly fail.
	 *
	 * \TODO -- Adjust-click close isn't a perfect copy of what the RO
	 *          version did: adjust clicks anywhere close the tree, and
	 *          selections persist.
	 */

	switch(pointer->buttons) {
	case wimp_CLICK_ADJUST:
		if (handled)
			ro_gui_dialog_close(tv->w);
		break;

	case wimp_CLICK_MENU:
		ro_gui_wimp_event_process_window_menu_click(pointer);
		break;
	}

	return true;
}
Esempio n. 9
0
/**
 * Informs the hotlist that some content has been visited
 *
 * \param content  the content visited
 */
void hotlist_visited(hlcache_handle *content)
{
	if (hotlist_tree != NULL) {
		hotlist_visited_internal(content, tree_get_root(hotlist_tree));
	}
}
Esempio n. 10
0
/* exported interface documented in hotlist.h */
bool hotlist_initialise(struct tree *tree, const char *hotlist_path, const char* folder_icon_name)
{
	struct node *node;
	const struct url_data *url_data;
	char *name;
	int hlst_loop;

	/* Either load or create a hotlist */

	creating_node = false;

	folder_icon = tree_load_icon(folder_icon_name);

	tree_url_node_init(folder_icon_name);

	if (tree == NULL)
		return false;

	hotlist_tree = tree;
	hotlist_tree_root = tree_get_root(hotlist_tree);

	if (tree_urlfile_load(hotlist_path, 
			      hotlist_tree,  
			      hotlist_node_callback, 
			      NULL)) {
		return true;
	}


	/* failed to load hotlist file, use default list */
	name = strdup("NetSurf");
	if (name == NULL) {
		LOG(("malloc failed"));
		warn_user("NoMemory", 0);
		return false;
	}
	node = tree_create_folder_node(hotlist_tree, hotlist_tree_root,
				       name, true, false, false);
	if (node == NULL) {
		free(name);
		return false;
	}

	tree_set_node_user_callback(node, hotlist_node_callback, NULL);
	tree_set_node_icon(hotlist_tree, node, folder_icon);

	for (hlst_loop = 0; hlst_loop != HOTLIST_ENTRIES_COUNT; hlst_loop++) {
		url_data = urldb_get_url_data(hotlist_default_entries[hlst_loop].url);
		if (url_data == NULL) {
			urldb_add_url(hotlist_default_entries[hlst_loop].url);
			urldb_set_url_persistence(
				hotlist_default_entries[hlst_loop].url,
				true);
			url_data = urldb_get_url_data(
				hotlist_default_entries[hlst_loop].url);
		}
		if (url_data != NULL) {
			tree_create_URL_node(hotlist_tree, node,
					hotlist_default_entries[hlst_loop].url,
					messages_get(hotlist_default_entries[hlst_loop].msg_key),
					hotlist_node_callback, NULL);
			tree_update_URL_node(hotlist_tree, node,
					hotlist_default_entries[hlst_loop].url,
					url_data);
		}
	}

	return true;
}