From b7e889339df85bc6078aa08a47d8307176ce6e91 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 25 Oct 2008 02:03:21 -0400 Subject: [PATCH] - 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 --- ChangeLog | 11 +++++++---- html/config.html | 6 ++++++ html/task.html | 5 ++++- src/Config.cpp | 4 ++++ src/command.cpp | 2 +- src/parse.cpp | 13 ++++++++++++- src/task.cpp | 11 ++++------- 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 92da6b0b0..0fb0f2823 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,12 +7,15 @@ represents a feature release, and the Z represents a patch. ------ current release --------------------------- -1.4.3 (10/9/2008) - + Fixed misleading task count at bottom on "info" report. +1.4.3 (10/24/2008) + + Fixed misleading task count at bottom on "info" report + Added support for a shadow file that contains a plain text task report, - with the "shadow.file" and "shadow.command" configuration variables. + with the "shadow.file" and "shadow.command" configuration variables The shadow file is automatically updated whenever the task database - changes. Useful for integrating with "Samurize". + changes. Useful for integrating with "Samurize" + + Task now displays a message whenever a shadow file is updated, if the + "shadow.notify" configuration variable is set "on" + + Bug: adding a task with a \n, \r or \f in it now fails properly ------ old releases ------------------------------ diff --git a/html/config.html b/html/config.html index 3a8be835e..eb4ba1c9b 100644 --- a/html/config.html +++ b/html/config.html @@ -322,6 +322,12 @@ ID Project Pri Description

+
shadow.notify
+
+ When this value is set to "on", task will display a message + whenever the shadow file is updated by some task command. +
+
diff --git a/html/task.html b/html/task.html index 9e5a30608..0a9ffc243 100644 --- a/html/task.html +++ b/html/task.html @@ -94,13 +94,16 @@ --> -

New in version 1.4.3 (9/18/2008)

+

New in version 1.4.3 (10/24/2008)

diff --git a/src/Config.cpp b/src/Config.cpp index 6fe00db3a..571b25c10 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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); diff --git a/src/command.cpp b/src/command.cpp index b696a8f93..5742a3797 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -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 or characters."); if (!tdb.addT (task)) throw std::string ("Could not create new task."); diff --git a/src/parse.cpp b/src/parse.cpp index c468a822c..36c4e349c 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -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; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/task.cpp b/src/task.cpp index 40a4a15a0..a0a097c59 100644 --- a/src/task.cpp +++ b/src/task.cpp @@ -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).");