6 typedef struct _bbsview_stuct {
8 StrBuf *MessageDropdown;
13 int bbsview_GetParamsGetServerCall(SharedMessageStatus *Stat,
21 VS = (bbsview_struct*) malloc(sizeof(bbsview_struct));
22 memset(VS, 0, sizeof(bbsview_struct));
23 *ViewSpecific = (void*)VS;
24 Stat->defaultsortorder = 1;
28 rlid[oper].cmd(cmd, len);
30 if (havebstr("maxmsgs"))
31 Stat->maxmsgs = ibstr("maxmsgs");
32 if (Stat->maxmsgs == 0) Stat->maxmsgs = DEFAULT_MAXMSGS;
34 if (havebstr("startmsg")) {
35 Stat->startmsg = lbstr("startmsg");
37 if (lbstr("SortOrder") == 2) {
39 Stat->num_displayed = -DEFAULT_MAXMSGS;
43 Stat->num_displayed = DEFAULT_MAXMSGS;
49 /* startmsg is an index within the message list.
50 * starting_from is the Citadel message number to be supplied to a "MSGS GT" operation
52 long DrawMessageDropdown(StrBuf *Selector, long maxmsgs, long startmsg, int nMessages, long starting_from)
64 WCTemplputParams SubTP;
67 memset(&SubTP, 0, sizeof(WCTemplputParams));
68 SubTP.Filter.ContextType = CTX_LONGVECTOR;
69 SubTP.Context = &vector;
70 TmpBuf = NewStrBufPlain(NULL, SIZ);
71 At = GetNewHashPos(WCC->summ, nMessages);
72 nItems = GetCount(WCC->summ);
78 vector[7] = starting_from;
83 vector[3] = abs(nMessages);
84 lo = GetHashPosCounter(WCC->summ, At);
85 wantmore = GetNextHashPos(WCC->summ, At, &hklen, &key, &vMsg);
89 if (lo + nMessages >= nItems) {
91 vector[3] = nItems - lo;
96 hi = lo + nMessages - 1;
99 if (lo + nMessages < -1) {
103 if ((lo % abs(nMessages)) != 0) {
104 int offset = (lo % abs(nMessages) *
105 (nMessages / abs(nMessages)));
107 vector[3] = abs(offset);
117 * Bump these because although we're thinking in zero base, the user
118 * is a drooling idiot and is thinking in one base.
124 dbg_print_longvector(vector);
125 DoTemplate(HKEY("select_messageindex"), TmpBuf, &SubTP);
126 StrBufAppendBuf(Selector, TmpBuf, 0);
130 if (maxmsgs == 9999999) {
137 dbg_print_longvector(vector);
138 DoTemplate(HKEY("select_messageindex_all"), TmpBuf, &SubTP);
139 StrBufAppendBuf(Selector, TmpBuf, 0);
146 int bbsview_PrintViewHeader(SharedMessageStatus *Stat, void **ViewSpecific)
149 WCTemplputParams SubTP;
151 VS = (bbsview_struct*)*ViewSpecific;
153 VS->BBViewToolBar = NewStrBufPlain(NULL, SIZ);
154 VS->MessageDropdown = NewStrBufPlain(NULL, SIZ);
156 /*** startmsg->maxmsgs = **/DrawMessageDropdown(VS->MessageDropdown,
160 Stat->lowest_found-1);
161 if (Stat->num_displayed < 0) {
162 Stat->startmsg += Stat->maxmsgs;
163 if (Stat->num_displayed != Stat->maxmsgs)
164 Stat->maxmsgs = abs(Stat->maxmsgs) + 1;
166 Stat->maxmsgs = abs(Stat->maxmsgs);
169 if (Stat->nummsgs > 0) {
170 memset(&SubTP, 0, sizeof(WCTemplputParams));
171 SubTP.Filter.ContextType = CTX_STRBUF;
172 SubTP.Context = VS->MessageDropdown;
173 DoTemplate(HKEY("msg_listselector_top"), VS->BBViewToolBar, &SubTP);
174 StrBufAppendBuf(WC->WBuf, VS->BBViewToolBar, 0);
175 FlushStrBuf(VS->BBViewToolBar);
180 int bbsview_LoadMsgFromServer(SharedMessageStatus *Stat,
182 message_summary* Msg,
188 VS = (bbsview_struct*)*ViewSpecific;
189 if (VS->displayed_msgs == NULL) {
190 VS->displayed_msgs = malloc(sizeof(long) *
191 ((Stat->maxmsgs < Stat->nummsgs) ?
195 if ((i >= Stat->startmsg) && (i < Stat->startmsg + Stat->maxmsgs)) {
196 VS->displayed_msgs[Stat->num_displayed] = Msg->msgnum;
197 Stat->num_displayed++;
203 int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
209 WCTemplputParams SubTP;
212 VS = (bbsview_struct*)*ViewSpecific;
213 if (Stat->nummsgs == 0) {
214 wc_printf("<div class=\"nomsgs\"><br><em>");
217 wc_printf(_("No new messages."));
220 wc_printf(_("No old messages."));
223 wc_printf(_("No messages here."));
225 wc_printf("</em><br></div>\n");
229 if (VS->displayed_msgs != NULL) {
230 /* if we do a split bbview in the future, begin messages div here */
232 for (a=0; a < Stat->num_displayed; ++a) {
233 read_message(WCC->WBuf, HKEY("view_message"), VS->displayed_msgs[a], NULL, &Mime);
236 /* if we do a split bbview in the future, end messages div here */
238 free(VS->displayed_msgs);
239 VS->displayed_msgs = NULL;
241 memset(&SubTP, 0, sizeof(WCTemplputParams));
242 SubTP.Filter.ContextType = CTX_STRBUF;
243 SubTP.Context = VS->MessageDropdown;
244 DoTemplate(HKEY("msg_listselector_bottom"), VS->BBViewToolBar, &SubTP);
245 StrBufAppendBuf(WCC->WBuf, VS->BBViewToolBar, 0);
252 int bbsview_Cleanup(void **ViewSpecific)
256 VS = (bbsview_struct*)*ViewSpecific;
258 FreeStrBuf(&VS->BBViewToolBar);
259 FreeStrBuf(&VS->MessageDropdown);
265 InitModule_BBSVIEWRENDERERS
268 RegisterReadLoopHandlerset(
270 bbsview_GetParamsGetServerCall,
271 bbsview_PrintViewHeader,
272 bbsview_LoadMsgFromServer,
273 bbsview_RenderView_or_Tail,