reenable media callbacks
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 24 Jul 2007 15:34:19 +0000 (15:34 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 24 Jul 2007 15:34:19 +0000 (15:34 +0000)
src/CMakeLists.txt
src/zypper-media-callbacks.h
src/zypper-misc.cc
src/zypper-misc.h

index af77002..bd3751f 100644 (file)
@@ -3,19 +3,6 @@ ADD_DEFINITIONS (
   -DLOCALEDIR=\\\"${CMAKE_INSTALL_PREFIX}/share/locale\\\"
 )
 
-SET( zypper_SRCS
-  zypper.cc
-  zypper-command.cc
-  zypper-getopt.cc
-  zypper-sources.cc
-  zypper-misc.cc
-  zypper-utils.cc
-  zypper-search.cc
-  zypper-info.cc
-  zypper-tabulator.cc
-  zypper-callbacks.cc
-)
-
 SET (zypper_HEADERS
   zypper.h
   zypper-command.h
@@ -33,6 +20,22 @@ SET (zypper_HEADERS
   zypper-source-callbacks.h
 )
 
+SET( zypper_SRCS
+  zypper.cc
+  zypper-command.cc
+  zypper-getopt.cc
+  zypper-sources.cc
+  zypper-misc.cc
+  zypper-utils.cc
+  zypper-search.cc
+  zypper-info.cc
+  zypper-tabulator.cc
+  zypper-callbacks.cc
+  ${zypper_HEADERS}
+)
+
+
+
 ADD_EXECUTABLE( zypper ${zypper_SRCS} )
 TARGET_LINK_LIBRARIES( zypper ${ZYPP_LIBRARY} ${READLINE_LIBRARY} )
 
index 686bdf6..536f516 100644 (file)
@@ -19,6 +19,7 @@
 #include <zypp/ZYppCallbacks.h>
 #include <zypp/Pathname.h>
 #include <zypp/KeyRing.h>
+#include <zypp/Repository.h>
 #include <zypp/Digest.h>
 #include <zypp/Url.h>
 
 
 using zypp::media::MediaChangeReport;
 using zypp::media::DownloadProgressReport;
+using zypp::Repository;
 
 ///////////////////////////////////////////////////////////////////
 namespace ZmartRecipients
 {
 
   struct MediaChangeReportReceiver : public zypp::callback::ReceiveReport<MediaChangeReport>
-  {/*
-    virtual MediaChangeReport::Action requestMedia( zypp::Source_Ref source, unsigned mediumNr, MediaChangeReport::Error error, const std::string & description )
-    { 
+  {
+    virtual MediaChangeReport::Action requestMedia( Repository repo,
+                                                    unsigned mediumNr,
+                                                    MediaChangeReport::Error error,
+                                                    const std::string & description )
+    {
       cout << "Please insert media [" << description << "] # " << mediumNr << ". Retry [y/n]: " << endl;
       if (readBoolAnswer())
         return MediaChangeReport::RETRY; 
       else
         return MediaChangeReport::ABORT; 
-    
     }
-    */
   };
 
     // progress for downloading a file
@@ -87,6 +90,7 @@ class MediaCallbacks {
   public:
     MediaCallbacks()
     {
+      MIL << "Set media callbacks.." << endl;
       _mediaChangeReport.connect();
       _mediaDownloadReport.connect();
     }
index e29b05a..2a0745a 100644 (file)
@@ -25,6 +25,30 @@ 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 f8d683c..333b067 100644 (file)
@@ -16,6 +16,8 @@
 #include "zypp/PoolItem.h"
 #include "zypper-tabulator.h"
 
+bool readBoolAnswer();
+
 /**
  * Initialize rpm database on target, if not already initialized. 
  */