icalproperty *p;
wcsession *WCC = WC;
- wprintf("<div class=\"fix_scrollbar_bug\">"
- "<table class=\"calendar_view_background\"><tbody id=\"taskview\">\n<tr>\n"
- "<th>");
- wprintf(_("Completed?"));
- wprintf("</th><th>");
- wprintf(_("Name of task"));
- wprintf("</th><th>");
- wprintf(_("Date due"));
- wprintf("</th><th>");
- wprintf(_("Category"));
- wprintf(" (<select id=\"selectcategory\"><option value=\"showall\">%s</option></select>)</th></tr>\n",
+ wc_printf("<table class=\"calendar_view_background\"><tbody id=\"taskview\">\n<tr>\n<th>");
+ wc_printf(_("Completed?"));
+ wc_printf("</th><th>");
+ wc_printf(_("Name of task"));
+ wc_printf("</th><th>");
+ wc_printf(_("Date due"));
+ wc_printf("</th><th>");
+ wc_printf(_("Category"));
+ wc_printf(" (<select id=\"selectcategory\"><option value=\"showall\">%s</option></select>)</th></tr>\n",
_("Show All"));
nItems = GetCount(WC->disp_cal_items);
int is_date;
Cal = (disp_cal*)vCal;
- wprintf("<tr><td>");
+ wc_printf("<tr><td>");
todoStatus = icalcomponent_get_status(Cal->cal);
- wprintf("<input type=\"checkbox\" name=\"completed\" value=\"completed\" ");
+ wc_printf("<input type=\"checkbox\" name=\"completed\" value=\"completed\" ");
if (todoStatus == ICAL_STATUS_COMPLETED) {
- wprintf("checked=\"checked\" ");
+ wc_printf("checked=\"checked\" ");
}
- wprintf("disabled=\"disabled\">\n</td><td>");
+ wc_printf("disabled=\"disabled\">\n</td><td>");
p = icalcomponent_get_first_property(Cal->cal,
ICAL_SUMMARY_PROPERTY);
- wprintf("<a href=\"display_edit_task?msgnum=%ld?taskrm=", Cal->cal_msgnum);
- urlescputs(ChrPtr(WC->wc_roomname));
- wprintf("\">");
- /* wprintf("<img align=middle "
+ wc_printf("<a href=\"display_edit_task?msgnum=%ld?taskrm=", Cal->cal_msgnum);
+ urlescputs(ChrPtr(WC->CurRoom.name));
+ wc_printf("\">");
+ /* wc_printf("<img align=middle "
"src=\"static/taskmanag_16x.gif\" border=0> "); */
if (p != NULL) {
escputs((char *)icalproperty_get_comment(p));
}
- wprintf("</a>\n");
- wprintf("</td>\n");
+ wc_printf("</a>\n");
+ wc_printf("</td>\n");
due = get_task_due_date(Cal->cal, &is_date);
- wprintf("<td><span");
+ wc_printf("<td><span");
if (due > 0) {
webcit_fmt_date(buf, SIZ, due, is_date ? DATEFMT_RAWDATE : DATEFMT_FULL);
- wprintf(">%s",buf);
+ wc_printf(">%s",buf);
}
else {
- wprintf(">");
+ wc_printf(">");
}
- wprintf("</span></td>");
- wprintf("<td>");
+ wc_printf("</span></td>");
+ wc_printf("<td>");
p = icalcomponent_get_first_property(Cal->cal,
ICAL_CATEGORIES_PROPERTY);
if (p != NULL) {
escputs((char *)icalproperty_get_categories(p));
}
- wprintf("</td>");
- wprintf("</tr>");
+ wc_printf("</td>");
+ wc_printf("</tr>");
}
- wprintf("</tbody></table></div>\n");
+ wc_printf("</tbody></table>\n");
/* Free the list */
DeleteHash(&WC->disp_cal_items);
void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, char *from,
int unread, calview *calv)
{
+ wcsession *WCC = WC;
icalcomponent *vtodo;
icalproperty *p;
struct icaltimetype IcalTime;
- time_t now;
int created_new_vtodo = 0;
icalproperty_status todoStatus;
- now = time(NULL);
-
if (supplied_vtodo != NULL) {
vtodo = supplied_vtodo;
/* TODO: Can we take all this and move it into a template? */
output_headers(1, 1, 1, 0, 0, 0);
- wprintf("<!-- start task edit form -->");
+ wc_printf("<!-- start task edit form -->");
p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
/* Get summary early for title */
- wprintf("<div class=\"box\">\n");
- wprintf("<div class=\"boxlabel\">");
- wprintf(_("Edit task"));
- wprintf("- ");
+ wc_printf("<div class=\"box\">\n");
+ wc_printf("<div class=\"boxlabel\">");
+ wc_printf(_("Edit task"));
+ wc_printf("- ");
if (p != NULL) {
escputs((char *)icalproperty_get_comment(p));
}
- wprintf("</div>");
+ wc_printf("</div>");
- wprintf("<div class=\"boxcontent\">\n");
- wprintf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
- wprintf("<div style=\"display: none;\">\n ");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n", msgnum);
- wprintf("<INPUT TYPE=\"hidden\" NAME=\"return_to_summary\" VALUE=\"%d\">\n",
+ wc_printf("<div class=\"boxcontent\">\n");
+ wc_printf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
+ wc_printf("<div style=\"display: none;\">\n ");
+
+ wc_printf("<input type=\"hidden\" name=\"go\" value=\"");
+ StrEscAppend(WCC->WBuf, WCC->CurRoom.name, NULL, 0, 0);
+ wc_printf("\">\n");
+
+ wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
+ wc_printf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n", msgnum);
+ wc_printf("<INPUT TYPE=\"hidden\" NAME=\"return_to_summary\" VALUE=\"%d\">\n",
ibstr("return_to_summary"));
- wprintf("</div>");
- wprintf("<table class=\"calendar_background\"><tr><td>");
- wprintf("<TABLE STYLE=\"border: none;\">\n");
+ wc_printf("</div>");
+ wc_printf("<table class=\"calendar_background\"><tr><td>");
+ wc_printf("<TABLE STYLE=\"border: none;\">\n");
- wprintf("<TR><TD>");
- wprintf(_("Summary:"));
- wprintf("</TD><TD>"
+ wc_printf("<TR><TD>");
+ wc_printf(_("Summary:"));
+ wc_printf("</TD><TD>"
"<INPUT TYPE=\"text\" NAME=\"summary\" "
"MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
if (p != NULL) {
escputs((char *)icalproperty_get_comment(p));
}
- wprintf("\"></TD></TR>\n");
+ wc_printf("\"></TD></TR>\n");
- wprintf("<TR><TD>");
- wprintf(_("Start date:"));
- wprintf("</TD><TD>");
+ wc_printf("<TR><TD>");
+ wc_printf(_("Start date:"));
+ wc_printf("</TD><TD>");
p = icalcomponent_get_first_property(vtodo, ICAL_DTSTART_PROPERTY);
- wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"nodtstart\" ID=\"nodtstart\" VALUE=\"NODTSTART\" ");
+ wc_printf("<INPUT TYPE=\"CHECKBOX\" NAME=\"nodtstart\" ID=\"nodtstart\" VALUE=\"NODTSTART\" ");
if (p == NULL) {
- wprintf("CHECKED=\"CHECKED\"");
+ wc_printf("CHECKED=\"CHECKED\"");
}
- wprintf(">");
- wprintf(_("No date"));
+ wc_printf(">");
+ wc_printf(_("No date"));
- wprintf(" ");
- wprintf("<span ID=\"dtstart_date\">");
- wprintf(_("or"));
- wprintf(" ");
+ wc_printf(" ");
+ wc_printf("<span ID=\"dtstart_date\">");
+ wc_printf(_("or"));
+ wc_printf(" ");
if (p != NULL) {
IcalTime = icalproperty_get_dtstart(p);
}
IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
display_icaltimetype_as_webform(&IcalTime, "dtstart", 0);
- wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"dtstart_time_assoc\" ID=\"dtstart_time_assoc\" VALUE=\"yes\"");
+ wc_printf("<INPUT TYPE=\"CHECKBOX\" NAME=\"dtstart_time_assoc\" ID=\"dtstart_time_assoc\" VALUE=\"yes\"");
if (!IcalTime.is_date) {
- wprintf("CHECKED=\"CHECKED\"");
+ wc_printf("CHECKED=\"CHECKED\"");
}
- wprintf(">");
- wprintf(_("Time associated"));
- wprintf("</span></TD></TR>\n");
+ wc_printf(">");
+ wc_printf(_("Time associated"));
+ wc_printf("</span></TD></TR>\n");
- wprintf("<TR><TD>");
- wprintf(_("Due date:"));
- wprintf("</TD><TD>");
+ wc_printf("<TR><TD>");
+ wc_printf(_("Due date:"));
+ wc_printf("</TD><TD>");
p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
- wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"nodue\" ID=\"nodue\" VALUE=\"NODUE\"");
+ wc_printf("<INPUT TYPE=\"CHECKBOX\" NAME=\"nodue\" ID=\"nodue\" VALUE=\"NODUE\"");
if (p == NULL) {
- wprintf("CHECKED=\"CHECKED\"");
- }
- wprintf(">");
- wprintf(_("No date"));
- wprintf(" ");
- wprintf("<span ID=\"due_date\">\n");
- wprintf(_("or"));
- wprintf(" ");
+ wc_printf("CHECKED=\"CHECKED\"");
+ }
+ wc_printf(">");
+ wc_printf(_("No date"));
+ wc_printf(" ");
+ wc_printf("<span ID=\"due_date\">\n");
+ wc_printf(_("or"));
+ wc_printf(" ");
if (p != NULL) {
IcalTime = icalproperty_get_due(p);
}
IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
display_icaltimetype_as_webform(&IcalTime, "due", 0);
- wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"due_time_assoc\" ID=\"due_time_assoc\" VALUE=\"yes\"");
+ wc_printf("<INPUT TYPE=\"CHECKBOX\" NAME=\"due_time_assoc\" ID=\"due_time_assoc\" VALUE=\"yes\"");
if (!IcalTime.is_date) {
- wprintf("CHECKED=\"CHECKED\"");
+ wc_printf("CHECKED=\"CHECKED\"");
}
- wprintf(">");
- wprintf(_("Time associated"));
- wprintf("</span></TD></TR>\n");
+ wc_printf(">");
+ wc_printf(_("Time associated"));
+ wc_printf("</span></TD></TR>\n");
todoStatus = icalcomponent_get_status(vtodo);
- wprintf("<TR><TD>\n");
- wprintf(_("Completed:"));
- wprintf("</TD><TD>");
- wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"status\" VALUE=\"COMPLETED\"");
+ wc_printf("<TR><TD>\n");
+ wc_printf(_("Completed:"));
+ wc_printf("</TD><TD>");
+ wc_printf("<INPUT TYPE=\"CHECKBOX\" NAME=\"status\" VALUE=\"COMPLETED\"");
if (todoStatus == ICAL_STATUS_COMPLETED) {
- wprintf(" CHECKED=\"CHECKED\"");
+ wc_printf(" CHECKED=\"CHECKED\"");
}
- wprintf(" >");
- wprintf("</TD></TR>");
+ wc_printf(" >");
+ wc_printf("</TD></TR>");
/* start category field */
p = icalcomponent_get_first_property(vtodo, ICAL_CATEGORIES_PROPERTY);
- wprintf("<TR><TD>");
- wprintf(_("Category:"));
- wprintf("</TD><TD>");
- wprintf("<INPUT TYPE=\"text\" NAME=\"category\" MAXLENGTH=\"32\" SIZE=\"32\" VALUE=\"");
+ wc_printf("<TR><TD>");
+ wc_printf(_("Category:"));
+ wc_printf("</TD><TD>");
+ wc_printf("<INPUT TYPE=\"text\" NAME=\"category\" MAXLENGTH=\"32\" SIZE=\"32\" VALUE=\"");
if (p != NULL) {
escputs((char *)icalproperty_get_categories(p));
}
- wprintf("\">");
- wprintf("</TD></TR>\n ");
+ wc_printf("\">");
+ wc_printf("</TD></TR>\n ");
/* end category field */
- wprintf("<TR><TD>");
- wprintf(_("Description:"));
- wprintf("</TD><TD>");
- wprintf("<TEXTAREA NAME=\"description\" "
+ wc_printf("<TR><TD>");
+ wc_printf(_("Description:"));
+ wc_printf("</TD><TD>");
+ wc_printf("<TEXTAREA NAME=\"description\" "
"ROWS=\"10\" COLS=\"80\">\n"
);
p = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY);
if (p != NULL) {
escputs((char *)icalproperty_get_comment(p));
}
- wprintf("</TEXTAREA></TD></TR></TABLE>\n");
+ wc_printf("</TEXTAREA></TD></TR></TABLE>\n");
- wprintf("<SPAN STYLE=\"text-align: center;\">"
+ wc_printf("<SPAN STYLE=\"text-align: center;\">"
"<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
" "
"<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
_("Delete"),
_("Cancel")
);
- wprintf("</td></tr></table>");
- wprintf("</FORM>\n");
- wprintf("</div></div></div>\n");
- wprintf("<!-- end task edit form -->");
+ wc_printf("</td></tr></table>");
+ wc_printf("</FORM>\n");
+ wc_printf("</div></div></div>\n");
+ wc_printf("<!-- end task edit form -->");
wDumpContent(1);
if (created_new_vtodo) {
);
}
/** Give this task a UID if it doesn't have one. */
- lprintf(9, "Give this task a UID if it doesn't have one.\n");
+ syslog(9, "Give this task a UID if it doesn't have one.\n");
if (icalcomponent_get_first_property(vtodo,
ICAL_UID_PROPERTY) == NULL) {
generate_uuid(buf);
}
/* Increment the sequence ID */
- lprintf(9, "Increment the sequence ID\n");
+ syslog(9, "Increment the sequence ID\n");
while (prop = icalcomponent_get_first_property(vtodo,
ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
i = icalproperty_get_sequence(prop);
- lprintf(9, "Sequence was %d\n", i);
+ syslog(9, "Sequence was %d\n", i);
if (i > sequence) sequence = i;
icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
++sequence;
- lprintf(9, "New sequence is %d. Adding...\n", sequence);
+ syslog(9, "New sequence is %d. Adding...\n", sequence);
icalcomponent_add_property(vtodo,
icalproperty_new_sequence(sequence)
);
* can't encapsulate something that may already be encapsulated
* somewhere else.
*/
- lprintf(9, "Encapsulating into a full VCALENDAR component\n");
+ syslog(9, "Encapsulating into a full VCALENDAR component\n");
encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vtodo));
/* Serialize it and save it to the message base */
/* Go back to wherever we came from */
if (ibstr("return_to_summary") == 1) {
- summary();
+ display_summary_page();
}
else {
- readloop(readfwd);
+ readloop(readfwd, eUseDefault);
}
}
+
+/*
+ * free memory allocated using libical
+ */
+void delete_task(void *vCal)
+{
+ disp_cal *Cal = (disp_cal*) vCal;
+ icalcomponent_free(Cal->cal);
+ free(Cal->from);
+ free(Cal);
+}
+
+
+/*
+ * Load a Task into a hash table for later display.
+ */
+void load_task(icalcomponent *event, long msgnum, char *from, int unread, calview *calv)
+{
+ icalproperty *ps = NULL;
+ struct icaltimetype dtstart, dtend;
+ wcsession *WCC = WC;
+ disp_cal *Cal;
+ size_t len;
+ icalcomponent *cptr = NULL;
+
+ dtstart = icaltime_null_time();
+ dtend = icaltime_null_time();
+
+ if (WCC->disp_cal_items == NULL) {
+ WCC->disp_cal_items = NewHash(0, Flathash);
+ }
+
+ Cal = (disp_cal*) malloc(sizeof(disp_cal));
+ memset(Cal, 0, sizeof(disp_cal));
+ Cal->cal = icalcomponent_new_clone(event);
+
+ /* Dezonify and decapsulate at the very last moment */
+ ical_dezonify(Cal->cal);
+ if (icalcomponent_isa(Cal->cal) != ICAL_VTODO_COMPONENT) {
+ cptr = icalcomponent_get_first_component(Cal->cal, ICAL_VTODO_COMPONENT);
+ if (cptr) {
+ cptr = icalcomponent_new_clone(cptr);
+ icalcomponent_free(Cal->cal);
+ Cal->cal = cptr;
+ }
+ }
+
+ Cal->unread = unread;
+ len = strlen(from);
+ Cal->from = (char*)malloc(len+ 1);
+ memcpy(Cal->from, from, len + 1);
+ Cal->cal_msgnum = msgnum;
+
+ /* Precalculate the starting date and time of this event, and store it in our top-level
+ * structure. Later, when we are rendering the calendar, we can just peek at these values
+ * without having to break apart every calendar item.
+ */
+ ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
+ if (ps != NULL) {
+ dtstart = icalproperty_get_dtstart(ps);
+ Cal->event_start = icaltime_as_timet(dtstart);
+ }
+
+ /* Do the same for the ending date and time. It makes the day view much easier to render. */
+ ps = icalcomponent_get_first_property(Cal->cal, ICAL_DTEND_PROPERTY);
+ if (ps != NULL) {
+ dtend = icalproperty_get_dtend(ps);
+ Cal->event_end = icaltime_as_timet(dtend);
+ }
+
+ /* Store it in the hash list. */
+ /* syslog(LOG_DEBUG, "INITIAL: %s", ctime(&Cal->event_start)); */
+ Put(WCC->disp_cal_items,
+ (char*) &Cal->event_start,
+ sizeof(Cal->event_start),
+ Cal,
+ delete_task
+ );
+}
+
+
+
/*
* Display task view
*/
{
/* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
- load_ical_object(Msg->msgnum, is_new, ICAL_VTODO_COMPONENT, display_individual_cal, NULL, 0);
+ load_ical_object(Msg->msgnum, is_new, ICAL_VTODO_COMPONENT, load_task, NULL, 0);
return 0;
}
void **ViewSpecific,
long oper,
char *cmd,
- long len)
+ long len,
+ char *filter,
+ long flen)
{
strcpy(cmd, "MSGS ALL");
Stat->maxmsgs = 32767;
VIEW_TASKS,
tasks_GetParamsGetServerCall,
NULL,
+ NULL,
+ NULL,
tasks_LoadMsgFromServer,
tasks_RenderView_or_Tail,
tasks_Cleanup);