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;
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",
);
}
/** Give this task a UID if it doesn't have one. */
- syslog(9, "Give this task a UID if it doesn't have one.\n");
+ syslog(LOG_DEBUG, "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 */
- syslog(9, "Increment the sequence ID\n");
+ syslog(LOG_DEBUG, "Increment the sequence ID\n");
while (prop = icalcomponent_get_first_property(vtodo,
ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
i = icalproperty_get_sequence(prop);
- syslog(9, "Sequence was %d\n", i);
+ syslog(LOG_DEBUG, "Sequence was %d\n", i);
if (i > sequence) sequence = i;
icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
++sequence;
- syslog(9, "New sequence is %d. Adding...\n", sequence);
+ syslog(LOG_DEBUG, "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.
*/
- syslog(9, "Encapsulating into a full VCALENDAR component\n");
+ syslog(LOG_DEBUG, "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, 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;
tasks_GetParamsGetServerCall,
NULL,
NULL,
+ NULL,
tasks_LoadMsgFromServer,
tasks_RenderView_or_Tail,
tasks_Cleanup);