/*****************************************************************************/ /* mainmenu.c The soyMAIL main menu is the panel present across the top of most pages, providing the folder selection [folder][Open], [New 999], [Search], [Options], [Contacts], [Compose], [Logout], [close] and [help] buttons. This module also provides the status panel. COPYRIGHT --------- Copyright (C) 2005-2024 Mark G.Daniel This program, comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under the conditions of the GNU GENERAL PUBLIC LICENSE, version 3, or any later version. VERSION HISTORY --------------- 18-APR-2014 MGD add form field STAND_ALONE to track standlone mode 27-FEB-2010 MGD add [^] to [contacts] button 07-OCT-2006 MGD soyMAIL autogenous authentication and logout 12-JUN-2006 MGD add form field CLIENT_TIME and JavaScript clientTime() to provide local (to browser) message origination time 16-MAR-2006 MGD revised [logout] support 27-FEB-2006 MGD [close] now has a JavaScript confirm for compose page 25-FEB-2006 MGD [logout] now has associated JavaScript confirm explaining the logout basics and allowing an opportunity to cancel bugfix; MainMenuRequest() FOLDER_LIST_CHANGE detect 't' 14-FEB-2006 MGD main menu [compose] button now has an associated [^] popup main menu [close] button for child windows 01-FEB-2005 MGD initial */ /*****************************************************************************/ #ifdef SOYMAIL_VMS_V7 #undef _VMS_V6_SOURCE #define _VMS_V6_SOURCE #undef __VMS_VER #define __VMS_VER 70000000 #undef __CRTL_VER #define __CRTL_VER 70000000 #endif #pragma nomember_alignment /* standard C header files */ #include #include #include #include #include /* VMS related header files */ #include #include #include #include /* application header file */ #include "soymail.h" #include "callmail.h" #include "cereal.h" #include "cgilib.h" #include "config.h" #include "login.h" #include "mainmenu.h" #include "newmail.h" #include "other.h" #include "message.h" #define FI_LI __FILE__, __LINE__ /* global storage */ /* external storage */ extern BOOL Debug, WatchEnabled; extern int VmsVersion; extern char *CgiEnvironmentPtr; extern char DocType[], SoftwareCopy[], SoftwareEnv[], SoftwareVn[]; extern CONFIG_DATA SoyMailConfig; extern USER_OPTIONS UserOptions; extern VMS_MAIL_USER VmsMailUser; /* ad hoc prototypes */ int lib$day_of_week(__unknown_params); int sys$fao(__unknown_params); /****************************************************************************/ /* Parse the buttons from the main menu. */ BOOL MainMenuRequest (REQUEST_DATA *rdptr) { /* must be static because it's pointed to for possible use later */ static char bbuf [64]; char *cptr, *sptr, *zptr; USER_OPTIONS *uoptr; REQUEST_DATA *sdptr; /*********/ /* begin */ /*********/ if (WatchEnabled) WatchThis ("MainMenuRequest()"); /* a bit of sanity checking */ if (!rdptr->PrivateAccess) ErrorExit (SS$_BUGCHECK, FI_LI); uoptr = &rdptr->UserOptions; sdptr = (REQUEST_DATA*)rdptr->StateDataPtr; CGIVARNULL (cptr, "FORM_FOLDER_LIST_CHANGE"); if (cptr && *cptr == 't') { /* folder selection (change) will propagate a search, [open] doesn't */ MessageFolderPage (rdptr); return (TRUE); } CGIVARNULL (cptr, "FORM_NEWMAIL_REFRESH"); if (cptr && *cptr == 'N') { NewMailMessage (rdptr); return (TRUE); } CGIVARNULL (cptr, "FORM_MAIN_BTN_CONTACTS_POPUP"); if (cptr) { ContactsPageRequest (rdptr); return (TRUE); } CGIVARNULL (cptr, "FORM_MAIN_BTN_COMPOSE_POPUP"); if (cptr) { ComposePageRequest (rdptr); return (TRUE); } CGIVARNULL (cptr, "FORM_MAIN_BTN"); if (!cptr) return (FALSE); rdptr->SearchData.InProgress = FALSE; /* we insert new message count into "new" button! */ for (sptr = cptr; *sptr && !isdigit(*sptr); sptr++); if (*sptr) { cptr = sptr; while (*cptr && isdigit(*cptr)) cptr++; while (*cptr && isspace(*cptr)) cptr++; zptr = (sptr = bbuf) + sizeof(bbuf)-1; while (*cptr && sptr < zptr) *sptr++ = *cptr++; if (sptr >= zptr) ErrorExit (SS$_BUGCHECK, FI_LI); sptr--; while (sptr > bbuf && isdigit(*sptr)) sptr--; *++sptr = '\0'; cptr = bbuf; } if (LangSame ("open", cptr)) { MessageFolderPage (rdptr); return (TRUE); } if (LangSame ("new", cptr)) { NewMailMessage (rdptr); return (TRUE); } /* searching can be disabled */ if (LangSame ("search", cptr) || LangSame ("search_new", cptr)) return (SearchPageRequest (rdptr)); if (LangSame ("options", cptr)) { OptionsPageRequest (rdptr); return (TRUE); } if (LangSame ("contacts", cptr)) { ContactsPageRequest (rdptr); return (TRUE); } if (LangSame ("compose", cptr)) { ComposePageRequest (rdptr); return (TRUE); } if (LangSame ("logout", cptr)) { if (SoyMailConfig.LogoutDisabled) { StatusMessage (FI_LI, 1, LangFor("logout_disabled")); return (FALSE); } if (SoyMailConfig.LoginSecret) { /* using soyMAIL's autogenous authentication, force re-login */ LoginPage (rdptr, "", NULL, 0); RequestAccessLog (NULL, "logout"); } else { strcat (rdptr->FormAction, SOY_LOGOUT_SENTINAL); CgiLibResponseRedirect (rdptr->FormAction); } return (TRUE); } if (LangSame ("help", cptr)) { HelpPageRequest (rdptr); return (TRUE); } return (FALSE); } /*****************************************************************************/ /* */ void MainMenuPageBegin ( REQUEST_DATA *rdptr, int ThisPageIdent ) { static char OperaChild0 [] = "\n", OperaChild1 [] = "\n"; int NewMessages, SoyMailHistory; char *cptr, *OperaChildPtr, *UserNamePtr; USER_OPTIONS *uoptr; REQUEST_DATA *sdptr; VMS_MAIL_MSG *vmptr; VMS_MAIL_USER *muptr; /*********/ /* begin */ /*********/ if (WatchEnabled) WatchThis ("MainMenuPageBegin()"); sdptr = (REQUEST_DATA*)rdptr->StateDataPtr; uoptr = &rdptr->UserOptions; muptr = &VmsMailUser; vmptr = &muptr->VmsMailMsg; if (!rdptr->ThisPageIdent) rdptr->ThisPageIdent = ThisPageIdent; if (rdptr->CharSetPtr) cptr = rdptr->CharSetPtr; else if (uoptr->ComposeCharSets[0]) cptr = uoptr->ComposeCharSets; else cptr = "utf-8"; if (strsame (cptr, "ascii", -1) || strsame (cptr, "us-ascii", -1)) cptr = "utf-8"; CgiLibResponseSetCharset (cptr); CgiLibResponseHeader (200, "text/html", "%s", rdptr->LoginSetCookiePtr); fprintf (stdout, "%s\n\ \n\ \n\ %s\ \n\ \n\ \n\ \n", DocType, CgiLibXUACompatible(NULL), SoftwareEnv, CgiEnvironmentPtr, SoftwareCopy, LangFor("lang_name"), LangFor("lang_author")); /* used to support some of the enhanced functionality */ SoyMailJavaScriptStuff (rdptr); /* returns a pointer to the '' requirement */ cptr = NewMailRefreshXMLHttpRequest (rdptr); SoyMailStyleStuff (rdptr, uoptr->Theme); fprintf (stdout, "%s\n\ \n\n", SoyMailPageTitle(rdptr)); if (ThisPageIdent == PAGE_HELP) fputs ("\n", stdout); else if (ThisPageIdent == PAGE_OPTIONS) fputs ("\n", stdout); else { fprintf (stdout, "' requirement */ if (cptr) fputs (cptr, stdout); if (rdptr->NewMailPlay) { fputs ("playYouGotMail();", stdout); rdptr->NewMailPlay = FALSE; } if (ThisPageIdent == PAGE_COMPOSE) { fputs ("contactListResize();", stdout); if (rdptr->ComposeData.EditorType == COMPOSE_EDITOR_HTML) fputs ("htmlEditorLoad();", stdout); } if (rdptr->FieldFocusPtr) fputs (rdptr->FieldFocusPtr, stdout); fputs ("\"", stdout); fprintf (stdout, " onunload=\"clearWorking();\" \ onfocus=\"refreshSoyMailForm();\" \ onblur=\"refreshSoyMailForm();\""); fprintf (stdout, ">\n"); } /* keeps track of previous soyMAIL usage history for (re-)login purposes */ CGIVAR (cptr, "FORM_SOYMAIL_HISTORY"); SoyMailHistory = atoi(cptr) + 1; OperaChildPtr = ""; if (rdptr->UserAgent == SOY_USER_AGENT_OPERA) { OperaChildPtr = OperaChild0; if (!strcmp (rdptr->CgiRequestMethodPtr, "POST")) { CGIVARNULL (cptr, "FORM_OPERA_CHILD"); if (!cptr || *cptr == '0') OperaChildPtr = OperaChild1; } } if (rdptr->CharSetPtr) cptr = rdptr->CharSetPtr; else if (uoptr->ComposeCharSets[0]) cptr = uoptr->ComposeCharSets; else cptr = "utf-8"; if (strsame (cptr, "ascii", -1) || strsame (cptr, "us-ascii", -1)) cptr = "utf-8"; fprintf (stdout, "
\n\ \n\ \n\ \n\ %s\ \n\ \n\ \n
\n\n", rdptr->FormAction, cptr, SoyMailHistory, OperaChildPtr); } /*****************************************************************************/ /* */ void MainMenuPageEnd (REQUEST_DATA *rdptr) { /*********/ /* begin */ /*********/ if (WatchEnabled) WatchThis ("MainMenuPageEnd()"); fprintf (stdout, "
\n\n"); RequestPrivateStateSave (rdptr); fputs ("
\n\n", stdout); StatTimer (TRUE); fputs ("\n\n", stdout); } /*****************************************************************************/ /* */ void MainMenuPlainPageBegin (REQUEST_DATA *rdptr) { char *cptr, *UserNamePtr; USER_OPTIONS *uoptr; VMS_MAIL_MSG *vmptr; VMS_MAIL_USER *muptr; /*********/ /* begin */ /*********/ if (WatchEnabled) WatchThis ("MainMenuPlainPageBegin()"); uoptr = &rdptr->UserOptions; muptr = &VmsMailUser; vmptr = &muptr->VmsMailMsg; if (rdptr->CharSetPtr) cptr = rdptr->CharSetPtr; else if (uoptr->ComposeCharSets[0]) cptr = uoptr->ComposeCharSets; else cptr = "utf-8"; if (strsame (cptr, "ascii", -1) || strsame (cptr, "us-ascii", -1)) cptr = "utf-8"; CgiLibResponseSetCharset (cptr); CgiLibResponseHeader (200, "text/html", "%s", rdptr->LoginSetCookiePtr); fprintf (stdout, "%s\n\ \n\ \n\ %s\ \n\ \n\ \n\ \n\ \ \n\ \ %s\n\ \n\n\ \n\ \n\ \n\ \n\
\n\n", DocType, CgiLibXUACompatible(NULL), SoftwareEnv, CgiEnvironmentPtr, SoftwareCopy, LangFor("lang_name"), LangFor("lang_author"), uoptr->FontFamily, uoptr->FontSize, SoyMailPageTitle(rdptr)); } /*****************************************************************************/ /* */ void MainMenuPlainPageEnd (REQUEST_DATA *rdptr) { /*********/ /* begin */ /*********/ if (WatchEnabled) WatchThis ("MainMenuPlainPageEnd()"); fprintf (stdout, "
\n\n\ \n\ \n"); } /*****************************************************************************/ /* Display the top-level main menu. */ void MainMenuBar (REQUEST_DATA *rdptr) { /*********/ /* begin */ /*********/ if (WatchEnabled) WatchThis ("MainMenuBar()"); MainMenuBarBegin (rdptr); if (rdptr->PrevPageIdent == PAGE_HELP) FolderOpenHelp (rdptr); else { fprintf (stdout, "\n\n"); FolderListInit (rdptr); FolderOpenSelect (rdptr); fprintf (stdout, "\n"); } MainMenuBarButtons (rdptr); MainMenuBarEnd (rdptr); } /*****************************************************************************/ /* */ void MainMenuBarBegin (REQUEST_DATA *rdptr) { char *cptr, *sptr; /*********/ /* begin */ /*********/ if (WatchEnabled) WatchThis ("MainMenuBarBegin()"); fprintf (stdout, "\n\ \n\ \n\
\n\ \n"); if (SoyMailConfig.PageTitle1 && SoyMailConfig.PageTitle2) { if (strchr (SoyMailConfig.PageTitle1, '<')) cptr = " style=\"padding-left:0.5em;\""; else cptr = " style=\"font-size:120%;padding-left:0.5em;\""; if (strchr (SoyMailConfig.PageTitle2, '<')) sptr = " style=\"padding-right:0.5em;\""; else sptr = " style=\"font-size:120%;padding-right:0.5em;\""; fprintf (stdout, "\ \n", cptr, SoyMailConfig.PageTitle1, sptr, SoyMailConfig.PageTitle2); } else if (SoyMailConfig.PageTitle1) { if (strchr (SoyMailConfig.PageTitle1, '<')) cptr = ""; else cptr = " style=\"font-size:120%;text-align:center;\""; fprintf (stdout, "\n", cptr, SoyMailConfig.PageTitle1); } fprintf (stdout, "\n\ \n\n"); } /*****************************************************************************/ /* */ void MainMenuBarEnd (REQUEST_DATA *rdptr) { /*********/ /* begin */ /*********/ if (WatchEnabled) WatchThis ("MainMenuBarEnd()"); fprintf (stdout, "\n\
%s%s
%s
  "); SoyMailLogo (rdptr); fprintf (stdout, "  
\n\
\n\ \n\n"); } /*****************************************************************************/ /* */ void MainMenuBarButtons (REQUEST_DATA *rdptr) { BOOL LogoutButton; char *cptr, *sptr, *LogoutConfirm; VMS_MAIL_USER *muptr; /*********/ /* begin */ /*********/ if (WatchEnabled) WatchThis ("MainMenuBarButtons()"); muptr = &VmsMailUser; fprintf (stdout, "\n\ \n\  \n\  \n\ ", rdptr->ThisPageIdent == PAGE_HELP || SoyMailConfig.SearchEnabled ? "" : " style=\"font-style:italic;\"", LangFor("search"), LangFor("options"), LangFor("contacts")); if (rdptr->ThisPageIdent != PAGE_HELP) fprintf (stdout, ""); fprintf (stdout, " \n\ ", LangFor("compose")); if (rdptr->ThisPageIdent != PAGE_HELP) fprintf (stdout, ""); fprintf (stdout, " \n"); if (rdptr->ThisPageIdent == PAGE_HELP) { fprintf (stdout, " \n", LangFor("logout")); } else { LogoutButton = FALSE; if (SoyMailConfig.LoginSecret) { /* using soyMAIL's own internal authentication */ LogoutButton = TRUE; LogoutConfirm = LANG_FOR_CONFIRM("login_confirm_logout"); } else if (CgiLibEnvironmentIsOsu()) { /* OSU does not appear to provide AUTH_TYPE */ LogoutButton = TRUE; LogoutConfirm = LANG_FOR_CONFIRM("logout_confirm"); } else { /* if it's BASIC or DIGEST authentication */ CGIVARNULL (cptr, "AUTH_TYPE"); if (!cptr) cptr = ""; if (strsame(cptr,"basic",-1) || strsame(cptr,"digest",-1)) { LogoutButton = TRUE; LogoutConfirm = LANG_FOR_CONFIRM("logout_confirm"); } } if (LogoutButton) { if (SoyMailConfig.LogoutDisabled) fprintf (stdout, " \n", LangFor("logout")); else fprintf (stdout, " \n", LangFor("logout"), LogoutConfirm); } } fprintf (stdout, "", LangFor("close"), rdptr->ThisPageIdent == PAGE_COMPOSE && !rdptr->ComposeData.AlreadySent ? "false" : "true"); fprintf (stdout, " \n\ \n\ \n\ \n", LangFor("help")); } /*****************************************************************************/