From 16939d06be6f78ee5ca6b0d5e7072e3cfcfdbb3f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 7 Dec 2008 11:34:05 +0000 Subject: [PATCH] * follow api-change in several places * new longint-vector replacer if you just want to blast some numbers in tiny templates * urlpart replacers so you can easily reference the actual api-name in templates (actualy needs to be enabled by the registerer of the api callback) * cleanup and templatize the bbview-selector bar --- webcit/addressbook_popup.c | 6 +- webcit/auth.c | 2 +- webcit/calendar_view.c | 10 +- webcit/inetconf.c | 2 +- webcit/messages.c | 186 +++++++------------ webcit/netconf.c | 2 +- webcit/preferences.c | 2 +- webcit/static/t/msg_listselector.html | 23 +++ webcit/static/t/select_messageindex.html | 1 + webcit/static/t/select_messageindex_all.html | 1 + webcit/subst.c | 89 ++++++++- webcit/summary.c | 4 +- webcit/webcit.c | 17 +- webcit/webcit.h | 2 + 14 files changed, 215 insertions(+), 132 deletions(-) create mode 100644 webcit/static/t/msg_listselector.html create mode 100644 webcit/static/t/select_messageindex.html create mode 100644 webcit/static/t/select_messageindex_all.html diff --git a/webcit/addressbook_popup.c b/webcit/addressbook_popup.c index b8be3e77a..3cb23ebdd 100644 --- a/webcit/addressbook_popup.c +++ b/webcit/addressbook_popup.c @@ -67,7 +67,7 @@ void display_address_book_middle_div(void) { } SortByHashKey(List, 1); - it = GetNewHashPos(); + it = GetNewHashPos(List, 0); while (GetNextHashPos(List, it, &len, &VCName, &Namee)) { wprintf(" diff --git a/webcit/static/t/select_messageindex_all.html b/webcit/static/t/select_messageindex_all.html new file mode 100644 index 000000000..2a69b1c1a --- /dev/null +++ b/webcit/static/t/select_messageindex_all.html @@ -0,0 +1 @@ + diff --git a/webcit/subst.c b/webcit/subst.c index ce0cd8d1b..259373290 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -1556,7 +1556,7 @@ void tmpl_iterate_subtmpl(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, vo List = It->StaticList; SubBuf = NewStrBuf(); - it = GetNewHashPos(); + it = GetNewHashPos(List, 0); while (GetNextHashPos(List, it, &len, &Key, &vContext)) { svprintf(HKEY("ITERATE:ODDEVEN"), WCS_STRING, "%s", (oddeven) ? "odd" : "even"); @@ -2075,6 +2075,91 @@ void tmplput_SORT_ORDER(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void } +void tmplput_long_vector(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +{ + long *LongVector = (long*) Context; + + if ((Tokens->Params[0]->Type == TYPE_LONG) && + (Tokens->Params[0]->lvalue <= LongVector[0])) + { + StrBufAppendPrintf(Target, "%ld", LongVector[Tokens->Params[0]->lvalue]); + } + else + { + if (Tokens->Params[0]->Type == TYPE_LONG) { + lprintf(1, "longvector [%s] (in '%s' line %ld); needs a long Parameter![%s]\n", + Tokens->Params[0]->Start, + ChrPtr(Tokens->FileName), + Tokens->Line, + ChrPtr(Tokens->FlatToken)); + StrBufAppendPrintf( + Target, + "
\nlongvector [%s] (in '%s' line %ld); needs a numerical Parameter!\n[%s]\n
\n", + Tokens->Params[0]->Start, + ChrPtr(Tokens->FileName), + Tokens->Line, + ChrPtr(Tokens->FlatToken)); + } + else { + lprintf(1, "longvector [%s] (in '%s' line %ld); doesn't have %ld Parameters," + " its just the size of %ld![%s]\n", + Tokens->Params[0]->Start, + ChrPtr(Tokens->FileName), + Tokens->Line, + Tokens->Params[0]->lvalue, + LongVector[0], + ChrPtr(Tokens->FlatToken)); + StrBufAppendPrintf( + Target, + "
\nlongvector [%s] (in '%s' line %ld); doesn't have %ld Parameters,"
+				" its just the size of %ld!\n[%s]\n
\n", + Tokens->Params[0]->Start, + ChrPtr(Tokens->FileName), + Tokens->Line, + Tokens->Params[0]->lvalue, + LongVector[0], + ChrPtr(Tokens->FlatToken)); + } + } +} + + + +int ConditionalLongVector(WCTemplateToken *Tokens, void *Context, int ContextType) +{ + long *LongVector = (long*) Context; + + if ((Tokens->Params[2]->Type == TYPE_LONG) && + (Tokens->Params[2]->lvalue <= LongVector[0])&& + (Tokens->Params[3]->Type == TYPE_LONG) && + (Tokens->Params[3]->lvalue <= LongVector[0])) + { + return LongVector[Tokens->Params[2]->lvalue] == LongVector[Tokens->Params[3]->lvalue]; + } + else + { + if ((Tokens->Params[2]->Type == TYPE_LONG) || + (Tokens->Params[2]->Type == TYPE_LONG)) { + lprintf(1, "ConditionalLongVector [%s] (in '%s' line %ld); needs two long Parameter![%s]\n", + Tokens->Params[0]->Start, + ChrPtr(Tokens->FileName), + Tokens->Line, + ChrPtr(Tokens->FlatToken)); + } + else { + lprintf(1, "longvector [%s] (in '%s' line %ld); doesn't have %ld / %ld Parameters," + " its just the size of %ld![%s]\n", + Tokens->Params[0]->Start, + ChrPtr(Tokens->FileName), + Tokens->Line, + Tokens->Params[2]->lvalue, + Tokens->Params[3]->lvalue, + LongVector[0], + ChrPtr(Tokens->FlatToken)); + } + } + return 0; +} void InitModule_SUBST @@ -2087,8 +2172,10 @@ InitModule_SUBST RegisterNamespace("ITERATE", 2, 100, tmpl_iterate_subtmpl, CTX_NONE); RegisterNamespace("DOBOXED", 1, 2, tmpl_do_boxed, CTX_NONE); RegisterNamespace("DOTABBED", 2, 100, tmpl_do_tabbed, CTX_NONE); + RegisterNamespace("LONGVECTOR", 1, 1, tmplput_long_vector, CTX_LONGVECTOR); RegisterConditional(HKEY("COND:SUBST"), 3, ConditionalVar, CTX_NONE); RegisterConditional(HKEY("COND:CONTEXTSTR"), 3, ConditionalContextStr, CTX_STRBUF); + RegisterConditional(HKEY("COND:LONGVECTOR"), 4, ConditionalLongVector, CTX_LONGVECTOR); } /*@}*/ diff --git a/webcit/summary.c b/webcit/summary.c index c18b57b81..41d2aa025 100644 --- a/webcit/summary.c +++ b/webcit/summary.c @@ -98,7 +98,7 @@ void tasks_section(void) { wprintf("
\n"); } else { - at = GetNewHashPos(); + at = GetNewHashPos(WCC->summ, 0); while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) { Msg = (message_summary*) vMsg; display_task(Msg, 0); @@ -138,7 +138,7 @@ void calendar_section(void) { wprintf("
\n"); } else { - at = GetNewHashPos(); + at = GetNewHashPos(WCC->summ, 0); while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) { Msg = (message_summary*) vMsg; load_calendar_item(Msg, 0, &c); diff --git a/webcit/webcit.c b/webcit/webcit.c index 24d0de348..095082ccb 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -171,7 +171,7 @@ void dump_vars(void) const char *HKey; HashPos *Cursor; - Cursor = GetNewHashPos (); + Cursor = GetNewHashPos (WCC->urlstrings, 0); while (GetNextHashPos(WCC->urlstrings, Cursor, &HKLen, &HKey, &U)) { u = (urlcontent*) U; wprintf("%38s = %s\n", u->url_key, ChrPtr(u->url_data)); @@ -1948,7 +1948,21 @@ void tmplput_csslocal(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void * csslocal, 0); } +void tmplput_url_part(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) +{ + StrBuf *UrlBuf; + struct wcsession *WCC = WC; + + if (WCC != NULL) { + if (Tokens->Params[0]->lvalue == 0) + UrlBuf = WCC->UrlFragment1; + else + UrlBuf = WCC->UrlFragment2; + StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, + UrlBuf, 1); + } +} @@ -1973,6 +1987,7 @@ InitModule_WEBCIT RegisterConditional(HKEY("COND:IMPMSG"), 0, ConditionalImportantMesage, CTX_NONE); RegisterConditional(HKEY("COND:BSTR"), 1, ConditionalBstr, CTX_NONE); RegisterNamespace("BSTR", 1, 2, tmplput_bstr, CTX_NONE); + RegisterNamespace("URLPART", 1, 2, tmplput_url_part, CTX_NONE); RegisterNamespace("CSSLOCAL", 0, 0, tmplput_csslocal, CTX_NONE); RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, CTX_NONE); RegisterNamespace("OFFERSTARTPAGE", 0, 0, offer_start_page, CTX_NONE); diff --git a/webcit/webcit.h b/webcit/webcit.h index 4e2e3f016..1303daf8b 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -321,6 +321,8 @@ typedef struct _wcsubst { #define CTX_MIME_ATACH 10 #define CTX_ATT 11 #define CTX_STRBUF 12 +#define CTX_LONGVECTOR 13 + void RegisterNS(const char *NSName, long len, int nMinArgs, -- 2.30.2