aux-items.h 10.1 KB
Newer Older
1
/*
David Byers's avatar
David Byers committed
2
 * $Id: aux-items.h,v 1.6 1998/12/30 17:39:35 byers Exp $
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
 * Copyright (C) 1994, 1995, 1996  Lysator Academic Computer Association.
 *
 * This file is part of the LysKOM server.
 * 
 * LysKOM is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 1, or (at your option) 
 * any later version.
 * 
 * LysKOM 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 General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with LysKOM; see the file COPYING.  If not, write to
 * Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
 * or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
 * MA 02139, USA.
 *
 * Please mail bug reports to bug-lyskom@lysator.liu.se. 
 */
/* Requires kom-types.h */


#define AUX_PREDEFINED_MIN      1
#define AUX_PREDEFINED_MAX      9999
#define AUX_CLIENT_SPECIFIC_MIN 10000
#define AUX_CLIENT_SPECIFIC_MAX 19999
#define AUX_EXPERIMENTAL_MIN    20000
#define AUX_EXPERIMENTAL_MAX    29999

#define AUX_IS_ILLEGAL(x) ((x) < 1)
#define AUX_IS_EXPERIMENTAL(x) ((x) >= AUX_EXPERIMENTAL_MIN && (x) <= AUX_EXPERIMENTAL_MAX)
#define AUX_IS_CLIENT_SPECIFIC(x) ((x) >= AUX_CLIENT_SPECIFIC_MIN && (x) <= AUX_CLIENT_SPECIFIC_MAX)
#define AUX_IS_PREDEFINED(x) (((x) >= AUX_PREDEFINED_MIN && (x) <= AUX_PREDEFINED_MAX) || (x) > AUX_EXPERIMENTAL_MAX)



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Valid values for text_a etc. */

#define AUX_ITEM_ADD_ON_CREATE 1
#define AUX_ITEM_ADD_ON_MODIFY 2

/* Valid values for action trigger data field */

#define AUX_ITEM_ADD_ACTION    1
#define AUX_ITEM_DELETE_ACTION 2
#define AUX_ITEM_UNDELETE_ACTION 3

/* Valid values for object_type fields */

#define OTHER_OBJECT_TYPE 0
#define TEXT_OBJECT_TYPE 1
#define CONF_OBJECT_TYPE 2
David Byers's avatar
David Byers committed
58
#define INFO_OBJECT_TYPE 3
59
60
61
62
63
64
65
66
67
68
69
70

typedef struct Aux_item_trigger_data_s
{
    short           action;
    short           object_type;
    unsigned long   item_index;
    unsigned long   object_no;
    void          * object;
} Aux_item_trigger_data;

typedef void (*Aux_item_trigger)(Aux_item_trigger_data *);

71
typedef struct Aux_item_definition_s {
72
    const char             *name;
73
74
75
76
77
78
79
80
81
    unsigned long           tag;
    Aux_item_flags          clear_flags;
    Aux_item_flags          set_flags;
    Bool                    author_only;
    Bool                    supervisor_only;
    Bool                    one_per_person;
    Bool                    may_not_delete;
    unsigned long           inherit_limit;
    Bool                    texts;
82
    short                   text_a; /* When can we add items of this type */
83
    Bool                    confs;
84
    short                   conf_a; /* When can we add items of this type */
85
86
87
88
    Bool                    letterboxes;
    Bool                    system;
    char                   *validate_regexp;
    struct re_pattern_buffer *cached_re_buf;
89
90
91
92
93
94
    unsigned long             num_delete_triggers;
    Aux_item_trigger        * delete_triggers;
    unsigned long             num_add_triggers;
    Aux_item_trigger        * add_triggers;
    unsigned long             num_undelete_triggers;
    Aux_item_trigger        * undelete_triggers;
95
96
97
    struct Aux_item_definition_s *next;
} Aux_item_definition;

98
99
typedef struct
{
100
    const char *name;
101
102
103
104
    Aux_item_trigger function;
} Aux_item_trigger_mapping;

extern Aux_item_trigger_mapping aux_item_triggers [];
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
extern Aux_item_definition empty_aux_item_definition;

/*
 * Predefined AUX Items
 */

#define AUX_Content_Type        1
#define AUX_Dont_Comment        2
#define AUX_Private_Comment     3
#define AUX_Quick_Reply         4





/* Inerit items from parent to target. counter is a pointer to
 * highest_aux_item or equivalent. target_creator is the creator
 * of the target object (author for texts, person for persons and
 * conference for conferences */

void aux_inherit_items(Aux_item_list *target, Aux_item_list *parent,
126
127
128
                       unsigned long *counter, Pers_no target_creator,
                       Bool creating, short object_type,
                       unsigned long object_no, void *object);
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146



/* Check for permission to add item to some object. def is NULL or the
 * item definition. item_creator is the person creating the item.
 * object_creator is the person who created the object we're adding
 * the item to. owner_check is FALSE only if we don't want to check
 * author and supervisor related definition flags (when creating a
 * person or conference, for example.) add_to_list is the list of
 * items already on the object or NULL, and start_looking_at is the
 * first position in add_to_list that we should look at.
 *
 * If you think you need to call this, and you're not hacking functions
 * in aux-items.c, you should rethink your strategy. */

Bool aux_item_add_perm(Aux_item *item, Aux_item_definition *def,
                       Pers_no item_creator, Pers_no object_creator,
                       Bool owner_check, Aux_item_list *add_to_list,
147
148
                       unsigned long start_looking_at, Bool creating,
                       short object_type);
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169




/* Prepare the items in list for addition to an object. creator is the
 * person who will add the items. The items in list will be modified.
 * You need to call this before sending the list to any of the other
 * functions. */

void prepare_aux_item_list(Aux_item_list *list, Pers_no creator);
void prepare_aux_item(Aux_item *item, Pers_no creator,
                      Aux_item_definition *def);



/* Find the aux_item_definition for item. Returns a pointer to the
 * definition or NULL if the item's tag is invalid. */

Aux_item_definition *find_aux_item_definition(Aux_item *item);


170
171
172
173
/* Get the function pointer for a named trigger */

Aux_item_trigger aux_item_find_trigger(char *trigger_name);

174
175
176
/* Get a pointer to the item in list with aux-no aux_no. Returns
 * NULL if there is no such item */

David Byers's avatar
David Byers committed
177
long find_aux_item_index(Aux_item_list *list, unsigned long aux_no);
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
Aux_item *find_aux_item(Aux_item_list *list, unsigned long aux_no);



/* Filter the items in original for sending to viewer. Result is a
 * pointer to an empty aux_item_list, in which copies of the items in
 * original will be places. All memory allocated in this call is
 * allocaed with tmp_alloc */

void filter_aux_item_list(Aux_item_list *original,
                          Aux_item_list *result,
                          Pers_no viewer,
                          Person *viewer_p);


/* delete items_to_delete from list_to_delete_from
 * list_to_delete_from and its elements may be modified */

void delete_aux_item_list(Number_list *items_to_delete,
197
198
199
200
                          Aux_item_list *list_to_delete_from,
                          short object_type,
                          unsigned long object_no,
                          void *object);
201
202
203
204
205
206
207



/* undelete items in items_to_undelete from list_to_undelete_from
 * list_to_delete_from and its elements may be modified */

void undelete_aux_item_list(Number_list *items_to_undelete,
208
209
210
211
                            Aux_item_list *list_to_undelete_from,
                            short object_type,
                            unsigned long object_no,
                            void *object);
212
213


David Byers's avatar
David Byers committed
214
215
216
void
commit_aux_item_list(Aux_item_list *list_to_commit);

217
218
219
220
221
222
223
224
225
226
227
228
229
230

/* Check if we may delete items_to_delete from list_to_delete_from
 * Elements in items_to_delete may be modified. Sets kom_errno,
 * err_stat and returns FAILURE if deletion of any single item is
 * not allowed */

Success check_delete_aux_item_list(Number_list *items_to_delete,
                                   Aux_item_list *list_to_delete_from);



/* Att item_list to the aux_item_list of text_s. item_creator is the
 * person who is adding the items. Does not check for permission first */
  
231
232
233
void text_stat_add_aux_item_list(Text_stat *text_s,
                                 Text_no text_no,
                                 Aux_item_list *item_list,
234
235
236
237
238
239
240
241
242
243
244
245
                                 Pers_no item_creator);



/* Check for permission to add items in list to aux_item_list
 * of text_s. item_creator is the person adding the items. Sets
 * kom_errno and err_stat and returns FAILURE if permission is
 * not granted. You MUST call perpare_aux_item_list on the list
 * before calling this! */

Success text_stat_check_add_aux_item_list(Text_stat *text_s,
                                          Aux_item_list *list,
246
247
                                          Pers_no item_creator,
                                          Bool creating);
248
249
250
251
252
253
254



Success conf_stat_check_add_aux_item(Conference          *conf,
                                     Conf_no        conf_no,
                                     Aux_item            *item,
                                     Pers_no              creator,
255
256
                                     Aux_item_definition *def,
                                     Bool creating);
257
258
259
260
261

Success
conf_stat_check_add_aux_item_list(Conference    *conf,
                                  Conf_no        conf_no,
                                  Aux_item_list *list,
262
263
                                  Pers_no        creator,
                                  Bool creating);
264
265
266
267
268
269
270
271
272
273
void
conf_stat_add_aux_item(Conference          *conf,
                       Conf_no              conf_no,
                       Aux_item            *item,
                       Aux_item_definition *def);
void
conf_stat_add_aux_item_list(Conference    *conf,
                            Conf_no        conf_no,
                            Aux_item_list *list,
                            Pers_no        creator);
274

275
276
277
278
279
280
281
282
283
284
285
286
287
288
void
system_add_aux_item_list(Info    *info,
                         Aux_item_list *item_list,
                         Pers_no        item_creator);

Success system_check_add_aux_item_list(Info *info,
                                       Aux_item_list *list,
                                       Pers_no creator);

void
initialize_aux_items(char *);

void
aux_item_definition_add(Aux_item_definition *);
289
290
291
292

/* Parser function from aux-item-def.y. */
void
parse_aux_item_definitions(char *file);