6
#include <zypp/base/Logger.h>
8
#include <zypp/ZYppFactory.h>
10
#include "zypp/Product.h"
11
#include "zypp/Package.h"
12
#include "zypp/Fetcher.h"
13
#include "zypp/TmpPath.h"
14
#include "zypp/ProgressData.h"
16
#include "zypp/sat/Pool.h"
18
#include "zypp/ZYppCallbacks.h"
22
using namespace zypp::repo;
23
using zypp::media::MediaChangeReport;
24
using zypp::media::DownloadProgressReport;
27
bool result_cb( const ResObject::Ptr &r )
32
struct MediaChangeReportReceiver : public zypp::callback::ReceiveReport<MediaChangeReport>
34
virtual MediaChangeReport::Action
35
requestMedia(zypp::Url & url,
37
const std::string & label,
38
MediaChangeReport::Error error,
39
const std::string & description,
40
const std::vector<std::string> & devices,
43
cout << label << " " <<description << std::endl;
44
MIL << "media problem, url: " << url.asString() << std::endl;
45
return MediaChangeReport::IGNORE;
49
struct DownloadProgressReportReceiver : public zypp::callback::ReceiveReport<DownloadProgressReport>
52
virtual void start( const Url &/*file*/, Pathname /*localfile*/ )
56
virtual bool progress(int value, const Url &file,
60
cout << file << " " << value << "% speed:" << dbps_current << " avg:" << dbps_avg << endl;
64
virtual Action problem( const Url &/*file*/
66
, const std::string &description )
68
cout << "PROBLEM: " << description << endl;
75
, const std::string &reason
78
cout << "finish:" << endl;
79
cout << reason << endl;
83
int main(int argc, char **argv)
87
ZYpp::Ptr z = getZYpp();
89
MediaChangeReportReceiver change_report;
90
DownloadProgressReportReceiver progress_report;
91
change_report.connect();
92
progress_report.connect();
94
MediaSetAccess access(Url("http://download.opensuse.org/update/11.1/rpm/x86_64"));
96
loc.setLocation("java-1_5_0-sun-1.5.0_update17-1.1.x86_64.rpm");
97
//loc.setOptional(true);
100
fetcher.enqueue(loc);
101
fetcher.start("./", access);
104
catch ( const Exception &e )
107
cout << e.msg() << endl;
108
cout << e.historyAsString();