Fixed a couple of memory leaks detected by Valgrind.
[citadel.git] / webcit / roomops.c
index 47bb358cf8d04222e500f7e4aed9a58431ed0d41..8fe2b827704aecfda2c2cfc3a2f8d3cd2fe0f3da 100644 (file)
@@ -3,13 +3,14 @@
  */
 /**
  * \defgroup RoomOps Lots of different room-related operations.
+ * \ingroup CitadelCommunitacion
  */
 /*@{*/
 #include "webcit.h"
 
 char floorlist[128][SIZ]; /**< list of our floor names */
 
-char *viewdefs[7]; /**< the different kinds of available views */
+char *viewdefs[8]; /**< the different kinds of available views */
 
 /**
  * \brief initialize the viewdefs with localized strings
@@ -22,6 +23,27 @@ void initialize_viewdefs(void) {
        viewdefs[4] = _("Task List");
        viewdefs[5] = _("Notes List");
        viewdefs[6] = _("Wiki");
+       viewdefs[7] = _("Calendar List");
+}
+
+/**
+ * \brief      Determine which views are allowed as the default for creating a new room.
+ *
+ * \param      which_view      The view ID being queried.
+ */
+int is_view_allowed_as_default(int which_view)
+{
+       switch(which_view) {
+               case VIEW_BBS:          return(1);
+               case VIEW_MAILBOX:      return(1);
+               case VIEW_ADDRESSBOOK:  return(1);
+               case VIEW_CALENDAR:     return(1);
+               case VIEW_TASKS:        return(1);
+               case VIEW_NOTES:        return(1);
+               case VIEW_WIKI:         return(0);      /**< because it isn't finished yet */
+               case VIEW_CALBRIEF:     return(0);
+               default:                return(0);      /**< should never get here */
+       }
 }
 
 
@@ -48,6 +70,25 @@ void load_floorlist(void)
 }
 
 
+/**
+ * \brief      Free a session's march list
+ *
+ * \param      wcf             Pointer to session being cleared
+ */
+void free_march_list(struct wcsession *wcf)
+{
+       struct march *mptr;
+
+       while (wcf->march == NULL) {
+               mptr = wcf->march->next;
+               free(wcf->march);
+               wcf->march = mptr;
+       }
+
+}
+
+
+
 /**
  * \brief remove a room from the march list
  */
@@ -271,7 +312,7 @@ void embed_room_graphic(void) {
                        "\">"
                );
        }
-       else if (WC->wc_view == VIEW_CALENDAR) {
+       else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
                wprintf("<img height=48 width=48 src=\""
                        "static/calarea_48x.gif"
                        "\">"
@@ -317,8 +358,7 @@ void embed_view_o_matic(void) {
        wprintf(_("View as:"));
        wprintf(" "
                "<SELECT NAME=\"newview\" SIZE=\"1\" "
-               "STYLE=\"font-family: Bitstream Vera Sans,Arial,Helvetica,sans-serif;"
-               " font-size: 7pt; background: #444455; color: #ddddcc;\" "
+               "STYLE=\"font-size: 7pt; background: #444455; color: #ddddcc;\" "
                "OnChange=\"location.href=viewomatic.newview.options"
                "[selectedIndex].value\">\n");
 
@@ -330,9 +370,10 @@ void embed_view_o_matic(void) {
                 */
                if (
                        (i == WC->wc_view)
-                  ||   (i == WC->wc_default_view)
-                  ||   ( (i == 0) && (WC->wc_default_view == 1) )
-                  ||   ( (i == 1) && (WC->wc_default_view == 0) )
+                       ||      (i == WC->wc_default_view)                      /**< default */
+                       ||      ( (i == 0) && (WC->wc_default_view == 1) )      /**< mail or bulletin */
+                       ||      ( (i == 1) && (WC->wc_default_view == 0) )      /**< mail or bulletin */
+                       ||      ( (i == 7) && (WC->wc_default_view == 3) )      /**< calendar */
                ) {
 
                        wprintf("<OPTION %s VALUE=\"changeview?view=%d\">",
@@ -452,6 +493,17 @@ void embed_room_banner(char *got, int navbar_style) {
                                                "</span></a></td>\n", _("Month view")
                                        );
                                        break;
+                               case VIEW_CALBRIEF:
+                                       wprintf(
+                                               "<td>"
+                                               "<a href=\"readfwd?calview=month\">"
+                                               "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
+                                               "border=\"0\">"
+                                               "<span class=\"navbar_link\">"
+                                               "%s"
+                                               "</span></a></td>\n", _("Calendar list")
+                                       );
+                                       break;
                                case VIEW_TASKS:
                                        wprintf(
                                                "<td>"
@@ -522,6 +574,7 @@ void embed_room_banner(char *got, int navbar_style) {
                                        );
                                        break;
                                case VIEW_CALENDAR:
+                               case VIEW_CALBRIEF:
                                        wprintf(
                                                "<td><a href=\"display_enter\">"
                                                "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
@@ -708,7 +761,7 @@ char *pop_march(int desired_floor)
  */
 void gotonext(void)
 {
-       char buf[SIZ];
+       char buf[256];
        struct march *mptr, *mptr2;
        char next_room[128];
 
@@ -1934,10 +1987,12 @@ void display_entroom(void)
                "       }                                               "
                "\">\n");
        for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
-               wprintf("<OPTION %s VALUE=\"%d\">",
-                       ((i == 0) ? "SELECTED" : ""), i );
-               escputs(viewdefs[i]);
-               wprintf("</OPTION>\n");
+               if (is_view_allowed_as_default(i)) {
+                       wprintf("<OPTION %s VALUE=\"%d\">",
+                               ((i == 0) ? "SELECTED" : ""), i );
+                       escputs(viewdefs[i]);
+                       wprintf("</OPTION>\n");
+               }
        }
        wprintf("</SELECT>\n");
 
@@ -2472,6 +2527,9 @@ void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
                else if (fold[i].view == VIEW_CALENDAR) {
                        wprintf("'static/calarea_16x.gif'");
                }
+               else if (fold[i].view == VIEW_CALBRIEF) {
+                       wprintf("'static/calarea_16x.gif'");
+               }
                else if (fold[i].view == VIEW_TASKS) {
                        wprintf("'static/taskmanag_16x.gif'");
                }
@@ -2679,6 +2737,9 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
                        else if (fold[i].view == VIEW_CALENDAR) {
                                icon = "calarea_16x.gif" ;
                        }
+                       else if (fold[i].view == VIEW_CALBRIEF) {
+                               icon = "calarea_16x.gif" ;
+                       }
                        else if (fold[i].view == VIEW_TASKS) {
                                icon = "taskmanag_16x.gif" ;
                        }