Skip to content
Snippets Groups Projects
Commit 4ad71419 authored by Eric Oulashin's avatar Eric Oulashin
Browse files

DDMsgReader: New msgSaveDir option to specify a default dir to save messages to (for the sysop)

parent 0d281709
No related branches found
No related tags found
2 merge requests!455Update branch with changes from master,!450DDMsgReader: New msgSaveDir option to specify a default dir to save messages to (for the sysop)
Pipeline #6546 passed
......@@ -96,5 +96,8 @@ indexedModeMenuSnapToNextWithNewAftarMarkAllRead=true
; the user if they want to delete a message after replying to it
promptDelPersonalEmailAfterReply=false
; The default directory on the BBS machine to save messages to (for the sysop)
msgSaveDir=
; The theme file name (for colors, strings, etc.)
themeFilename=DefaultTheme.cfg
......@@ -156,6 +156,9 @@
* 2024-08-04 Eric Oulashin Version 1.95e
* Fix: Indexed newscan mode for new users now shows the number of new messages
* in sub-boards like it's supposed to.
* 2024-08-09 Eric Oulashin Version 1.95f
* New config option: msgSaveDir, which specifies the directory on the BBS PC
* to save messages to. Can be empty, to use a full path inputted by the user.
*/
 
"use strict";
......@@ -271,8 +274,8 @@ var hexdump = load('hexdump_lib.js');
*/
 
// Reader version information
var READER_VERSION = "1.95e";
var READER_DATE = "2024-08-04";
var READER_VERSION = "1.95f";
var READER_DATE = "2024-08-09";
 
// Keyboard key codes for displaying on the screen
var UP_ARROW = ascii(24);
......@@ -1199,6 +1202,9 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
// PC. This could be a boolean (true/false) or the string "ask" to prompt every time
this.saveAllHdrsWhenSavingMsgToBBSPC = false;
 
// For the sysop, the directory on the BBS PC for where to save messages (empty by default)
this.msgSaveDir = "";
this.cfgFilename = "DDMsgReader.cfg";
// Check the command-line arguments for a custom configuration file name
// before reading the configuration file. Defaults to the current user
......@@ -9554,6 +9560,8 @@ function DigDistMsgReader_ReadConfigFile()
}
if (typeof(settingsObj["saveAllHdrsWhenSavingMsgToBBSPC"]) === "boolean")
this.saveAllHdrsWhenSavingMsgToBBSPC = settingsObj.saveAllHdrsWhenSavingMsgToBBSPC;
if (typeof(settingsObj["msgSaveDir"]) === "string" && settingsObj.msgSaveDir.length > 0 && file_isdir(settingsObj.msgSaveDir))
this.msgSaveDir = settingsObj.msgSaveDir;
// User setting defaults
if (typeof(settingsObj.reverseListOrder === "boolean"))
this.userSettings.listMessagesInReverse = settingsObj.reverseListOrder;
......@@ -14492,7 +14500,8 @@ function DigDistMsgReader_SaveMsgHexDumpToFile(pMsgHdr, pOutFilename)
var hexLines = hexdump.generate(undefined, msgText, /* ASCII: */true, /* offsets: */true);
if (Array.isArray(hexLines) && hexLines.length > 0)
{
var outFile = new File(pOutFilename);
var outFilename = genPathedFilename(this.msgSaveDir, pOutFilename);
var outFile = new File(outFilename);
if (outFile.open("w"))
{
// Write the message header lines
......@@ -16929,7 +16938,8 @@ function DigDistMsgReader_SaveMsgToFile(pMsgHdr, pFilename, pPromptPos)
var hdrLines = this.GetExtdMsgHdrInfo(msgbase, pMsgHdr.number, false, false, false, false);
msgbase.close();
 
var messageSaveFile = new File(pFilename);
var outFilename = genPathedFilename(this.msgSaveDir, pFilename);
var messageSaveFile = new File(outFilename);
if (messageSaveFile.open("w"))
{
var writeAllHeaders = false;
......@@ -24719,6 +24729,36 @@ function entryExistsInGlobalEmailFilter(pEmailAddr)
return entryExists;
}
 
// Returns whether a path string is (likely) a valid Windows path string
function testForWindowsPath(pPathStr)
{
if (typeof(pPathStr) !== "string")
return false;
// Check whether it starts with <letter>:\, <letter>:/, or "\\" (for a network path)
return /^[a-zA-Z]:\\/.test(pPathStr) || /^[a-zA-Z]:\//.test(pPathStr) || /^\\\\/.test(pPathStr);
}
// For a given filename, if it has a / or is a good-looking Windows path, then use it as the full path.
// Otherwise, if the defautl directory (pDefaultDir) is not blank and exists, then use it & append
// pFilename; otherwise, treat pFilename as fully-pathed.
//
// Parameters:
// pDefaultDir: A default directory to use to fully-path the filename
// pFilename: A filename by itself or an absolute Path
//
// Return value: The fully-pathed filename, using either the default path or fully-pathed as specified by pFilename
function genPathedFilename(pDefaultDir, pFilename)
{
var outFilename = "";
if (pFilename.indexOf("/") > -1 || (gRunningInWindows && testForWindowsPath(pFilename)))
outFilename = pFilename;
else if (pDefaultDir.length > 0 && file_isdir(pDefaultDir))
outFilename = backslash(pDefaultDir) + pFilename;
else
outFilename = pFilename;
return outFilename;
}
///////////////////////////////////////////////////////////////////////////////////
 
// For debugging: Writes some text on the screen at a given location with a given pause.
......
......@@ -5,7 +5,7 @@
// If you have DDMsgReader in a directory other than xtrn/DDMsgReader, then the changes to
// DDMsgReader.cfg will be saved in that directory (assuming you're running ddmr_cfg.js from
// that same directory).
// Currently for DDMsgReader 1.95e.
// Currently for DDMsgReader 1.95f.
//
// If you're running DDMsgReader from xtrn/DDMsgReader (the standard location) and you want
// to save the configuration file there (rather than sbbs/mods), you can use one of the
......@@ -18,7 +18,7 @@ require("sbbsdefs.js", "P_NONE");
require("uifcdefs.js", "UIFC_INMSG");
if (!uifc.init("DigDist. Message Reader 1.95e Configurator"))
if (!uifc.init("DigDist. Message Reader 1.95f Configurator"))
{
print("Failed to initialize uifc");
exit(1);
......@@ -110,6 +110,7 @@ function doMainMenu()
"enableIndexedModeMsgListCache", // Boolean
"quickUserValSetIndex", // Number (can be -1)
"saveAllHdrsWhenSavingMsgToBBSPC", // Boolean
"msgSaveDir", // String
"useIndexedModeForNewscan", // Boolean
"displayIndexedModeMenuIfNoNewMessages", // Boolean
"indexedModeMenuSnapToFirstWithNew", // Boolean
......@@ -143,6 +144,7 @@ function doMainMenu()
"Enable Indexed Mode Message List Cache",
"Quick User Val Set Index",
"Save All Headers When Saving Message To BBS PC",
"Default directory to save messages to",
"Use Indexed Mode For Newscan",
"Display Indexed menu even with no new messages",
"Index menu: Snap to sub-boards w/ new messages",
......@@ -246,6 +248,24 @@ function doMainMenu()
menuItems[optionMenuSelection] = formatCfgMenuText(itemTextMaxLen, optionStrs[optionMenuSelection], gCfgInfo.cfgOptions[optName]);
}
}
else if (optName == "msgSaveDir")
{
var userInput = uifc.input(WIN_MID, "Message save dir", gCfgInfo.cfgOptions[optName], 0, K_EDIT);
if (typeof(userInput) === "string" && userInput.length > 0)
{
if (file_isdir(userInput))
{
anyOptionChanged = (userInput != gCfgInfo.cfgOptions[optName]);
if (anyOptionChanged)
{
gCfgInfo.cfgOptions[optName] = userInput;
menuItems[optionMenuSelection] = formatCfgMenuText(itemTextMaxLen, optionStrs[optionMenuSelection], gCfgInfo.cfgOptions[optName]);
}
}
else
uifc.msg("That directory doesn't exist!");
}
}
else
{
// Multiple-choice
......@@ -359,7 +379,6 @@ function promptThemeFilename()
return chosenThemeFilename;
}
// Prompts the user to select one of multiple values for an option
//
// Parameters:
......@@ -541,6 +560,11 @@ function getOptionHelpText()
optionHelpText["saveAllHdrsWhenSavingMsgToBBSPC"] += "option specifies whether or not to save all the message headers along with the message. If disabled, ";
optionHelpText["saveAllHdrsWhenSavingMsgToBBSPC"] += "only a few relevant headers will be saved (such as From, To, Subject, and message time).";
optionHelpText["msgSaveDir"] = "Default directory to save messages to: The default directory on the BBS machine to save messages to (for the sysop). This can ";
optionHelpText["msgSaveDir"] += "be blank, in which case, you would need to enter the full path every time when saving a message. If you specify ";
optionHelpText["msgSaveDir"] += "a directory, it will save there if you only enter a filename, but you can still enter a fully-pathed ";
optionHelpText["msgSaveDir"] += "filename to save a message in a different directory.";
optionHelpText["useIndexedModeForNewscan"] = "Used Indexed Mode For Newscan: Whether or not to use indexed mode for message newscans (not for new-to-you ";
optionHelpText["useIndexedModeForNewscan"] += "scans). This is a default for a user setting. When indexed mode is enabled for newscans, the reader displays ";
optionHelpText["useIndexedModeForNewscan"] += "a menu showing each sub-board and the number of new messages and total messages in each. When disabled, ";
......@@ -752,6 +776,8 @@ function readDDMsgReaderCfgFile()
retObj.cfgOptions.quickUserValSetIndex = -1;
if (!retObj.cfgOptions.hasOwnProperty("saveAllHdrsWhenSavingMsgToBBSPC"))
retObj.cfgOptions.saveAllHdrsWhenSavingMsgToBBSPC = false;
if (!retObj.cfgOptions.hasOwnProperty("msgSaveDir"))
retObj.cfgOptions.msgSaveDir = "";
if (!retObj.cfgOptions.hasOwnProperty("useIndexedModeForNewscan"))
retObj.cfgOptions.useIndexedModeForNewscan = false;
if (!retObj.cfgOptions.hasOwnProperty("displayIndexedModeMenuIfNoNewMessages"))
......
Digital Distortion Message Reader
Version 1.95e
Release date: 2024-08-04
Version 1.95f
Release date: 2024-08-08
by
......@@ -831,6 +831,16 @@ promptDelPersonalEmailAfterReply Default for a user setting: When reading
the user if they want to delete a message
after replying to it
msgSaveDir The default directory on the BBS machine
to save messages to (for the sysop). This
can be blank, in which case, you would
need to enter the full path every time
when saving a message. If you specify a
directory, it will save there if you only
enter a filename, but you can still enter
a fully-pathed filename to save a message
in a different directory.
themeFilename The name of the configuration file to
use for colors & string settings
......
......@@ -5,6 +5,9 @@ Revision History (change log)
=============================
Version Date Description
------- ---- -----------
1.95f 2024-08-08 New config option: msgSaveDir, which specifies the
directory on the BBS PC to save messages to. Can be empty,
to use a full path inputted by the user.
1.95e 2024-08-04 Fix: Indexed newscan mode for new users now shows the
number of new messages in sub-boards like it's supposed
to.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment