1 #ifndef EL__SESSION_DOWNLOAD_H
2 #define EL__SESSION_DOWNLOAD_H
4 #include "main/object.h"
5 #include "network/state.h"
6 #include "util/lists.h"
21 typedef void (download_callback_T
)(struct download
*, void *);
24 /* XXX: order matters there, there's some hard initialization in
25 * src/session/session.c and src/viewer/text/view.c */
26 LIST_HEAD(struct download
);
28 struct connection
*conn
;
29 struct cache_entry
*cached
;
30 /** The callback is called when connection gets into a progress state,
31 * after it's over (in a result state), and also periodically after
32 * the download starts receiving some data. */
33 download_callback_T
*callback
;
35 struct progress
*progress
;
37 enum connection_state state
;
38 enum connection_state prev_error
;
39 enum connection_priority pri
;
43 LIST_HEAD(struct type_query
);
44 struct download download
;
45 struct cache_entry
*cached
;
48 unsigned char *target_frame
;
49 unsigned char *external_handler
;
51 unsigned int copiousoutput
:1;
55 struct file_download
{
56 OBJECT_HEAD(struct file_download
);
60 unsigned char *external_handler
;
62 struct terminal
*term
;
68 struct download download
;
70 /** Should the file be deleted when destroying the structure */
71 unsigned int delete:1;
73 /** Should the download be stopped/interrupted when destroying the structure */
76 /** Whether to block the terminal when running the external handler. */
79 /** Whether copiousoutput mode is used by the mailcap entry */
80 unsigned int copiousoutput
:1;
82 /** The current dialog for this download. Can be NULL. */
83 struct dialog_data
*dlg_data
;
84 struct listbox_item
*box_item
;
87 /** Stack of all running downloads */
88 extern LIST_OF(struct file_download
) downloads
;
91 is_in_downloads_list(struct file_download
*file_download
)
93 struct file_download
*down
;
95 foreach (down
, downloads
)
96 if (file_download
== down
) return 1;
101 int download_is_progressing(struct download
*download
);
103 int are_there_downloads(void);
105 void start_download(void *, unsigned char *);
106 void resume_download(void *, unsigned char *);
107 void create_download_file(struct terminal
*, unsigned char *, unsigned char **,
109 void (*)(struct terminal
*, int, void *, int),
112 void abort_all_downloads(void);
113 void destroy_downloads(struct session
*);
115 int setup_download_handler(struct session
*, struct download
*, struct cache_entry
*, int);
117 void abort_download(struct file_download
*file_download
);
118 void done_type_query(struct type_query
*type_query
);
120 void tp_display(struct type_query
*type_query
);
121 void tp_save(struct type_query
*type_query
);
122 void tp_cancel(void *data
);
123 struct file_download
*init_file_download(struct uri
*uri
, struct session
*ses
, unsigned char *file
, int fd
);