1 /*  download_setting.h
2  *
3  *
4  *  2003  Plus Huang
5  */
6 
7 #ifndef __DOWNLOAD_SETTING_H
8 #define __DOWNLOAD_SETTING_H
9 
10 #include "proxy_setting.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #define DOWNLOAD_SETTING(o)   ((DownloadSetting*)(o))
17 #define DOWNLOAD_SETTING_TAG  "download_setting"
18 
19 typedef struct _DownloadSetting   DownloadSetting;
20 
21 struct _DownloadSetting {
22 	ProxySetting  proxy;
23 
24 	unsigned int  n_parts;
25 	unsigned int  n_redirect;
26 	unsigned int  n_retries;
27 	unsigned int  retry_delay;
28 
29 	unsigned int  multiple:1;         // if TRUE, filename and url will be ignored
30 	unsigned int  start_mode:3;
31 	unsigned int  state:4;            // download runtime state
32 	char* url;
33 	char* directory;
34 	char* filename;
35 
36 	char* referer;
37 };
38 
39 enum DOWNLOAD_SETTING_START_MODE {
40 	DOWNLOAD_START_AUTO,
41 	DOWNLOAD_START_MANUAL,
42 };
43 
44 enum DOWNLOAD_STATE {
45 	DOWNLOAD_STATE_WAITING,
46 	DOWNLOAD_STATE_PAUSE,
47 	DOWNLOAD_STATE_ERROR,
48 	DOWNLOAD_STATE_EXECUTING,
49 	DOWNLOAD_STATE_RETRY,
50 	DOWNLOAD_STATE_COMPLETED,
51 	DOWNLOAD_STATE_RECYCLED,
52 	DOWNLOAD_N_STATE
53 };
54 
55 DownloadSetting* download_setting_init (DownloadSetting* dd);
56 void download_setting_destroy (DownloadSetting* dd);
57 void download_setting_clear (DownloadSetting* dd);
58 void download_setting_assign (DownloadSetting* dd, DownloadSetting* src);
59 void download_setting_set_start_mode (DownloadSetting* dd, int mode);
60 
61 #define download_setting_new()         \
62         download_setting_init (g_malloc (sizeof(DownloadSetting)))
63 
64 #define download_setting_set_url(d, str)          setting_set_string (&(d)->url, str)
65 #define download_setting_set_directory(d, str)    setting_set_string (&(d)->directory, str)
66 #define download_setting_set_filename(d, str)     setting_set_string (&(d)->filename, str)
67 #define download_setting_set_referer(d, str)      setting_set_string (&(d)->referer, str)
68 
69 void download_setting_write_xml (DownloadSetting* setting,
70                                  FILE* file, int level);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif  // End of __DOWNLOAD_SETTING_H
77 
78