1 /*  category_setting.h
2  *
3  *
4  *  2003  Plus Huang
5  */
6 
7 #ifndef __CATEGORY_SETTING_H
8 #define __CATEGORY_SETTING_H
9 
10 #include "download_setting.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #define CATEGORY_SETTING(o)   ((CategorySetting*)(o))
17 #define CATEGORY_SETTING_TAG  "category_setting"
18 
19 typedef struct _CategorySetting   CategorySetting;
20 
21 struct _CategorySetting {
22 	DownloadSetting download;
23 
24 	char*        name;
25 
26 	unsigned int state:4;         // category runtime state
27 	unsigned int multiple:1;      // if TRUE, name will be ignored
28 
29 	unsigned int n_active_download;
30 	unsigned int completed_capacity;
31 	unsigned int recycled_capacity;
32 
33 	// column visible
34 	unsigned int col_completed:1;
35 	unsigned int col_total:1;
36 	unsigned int col_speed:1;
37 	unsigned int col_retry:1;
38 	unsigned int col_url:1;
39 	// text area
40 	unsigned int text_filename:1;
41 	unsigned int text_directory:1;
42 	unsigned int text_url:1;
43 	unsigned int text_start_mode:1;
44 	unsigned int text_message:1;
45 };
46 
47 enum CATEGORY_STATE {
48 	CATEGORY_STATE_WAITING   = DOWNLOAD_STATE_WAITING,
49 	CATEGORY_STATE_PAUSE     = DOWNLOAD_STATE_PAUSE,
50 	CATEGORY_STATE_EXECUTING = DOWNLOAD_STATE_EXECUTING,
51 	CATEGORY_STATE_COMPLETED = DOWNLOAD_STATE_COMPLETED,
52 	CATEGORY_STATE_RECYCLED  = DOWNLOAD_STATE_RECYCLED,
53 	CATEGORY_N_STATE         = DOWNLOAD_N_STATE
54 };
55 
56 CategorySetting* category_setting_init (CategorySetting* cd);
57 void category_setting_destroy (CategorySetting* cd);
58 void category_setting_clear (CategorySetting* cd);
59 void category_setting_assign (CategorySetting* cd, CategorySetting* src);
60 
61 #define category_setting_new ()    \
62         category_setting_init (g_malloc (sizeof (CategorySetting)))
63 
64 #define category_setting_set_name(cs, str)    setting_set_string (&(cs)->name, str)
65 
66 void category_setting_write_xml (CategorySetting* setting,
67                                  FILE* file, int level);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif  // End of __CATEGORY_SETTING_H
74