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 /** Used by delayed_open() and delayed_goto_uri_frame(). */
27 unsigned char *target
;
30 enum remote_session_flags
{
31 SES_REMOTE_NEW_TAB
= 1,
32 SES_REMOTE_NEW_WINDOW
= 2,
33 SES_REMOTE_CURRENT_TAB
= 4,
34 SES_REMOTE_PROMPT_URL
= 8,
36 SES_REMOTE_ADD_BOOKMARK
= 32,
37 SES_REMOTE_INFO_BOX
= 64,
40 /** This is generic frame descriptor, meaningful mainly for ses_*_frame*(). */
42 LIST_HEAD(struct frame
);
50 /** Use for keyboard prefixes. */
52 /** This is the repeat count being inserted by user so far.
53 * It is stored intermediately per-session. */
57 /** If the previous key was a mark prefix, this describes what kind
58 * of action are we supposed to do when we receive the next key. */
59 enum { KP_MARK_NOTHING
, KP_MARK_SET
, KP_MARK_GOTO
} mark
;
65 /** This describes, what are we trying to do right now. We pass this around so
66 * that we can use generic scheduler routines and when the control will get
67 * back to our subsystem, we will know what are we up to. */
78 /* TODO: union --pasky */
81 struct location
*location
;
85 struct session_status
{
86 unsigned int show_tabs_bar
:1;
87 unsigned int show_status_bar
:1;
88 unsigned int show_title_bar
:1;
90 int force_show_status_bar
:2;
91 int force_show_title_bar
:2;
93 unsigned int set_window_title
:1;
94 unsigned char *last_title
;
95 #ifdef CONFIG_ECMASCRIPT
96 unsigned char *window_status
;
100 unsigned int show_leds
:1;
101 struct led_panel leds
;
103 struct led
*insert_mode_led
;
104 struct led
*ecmascript_led
;
105 struct led
*popup_led
;
106 struct led
*download_led
;
108 /** Has the tab been visited yet. */
109 unsigned int visited
:1;
111 /** Is processing file requests. */
112 unsigned int processing_file_requests
:1;
113 unsigned int show_tabs_bar_at_top
:1;
124 NAVIGATE_CURSOR_ROUTING
,
127 /** This is one of the building stones of ELinks architecture --- this structure
128 * carries information about the specific ELinks session. Each tab (thus, at
129 * least one per terminal, in the normal case) has its own session. Session
130 * describes mainly the current browsing and control state, from the currently
131 * viewed document through the browsing history of this session to the status
132 * bar information. */
134 LIST_HEAD(struct session
);
137 #ifdef CONFIG_SCRIPTING_SPIDERMONKEY
138 struct JSObject
*jsobject
; /* Instance of session_class */
141 /** @name The vital session data
146 /* Session-specific options */
148 struct option
*option
;
151 /** @} @name Browsing history
154 struct ses_history history
;
155 #ifdef CONFIG_SCRIPTING_SPIDERMONKEY
156 struct JSObject
*history_jsobject
; /* Instance of location_array_class */
160 /** @} @name The current document
163 LIST_OF(struct file_to_load
) more_files
;
165 struct download loading
;
166 struct uri
*loading_uri
;
168 enum cache_mode reloadlevel
;
171 struct document_view
*doc_view
;
172 LIST_OF(struct document_view
) scrn_frames
;
174 /** The URI from which the next start_download() or resume_download()
175 * call should download, or NULL if no such call is pending.
177 * When the user requests a download, one of those functions
178 * is given as a callback to query_file(), which asks the user
179 * where to save the downloaded file. The URI cannot be given
180 * to the callback as a parameter because query_file()
181 * supports only one void * parameter for the callback and
182 * that one is already used for the struct session *.
183 * Instead, the URI is saved here before the query_file()
185 struct uri
*download_uri
;
187 /** The URI which is the referrer to the current loaded document
188 * or NULL if there are no referrer.
190 * The @c referrer member's sole purpose is to have the information
191 * handy when loading URIs. It is not 'filtered' in anyway at this
192 * level only at the lower ones. */
193 struct uri
*referrer
;
196 /** @} @name The current action-in-progress selector
199 struct session_task task
;
202 /** @} @name The current browsing state
205 int search_direction
;
206 struct kbdprefix kbdprefix
;
208 timer_id_T display_timer
;
210 /** The text input form insert mode. It is a tristate controlled by the
211 * boolean document.browse.forms.insert_mode option. When disabled we
212 * use modeless insertion and we always insert stuff into the text
213 * input field. When enabled it is possible to switch insertion on and
214 * off using ::ACT_EDIT_ENTER and *_CANCEL. */
215 enum insert_mode insert_mode
;
217 enum navigate_mode navigate_mode
;
219 unsigned char *search_word
;
220 unsigned char *last_search_word
;
223 /** The possibly running type queries (what-to-do-with-that-file?) */
224 LIST_OF(struct type_query
) type_queries
;
226 /** The info for status displaying */
227 struct session_status status
;
232 extern LIST_OF(struct session
) sessions
;
233 extern enum remote_session_flags remote_session_flags
;
235 /** This returns a pointer to the current location inside of the given session.
236 * That's nice for encapsulation and already paid out once ;-). */
237 #define cur_loc(x) ((x)->history.current)
239 /** Return if we have anything being loaded in this session already.
240 * @relates session */
242 have_location(struct session
*ses
) {
243 return !!cur_loc(ses
);
246 /** Swaps the current session referrer with the new one passed as @a referrer.
247 * @a referrer may be NULL.
248 * @relates session */
249 void set_session_referrer(struct session
*ses
, struct uri
*referrer
);
252 print_error_dialog(struct session
*ses
, struct connection_state state
,
253 struct uri
*uri
, enum connection_priority priority
);
255 void process_file_requests(struct session
*);
257 struct string
*encode_session_info(struct string
*info
,
258 LIST_OF(struct string_list_item
) *url_list
);
260 /** @returns zero if the info was remote sessions or if it failed to
261 * create any sessions. */
262 int decode_session_info(struct terminal
*term
, struct terminal_info
*info
);
264 /** Registers a base session and returns its id. Value <= 0 means error. */
266 add_session_info(struct session
*ses
, struct uri
*uri
, struct uri
*referrer
,
267 enum cache_mode cache_mode
, enum task_type task
);
269 void done_saved_session_info(void);
271 struct session
*init_session(struct session
*ses
, struct terminal
*term
,
272 struct uri
*uri
, int in_background
);
274 void doc_loading_callback(struct download
*, struct session
*);
276 void abort_loading(struct session
*, int);
277 void reload_frame(struct session
*, unsigned char *, enum cache_mode
);
278 void reload(struct session
*, enum cache_mode
);
279 void load_frames(struct session
*, struct document_view
*);
281 struct frame
*ses_find_frame(struct session
*, unsigned char *);
283 void free_files(struct session
*);
284 void display_timer(struct session
*ses
);
286 /** session_is_loading() is like !!get_current_download() but doesn't take
287 * session.req_sent into account.
288 * @relates session */
289 int session_is_loading(struct session
*ses
);
290 struct download
*get_current_download(struct session
*ses
);
292 /** Information about the current document */
293 unsigned char *get_current_url(struct session
*, unsigned char *, size_t);
294 unsigned char *get_current_title(struct session
*, unsigned char *, size_t);
296 struct link
*get_current_session_link(struct session
*ses
);
297 struct link
*get_current_link_in_view(struct document_view
*doc_view
);
298 unsigned char *get_current_link_url(struct session
*, unsigned char *, size_t);
299 unsigned char *get_current_link_name(struct session
*, unsigned char *, size_t);
301 extern LIST_OF(struct questions_entry
) questions_queue
;
302 void add_questions_entry(void (*callback
)(struct session
*, void *), void *data
);
303 void check_questions_queue(struct session
*ses
);
305 unsigned char *get_homepage_url(void);
307 /** Returns current keyboard repeat count and reset it. */
308 int eat_kbd_repeat_count(struct session
*ses
);
310 /** Set current keyboard repeat count to given value and update link
311 * highlighting and status bar. */
312 int set_kbd_repeat_count(struct session
*ses
, int new_count
);