summaryrefslogtreecommitdiff
path: root/gio/fen/fen-data.h
blob: 842358be4ca85a2c1b18fdebc0cd4ab24e1bd53e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:set expandtab ts=4 shiftwidth=4: */
/* 
 * Copyright (C) 2008 Sun Microsystem.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Authors: Lin Ma <lin.ma@sun.com>
 */

#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "fen-node.h"
#include "fen-kernel.h"

#ifndef _FEN_DATA_H_
#define _FEN_DATA_H_

#define FN_EVENT_CREATED	0
#define FN_NAME(fp)	(((fdata*)(fp))->fobj.fo_name)
#define FN_NODE(fp)	(((fdata*)(fp))->node)
#define	FN_IS_DIR(fp)	(((fdata*)(fp))->is_dir)
#define	FN_IS_PASSIVE(fp)	(((fdata*)(fp))->subs == NULL)
#define	FN_IS_MONDIR(fp)	(((fdata*)(fp))->mon_dir_num > 0)
#define	FN_IS_LIVING(fp)	(!((fdata*)(fp))->is_cancelled)

typedef struct
{
	file_obj_t fobj;
    off_t len;
    gboolean is_cancelled;

    node_t* node;
	/* to identify if the path is dir */
	gboolean is_dir;
    guint mon_dir_num;

	/* List of subscriptions monitoring this fdata/path */
	GList *subs;

    /* prcessed changed events num */
    guint changed_event_num;
    
    /* process events source id */
    GQueue* eventq;
    guint eventq_id;
    guint change_update_id;
} fdata;

/* fdata functions */
fdata* fdata_new (node_t* node, gboolean is_mondir);
void fdata_reset (fdata* data);
void fdata_emit_events_once (fdata *f, int event, gpointer sub);
void fdata_emit_events (fdata *f, int event);
void fdata_add_event (fdata *f, fnode_event_t *ev);
void fdata_adjust_deleted (fdata *f);
fdata* get_parent_data (fdata* data);
node_t* get_parent_node (fdata* data);
gboolean is_monitoring (fdata* data);

/* sub */
void fdata_sub_add (fdata *f, gpointer sub);
void fdata_sub_remove (fdata *f, gpointer sub);

/* misc */
node_t* add_missing_cb (node_t* parent, gpointer user_data);
gboolean pre_del_cb (node_t* node, gpointer user_data);

/* init */
gboolean fdata_class_init (void (*user_emit_cb) (fdata*, int),
  void (*user_emit_once_cb) (fdata*, int,  gpointer),
  int (*user_event_converter) (int event));

#endif /* _FEN_DATA_H_ */