Back to index

webcit  8.12-dfsg
Functions
summary.c File Reference
#include "webcit.h"
#include "calendar.h"

Go to the source code of this file.

Functions

int calendar_summary_view (void)
void output_date (void)
void tmplput_output_date (StrBuf *Target, WCTemplputParams *TP)
void new_messages_section (void)
void tasks_section (void)
void calendar_section (void)
void tmplput_new_messages_section (StrBuf *Target, WCTemplputParams *TP)
void tmplput_tasks_section (StrBuf *Target, WCTemplputParams *TP)
void tmplput_calendar_section (StrBuf *Target, WCTemplputParams *TP)
void display_summary_page (void)
void InitModule_SUMMARY (void)

Function Documentation

void calendar_section ( void  )

Definition at line 137 of file summary.c.

                            {
       char cmd[SIZ];
       char filter[SIZ];
       int num_msgs = 0;
       HashPos *at;
       const char *HashKey;
       long HKLen;
       void *vMsg;
       message_summary *Msg;
       wcsession *WCC = WC;
       StrBuf *Buf;
       void *v = NULL;
       SharedMessageStatus Stat;

       memset(&Stat, 0, sizeof(SharedMessageStatus));
       Stat.maxload = 10000;
       Stat.lowest_found = (-1);
       Stat.highest_found = (-1);
       
       Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
       gotoroom(Buf);
       FreeStrBuf(&Buf);
       if ( (WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF) ) {
              num_msgs = 0;
       }
       else {
              num_msgs = load_msg_ptrs("MSGS ALL", NULL, &Stat, NULL);
       }
       calendar_GetParamsGetServerCall(&Stat, 
                                   &v,
                                   readnew, 
                                   cmd, 
                                   sizeof(cmd),
                                   filter,
                                   sizeof(filter));


       if (num_msgs > 0) {
              at = GetNewHashPos(WCC->summ, 0);
              while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
                     Msg = (message_summary*) vMsg;            
                     calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0);
              }
              DeleteHashPos(&at);
       }
       if (calendar_summary_view() < 1) {
              wc_printf("<i>");
              wc_printf(_("(Nothing)"));
              wc_printf("</i><br>\n");
       }
       __calendar_Cleanup(&v);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int calendar_summary_view ( void  )

Definition at line 1320 of file calendar_view.c.

                                {
       long hklen;
       const char *HashKey;
       void *vCal;
       HashPos *Pos;
       disp_cal *Cal;
       icalproperty *p;
       struct icaltimetype t;
       time_t event_tt;
       struct tm event_tm;
       struct tm today_tm;
       time_t now;
       int all_day_event = 0;
       char timestring[SIZ];
       wcsession *WCC = WC;
       int num_displayed = 0;

       if (GetCount(WC->disp_cal_items) == 0) {
              return(0);
       }

       now = time(NULL);
       localtime_r(&now, &today_tm);

       Pos = GetNewHashPos(WCC->disp_cal_items, 0);
       while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
              Cal = (disp_cal*)vCal;
              p = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
              if (p != NULL) {
                     t = icalproperty_get_dtstart(p);
                     event_tt = icaltime_as_timet(t);
                     if (t.is_date) {
                            all_day_event = 1;
                     }
                     else {
                            all_day_event = 0;
                     }
                     fmt_time(timestring, SIZ, event_tt);

                     if (all_day_event) {
                            gmtime_r(&event_tt, &event_tm);
                     }
                     else {
                            localtime_r(&event_tt, &event_tm);
                     }

                     if ( (event_tm.tm_year == today_tm.tm_year)
                            && (event_tm.tm_mon == today_tm.tm_mon)
                            && (event_tm.tm_mday == today_tm.tm_mday)
                     ) {

                            p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
                            if (p == NULL) {
                                   p = icalproperty_new_summary(_("Untitled Task"));
                                   icalcomponent_add_property(Cal->cal, p);
                            }
                            if (p != NULL)
                            {
                                   if (WCC->CurRoom.view == VIEW_TASKS) {
                                          wc_printf("<a href=\"display_edit_task"
                                                 "?msgnum=%ld"
                                                 "?return_to_summary=1"
                                                 "?go=",
                                                 Cal->cal_msgnum
                                          );
                                          escputs(ChrPtr(WCC->CurRoom.name));
                                          wc_printf("\">");
                                   }
                                   else {
                                          wc_printf("<a href=\"display_edit_event"
                                                 "?msgnum=%ld"
                                                 "?calview=summary"
                                                 "?year=%d"
                                                 "?month=%d"
                                                 "?day=%d"
                                                 "?go=",
                                                 Cal->cal_msgnum,
                                                 today_tm.tm_year + 1900,
                                                 today_tm.tm_mon + 1,
                                                 today_tm.tm_mday
                                          );
                                          escputs(ChrPtr(WCC->CurRoom.name));
                                          wc_printf("\">");
                                   }
                                   escputs((char *) icalproperty_get_comment(p));
                                   if (!all_day_event) {
                                          wc_printf(" (%s)", timestring);
                                   }
                                   wc_printf("</a><br>\n");
                                   ++num_displayed;
                            }
                     }
              }
       }
       DeleteHashPos(&Pos);
       DeleteHash(&WC->disp_cal_items);
       return(num_displayed);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void display_summary_page ( void  )

Definition at line 204 of file summary.c.

{
       output_headers(1, 1, 1, 0, 0, 0); 
       do_template("summary_page");
       wDumpContent(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void InitModule_SUMMARY ( void  )

Definition at line 214 of file summary.c.

{
       RegisterNamespace("TIME:NOW", 0, 0, tmplput_output_date, NULL, CTX_NONE);
       WebcitAddUrlHandler(HKEY("summary"), "", 0, display_summary_page, ANONYMOUS);
       WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX);
       WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX);
       WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void new_messages_section ( void  )

Definition at line 53 of file summary.c.

                                {
       char buf[SIZ];
       char room[SIZ];
       int i;
       int number_of_rooms_to_check;
       char *rooms_to_check = "Mail|Lobby";


       number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
       if (number_of_rooms_to_check == 0) return;

       wc_printf("<table border=\"0\" width=\"100%%\">\n");
       for (i=0; i<number_of_rooms_to_check; ++i) {
              extract_token(room, rooms_to_check, i, '|', sizeof room);

              serv_printf("GOTO %s", room);
              serv_getln(buf, sizeof buf);
              if (buf[0] == '2') {
                     extract_token(room, &buf[4], 0, '|', sizeof room);
                     wc_printf("<tr><td><a href=\"dotgoto?room=");
                     urlescputs(room);
                     wc_printf("\">");
                     escputs(room);
                     wc_printf("</a></td><td>%d/%d</td></tr>\n",
                            extract_int(&buf[4], 1),
                            extract_int(&buf[4], 2)
                     );
              }
       }
       wc_printf("</table>\n");

}

Here is the call graph for this function:

Here is the caller graph for this function:

void output_date ( void  )

Definition at line 23 of file summary.c.

                       {
       struct tm tm;
       time_t now;
       char buf[128];

       time(&now);
       localtime_r(&now, &tm);

       wc_strftime(buf, 32, "%A, %x", &tm);
       wc_printf("%s", buf);
}

Here is the call graph for this function:

void tasks_section ( void  )

Definition at line 90 of file summary.c.

                         {
       int num_msgs = 0;
       HashPos *at;
       const char *HashKey;
       long HKLen;
       void *vMsg;
       message_summary *Msg;
       wcsession *WCC = WC;
       StrBuf *Buf;
       SharedMessageStatus Stat;

       memset(&Stat, 0, sizeof(SharedMessageStatus));
       Stat.maxload = 10000;
       Stat.lowest_found = (-1);
       Stat.highest_found = (-1);

       Buf = NewStrBufPlain(HKEY("_TASKS_"));
       gotoroom(Buf);
       FreeStrBuf(&Buf);

       if (WCC->CurRoom.view != VIEW_TASKS) {
              num_msgs = 0;
       }
       else {
              num_msgs = load_msg_ptrs("MSGS ALL", NULL, &Stat, NULL);
       }

       if (num_msgs > 0) {
              at = GetNewHashPos(WCC->summ, 0);
              while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
                     Msg = (message_summary*) vMsg;            
                     tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
              }
              DeleteHashPos(&at);
       }

       if (calendar_summary_view() < 1) {
              wc_printf("<i>");
              wc_printf(_("(None)"));
              wc_printf("</i><br>\n");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_calendar_section ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 196 of file summary.c.

Here is the call graph for this function:

void tmplput_new_messages_section ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 190 of file summary.c.

Here is the call graph for this function:

void tmplput_output_date ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 35 of file summary.c.

{
       struct tm tm;
       time_t now;
       char buf[128];
       size_t n;

       time(&now);
       localtime_r(&now, &tm);

       n = wc_strftime(buf, 32, "%A, %x", &tm);
       StrBufAppendBufPlain(Target, buf, n, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_tasks_section ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 193 of file summary.c.

                                                                 {
       tasks_section();
}

Here is the call graph for this function: