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