ref: refs/heads/master
commit adc20a8d22f6beb59a63ba0063c95f9d49aecb5e
Author: Duncan Mac-Vicar P
Date: Tue Mar 3 11:34:29 2009 +0100
my testcase for testing aria reports
---
devel/devel.dmacvicar/CMakeLists.txt | 3 +
devel/devel.dmacvicar/getfile.cc | 106 ++++++++++++++++++++++++++++++++++
2 files changed, 109 insertions(+), 0 deletions(-)
diff --git a/devel/devel.dmacvicar/CMakeLists.txt b/devel/devel.dmacvicar/CMakeLists.txt
index f9efa10..88607e6 100644
--- a/devel/devel.dmacvicar/CMakeLists.txt
+++ b/devel/devel.dmacvicar/CMakeLists.txt
@@ -6,6 +6,9 @@ TARGET_LINK_LIBRARIES(rpmbuilder zypp )
ADD_EXECUTABLE(testbed testbed.cc)
TARGET_LINK_LIBRARIES(testbed zypp )
+ADD_EXECUTABLE(getfile getfile.cc)
+TARGET_LINK_LIBRARIES(getfile zypp )
+
FIND_PACKAGE(Zsync)
IF(ZSYNC_FOUND)
ADD_EXECUTABLE(zsync zsync.cc)
diff --git a/devel/devel.dmacvicar/getfile.cc b/devel/devel.dmacvicar/getfile.cc
new file mode 100644
index 0000000..0eeb37f
--- /dev/null
+++ b/devel/devel.dmacvicar/getfile.cc
@@ -0,0 +1,106 @@
+#include
+
+#include <iostream>
+#include <fstream>
+
+#include
+#include
+#include
+
+#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 "zypp/ZYppCallbacks.h"
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::repo;
+using zypp::media::MediaChangeReport;
+using zypp::media::DownloadProgressReport;
+
+
+bool result_cb( const ResObject::Ptr &r )
+{
+ cout << r << endl;
+}
+
+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::vectorstd::string & devices,
+ unsigned int & index)
+ {
+ cout << std::endl;
+ MIL << "media problem, url: " << url.asString() << std::endl;
+ return MediaChangeReport::IGNORE;
+ }
+ };
+
+struct DownloadProgressReportReceiver : public zypp::callback::ReceiveReport<DownloadProgressReport>
+{
+
+ virtual void start( const Url &/*file*/, Pathname /*localfile*/ )
+ {
+ }
+
+ virtual bool progress(int value, const Url &file,
+ double dbps_avg,
+ double dbps_current)
+ {
+ cout << file << " " << value << "% speed:" << dbps_current << " avg:" << dbps_avg << endl;
+ return true;
+ }
+
+ virtual Action problem( const Url &/*file*/
+ , Error /*error*/
+ , const std::string &/*description*/ ) { return ABORT; }
+
+ virtual void finish(
+ const Url &/*file*/
+ , Error /*error*/
+ , const std::string &/*reason*/
+ ) {}
+};
+
+int main(int argc, char **argv)
+{
+ try
+ {
+ ZYpp::Ptr z = getZYpp();
+
+ MediaChangeReportReceiver change_report;
+ DownloadProgressReportReceiver progress_report;
+ change_report.connect();
+ progress_report.connect();
+
+ MediaSetAccess access(Url("http://download.opensuse.org/update/11.1/rpm/x86_64"));
+ OnMediaLocation loc;
+ loc.setLocation("java-1_5_0-sun-1.5.0_update17-1.1.x86_64.rpm");
+ //loc.setOptional(true);
+
+ Fetcher fetcher;
+ fetcher.enqueue(loc);
+ fetcher.start("./", access);
+
+ }
+ catch ( const Exception &e )
+ {
+ ZYPP_CAUGHT(e);
+ cout << e.msg() << endl;
+ }
+
+ return 0;
+}
+
+
+
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org