- fixed non-interactive mode for media change request (#294685)
authorJan Kupec <jkupec@suse.cz>
Thu, 26 Jul 2007 10:14:04 +0000 (10:14 +0000)
committerJan Kupec <jkupec@suse.cz>
Thu, 26 Jul 2007 10:14:04 +0000 (10:14 +0000)
src/zypper-media-callbacks.h
src/zypper-misc.cc
src/zypper-misc.h

index 536f516..be7670f 100644 (file)
@@ -23,6 +23,7 @@
 #include <zypp/Digest.h>
 #include <zypp/Url.h>
 
+#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; 
index f565c28..593b973 100644 (file)
@@ -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;
index ba04ee0..eb9358d 100644 (file)
@@ -16,8 +16,6 @@
 #include "zypp/PoolItem.h"
 #include "zypper-tabulator.h"
 
-bool readBoolAnswer();
-
 /**
  * Initialize rpm database on target, if not already initialized. 
  */