Пример #1
0
/* exported interface documented in cookie_manager.h */
void cookie_manager_remove(const struct cookie_data *data)
{
	struct cookie_manager_folder *parent = NULL;
	struct cookie_manager_entry *cookie = NULL;
	nserror err;

	assert(data != NULL);

	/* If we don't have a cookie manager at the moment, just return */
	if (cm_ctx.tree == NULL)
		return;

	err = cookie_manager_find_folder(NULL, data->domain,
			strlen(data->domain), &parent);
	if (err != NSERROR_OK || parent == NULL) {
		/* Nothing to delete */
		return;
	}

	err = cookie_manager_find_entry(parent->folder, data->name,
			strlen(data->name), &cookie);
	if (err != NSERROR_OK || cookie == NULL) {
		/* Nothing to delete */
		return;
	}

	/* Delete the node */
	treeview_delete_node(cm_ctx.tree, cookie->entry, TREE_OPTION_NONE);
}
Пример #2
0
/**
 * Internal routine to actually perform global history addition
 *
 * \param url The URL to add
 * \param data URL data associated with URL
 * \return true (for urldb_iterate_entries)
 */
static bool global_history_add_entry(nsurl *url,
		const struct url_data *data)
{
	int slot;
	time_t visit_date;
	time_t earliest_date = gh_ctx.today - (N_DAYS - 1) * N_SEC_PER_DAY;
	bool got_treeview = gh_ctx.tree != NULL;

	assert((url != NULL) && (data != NULL));

	visit_date = data->last_visit;

	/* Find day array slot for entry */
	if (visit_date >= gh_ctx.today) {
		slot = 0;
	} else if (visit_date >= earliest_date) {
		slot = (gh_ctx.today - visit_date) / N_SEC_PER_DAY + 1;
	} else {
		/* too old */
		return true;
	}

	if (got_treeview == true) {
		/* The treeview for global history already exists */
		struct global_history_entry *e;

		/* Delete any existing entry for this URL */
		e = global_history_find(url);
		if (e != NULL) {
			treeview_delete_node(gh_ctx.tree, e->entry,
					TREE_OPTION_SUPPRESS_REDRAW |
					TREE_OPTION_SUPPRESS_RESIZE);
		}
	}

	if (global_history_add_entry_internal(url, slot, data,
			got_treeview) != NSERROR_OK) {
		return false;
	}

	return true;
}