]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* move serv_info into the session, here we can control its de/allocation the right...
[citadel.git] / webcit / messages.c
index 015e36187ac86ab10c84e46a21b379cb660da29f..a30263a2f924620c8f1aa13727c5c644e5d9ead5 100644 (file)
@@ -12,7 +12,7 @@
 HashList *MsgHeaderHandler = NULL;
 HashList *MsgEvaluators = NULL;
 HashList *MimeRenderHandler = NULL;
-int analyze_msg = 0;
+int dbg_analyze_msg = 0;
 
 #define SUBJ_COL_WIDTH_PCT             50      /**< Mailbox view column width */
 #define SENDER_COL_WIDTH_PCT           30      /**< Mailbox view column width */
@@ -43,7 +43,9 @@ typedef struct _MsgPartEvaluatorStruct {
  * printable_view      Nonzero to display a printable view
  * section             Optional for encapsulated message/rfc822 submessage
  */
-int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *PartNum) {
+int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *PartNum) 
+{
+       wcsession *WCC = WC;
        StrBuf *Buf;
        StrBuf *HdrToken;
        StrBuf *FoundCharset;
@@ -109,7 +111,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in
                        StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
                        
 #ifdef TECH_PREVIEW
-                       if (analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
+                       if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
 #endif
                        /* look up one of the examine_* functions to parse the content */
                        if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
@@ -136,7 +138,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in
                                if (StrLength(HdrToken) > 0) {
                                        StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
 #ifdef TECH_PREVIEW
-                                       if (analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
+                                       if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
 #endif
                                        /* the examine*'s know how to do with mime headers too... */
                                        if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
@@ -208,8 +210,8 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in
        else 
        {
                if ((StrLength(Msg->OtherNode)>0) && 
-                   (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(serv_info.serv_nodename))) &&
-                   (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(serv_info.serv_humannode)) ))
+                   (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_nodename))) &&
+                   (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_humannode)) ))
                {
                        if (Msg->reply_to == NULL)
                                Msg->reply_to = NewStrBuf();
@@ -256,13 +258,14 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in
  */
 void embed_message(void) {
        long msgnum = 0L;
+       wcsession *WCC = WC;
        const StrBuf *Tmpl = sbstr("template");
 
-       msgnum = StrTol(WC->UrlFragment2);
+       msgnum = StrTol(WCC->UrlFragment2);
        if (StrLength(Tmpl) > 0) 
-               read_message(WC->WBuf, SKEY(Tmpl), msgnum, 0, NULL);
+               read_message(WCC->WBuf, SKEY(Tmpl), msgnum, 0, NULL);
        else 
-               read_message(WC->WBuf, HKEY("view_message"), msgnum, 0, NULL);
+               read_message(WCC->WBuf, HKEY("view_message"), msgnum, 0, NULL);
 }
 
 
@@ -440,8 +443,8 @@ int load_msg_ptrs(char *servcmd, int with_headers)
                                StrBufExtract_token(Buf2, Buf, 3, '|');
                                if ((StrLength(Buf2) !=0 ) &&
                                    ( ((WCC->room_flags & QR_NETWORK)
-                                      || ((strcasecmp(ChrPtr(Buf2), ChrPtr(serv_info.serv_nodename))
-                                           && (strcasecmp(ChrPtr(Buf2), ChrPtr(serv_info.serv_fqdn))))))))
+                                      || ((strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_nodename))
+                                           && (strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_fqdn))))))))
                                {
                                        StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
                                        StrBufAppendBuf(Msg->from, Buf2, 0);
@@ -568,7 +571,12 @@ long DrawMessageDropdown(StrBuf *Selector, long maxmsgs, long startmsg, int nMes
        }
        vector[6] = 0;
        FlushStrBuf(TmpBuf);
-       vector[1] = lbstr("maxmsgs") == 9999999;
+       if (maxmsgs == 9999999) {
+               vector[1] = 1;
+               ret = maxmsgs;
+       }
+       else
+               vector[1] = 0;          
        vector[2] = 0;
        dbg_print_longvector(vector);
        DoTemplate(HKEY("select_messageindex_all"), TmpBuf, &SubTP);
@@ -914,7 +922,10 @@ DONE:
        case VIEW_NOTES:
                break;
        case VIEW_ADDRESSBOOK:
-               do_addrbook_view(addrbook, num_ab);     /** Render the address book */
+               if (is_singlecard)
+                       read_message(WC->WBuf, HKEY("view_message"), lbstr("startmsg"), 0, NULL);
+               else
+                       do_addrbook_view(addrbook, num_ab);     /** Render the address book */
                break;
        case VIEW_MAILBOX: 
        case VIEW_BBS:
@@ -955,12 +966,12 @@ void post_mime_to_server(void) {
        char *txtmail = NULL;
 
        sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
-               ChrPtr(serv_info.serv_fqdn),
+               ChrPtr(WCC->serv_info->serv_fqdn),
                getpid(),
                ++seq
        );
        sprintf(alt_boundary, "Citadel--Multipart--%s--%04x--%04x",
-               ChrPtr(serv_info.serv_fqdn),
+               ChrPtr(WCC->serv_info->serv_fqdn),
                getpid(),
                ++seq
        );
@@ -1639,7 +1650,7 @@ void jsonMessageListHdr(void)
        /* TODO: make a generic function */
   hprintf("HTTP/1.1 200 OK\r\n");
   hprintf("Content-type: application/json; charset=utf-8\r\n");
-  hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(serv_info.serv_software));
+  hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
   hprintf("Connection: close\r\n");
   hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
   begin_burst();
@@ -1654,8 +1665,10 @@ void new_summary_view(void) {
 /** Output message list in JSON-format */
 void jsonMessageList(void) {
   const StrBuf *room = sbstr("room");
+  long oper = (havebstr("query")) ? do_search : readnew;
   WC->is_ajax = 1; 
-  smart_goto(room);
+  gotoroom(room);
+  readloop(oper);
   WC->is_ajax = 0;
 }