1 /*
2 	category_store.h
3 
4 
5 
6 	2003   Plus Huang
7  */
8 
9 #ifndef __CATEGORY_STORE_H
10 #define __CATEGORY_STORE_H
11 
12 #include "category.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 typedef struct _CategoryStore CategoryStore;
19 
20 #define CATEGORY_STORE_TAG    "category_store"
21 
22 struct _CategoryStore {
23 	GStaticRecMutex     mutex;
24 	gint                n_thread;
25 	gint                n_thread_limit;
26 
27 	GtkListStore*       list_store;
28 	GtkTreeStore*       tree_store;
29 };
30 
31 enum CATEGORY_COLUMN_NAME {
32 	CATEGORY_COL_DATA,
33 	CATEGORY_COL_DOWNLOAD_STORE,
34 	CATEGORY_COL_DOWNLOAD_VIEW,
35 	CATEGORY_N_COL
36 };
37 
38 void category_store_init (CategoryStore* cs);
39 void category_store_clear (CategoryStore* cs);
40 
41 void category_store_append (CategoryStore* cs,
42                             Category* cate);
43 void category_store_erase (CategoryStore* cs,
44                            Category* cate);
45 
46 Category* category_store_get_next (CategoryStore* cs,
47                                    Category* category);
48 
49 #define category_store_lock(cs)        g_static_rec_mutex_lock (&(cs)->mutex)
50 #define category_store_unlock(cs)      g_static_rec_mutex_unlock (&(cs)->mutex)
51 
52 // thread manager for CategoryStore
53 void category_store_thread_ref (CategoryStore* cs);
54 void category_store_thread_unref (CategoryStore* cs);
55 
56 void category_store_thread_activate_1 (CategoryStore* cs,
57                                        Category* category);
58 void category_store_thread_activate_next (CategoryStore* cs,
59                                           Category* category);
60 
61 void category_store_thread_activate (CategoryStore* cs);
62 void category_store_thread_stop (CategoryStore* cs);
63 void category_store_thread_destroy (CategoryStore* ca);
64 
65 #define category_store_thread_is_active(cs)   ((cs)->n_thread)
66 
67 // xml
68 void category_store_write_xml (CategoryStore* store,
69                                FILE* file, int level);
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif  // End of __CATEGORY_STORE_H
76 
77