From ff01cf1d6b1e648e978b7d584a7a1172be0b5bb0 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Wilfried=20G=C3=B6esgens?=
Date: Sun, 7 Dec 2008 23:27:13 +0000
Subject: [PATCH] * make readloop long-controlled * move param-dependant code
into callback hooks * migrate all places to the new enums fed into readloop
---
webcit/calendar.c | 2 +-
webcit/event.c | 2 +-
webcit/messages.c | 89 +++++++++-----------
webcit/msg_renderers.c | 40 +++++++++
webcit/notes.c | 2 +-
webcit/roomops.c | 2 +-
webcit/static/t/msg_listselector.html | 6 +-
webcit/static/t/select_messageindex.html | 2 +-
webcit/static/t/select_messageindex_all.html | 2 +-
webcit/static/t/summary_trailer.html | 7 ++
webcit/vcard_edit.c | 4 +-
webcit/webcit.c | 4 +-
webcit/webcit.h | 17 +++-
13 files changed, 114 insertions(+), 65 deletions(-)
create mode 100644 webcit/static/t/summary_trailer.html
diff --git a/webcit/calendar.c b/webcit/calendar.c
index 33864203e..9dc2b0733 100644
--- a/webcit/calendar.c
+++ b/webcit/calendar.c
@@ -932,7 +932,7 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
}
/** Go back to the task list */
- readloop("readfwd");
+ readloop(readfwd);
}
diff --git a/webcit/event.c b/webcit/event.c
index ae3417462..0258c2ffc 100644
--- a/webcit/event.c
+++ b/webcit/event.c
@@ -1147,6 +1147,6 @@ STARTOVER: for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
/* If this was a save or delete, go back to the calendar view. */
if (!havebstr("check_button")) {
- readloop("readfwd");
+ readloop(readfwd);
}
}
diff --git a/webcit/messages.c b/webcit/messages.c
index 269d1da79..7a2bc8bde 100644
--- a/webcit/messages.c
+++ b/webcit/messages.c
@@ -938,10 +938,13 @@ int load_msg_ptrs(char *servcmd, int with_headers)
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;
}
@@ -1000,15 +1003,18 @@ void DrawMessageSummarySelector(StrBuf *BBViewToolBar, long maxmsgs, long startm
FlushStrBuf(BBViewToolBar);
DoTemplate(HKEY("msg_listselector"), BBViewToolBar, Selector, CTX_STRBUF);
FreeStrBuf(&Selector);
+ 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 *BBViewToolBar = NULL;
void *vMsg;
@@ -1020,7 +1026,7 @@ void readloop(char *oper)
///int b = 0;
int nummsgs;
long startmsg = 0;
- int maxmsgs;
+ int maxmsgs = 0;
long *displayed_msgs = NULL;
int num_displayed = 0;
int is_summary = 0;
@@ -1071,7 +1077,7 @@ void readloop(char *oper)
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 {
@@ -1095,25 +1101,11 @@ void readloop(char *oper)
* 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");
}
}
@@ -1122,12 +1114,15 @@ void readloop(char *oper)
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;
}
+
+ bbs_reverse = is_bbview && (lbstr("SortOrder") == 2);
+
if (startmsg == 0L) {
if (bbs_reverse) {
Msg = GetMessagePtrAt((nummsgs >= maxmsgs) ? (nummsgs - maxmsgs) : 0, WCC->summ);
@@ -1165,11 +1160,14 @@ void readloop(char *oper)
if (nummsgs == 0) {
if (care_for_empty_list) {
wprintf("
");
- 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("
\n");
@@ -1292,18 +1290,7 @@ void readloop(char *oper)
}
if (is_summary) {
- wprintf(""
- "\n"); /**< end of 'fix_scrollbar_bug' div */
- wprintf(""); /**< end of 'message_list' div */
-
- /** Here's the grab-it-to-resize-the-message-list widget */
- wprintf("
"
- "
"
- "
\n"
- );
-
- wprintf("
"); /**< The preview pane will initially be empty */
+ do_template("summary_trailer", NULL);
} else if (WCC->is_mobile) {
wprintf("