indent -kr -i8 -brf -bbb -fnc -l132 -nce on all of webcit-classic
[citadel.git] / webcit / roomops.h
1
2 /*
3  * Copyright (c) 1996-2013 by the citadel.org team
4  *
5  * This program is open source software.  You can redistribute it and/or
6  * modify it under the terms of the GNU General Public License, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  */
13
14
15 #define VIRTUAL_MY_FLOOR -1
16
17 /*
18  * This struct holds a list of rooms for "Goto" operations.
19  */
20 struct march {
21         struct march *next;     /* pointer to next in linked list */
22         char march_name[128];   /* name of room */
23         int march_floor;        /* floor number of room */
24         int march_order;        /* sequence in which we are to visit this room */
25 };
26
27 /*
28  * This struct holds a list of rooms for client display. It is a binary tree.
29  */
30 struct roomlisting {
31         struct roomlisting *lnext;      /* pointer to 'left' tree node */
32         struct roomlisting *rnext;      /* pointer to 'right' tree node */
33         char rlname[128];       /* name of room */
34         unsigned rlflags;       /* room flags */
35         int rlfloor;            /* the floor it resides on */
36         int rlorder;            /* room listing order */
37 };
38
39
40
41
42
43 typedef struct _floor {
44         int ID;
45         StrBuf *Name;
46         long NRooms;
47         long AlphaN;
48 } Floor;
49
50 /*
51  * Data structure for roomlist-to-folderlist conversion 
52  */
53 struct __ofolder {
54         int floor;              /* which floor is it on */
55         char room[SIZ];         /* which roomname ??? */
56         char name[SIZ];         /* which is its own name??? */
57         int hasnewmsgs;         /* are there unread messages inside */
58         int is_mailbox;         /* is it a mailbox?  */
59         int selectable;         /* can we select it ??? */
60         int view;               /* whats its default view? inbox/calendar.... */
61         int num_rooms;          /* If this is a floor, how many rooms does it have */
62 };
63
64
65
66 /*
67  * Data structure for roomlist-to-folderlist conversion 
68  */
69 typedef struct _folder {
70         /* Data citserver tells us about the room */
71         long QRFlags;           /* roomflags */
72         long QRFlags2;          /* Bitbucket NO2 */
73         long RAFlags;
74
75         int view;               /* whats its default view? inbox/calendar.... */
76         long defview;
77         long lastchange;        /* todo... */
78
79         /* later evaluated data from the serverdata */
80         StrBuf *name;           /* the full name of the room we're talking about */
81         long nRoomNameParts;
82         StrBuf **RoomNameParts;
83
84         int floorid;            /* which floor is it on */
85         const Floor *Floor;     /* point to the floor we're on.. */
86
87         int hasnewmsgs;         /* are there unread messages inside */
88         int is_inbox;           /* is it a mailbox?  */
89
90         int RoomAideLoaded;
91         StrBuf *RoomAide;
92
93 /* only available if GNET contains this */
94         const StrBuf *RoomAlias;        /* by what mail will this room send mail? */
95
96 /* only available if GETR was run */
97         int XALoaded;
98         StrBuf *XAPass;
99         StrBuf *Directory;
100         long Order;
101
102 /* Only available from the GOTO context... */
103         long nNewMessages;
104         long nTotalMessages;
105         long LastMessageRead;
106         long HighestRead;
107         int ShowInfo;
108         int UsersNewMAilboxMessages;    /* should we notify the user about new messages? */
109         int IsTrash;
110
111 /* Only available if certain other commands ran */
112         int XHaveRoomPic;
113         int XHaveRoomPicLoaded;
114
115         int XHaveInfoTextLoaded;
116         StrBuf *XInfoText;
117
118         int XHaveDownloadCount;
119         int XDownloadCount;
120
121         int BumpUsers;          /* if SETR set to 1 to make all users who knew this room to forget about it. */
122
123         HashList *IgnetCfgs[maxRoomNetCfg + 1];
124 } folder;
125
126 HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP);
127 void vDeleteFolder(void *vFolder);
128 void FlushFolder(folder * room);
129 void FlushIgnetCfgs(folder * room);
130 void ParseGoto(folder * proom, StrBuf * Line);
131 void FlushRoomlist(void);       /* release our caches, so a deleted / zapped room disapears */
132 void ReloadCurrentRoom(void);   /* Flush cache; reload current state */
133
134 HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP);
135 HashList *GetRoomListHash(StrBuf * Target, WCTemplputParams * TP);
136 int SortRoomsByListOrder(const void *room1, const void *room2);
137 void tmplput_roombanner(StrBuf * Target, WCTemplputParams * TP);
138
139
140 void LoadRoomAide(void);
141 void LoadRoomXA(void);
142 void LoadXRoomPic(void);
143 void LoadXRoomInfoText(void);
144 void LoadXRoomXCountFiles(void);
145
146 long gotoroom(const StrBuf * gname);
147
148 void slrp_highest(void);
149 void remove_march(const StrBuf * aaa);
150 void dotskip(void);
151 void smart_goto(const StrBuf * next_room);
152 void free_march_list(wcsession * wcf);
153
154 /*
155  * wrapper around usual sort-comparator; private rooms will allways be prefered, -1 if one of them NULL
156  */
157 int CompareRooms(const folder * room1, const folder * room2);
158
159
160 #define REST_TOPLEVEL 0
161 #define REST_IN_NAMESPACE (1<<0)
162 #define REST_IN_FLOOR (1<<1)
163 #define REST_IN_ROOM (1<<2)
164 #define REST_HAVE_SUB_ROOMS (1<<3)
165 #define REST_GOT_LOCAL_PART (1<<4)
166 #define REST_NONEXIST (1<<5)
167
168
169 extern CtxType CTX_ROOMS;
170 extern CtxType CTX_FLOORS;