1 
2 #ifndef __GAM_NODE_H__
3 #define __GAM_NODE_H__
4 
5 #include <glib.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include "gam_event.h"
9 #include "gam_subscription.h"
10 #include "gam_fs.h"
11 
12 G_BEGIN_DECLS
13 
14 #define FLAG_NEW_NODE 1 << 5
15 
16 /*
17  * Special monitoring modes (pflags)
18  */
19 #define MON_MISSING 1 << 0  /* The resource is missing */
20 #define MON_NOKERNEL    1 << 1  /* file(system) not monitored by the kernel */
21 #define MON_BUSY    1 << 2  /* Too busy to be monitored by the kernel */
22 #define MON_WRONG_TYPE  1 << 3  /* Expecting a directory and got a file */
23 #define MON_ALL_PFLAGS (MON_MISSING|MON_NOKERNEL|MON_BUSY|MON_WRONG_TYPE)
24 
25 typedef struct _GamNode GamNode;
26 
27 typedef gboolean (*GamSubFilterFunc) (GamSubscription *sub);
28 
29 struct _GamNode {
30         /* the node informations proper */
31 	char *path;		/* The file path */
32 	GList *subs;		/* the list of subscriptions */
33 	GNode *node;		/* pointer in the tree */
34 	gboolean is_dir;	/* is that a directory or expected to be one */
35 	int flags;		/* generic flags */
36 	int poll_time;		/* How often this node should be polled */
37 	gam_fs_mon_type mon_type; /* the type of notification that should be done */
38 
39         /* what used to be stored in a separate data structure */
40 	int checks;
41 	int pflags;		/* A combination of MON_xxx flags */
42 	time_t lasttime;	/* Epoch of last time checking was done */
43 	int flow_on_ticks;	/* Number of ticks while flow control is on */
44 	struct stat sbuf;	/* The stat() informations in last check */
45 };
46 
47 
48 GamNode               *gam_node_new                 (const char     *path,
49 						   GamSubscription *initial_sub,
50 						   gboolean        is_dir);
51 
52 void                  gam_node_free                (GamNode         *node);
53 
54 GamNode               *gam_node_parent              (GamNode         *node);
55 
56 gboolean              gam_node_is_dir              (GamNode         *node);
57 
58 void                  gam_node_set_is_dir          (GamNode         *node,
59 						   gboolean        is_dir);
60 
61 const char           *gam_node_get_path            (GamNode         *node);
62 
63 GList                *gam_node_get_subscriptions   (GamNode         *node);
64 
65 gboolean              gam_node_add_subscription    (GamNode         *node,
66 						   GamSubscription *sub);
67 
68 gboolean              gam_node_remove_subscription (GamNode         *node,
69 						   GamSubscription *sub);
70 
71 gboolean              gam_node_has_dir_subscriptions(GamNode * node);
72 
73 void                  gam_node_set_node            (GamNode         *node,
74 						   GNode          *gnode);
75 GNode                *gam_node_get_node            (GamNode         *node);
76 
77 void                  gam_node_set_data            (GamNode         *node,
78 						   gpointer        data,
79 						   GDestroyNotify  destroy);
80 
81 gpointer              gam_node_get_data            (GamNode         *node);
82 
83 void                  gam_node_set_flag            (GamNode         *node,
84 						   int             flag);
85 void                  gam_node_unset_flag          (GamNode         *node,
86 						   int             flag);
87 gboolean              gam_node_has_flag            (GamNode         *node,
88 						   int             flag);
89 
90 void                  gam_node_set_pflag            (GamNode         *node,
91 						     int             flag);
92 void                  gam_node_unset_pflag          (GamNode         *node,
93 						     int             flag);
94 gboolean              gam_node_has_pflag            (GamNode         *node,
95 						     int             flag);
96 void                  gam_node_set_pflags           (GamNode         *node,
97 						     int             flags);
98 gboolean              gam_node_has_pflags           (GamNode         *node,
99 						     int             flags);
100 
101 
102 void	gam_node_emit_event (GamNode *node, GaminEventType event);
103 
104 
105 G_END_DECLS
106 
107 #endif /* __GAM_NODE_H__ */
108