StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
}
}
- it = GetNewHashPos();
+ it = GetNewHashPos(Msg->AllAttach, 0);
while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
(vMime != NULL)) {
wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
long msgnum = 0L;
const StrBuf *Tmpl = sbstr("template");
- msgnum = StrTol(WC->UrlFragment1);
+ msgnum = StrTol(WC->UrlFragment2);
if (StrLength(Tmpl) > 0)
read_message(WC->WBuf, SKEY(Tmpl), msgnum, 0, NULL);
else
void print_message(void) {
long msgnum = 0L;
- msgnum = StrTol(WC->UrlFragment1);
+ msgnum = StrTol(WC->UrlFragment2);
output_headers(0, 0, 0, 0, 0, 0);
hprintf("Content-type: text/html\r\n"
*/
void mobile_message_view(void) {
long msgnum = 0L;
- msgnum = StrTol(WC->UrlFragment1);
+ msgnum = StrTol(WC->UrlFragment2);
output_headers(1, 0, 0, 0, 0, 1);
begin_burst();
do_template("msgcontrols", NULL);
long msgnum = 0L;
char buf[1024];
- msgnum = StrTol(WC->UrlFragment1);
+ msgnum = StrTol(WC->UrlFragment2);
output_headers(0, 0, 0, 0, 0, 0);
hprintf("Content-type: text/plain\r\n"
inline message_summary* GetMessagePtrAt(int n, HashList *Summ)
{
+ const char *Key;
+ long HKLen;
void *vMsg;
+
if (Summ == NULL)
return NULL;
- GetHash(Summ, (const char*)&n, sizeof(n), &vMsg);
+ GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
return (message_summary*) vMsg;
}
+void DrawMessageDropdown(StrBuf *Selector, long maxmsgs, long startmsg)
+{
+ StrBuf *TmpBuf;
+ struct wcsession *WCC = WC;
+ message_summary* Msg;
+ int lo, hi, n;
+ int i = 0;
+ long StartMsg;
+ void *vMsg;
+ long hklen;
+ const char *key;
+ int done = 0;
+ int nItems;
+ HashPos *At;
+ long vector[16];
+ int nMessages = DEFAULT_MAXMSGS;
+
+ TmpBuf = NewStrBuf();
+ At = GetNewHashPos(WCC->summ, (lbstr("SortOrder") == 1)? -nMessages : nMessages);
+ nItems = GetCount(WCC->summ);
+
+ vector[0] = 7;
+ vector[1] = startmsg;
+ vector[2] = maxmsgs;
+ vector[3] = 0;
+ vector[4] = 1;
+
+ while (!done) {
+ lo = GetHashPosCounter(At);
+ if (lo + nMessages > nItems) {
+ hi = nItems;
+ }
+ else {
+ hi = lo + nMessages;
+ }
+ done = !GetNextHashPos(WCC->summ, At, &hklen, &key, &vMsg);
+ Msg = (message_summary*) vMsg;
+ n = (Msg==NULL)? 0 : Msg->msgnum;
+ if (i == 0)
+ StartMsg = n;
+ vector[4] = lo;
+ vector[5] = hi;
+ vector[6] = n;
+ FlushStrBuf(TmpBuf);
+ DoTemplate(HKEY("select_messageindex"), TmpBuf, &vector, CTX_LONGVECTOR);
+ StrBufAppendBuf(Selector, TmpBuf, 0);
+ i++;
+ }
+ vector[6] = StartMsg;
+ FlushStrBuf(TmpBuf);
+ DoTemplate(HKEY("select_messageindex_all"), TmpBuf, &vector, CTX_LONGVECTOR);
+ StrBufAppendBuf(Selector, TmpBuf, 0);
+ FreeStrBuf(&TmpBuf);
+ DeleteHashPos(&At);
+}
+
+
+extern readloop_struct rlid[];
+
/*
* command loop for reading messages
*
* Set oper to "readnew" or "readold" or "readfwd" or "headers"
*/
-void readloop(char *oper)
+void readloop(long oper)
{
+ StrBuf *MessageDropdown = NULL;
StrBuf *BBViewToolBar = NULL;
void *vMsg;
message_summary *Msg;
char buf[SIZ];
char old_msgs[SIZ];
int a = 0;
- int b = 0;
- int n;
+ ///int b = 0;
int nummsgs;
- long startmsg;
- int maxmsgs;
+ long startmsg = 0;
+ int maxmsgs = 0;
long *displayed_msgs = NULL;
int num_displayed = 0;
int is_summary = 0;
int is_tasks = 0;
int is_notes = 0;
int is_bbview = 0;
- int lo, hi;
int lowest_displayed = (-1);
int highest_displayed = 0;
addrbookent *addrbook = NULL;
int num_ab = 0;
int bbs_reverse = 0;
- struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
+ struct wcsession *WCC = WC;
HashPos *at;
const char *HashKey;
long HKLen;
strcpy(cmd, "MSGS ALL|||1");
maxmsgs = 32767;
parse_calendar_view_request(&calv);
+ break;
case VIEW_TASKS:
is_tasks = 1;
strcpy(cmd, "MSGS ALL");
maxmsgs = 32767;
+ break;
case VIEW_NOTES:
is_notes = 1;
strcpy(cmd, "MSGS ALL");
maxmsgs = 32767;
wprintf("<div id=\"new_notes_here\"></div>\n");
+ break;
case VIEW_ADDRESSBOOK:
is_singlecard = ibstr("is_singlecard");
if (maxmsgs > 1) {
is_addressbook = 1;
- if (!strcmp(oper, "do_search")) {
+ if (oper == do_search) {
snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
}
else {
default:
care_for_empty_list = 1;
startmsg = lbstr("startmsg");
- maxmsgs = ibstr("maxmsgs");
+ if (havebstr("maxmsgs"))
+ maxmsgs = ibstr("maxmsgs");
is_summary = (ibstr("is_summary") && !WCC->is_mobile);
if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
* When in summary mode, always show ALL messages instead of just
* new or old. Otherwise, show what the user asked for.
*/
- if (!strcmp(oper, "readnew")) {
- strcpy(cmd, "MSGS NEW");
- }
- else if (!strcmp(oper, "readold")) {
- strcpy(cmd, "MSGS OLD");
- }
- else if (!strcmp(oper, "do_search")) {
- snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
- }
- else {
- strcpy(cmd, "MSGS ALL");
- }
+ rlid[oper].cmd(cmd, sizeof(cmd));
if ((WCC->wc_view == VIEW_MAILBOX) && (maxmsgs > 1) && !WCC->is_mobile) {
is_summary = 1;
- if (!strcmp(oper, "do_search")) {
- snprintf(cmd, sizeof(cmd), "MSGS SEARCH|%s", bstr("query"));
- }
- else {
+ if (oper != do_search) {
strcpy(cmd, "MSGS ALL");
}
}
if (is_summary) { /**< fetch header summary */
load_seen = 1;
snprintf(cmd, sizeof(cmd), "MSGS %s|%s||1",
- (!strcmp(oper, "do_search") ? "SEARCH" : "ALL"),
- (!strcmp(oper, "do_search") ? bstr("query") : "")
+ (oper == do_search) ? "SEARCH" : "ALL",
+ (oper == do_search) ? bstr("query") : ""
);
startmsg = 1;
maxmsgs = 9999999;
}
- if (startmsg == 0L) {
+
+ bbs_reverse = is_bbview && (lbstr("SortOrder") == 2);
+
+ if (is_bbview && (startmsg == 0L)) {
if (bbs_reverse) {
Msg = GetMessagePtrAt((nummsgs >= maxmsgs) ? (nummsgs - maxmsgs) : 0, WCC->summ);
startmsg = (Msg==NULL)? 0 : Msg->msgnum;
}
-
-
-
-
-
output_headers(1, 1, 1, 0, 0, 0);
/*
if (nummsgs == 0) {
if (care_for_empty_list) {
wprintf("<div align=\"center\"><br /><em>");
- if (!strcmp(oper, "readnew")) {
+ switch (oper) {
+ case readnew:
wprintf(_("No new messages."));
- } else if (!strcmp(oper, "readold")) {
+ break;
+ case readold:
wprintf(_("No old messages."));
- } else {
+ break;
+ default:
wprintf(_("No messages here."));
}
wprintf("</em><br /></div>\n");
if (buf[0] == '2') {
strcpy(old_msgs, &buf[4]);
}
- at = GetNewHashPos();
+ at = GetNewHashPos(WCC->summ, 0);
while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
/** Are you a new message, or an old message? */
Msg = (message_summary*) vMsg;
- if (is_summary) {
- if (is_msg_in_mset(old_msgs, Msg->msgnum)) {
- Msg->is_new = 0;
- }
- else {
- Msg->is_new = 1;
- }
+ if (is_msg_in_mset(old_msgs, Msg->msgnum)) {
+ Msg->is_new = 0;
+ }
+ else {
+ Msg->is_new = 1;
}
}
DeleteHashPos(&at);
* If we're not currently looking at ALL requested
* messages, then display the selector bar
*/
- if (is_bbview) {
- const char *selected;
- StrBuf *Selector = NewStrBuf();
+ if (is_bbview) {
BBViewToolBar = NewStrBuf();
-///// DoTemplate("bbview_scrollbar");
- /** begin bbview scroller */
- StrBufAppendPrintf(BBViewToolBar, "<form name=\"msgomatictop\" class=\"selector_top\" > \n <p>");
- StrBufAppendPrintf(BBViewToolBar, _("Reading #"));//// TODO this isn't used, should it? : , lowest_displayed, highest_displayed);
-
- StrBufAppendPrintf(BBViewToolBar, "<select name=\"whichones\" size=\"1\" "
- "OnChange=\"location.href=msgomatictop.whichones.options"
- "[selectedIndex].value\">\n");
-
- if (bbs_reverse) {
- for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
- hi = b + 1;
- lo = b - maxmsgs + 2;
- if (lo < 1) lo = 1;
-
- Msg = GetMessagePtrAt(lo-1, WCC->summ);
- n = (Msg==NULL)? 0 : Msg->msgnum;
- selected = ((n == startmsg) ? "selected" : "");
-
- StrBufAppendPrintf(Selector,
- "<option %s value="
- "\"%s"
- "&startmsg=%ld"
- "&maxmsgs=%d"
- "&is_summary=%d\">"
- "%d-%d</option> \n",
- selected,
- oper,
-
-
- maxmsgs,
- is_summary,
- hi, lo);
- }
- }
- else {
- for (b=0; b<nummsgs; b = b + maxmsgs) {
- lo = b + 1;
- hi = b + maxmsgs + 1;
- if (hi > nummsgs) hi = nummsgs;
-
- Msg = GetMessagePtrAt(b, WCC->summ);
- n = (Msg==NULL)? 0 : Msg->msgnum;
- selected = ((n == startmsg) ? "selected" : "");
- Msg = GetMessagePtrAt(lo-1, WCC->summ);
- StrBufAppendPrintf(Selector,
- "<option %s value="
- "\"%s"
- "&startmsg=%ld"
- "&maxmsgs=%d"
- "&is_summary=%d\">"
- "%d-%d</option> \n",
- selected,
- oper,
- (Msg==NULL)? 0 : Msg->msgnum,
- maxmsgs,
- is_summary,
- lo, hi);
- }
- }
-
- StrBufAppendBuf(BBViewToolBar, Selector, 0);
+ MessageDropdown = NewStrBuf();
- Msg = GetMessagePtrAt(0, WCC->summ);
-
- StrBufAppendPrintf(BBViewToolBar, "<option value=\"%s?startmsg=%ld"
- "&maxmsgs=9999999&is_summary=0\">",
- oper,
- (Msg==NULL)? 0 : Msg->msgnum);
- StrBufAppendPrintf(BBViewToolBar, _("All"));
-
- StrBufAppendPrintf(BBViewToolBar, "</option>");
- StrBufAppendPrintf(BBViewToolBar, "</select> ");
- StrBufAppendPrintf(BBViewToolBar, _("of %d messages."), nummsgs);
-
- /** forward/reverse */
- StrBufAppendPrintf(BBViewToolBar, "<input type=\"radio\" %s name=\"direction\" value=\"\""
- "OnChange=\"location.href='%s?sortby=forward'\"",
- (bbs_reverse ? "" : "checked"),
- oper
- );
- StrBufAppendPrintf(BBViewToolBar, ">");
- StrBufAppendPrintf(BBViewToolBar, _("oldest to newest"));
- StrBufAppendPrintf(BBViewToolBar, " ");
-
- StrBufAppendPrintf(BBViewToolBar, "<input type=\"radio\" %s name=\"direction\" value=\"\""
- "OnChange=\"location.href='%s?sortby=reverse'\"",
- (bbs_reverse ? "checked" : ""),
- oper
- );
- StrBufAppendPrintf(BBViewToolBar, ">");
- StrBufAppendPrintf(BBViewToolBar, _("newest to oldest"));
- StrBufAppendPrintf(BBViewToolBar, "\n");
-
- StrBufAppendPrintf(BBViewToolBar, "</p></form>\n");
+ DrawMessageDropdown(MessageDropdown, maxmsgs, startmsg);
+
+ DoTemplate(HKEY("msg_listselector_top"), BBViewToolBar, MessageDropdown, CTX_STRBUF);
StrBufAppendBuf(WCC->WBuf, BBViewToolBar, 0);
- /** end bbview scroller */
+ FlushStrBuf(BBViewToolBar);
}
- at = GetNewHashPos();
+ at = GetNewHashPos(WCC->summ, 0);
while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
Msg = (message_summary*) vMsg;
if ((Msg->msgnum >= startmsg) && (num_displayed < maxmsgs)) {
}
if (is_summary) {
- wprintf("</table>"
- "</div>\n"); /**< end of 'fix_scrollbar_bug' div */
- wprintf("</div>"); /**< end of 'message_list' div */
-
- /** Here's the grab-it-to-resize-the-message-list widget */
- wprintf("<div id=\"resize_msglist\" "
- "onMouseDown=\"CtdlResizeMsgListMouseDown(event)\">"
- "<div class=\"fix_scrollbar_bug\"> <hr>"
- "</div></div>\n"
- );
-
- wprintf("<div id=\"preview_pane\">"); /**< The preview pane will initially be empty */
+ do_template("summary_trailer", NULL);
} else if (WCC->is_mobile) {
wprintf("</div>");
}
*/
if (is_bbview) {
/** begin bbview scroller */
+
+ DoTemplate(HKEY("msg_listselector_bottom"), BBViewToolBar, MessageDropdown, CTX_STRBUF);
StrBufAppendBuf(WCC->WBuf, BBViewToolBar, 0);
+
+ FreeStrBuf(&BBViewToolBar);
+ FreeStrBuf(&MessageDropdown);
}
DONE:
DeleteHash(&WCC->summ);
}
if (addrbook != NULL) free(addrbook);
+ FreeStrBuf(&BBViewToolBar);
}
HashPos *it;
/* Add in the attachments */
- it = GetNewHashPos();
+ it = GetNewHashPos(WCC->attachments, 0);
while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
att = (wc_attachment*)vAtt;
encoded_length = ((att->length * 150) / 100);
* Otherwise, just go to the "read messages" loop.
*/
else {
- readloop("readnew");
+ readloop(readnew);
}
}
}
else if (buf[0] != '2') { /** Any other error means that we cannot continue */
sprintf(WCC->ImportantMessage, "%s", &buf[4]);
- readloop("readnew");
+ readloop(readnew);
return;
}
serv_getln(buf, sizeof buf);
sprintf(WC->ImportantMessage, "%s", &buf[4]);
- readloop("readnew");
+ readloop(readnew);
}
sprintf(WC->ImportantMessage, (_("The message was not moved.")));
}
- readloop("readnew");
+ readloop(readnew);
}
wDumpContent(1);
}
-void readnew(void) { readloop("readnew");}
-void readold(void) { readloop("readold");}
-void readfwd(void) { readloop("readfwd");}
-void headers(void) { readloop("headers");}
-void do_search(void) { readloop("do_search");}
+void h_readnew(void) { readloop(readnew);}
+void h_readold(void) { readloop(readold);}
+void h_readfwd(void) { readloop(readfwd);}
+void h_headers(void) { readloop(headers);}
+void h_do_search(void) { readloop(do_search);}
InitModule_MSG
(void)
{
- WebcitAddUrlHandler(HKEY("readnew"), readnew, 0);
- WebcitAddUrlHandler(HKEY("readold"), readold, 0);
- WebcitAddUrlHandler(HKEY("readfwd"), readfwd, 0);
- WebcitAddUrlHandler(HKEY("headers"), headers, 0);
- WebcitAddUrlHandler(HKEY("do_search"), do_search, 0);
+ WebcitAddUrlHandler(HKEY("readnew"), h_readnew, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readold"), h_readold, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readfwd"), h_readfwd, NEED_URL);
+ WebcitAddUrlHandler(HKEY("headers"), h_headers, NEED_URL);
+ WebcitAddUrlHandler(HKEY("do_search"), h_do_search, 0);
WebcitAddUrlHandler(HKEY("display_enter"), display_enter, 0);
WebcitAddUrlHandler(HKEY("post"), post_message, 0);
WebcitAddUrlHandler(HKEY("move_msg"), move_msg, 0);