- Added support for shadow.notify to indicate when the shadow file is updated

- Fixed description validation bug that allowed \n, \r and \f in a description, then rendered the pending.data file unparseable
This commit is contained in:
Paul Beckingham
2008-10-25 02:03:21 -04:00
parent 2a5736b876
commit b7e889339d
7 changed files with 38 additions and 14 deletions

View File

@@ -131,6 +131,10 @@ void Config::createDefault (const std::string& home)
fprintf (out, "#color.tag.bug=yellow\n");
fprintf (out, "#color.project.home=on_green\n");
fprintf (out, "#color.keyword.car=on_blue\n");
fprintf (out, "#shadow.file=%s/shadow.txt\n", dataDir.c_str ());
fprintf (out, "#shadow.command=list\n");
fprintf (out, "#shadow.notify=on\n");
fprintf (out, "#default.command=list\n");
fclose (out);

View File

@@ -82,7 +82,7 @@ void handleAdd (TDB& tdb, T& task, Config& conf)
// Disallow blank descriptions.
if (task.getDescription () == "")
throw std::string ("Cannot add a blank task.");
throw std::string ("Cannot add a task that is blank, or contains <CR> or <LF> characters.");
if (!tdb.addT (task))
throw std::string ("Could not create new task.");

View File

@@ -284,10 +284,21 @@ static bool validTag (const std::string& input)
////////////////////////////////////////////////////////////////////////////////
static bool validDescription (const std::string& input)
{
if (input.length () > 0)
/*
if (input.length () > 0 &&
input.find ("\r") == std::string::npos &&
input.find ("\f") == std::string::npos &&
input.find ("\n") == std::string::npos)
return true;
return false;
*/
if (input.length () == 0) return false;
if (input.find ("\r") != std::string::npos) return false;
if (input.find ("\f") != std::string::npos) return false;
if (input.find ("\n") != std::string::npos) return false;
return true;
}
////////////////////////////////////////////////////////////////////////////////

View File

@@ -679,13 +679,10 @@ void updateRecurrenceMask (
// Using gTdb and gConf, generate a report.
void onChangeCallback ()
{
std::cout << "--- callback" << std::endl;
try
{
if (gConf && gTdb)
{
std::cout << "--- valid globals" << std::endl;
// Determine if shadow file is enabled.
std::string shadowFile = expandPath (gConf->get ("shadow.file"));
if (shadowFile != "")
@@ -695,8 +692,6 @@ void onChangeCallback ()
gConf->set ("curses", "off");
gConf->set ("color", "off");
std::cout << "--- shadowFile " << shadowFile<< std::endl;
// Run report. Use shadow.command, using default.command as a fallback
// with "list" as a default.
std::string command = gConf->get ("shadow.command",
@@ -714,13 +709,15 @@ void onChangeCallback ()
else
throw std::string ("Could not write file '") + shadowFile + "'";
std::cout << "--- Complete " << std::endl;
gConf->set ("curses", oldCurses);
gConf->set ("color", oldColor);
}
else
throw std::string ("No specified shadow file '") + shadowFile + "'.";
// Optionally display a notification that the shadow file was updated.
if (gConf->get (std::string ("shadow.notify"), false))
std::cout << "[Shadow file '" << shadowFile << "' updated]" << std::endl;
}
else
throw std::string ("Internal error (TDB/Config).");