1
/* Visited URL history managment - NOT goto_url_dialog history! */
2
/* $Id: history.c,v 1.82 2004/06/25 09:54:46 jonas Exp $ */
12
#include "cache/cache.h"
13
#include "config/options.h"
14
#include "dialogs/status.h"
15
#include "protocol/uri.h"
16
#include "sched/connection.h"
17
#include "sched/history.h"
18
#include "sched/location.h"
19
#include "sched/session.h"
20
#include "sched/task.h"
21
#include "util/memory.h"
22
#include "util/string.h"
23
#include "viewer/text/view.h"
24
#include "viewer/text/vs.h"
28
free_history(struct list_head *history)
30
while (!list_empty(*history)) {
31
struct location *loc = history->next;
34
destroy_location(loc);
40
create_history(struct ses_history *history)
42
init_list(history->history);
43
history->current = NULL;
47
destroy_history(struct ses_history *history)
49
free_history(&history->history);
50
history->current = NULL;
54
clean_unhistory(struct ses_history *history)
56
if (!history->current) return;
58
while (list_has_next(history->history, history->current)) {
59
struct location *loc = history->current->next;
62
destroy_location(loc);
66
/* If history->current points to an entry redundant to @loc, remove that
70
compress_history(struct ses_history *history, struct location *loc)
72
struct location *current = history->current;
76
if (uris_compare(current->vs.uri, loc->vs.uri)
77
|| (current->download.cached->redirect
78
&& current->download.cached->redirect == loc->vs.uri)) {
79
del_from_history(history, current);
80
destroy_location(current);
87
ses_history_move(struct session *ses)
94
mem_free_set(&ses->search_word, NULL);
96
/* Does it make sense? */
98
if (!have_location(ses) || !ses->task.target_location)
101
if (ses->task.target_location
102
== (struct location *) &ses->history.history)
107
ses->history.current = ses->task.target_location;
111
/* There can be only one ... */
112
if (compare_uri(loc->vs.uri, ses->loading_uri, 0))
115
/* Remake that location. */
117
del_from_history(&ses->history, loc);
118
destroy_location(loc);
121
/* Maybe trash the unhistory. */
123
if (get_opt_bool("document.history.keep_unhistory"))
124
clean_unhistory(&ses->history);
129
go_history(struct session *ses, struct location *loc)
131
ses->reloadlevel = CACHE_MODE_NORMAL;
133
if (ses->task.type) {
134
abort_loading(ses, 0);
135
print_screen_status(ses);
136
reload(ses, CACHE_MODE_NORMAL);
140
if (!have_location(ses)
141
|| loc == (struct location *) &ses->history.history) {
142
/* There's no history, at most only the current location. */
146
abort_loading(ses, 0);
148
set_session_referrer(ses, NULL);
150
ses_goto(ses, loc->vs.uri, NULL, loc,
151
CACHE_MODE_ALWAYS, TASK_HISTORY, 0);