]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* Began implementing month view
[citadel.git] / webcit / messages.c
index f4a43e3fbe727c03ff86ea6daea78ea4bf317ade..b40b587f4bd7f455f4fc95e5a52d5e12e15eba15 100644 (file)
@@ -216,13 +216,15 @@ void read_message(long msgnum) {
        int nhdr = 0;
        int bq = 0;
        char vcard_partnum[SIZ];
-       char *vcard_source = NULL;
+       char cal_partnum[SIZ];
+       char *part_source = NULL;
 
        strcpy(from, "");
        strcpy(node, "");
        strcpy(rfca, "");
        strcpy(reply_to, "");
        strcpy(vcard_partnum, "");
+       strcpy(cal_partnum, "");
 
        serv_printf("MSG4 %ld", msgnum);
        serv_gets(buf);
@@ -330,10 +332,17 @@ void read_message(long msgnum) {
                                        msgnum, mime_partnum);
                        }
 
+                       /*** begin handler prep ***/
                        if (!strcasecmp(mime_content_type, "text/x-vcard")) {
                                strcpy(vcard_partnum, mime_partnum);
                        }
 
+                       if (!strcasecmp(mime_content_type, "text/calendar")) {
+                               strcpy(cal_partnum, mime_partnum);
+                       }
+
+                       /*** end handler prep ***/
+
                }
 
        }
@@ -456,9 +465,10 @@ void read_message(long msgnum) {
                free(mime_http);
        }
 
+       /* Handler for vCard parts */
        if (strlen(vcard_partnum) > 0) {
-               vcard_source = load_mimepart(msgnum, vcard_partnum);
-               if (vcard_source != NULL) {
+               part_source = load_mimepart(msgnum, vcard_partnum);
+               if (part_source != NULL) {
 
                        /* If it's my vCard I can edit it */
                        if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
@@ -470,11 +480,23 @@ void read_message(long msgnum) {
                        }
 
                        /* In all cases, display the full card */
-                       display_vcard(vcard_source, 0, 1);
-                       free(vcard_source);
+                       display_vcard(part_source, 0, 1);
                }
        }
 
+       /* Handler for calendar parts */
+       if (strlen(cal_partnum) > 0) {
+               part_source = load_mimepart(msgnum, cal_partnum);
+               if (part_source != NULL) {
+                       cal_process_attachment(part_source);
+               }
+       }
+
+       if (part_source) {
+               free(part_source);
+               part_source = NULL;
+       }
+
 }
 
 
@@ -650,6 +672,8 @@ void readloop(char *oper)
        int num_displayed = 0;
        int is_summary = 0;
        int is_addressbook = 0;
+       int is_calendar = 0;
+       int is_tasks = 0;
        int remaining_messages;
        int lo, hi;
        int lowest_displayed = (-1);
@@ -706,16 +730,31 @@ void readloop(char *oper)
                else wprintf("<A HREF=\"/readfwd?alpha=1\">(other)</A>\n");
                wprintf("<HR width=100%%>\n");
        }
+       if (WC->wc_view == 3) {         /* calendar */
+               is_calendar = 1;
+               strcpy(cmd, "MSGS ALL");
+               maxmsgs = 32767;
+       }
+       if (WC->wc_view == 4) {         /* tasks */
+               is_tasks = 1;
+               strcpy(cmd, "MSGS ALL");
+               maxmsgs = 32767;
+               wprintf("<UL>");
+       }
 
        nummsgs = load_msg_ptrs(cmd);
        if (nummsgs == 0) {
-               if (!strcmp(oper, "readnew")) {
-                       wprintf("<EM>No new messages in this room.</EM>\n");
-               } else if (!strcmp(oper, "readold")) {
-                       wprintf("<EM>No old messages in this room.</EM>\n");
-               } else {
-                       wprintf("<EM>This room is empty.</EM>\n");
+
+               if ((!is_tasks) && (!is_calendar)) {
+                       if (!strcmp(oper, "readnew")) {
+                               wprintf("<EM>No new messages in this room.</EM>\n");
+                       } else if (!strcmp(oper, "readold")) {
+                               wprintf("<EM>No old messages in this room.</EM>\n");
+                       } else {
+                               wprintf("<EM>This room is empty.</EM>\n");
+                       }
                }
+
                goto DONE;
        }
 
@@ -770,6 +809,12 @@ void readloop(char *oper)
                        else if (is_addressbook) {
                                display_addressbook(WC->msgarr[a], alpha);
                        }
+                       else if (is_calendar) {
+                               display_calendar(WC->msgarr[a]);
+                       }
+                       else if (is_tasks) {
+                               display_task(WC->msgarr[a]);
+                       }
                        else {
                                read_message(WC->msgarr[a]);
                        }
@@ -795,6 +840,10 @@ void readloop(char *oper)
                wprintf("</TABLE>\n");
        }
 
+       if (is_tasks) {
+               wprintf("</UL>\n");
+       }
+
        /* Bump these because although we're thinking in zero base, the user
         * is a drooling idiot and is thinking in one base.
         */
@@ -902,7 +951,18 @@ void readloop(char *oper)
        }
        if (is_summary) wprintf("</FORM>\n");
 
-DONE:  wDumpContent(1);
+DONE:
+       if (is_tasks) {
+               wprintf("<A HREF=\"/display_edit_task?msgnum=0\">"
+                       "Add new task</A>\n"
+               );
+       }
+
+       if (is_calendar) {
+               do_calendar_view();
+       }
+
+       wDumpContent(1);
 }