From: Jan Kupec Date: Thu, 26 Jul 2007 10:14:04 +0000 (+0000) Subject: - fixed non-interactive mode for media change request (#294685) X-Git-Tag: BASE-SuSE-Linux-10_3-Branch~259 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=451f1476b9a8ffc27266f60fe791acb4a60a3fa1;p=platform%2Fupstream%2Fzypper.git - fixed non-interactive mode for media change request (#294685) --- diff --git a/src/zypper-media-callbacks.h b/src/zypper-media-callbacks.h index 536f516..be7670f 100644 --- a/src/zypper-media-callbacks.h +++ b/src/zypper-media-callbacks.h @@ -23,6 +23,7 @@ #include #include +#include "zypper-callbacks.h" #include "AliveCursor.h" using zypp::media::MediaChangeReport; @@ -40,8 +41,11 @@ namespace ZmartRecipients MediaChangeReport::Error error, const std::string & description ) { - cout << "Please insert media [" << description << "] # " << mediumNr << ". Retry [y/n]: " << endl; - if (readBoolAnswer()) + // TranslatorExplanation don't translate letters 'y' and 'n' for now + std::string request = boost::str(boost::format( + _("Please insert media [%s] # %d and type 'y' to continue or 'n' to cancel the operation.")) + % description % mediumNr); + if (read_bool_answer(request, false)) return MediaChangeReport::RETRY; else return MediaChangeReport::ABORT; diff --git a/src/zypper-misc.cc b/src/zypper-misc.cc index f565c28..593b973 100644 --- a/src/zypper-misc.cc +++ b/src/zypper-misc.cc @@ -25,30 +25,6 @@ extern ZYpp::Ptr God; extern RuntimeData gData; extern Settings gSettings; -// return the default value on input failure -// TODO make this locale dependent? -bool read_bool_with_default (bool defval) { - istream & stm = cin; - - string c = ""; - while (stm.good () && c != "y" && c != "Y" && c != "N" && c != "n") - c = zypp::str::getline (stm, zypp::str::TRIM); - - if (c == "y" || c == "Y") - return true; - else if (c == "n" || c == "N") - return false; - else - return defval; -} - -// Read an answer (ynYN) -// Defaults to 'false' -bool readBoolAnswer() -{ - return read_bool_with_default (false); -} - void cond_init_target () { static bool done = false; diff --git a/src/zypper-misc.h b/src/zypper-misc.h index ba04ee0..eb9358d 100644 --- a/src/zypper-misc.h +++ b/src/zypper-misc.h @@ -16,8 +16,6 @@ #include "zypp/PoolItem.h" #include "zypper-tabulator.h" -bool readBoolAnswer(); - /** * Initialize rpm database on target, if not already initialized. */