* collect sender / read / unread information for calendar items
authorWilfried Göesgens <willi@citadel.org>
Sun, 24 Feb 2008 15:13:49 +0000 (15:13 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 24 Feb 2008 15:13:49 +0000 (15:13 +0000)
* dislpay the sender in the bubbles
* set the event Class depending on read / unread state
* added some css classes to view this information

webcit/calendar.c
webcit/calendar_view.c
webcit/event.c
webcit/messages.c
webcit/notes.c
webcit/static/webcit.css
webcit/summary.c
webcit/webcit.h

index d882ee7701da06d8e5c3085a8119f0759dc889ab..3a78ac3d880e8b910afd5748c36ee5681bc048a6 100644 (file)
@@ -446,13 +446,16 @@ void handle_rsvp(void) {
  * \param cal Our calendar to process
  * \param msgnum number of the mesage in our db
  */
-void display_individual_cal(icalcomponent *cal, long msgnum)
+void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unread)
 {
        struct wcsession *WCC = WC;     /* stack this for faster access (WC is a function) */
 
        WCC->num_cal += 1;
        WCC->disp_cal = realloc(WC->disp_cal, (sizeof(struct disp_cal) * WCC->num_cal) );
        WCC->disp_cal[WCC->num_cal - 1].cal = icalcomponent_new_clone(cal);
+       WCC->disp_cal[WCC->num_cal - 1].unread = unread;
+       WCC->disp_cal[WCC->num_cal - 1].from = malloc (strlen(from) + 1);
+       strcpy (WCC->disp_cal[WCC->num_cal - 1].from, from);
        ical_dezonify(WCC->disp_cal[WCC->num_cal - 1].cal);
        WCC->disp_cal[WCC->num_cal - 1].cal_msgnum = msgnum;
 }
@@ -465,7 +468,7 @@ void display_individual_cal(icalcomponent *cal, long msgnum)
  * \param supplied_vtodo the todo item we want to edit
  * \param msgnum number of the mesage in our db
  */
-void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
+void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, char *from, int unread) {
        icalcomponent *vtodo;
        icalproperty *p;
        struct icaltimetype t;
@@ -489,7 +492,9 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
                        display_edit_individual_task(
                                icalcomponent_get_first_component(
                                        vtodo, ICAL_VTODO_COMPONENT
-                               ), msgnum
+                                       ), 
+                               msgnum,
+                               from, unread
                        );
                        return;
                }
@@ -594,7 +599,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
  * \param supplied_vtodo the task to save
  * \param msgnum number of the mesage in our db
  */
-void save_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
+void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from, int unread) {
        char buf[SIZ];
        int delete_existing = 0;
        icalproperty *prop;
@@ -617,8 +622,8 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
                if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
                        save_individual_task(
                                icalcomponent_get_first_component(
-                                       vtodo, ICAL_VTODO_COMPONENT
-                               ), msgnum
+                                       vtodo, ICAL_VTODO_COMPONENT), 
+                               msgnum, from, unread
                        );
                        return;
                }
@@ -763,11 +768,12 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum) {
  * \param callback a funcion \todo
  *
  */
-void display_using_handler(long msgnum,
-                       icalcomponent_kind which_kind,
-                       void (*callback)(icalcomponent *, long)
+void display_using_handler(long msgnum, int unread,
+                          icalcomponent_kind which_kind,
+                          void (*callback)(icalcomponent *, long, char*, int)
        ) {
        char buf[1024];
+       char from[128] = "";
        char mime_partnum[256];
        char mime_filename[256];
        char mime_content_type[256];
@@ -798,6 +804,9 @@ void display_using_handler(long msgnum,
                                strcpy(relevant_partnum, mime_partnum);
                        }
                }
+               else if (!strncasecmp(buf, "from=", 4)) {
+                       extract_token(from, buf, 1, '=', sizeof(from));
+               }
        }
 
        if (!IsEmptyStr(relevant_partnum)) {
@@ -811,7 +820,7 @@ void display_using_handler(long msgnum,
 
                                /** Simple components of desired type */
                                if (icalcomponent_isa(cal) == which_kind) {
-                                       callback(cal, msgnum);
+                                       callback(cal, msgnum, from, unread);
                                }
 
                                /** Subcomponents of desired type */
@@ -820,7 +829,7 @@ void display_using_handler(long msgnum,
                                    (c != 0);
                                    c = icalcomponent_get_next_component(cal,
                                    which_kind)) {
-                                       callback(c, msgnum);
+                                       callback(c, msgnum, from, unread);
                                }
                                icalcomponent_free(cal);
                        }
@@ -834,8 +843,8 @@ void display_using_handler(long msgnum,
  * \brief display whole calendar
  * \param msgnum number of the mesage in our db
  */
-void display_calendar(long msgnum) {
-       display_using_handler(msgnum,
+void display_calendar(long msgnum, int unread) {
+       display_using_handler(msgnum, unread,
                                ICAL_VEVENT_COMPONENT,
                                display_individual_cal);
 }
@@ -844,8 +853,8 @@ void display_calendar(long msgnum) {
  * \brief display whole taksview
  * \param msgnum number of the mesage in our db
  */
-void display_task(long msgnum) {
-       display_using_handler(msgnum,
+void display_task(long msgnum, int unread) {
+       display_using_handler(msgnum, unread,
                                ICAL_VTODO_COMPONENT,
                                display_individual_cal);
 }
@@ -864,13 +873,13 @@ void display_edit_task(void) {
        msgnum = atol(bstr("msgnum"));
        if (msgnum > 0L) {
                /** existing task */
-               display_using_handler(msgnum,
+               display_using_handler(msgnum, 0,
                                ICAL_VTODO_COMPONENT,
                                display_edit_individual_task);
        }
        else {
                /** new task */
-               display_edit_individual_task(NULL, 0L);
+               display_edit_individual_task(NULL, 0L, "", 0);
        }
 }
 
@@ -882,12 +891,12 @@ void save_task(void) {
 
        msgnum = atol(bstr("msgnum"));
        if (msgnum > 0L) {
-               display_using_handler(msgnum,
+               display_using_handler(msgnum, 0,
                                ICAL_VTODO_COMPONENT,
                                save_individual_task);
        }
        else {
-               save_individual_task(NULL, 0L);
+               save_individual_task(NULL, 0L, "", 0);
        }
 }
 
@@ -900,13 +909,13 @@ void display_edit_event(void) {
        msgnum = atol(bstr("msgnum"));
        if (msgnum > 0L) {
                /* existing event */
-               display_using_handler(msgnum,
+               display_using_handler(msgnum, 0,
                                ICAL_VEVENT_COMPONENT,
                                display_edit_individual_event);
        }
        else {
                /* new event */
-               display_edit_individual_event(NULL, 0L);
+               display_edit_individual_event(NULL, 0L, "", 0);
        }
 }
 
@@ -919,12 +928,12 @@ void save_event(void) {
        msgnum = atol(bstr("msgnum"));
 
        if (msgnum > 0L) {
-               display_using_handler(msgnum,
+               display_using_handler(msgnum, 0,
                                ICAL_VEVENT_COMPONENT,
                                save_individual_event);
        }
        else {
-               save_individual_event(NULL, 0L);
+               save_individual_event(NULL, 0L, "", 0);
        }
 }
 
index b5525b1beb5274d461db2a0b257f008fa628005d..699d83e73835d5099a9fc7c88aec0924af37f9fc 100644 (file)
@@ -259,14 +259,16 @@ void calendar_month_view_display_events(int year, int month, int day)
                                }
 
                                wprintf("<font size=-1>"
-                                       "<a href=\"display_edit_event?"
+                                       "<a class=\"event%s\" href=\"display_edit_event?"
                                        "msgnum=%ld&calview=month&year=%d&month=%d&day=%d\""
                                        " btt_tooltext=\"",
+                                       (Cal->unread)?"_unread":"_read",
                                        WC->disp_cal[i].cal_msgnum,
                                        year, month, day
                                );
 
-                               wprintf("<i>%s</i> ", _("Summary:"));
+                               wprintf("<i>%s: %s</i><br />", _("From"), Cal->from);
+                               wprintf("<i>%s</i> ",          _("Summary:"));
                                escputs((char *)icalproperty_get_comment(p));
                                wprintf("<br />");
                                
@@ -356,12 +358,14 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
        time_t event_tt;
        time_t event_tts;
        time_t event_tte;
+       struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
        struct tm event_tms;
        struct tm event_tme;
        struct tm today_tm;
        icalproperty *p;
        icalproperty *e;
        struct icaltimetype t;
+       struct disp_cal *Cal;
        int month, day, year;
        int all_day_event = 0;
        char *timeformat;
@@ -378,7 +382,8 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
        year = today_tm.tm_year + 1900;
 
        for (i=0; i<(WC->num_cal); ++i) {
-               p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
+               Cal = &WCC->disp_cal[i];
+               p = icalcomponent_get_first_property(Cal->cal,
                                                ICAL_DTSTART_PROPERTY);
                if (p != NULL) {
                        t = icalproperty_get_dtstart(p);
@@ -418,16 +423,17 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
                                        hours=(int)(difftime / 60);
                                        minutes=difftime % 60;
                                        wprintf("<tr><td bgcolor='%s'>%i:%2i</td><td bgcolor='%s'>"
-                                                       "<font size=-1>"
-                                                       "<a href=\"display_edit_event?msgnum=%ld&calview=calbrief&year=%s&month=%s&day=%s\">",
-                                                       daycolor,
-                                                       hours, minutes,
-                                                       daycolor,
-                                                       WC->disp_cal[i].cal_msgnum,
-                                                       bstr("year"),
-                                                       bstr("month"),
-                                                       bstr("day")
-                                                       );
+                                               "<font size=-1>"
+                                               "<a class=\"event%s\" href=\"display_edit_event?msgnum=%ld&calview=calbrief&year=%s&month=%s&day=%s\">",
+                                               daycolor,
+                                               hours, minutes,
+                                               (Cal->unread)?"_unread":"_read",                                                
+                                               daycolor,
+                                               WC->disp_cal[i].cal_msgnum,
+                                               bstr("year"),
+                                               bstr("month"),
+                                               bstr("day")
+                                               );
 
                                        escputs((char *)
                                                        icalproperty_get_comment(p));
@@ -880,14 +886,16 @@ void calendar_day_view_display_events(time_t thetime,
 
                        if (all_day_event && notime_events)
                        {
-                              wprintf("<li class=\"event\"> "
+                              wprintf("<li class=\"event_framed%s\"> "
                                 "<a href=\"display_edit_event?"
                                 "msgnum=%ld&calview=day&year=%d&month=%d&day=%d\" "
                                 " class=\"event_title\" "
                                 " btt_tooltext=\"",
+                                     (Cal->unread)?"_unread":"_read",
                                         Cal->cal_msgnum, year, month, day);
-                                wprintf("<i>%s</i><br />", _("All day event"));
-                                wprintf("<i>%s</i> ",    _("Summary:"));
+                                wprintf("<i>%s</i><br />",      _("All day event"));
+                               wprintf("<i>%s: %s</i><br />",  _("From"), Cal->from);
+                                wprintf("<i>%s</i> ",           _("Summary:"));
                                 escputs((char *) icalproperty_get_comment(p));
                                 wprintf("<br />");
                                q = icalcomponent_get_first_property(Cal->cal,ICAL_LOCATION_PROPERTY);
@@ -916,14 +924,16 @@ void calendar_day_view_display_events(time_t thetime,
                        }
                        else if (ongoing_event && notime_events) 
                        {
-                               wprintf("<li class=\"event\"> "
+                               wprintf("<li class=\"event_framed%s\"> "
                                "<a href=\"display_edit_event?"
                                "msgnum=%ld&calview=day&year=%d&month=%d&day=%d\" "
                                " class=\"event_title\" " 
                                 "btt_tooltext=\"",
+                                       (Cal->unread)?"_unread":"_read",
                                Cal->cal_msgnum, year, month, day);
-                                wprintf("<i>%s</i><br />", _("Ongoing event"));
-                                wprintf("<i>%s</i> ",    _("Summary:"));
+                                wprintf("<i>%s</i><br />",     _("Ongoing event"));
+                               wprintf("<i>%s: %s</i><br />", _("From"), Cal->from);
+                                wprintf("<i>%s</i> ",          _("Summary:"));
                                 escputs((char *) icalproperty_get_comment(p));
                                 wprintf("<br />");
                                 q = icalcomponent_get_first_property(Cal->cal,ICAL_LOCATION_PROPERTY);
@@ -989,10 +999,11 @@ void calendar_day_view_display_events(time_t thetime,
                                        /* should never get here */
                                }
 
-                               wprintf("<dd  class=\"event\" "
+                               wprintf("<dd  class=\"event_framed%s\" "
                                        "style=\"position: absolute; "
                                        "top:%dpx; left:%dpx; "
                                        "height:%dpx; \" >",
+                                       (Cal->unread)?"_unread":"_read",
                                        top, (gap * 40), (bottom-top)
                                        );
                                wprintf("<a href=\"display_edit_event?"
@@ -1000,7 +1011,8 @@ void calendar_day_view_display_events(time_t thetime,
                                        "class=\"event_title\" "
                                                "btt_tooltext=\"",
                                        Cal->cal_msgnum, year, month, day, t.hour);
-                                wprintf("<i>%s</i> ",    _("Summary:"));
+                               wprintf("<i>%s: %s</i><br />", _("From"), Cal->from);
+                                wprintf("<i>%s</i> ",          _("Summary:"));
                                 escputs((char *) icalproperty_get_comment(p));
                                 wprintf("<br />");
                                 q = icalcomponent_get_first_property(Cal->cal,ICAL_LOCATION_PROPERTY);
index a67e44445b659db03841afa2991c4fabd26ec839..000e070f758ea661ae47143d5068973f3ce366cb 100644 (file)
@@ -17,7 +17,7 @@
  * \param supplied_vevent the event to edit
  * \param msgnum reference on the citserver
  */
-void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) {
+void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from, int unread) {
        icalcomponent *vevent;
        icalproperty *p;
        icalvalue *v;
@@ -55,8 +55,8 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
                        display_edit_individual_event(
                                icalcomponent_get_first_component(
-                                       vevent, ICAL_VEVENT_COMPONENT
-                               ), msgnum
+                                       vevent, ICAL_VEVENT_COMPONENT), 
+                               msgnum, from, unread
                        );
                        return;
                }
@@ -428,7 +428,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
  * \param supplied_vevent the event to save
  * \param msgnum the index on the citserver
  */
-void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
+void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from, int unread) {
        char buf[SIZ];
        icalproperty *prop;
        icalcomponent *vevent, *encaps;
@@ -457,8 +457,8 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
                        save_individual_event(
                                icalcomponent_get_first_component(
-                                       vevent, ICAL_VEVENT_COMPONENT
-                               ), msgnum
+                                       vevent, ICAL_VEVENT_COMPONENT), 
+                               msgnum, from, unread
                        );
                        return;
                }
@@ -721,7 +721,7 @@ STARTOVER:  for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                        check_attendee_availability(encaps);
 
                        /** This displays the form again, with our annotations */
-                       display_edit_individual_event(encaps, msgnum);
+                       display_edit_individual_event(encaps, msgnum, from, unread);
 
                        icalcomponent_free(encaps);
                }
index 8ecc80eae35de1179c707ec9dfd05fd49f445eb1..76dd1ab0f4ddf6b1b0b9c3a2894555fd995226a0 100644 (file)
@@ -2346,7 +2346,7 @@ void readloop(char *oper)
         * new messages.
         */
        strcpy(old_msgs, "");
-       if (is_summary) {
+       if ((is_summary) || (WCC->wc_default_view == VIEW_CALENDAR)){
                serv_puts("GTSN");
                serv_getln(buf, sizeof buf);
                if (buf[0] == '2') {
@@ -2358,7 +2358,7 @@ void readloop(char *oper)
 
        if (WCC->wc_default_view == VIEW_CALENDAR) {            /**< calendar */
                is_calendar = 1;
-               strcpy(cmd, "MSGS ALL");
+               strcpy(cmd, "MSGS ALL|||1");
                maxmsgs = 32767;
        }
        if (WCC->wc_default_view == VIEW_TASKS) {               /**< tasks */
@@ -2395,7 +2395,7 @@ void readloop(char *oper)
                goto DONE;
        }
 
-       if (is_summary) {
+       if ((is_summary) || (WCC->wc_default_view == VIEW_CALENDAR)){
                for (a = 0; a < nummsgs; ++a) {
                        /** Are you a new message, or an old message? */
                        if (is_summary) {
@@ -2638,13 +2638,13 @@ void readloop(char *oper)
                                addrbook[num_ab-1].ab_msgnum = WCC->msgarr[a];
                        }
                        else if (is_calendar) {
-                               display_calendar(WCC->msgarr[a]);
+                               display_calendar(WCC->msgarr[a], WCC->summ[a].is_new);
                        }
                        else if (is_tasks) {
-                               display_task(WCC->msgarr[a]);
+                               display_task(WCC->msgarr[a], WCC->summ[a].is_new);
                        }
                        else if (is_notes) {
-                               display_note(WCC->msgarr[a]);
+                               display_note(WCC->msgarr[a], WCC->summ[a].is_new);
                        }
                        else {
                                if (displayed_msgs == NULL) {
index 0d790ec7a86f89bcc3c1cf79de2dd6b7effdce54..3896d11cfe21588ca2e3d2bb8110dd36966412dd 100644 (file)
@@ -14,7 +14,7 @@
  * \brief display sticky notes
  * \param msgnum the citadel mesage number
  */
-void display_note(long msgnum)
+void display_note(long msgnum, int unread)
 {
        char buf[SIZ];
        char notetext[SIZ];
index 9f498030779dc5f8357d582f3d0c7d0eb6f4b8cb..dc68ca10e35b58e3319b3efb20487b724d2164c9 100644 (file)
@@ -1230,7 +1230,7 @@ td.events_of_the_day {
        vertical-align: top;
 }
 
-.event {
+.event_framed_unread {
        filter:alpha(opacity=50);   /* Internet Explorer 6     */
        -moz-opacity:0.5;           /* Mozilla 1.6 and prec.   */
        opacity: 0.5;               /* CSS3 draft and Mozilla  */
@@ -1241,7 +1241,45 @@ td.events_of_the_day {
        padding: 0 4px 0 4px; 
 }
 
-li.event span, a.event_title {
+li.event_framed_unread span, a.event_title {
+       filter:alpha(opacity=100); 
+       -moz-opacity:1.0;         
+       opacity: 1.0;
+        font-size: 11px;     
+}
+
+.event_framed_read {
+       filter:alpha(opacity=50);   /* Internet Explorer 6     */
+       -moz-opacity:0.5;           /* Mozilla 1.6 and prec.   */
+       opacity: 0.5;               /* CSS3 draft and Mozilla  */
+       -moz-border-radius: 8px;    /* CSS3 draft and Mozilla  */
+       border: solid 1px red;
+       background-color: yellow;
+       z-index: 10;
+       padding: 0 4px 0 4px; 
+}
+
+li.event_framed_read span, a.event_title {
+       filter:alpha(opacity=100); 
+       -moz-opacity:1.0;         
+       opacity: 1.0;
+        font-size: 11px;     
+}
+
+.event_read {
+}
+
+li.event_read span, a.event_read_title {
+       filter:alpha(opacity=100); 
+       -moz-opacity:1.0;         
+       opacity: 1.0;
+        font-size: 11px;     
+}
+
+.event_unread {
+}
+
+li.event_unread span, a.event_read_title {
        filter:alpha(opacity=100); 
        -moz-opacity:1.0;         
        opacity: 1.0;
index e78399eabc0692e697a25b9cfabe6ea5aeea1245..06487fb9f94716bb44534da086f4070793ac6c38 100644 (file)
@@ -140,7 +140,7 @@ void tasks_section(void) {
        }
        else {
                for (i=0; i<num_msgs; ++i) {
-                       display_task(WC->msgarr[i]);
+                       display_task(WC->msgarr[i], 0);
                }
        }
 
@@ -179,7 +179,7 @@ void calendar_section(void) {
        }
        else {
                for (i=0; i<num_msgs; ++i) {
-                       display_calendar(WC->msgarr[i]);
+                       display_calendar(WC->msgarr[i], 0);
                }
                calendar_summary_view();
        }
index cad424573548bac308cb55b5a4322cd8b94f8341..ab0f7669635642f2a8d82e00ecf42c7ee0927e42 100644 (file)
@@ -390,6 +390,8 @@ struct wcsession {
        struct disp_cal {                                       
                icalcomponent *cal;             /**< cal items for display */
                long cal_msgnum;                /**< cal msgids for display */
+               char *from;                     /**< owner of this component */
+               int unread;                     /**< already seen by the user? */
        } *disp_cal;                                            
        int num_cal;                            /**< number of calendar items for display */
 #endif                                                                                 
@@ -650,9 +652,9 @@ void summary(void);
 void summary_inner_div(void);
 ssize_t write(int fd, const void *buf, size_t count);
 void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum);
-void display_calendar(long msgnum);
-void display_task(long msgnum);
-void display_note(long msgnum);
+void display_calendar(long msgnum, int unread);
+void display_task(long msgnum, int unread);
+void display_note(long msgnum, int unread);
 void updatenote(void);
 void do_calendar_view(void);
 void do_tasks_view(void);
@@ -690,6 +692,7 @@ void burn_folder_cache(time_t age);
 void list_all_rooms_by_floor(char *viewpref);
 void display_room_directory(void);
 void display_picture(void);
+void display_pictureview(void);
 void download_file(char *);
 void upload_file(void);
 
@@ -701,8 +704,8 @@ void save_event(void);
 void display_icaltimetype_as_webform(struct icaltimetype *, char *);
 void icaltime_from_webform(struct icaltimetype *result, char *prefix);
 void icaltime_from_webform_dateonly(struct icaltimetype *result, char *prefix);
-void display_edit_individual_event(icalcomponent *supplied_vtodo, long msgnum);
-void save_individual_event(icalcomponent *supplied_vtodo, long msgnum);
+void display_edit_individual_event(icalcomponent *supplied_vtodo, long msgnum, char *from, int unread);
+void save_individual_event(icalcomponent *supplied_vtodo, long msgnum, char *from, int unread);
 void respond_to_request(void);
 void handle_rsvp(void);
 void ical_dezonify(icalcomponent *cal);