예제 #1
0
/**
 * Creates an empty tree entry for a cookie, and links it into the tree.
 *
 * All information is copied from the cookie_data, and as such can
 * be edited and should be freed.
 *
 * \param parent      the node to link to
 * \param data	      the cookie data to use
 * \return NSERROR_OK on success, appropriate error otherwise
 */
static nserror cookie_manager_create_cookie_node(
		struct cookie_manager_folder *parent,
		const struct cookie_data *data)
{
	nserror err;
	struct cookie_manager_entry *cookie;

	/* Create new cookie manager entry */
	cookie = malloc(sizeof(struct cookie_manager_entry));
	if (cookie == NULL) {
		return NSERROR_NOMEM;
	}

	cookie->user_delete = false;

	err = cookie_manager_set_treeview_field_data(cookie, data);
	if (err != NSERROR_OK) {
		free(cookie);
		return err;
	}

	err = treeview_create_node_entry(cm_ctx.tree, &(cookie->entry),
			parent->folder, TREE_REL_FIRST_CHILD,
			cookie->data, cookie,
			cm_ctx.built ? TREE_OPTION_NONE :
					TREE_OPTION_SUPPRESS_RESIZE |
					TREE_OPTION_SUPPRESS_REDRAW);
	if (err != NSERROR_OK) {
		cookie_manager_free_treeview_field_data(cookie);
		free(cookie);
		return err;
	}

	return NSERROR_OK;
}
예제 #2
0
/**
 * Add a global history entry to the treeview
 *
 * \param e	entry to add to treeview
 * \param slot  global history slot containing entry
 * \return NSERROR_OK on success, or appropriate error otherwise
 *
 * It is assumed that the entry is unique (for its URL) in the global
 * history table
 */
static nserror global_history_entry_insert(struct global_history_entry *e,
		int slot)
{
	nserror err;

	treeview_node *parent;
	err = global_history_get_parent_treeview_node(&parent, slot);
	if (err != NSERROR_OK) {
		return err;
	}

	err = treeview_create_node_entry(gh_ctx.tree, &(e->entry),
			parent, TREE_REL_FIRST_CHILD, e->data, e,
			gh_ctx.built ? TREE_OPTION_NONE :
					TREE_OPTION_SUPPRESS_RESIZE |
					TREE_OPTION_SUPPRESS_REDRAW);
	if (err != NSERROR_OK) {
		return err;
	}

	return NSERROR_OK;
}