Imported Upstream version 14.48.2
[platform/upstream/libzypp.git] / devel / devel.dmacvicar / testbed.cc
index 5e128c5..f0ebf04 100644 (file)
@@ -1,61 +1,81 @@
+#include <sys/time.h>
+
 #include <iostream>
 #include <fstream>
-#include <sstream>
-#include <streambuf>
-
-#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
-#include "boost/filesystem/fstream.hpp"    // ditto
-
-#include <boost/iostreams/device/file_descriptor.hpp>
 
 #include <zypp/base/Logger.h>
-#include <zypp/Locale.h>
 #include <zypp/ZYpp.h>
 #include <zypp/ZYppFactory.h>
-#include <zypp/TranslatedText.h>
-///////////////////////////////////////////////////////////////////
 
-#include <zypp/base/Logger.h>
+#include "zypp/Product.h"
+#include "zypp/Package.h"
+#include "zypp/Fetcher.h"
+#include "zypp/TmpPath.h"
+#include "zypp/ProgressData.h"
 
+#include "zypp/sat/Pool.h"
 
-#include <map>
-#include <set>
+#include "zypp/ZYppCallbacks.h"
 
-#include "zypp/CapFactory.h"
-#include "zypp/KeyRing.h"
-#include "zypp/PublicKey.h"
+using namespace std;
+using namespace zypp;
+using namespace zypp::repo;
+using zypp::media::MediaChangeReport;
 
-#include "zypp/ZYppFactory.h"
 
-#include "zypp/MediaSetAccess.h"
-#include "zypp2/source/yum/YUMSourceCacher.h"
+bool result_cb( const ResObject::Ptr &r )
+{
+  cout << r << endl;
+}
 
-using namespace zypp::detail;
+struct MediaChangeReportReceiver : public zypp::callback::ReceiveReport<MediaChangeReport>
+  {
+    virtual MediaChangeReport::Action
+    requestMedia(zypp::Url & url,
+                 unsigned                         mediumNr,
+                 const std::string &              label,
+                 MediaChangeReport::Error         error,
+                 const std::string &              description,
+                 const std::vector<std::string> & devices,
+                 unsigned int &                   index)
+    {
+      cout << std::endl;
+      MIL << "media problem, url: " << url.asString() << std::endl;
+      return MediaChangeReport::IGNORE;
+    }
+  };
 
-using namespace std;
-using namespace zypp;
-using namespace zypp::source;
-//using namespace DbXml;
 
-int main()
+int main(int argc, char **argv)
 {
-  //MediaSetAccess ma( Url("cd:///"), Pathname("/"));
-  //MIL << "done 1" << std::endl;
-  //ChecksumFileChecker checker(CheckSum("sha1", "fa0abb22f703a3a41f7a39f0844b24daf572fd4c"));
-  //Pathname local = ma.provideFile("content", 1, checker);
-  //MIL << local << std::endl;
-  try
-  {
-    //zypp::source::yum::YUMSourceCacher cacher(Pathname("/"));
-    //cacher.cache( Url("dir:/space/tmp/factory-yum"), Pathname("/"));
-    ZYpp::Ptr z = getZYpp();
-    z->initTarget("/", false);
+    try
+    {
+      ZYpp::Ptr z = getZYpp();
     
-  }
-  catch ( const Exception &e )
-  {
-    MIL << "Sorry, bye" << endl;
-  }
+      MediaChangeReportReceiver report;
+      report.connect();
+      
+
+      Fetcher fetcher;
+      MediaSetAccess access(Url("http://ftp.kernel.org/pub"));
+      filesystem::TmpDir tmp;
+      
+      OnMediaLocation loc;
+      loc.setLocation("/README2");
+      loc.setOptional(true);
+      
+      fetcher.enqueue(loc);
+      fetcher.start(tmp.path(), access);
+      
+    }
+    catch ( const Exception &e )
+    {
+      ZYPP_CAUGHT(e);
+      cout << e.msg() << endl;
+    }
+    
+    return 0;
 }
 
 
+