1 #ifndef EL__SESSION_SESSION_H
2 #define EL__SESSION_SESSION_H
4 #include "bfu/dialog.h"
5 #include "cache/cache.h"
6 #include "main/timer.h" /* timer_id_T */
7 #include "network/state.h"
8 #include "session/download.h"
9 #include "session/history.h"
10 #include "util/lists.h"
11 #include "viewer/text/vs.h"
16 struct session_status
;
23 enum remote_session_flags
{
24 SES_REMOTE_NEW_TAB
= 1,
25 SES_REMOTE_NEW_WINDOW
= 2,
26 SES_REMOTE_CURRENT_TAB
= 4,
27 SES_REMOTE_PROMPT_URL
= 8,
29 SES_REMOTE_ADD_BOOKMARK
= 32,
30 SES_REMOTE_INFO_BOX
= 64,
33 /* This is generic frame descriptor, meaningful mainly for ses_*_frame*(). */
35 LIST_HEAD(struct frame
);
43 /* Use for keyboard prefixes. */
45 /* This is the repeat count being inserted by user so far. It is stored
46 * intermediately per-session. */
50 /* If the previous key was a mark prefix, this describes what kind of
51 * action are we supposed to do when we receive the next key. */
52 enum { KP_MARK_NOTHING
, KP_MARK_SET
, KP_MARK_GOTO
} mark
;
58 /* This describes, what are we trying to do right now. We pass this around so
59 * that we can use generic scheduler routines and when the control will get
60 * back to our subsystem, we will know what are we up to. */
71 /* TODO: union --pasky */
74 struct location
*location
;
78 struct session_status
{
79 unsigned int show_tabs_bar
:1;
80 unsigned int show_status_bar
:1;
81 unsigned int show_title_bar
:1;
83 int force_show_status_bar
:2;
84 int force_show_title_bar
:2;
86 unsigned int set_window_title
:1;
87 unsigned char *last_title
;
90 unsigned int show_leds
:1;
91 struct led_panel leds
;
93 struct led
*insert_mode_led
;
94 struct led
*ecmascript_led
;
95 struct led
*popup_led
;
97 /* Has the tab been visited yet. */
98 unsigned int visited
:1;
100 /* Is processing file requests. */
101 unsigned int processing_file_requests
:1;
112 NAVIGATE_CURSOR_ROUTING
,
115 /* This is one of the building stones of ELinks architecture --- this structure
116 * carries information about the specific ELinks session. Each tab (thus, at
117 * least one per terminal, in the normal case) has its own session. Session
118 * describes mainly the current browsing and control state, from the currently
119 * viewed document through the browsing history of this session to the status
120 * bar information. */
122 LIST_HEAD(struct session
);
125 /* The vital session data */
130 /* Browsing history */
132 struct ses_history history
;
135 /* The current document */
137 struct list_head more_files
; /* -> struct file_to_load */
139 struct download loading
;
140 struct uri
*loading_uri
;
142 enum cache_mode reloadlevel
;
145 struct document_view
*doc_view
;
146 struct list_head scrn_frames
; /* -> struct document_view */
148 struct uri
*download_uri
;
150 /* The URI which is the referrer to the current loaded document or NULL
151 * if there are no referrer. */
152 /* The @referrer members sole purpose is to have the information handy
153 * when loading URIs. It is not 'filtered' in anyway at this level only
154 * at the lower ones. */
155 struct uri
*referrer
;
158 /* The current action-in-progress selector */
160 struct session_task task
;
163 /* The current browsing state */
165 int search_direction
;
166 struct kbdprefix kbdprefix
;
168 timer_id_T display_timer
;
170 /* The text input form insert mode. It is a tristate controlled by the
171 * boolean document.browse.forms.insert_mode option. When disabled we
172 * use mode less insertion and we always insert stuff into the text
173 * input field. When enabled it is possible to switch insertion on and
174 * off using ACT_EDIT_ENTER and *_CANCEL. */
175 enum insert_mode insert_mode
;
177 enum navigate_mode navigate_mode
;
179 unsigned char *search_word
;
180 unsigned char *last_search_word
;
183 /* The possibly running type queries (what-to-do-with-that-file?) */
184 struct list_head type_queries
; /* -> struct type_query */
186 /* The info for status displaying */
187 struct session_status status
;
190 extern struct list_head sessions
; /* -> struct session */
191 extern enum remote_session_flags remote_session_flags
;
193 /* This returns a pointer to the current location inside of the given session.
194 * That's nice for encapsulation and alrady paid out once ;-). */
195 #define cur_loc(x) ((x)->history.current)
197 /* Return if we have anything being loaded in this session already. */
199 have_location(struct session
*ses
) {
200 return !!cur_loc(ses
);
203 /* Swaps the current session referrer with the new one passed as @referrer */
204 /* @referrer may be NULL */
205 void set_session_referrer(struct session
*ses
, struct uri
*referrer
);
208 print_error_dialog(struct session
*ses
, enum connection_state state
,
209 struct uri
*uri
, enum connection_priority priority
);
211 void process_file_requests(struct session
*);
213 struct string
*encode_session_info(struct string
*info
, struct list_head
*url_list
);
215 /* Returns zero if the info was remote sessions or if it failed to create any
217 int decode_session_info(struct terminal
*term
, struct terminal_info
*info
);
219 /* Registers a base session and returns it's id. Value <= 0 means error. */
221 add_session_info(struct session
*ses
, struct uri
*uri
, struct uri
*referrer
,
222 enum cache_mode cache_mode
, enum task_type task
);
224 void done_saved_session_info(void);
226 struct session
*init_session(struct session
*ses
, struct terminal
*term
,
227 struct uri
*uri
, int in_background
);
229 void doc_loading_callback(struct download
*, struct session
*);
231 void abort_loading(struct session
*, int);
232 void reload(struct session
*, enum cache_mode
);
233 void load_frames(struct session
*, struct document_view
*);
235 struct frame
*ses_find_frame(struct session
*, unsigned char *);
237 void free_files(struct session
*);
238 void display_timer(struct session
*ses
);
240 /* session_is_loading() is like !!get_current_download() but doesn't take
241 * @req_sent into account. */
242 struct download
*get_current_download(struct session
*ses
);
243 int session_is_loading(struct session
*ses
);
245 /* Information about the current document */
246 unsigned char *get_current_url(struct session
*, unsigned char *, size_t);
247 unsigned char *get_current_title(struct session
*, unsigned char *, size_t);
249 struct link
*get_current_session_link(struct session
*ses
);
250 struct link
*get_current_link_in_view(struct document_view
*doc_view
);
251 unsigned char *get_current_link_url(struct session
*, unsigned char *, size_t);
252 unsigned char *get_current_link_name(struct session
*, unsigned char *, size_t);
254 extern struct list_head questions_queue
;
255 void add_questions_entry(void (*callback
)(struct session
*, void *), void *data
);
256 void check_questions_queue(struct session
*ses
);
258 unsigned char *get_homepage_url(void);
260 /* Returns current keyboard repeat count and reset it. */
261 int eat_kbd_repeat_count(struct session
*ses
);