| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/source/SourceMediaAccess.cc
- *
-*/
+
#include <iostream>
#include <fstream>
#include "zypp/base/LogTools.h"
#include "zypp/ZYppCallbacks.h"
-#include "zypp/source/SourceMediaAccess.h"
-//#include "zypp/source/SourceMediaAccessReportReceivers.h"
+#include "zypp/MediaSetAccess.h"
+//#include "zypp/source/MediaSetAccessReportReceivers.h"
using std::endl;
namespace zypp
{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
-namespace source
-{ /////////////////////////////////////////////////////////////////
-
- SourceMediaAccess::SourceMediaAccess( const Url &url, const Pathname &path )
+ MediaSetAccess::MediaSetAccess( const Url &url, const Pathname &path )
: _url(url),
_path(path)
{
- std::vector<media::MediaVerifierRef> single_media;
- single_media[0] = media::MediaVerifierRef(new media::NoVerifier());
- _verifiers = single_media;
+ MIL << "initializing.." << std::endl;
+ //std::vector<media::MediaVerifierRef> single_media;
+ //single_media[0] = media::MediaVerifierRef(new media::NoVerifier());
+ //_verifiers = single_media;
}
- SourceMediaAccess::~SourceMediaAccess()
+ MediaSetAccess::~MediaSetAccess()
{
}
- void SourceMediaAccess::setVerifiers( const std::vector<media::MediaVerifierRef> &verifiers )
+ void MediaSetAccess::setVerifiers( const std::vector<media::MediaVerifierRef> &verifiers )
{
_verifiers = verifiers;
}
- const Pathname SourceMediaAccess::provideFile(const Pathname & file, const unsigned media_nr )
+// callback::SendReport<source::DownloadFileReport> report;
+// DownloadProgressFileReceiver download_report( report );
+// SourceFactory source_factory;
+// Url file_url( url().asString() + file_r.asString() );
+// report->start( source_factory.createFrom(this), file_url );
+// callback::TempConnect<media::DownloadProgressReport> tmp_download( download_report );
+// Pathname file = provideJustFile( file_r, media_nr, cached, checkonly );
+// report->finish( file_url, source::DownloadFileReport::NO_ERROR, "" );
+// return file;
+
+ const Pathname MediaSetAccess::provideFile(const Pathname & file, const unsigned media_nr )
+ {
+ return provideFileInternal( file, media_nr, false, false);
+ }
+
+ const Pathname MediaSetAccess::tryToProvideFile(const Pathname & file, const unsigned media_nr )
+ {
+ return provideFileInternal( file, media_nr, false, false);
+ }
+
+ const Pathname MediaSetAccess::provideFileInternal(const Pathname & file, const unsigned media_nr, bool cached, bool checkonly )
{
callback::SendReport<media::MediaChangeReport> report;
media::MediaManager media_mgr;
- bool checkonly = false;
// get the mediaId, but don't try to attach it here
media::MediaAccessId media = getMediaAccessId( media_nr);
else if ( user == media::MediaChangeReport::IGNORE )
{
DBG << "Skipping" << endl;
- ZYPP_THROW ( SkipRequestedException("User-requested skipping of a file") );
+ ZYPP_THROW ( source::SkipRequestedException("User-requested skipping of a file") );
}
else if ( user == media::MediaChangeReport::EJECT )
{
return media_mgr.localPath( media, file );
}
- media::MediaAccessId SourceMediaAccess::getMediaAccessId (media::MediaNr medianr)
+ media::MediaAccessId MediaSetAccess::getMediaAccessId (media::MediaNr medianr)
{
media::MediaManager media_mgr;
return id;
}
- Url SourceMediaAccess::rewriteUrl (const Url & url_r, const media::MediaNr medianr)
+ Url MediaSetAccess::rewriteUrl (const Url & url_r, const media::MediaNr medianr)
{
std::string scheme = url_r.getScheme();
if (scheme == "cd" || scheme == "dvd")
return url_r;
}
- std::ostream & SourceMediaAccess::dumpOn( std::ostream & str ) const
+ std::ostream & MediaSetAccess::dumpOn( std::ostream & str ) const
{
return str;
}
-// media::MediaVerifierRef SourceMediaAccess::verifier(unsigned media_nr)
+// media::MediaVerifierRef MediaSetAccess::verifier(unsigned media_nr)
// { return media::MediaVerifierRef(new media::NoVerifier()); }
- SourceMediaVerifier::SourceMediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr)
+ MediaVerifier::MediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr)
: _media_vendor(vendor_r)
, _media_id(id_r)
, _media_nr(media_nr)
{}
- bool SourceMediaVerifier::isDesiredMedia(const media::MediaAccessRef &ref)
+ bool MediaVerifier::isDesiredMedia(const media::MediaAccessRef &ref)
{
if (_media_vendor.empty() || _media_id.empty())
return true;
/////////////////////////////////////////////////////////////////
} // namespace source
///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
| |
\---------------------------------------------------------------------*/
-#ifndef ZYPP_SourceMediaAccess_H
-#define ZYPP_SourceMediaAccess_H
+#ifndef ZYPP_MediaSetAccess_H
+#define ZYPP_MediaSetAccess_H
#include <iosfwd>
#include <string>
#include "zypp/base/PtrTypes.h"
#include "zypp/media/MediaManager.h"
#include "zypp/Pathname.h"
+#include "zypp/CheckSum.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace source
- { /////////////////////////////////////////////////////////////////
- DEFINE_PTR_TYPE(SourceMediaAccess);
+ DEFINE_PTR_TYPE(MediaSetAccess);
- class SourceMediaVerifier : public zypp::media::MediaVerifierBase
+ class MediaVerifier : public zypp::media::MediaVerifierBase
{
public:
/** ctor */
- SourceMediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr = 1);
+ MediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr = 1);
/**
* Check if the specified attached media contains
* the desired media number (e.g. SLES10 CD1).
media::MediaNr _media_nr;
};
+ class OnMediaLocation
+ {
+ public:
+ OnMediaLocation()
+ {};
+ private:
+
+ };
+
+ typedef boost::function<bool ( const Pathname &file )> FileChecker;
+
+ class NullFileChecker
+ {
+ public:
+ bool operator()( const Pathname &file )
+ { return true; }
+ };
+
+ class ChecksumFileChecker
+ {
+ public:
+ ChecksumFileChecker( const CheckSum &checksum )
+ {}
+ bool operator()( const Pathname &file)
+ { return true; }
+ };
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : SourceCache
//
- class SourceMediaAccess : public base::ReferenceCounted, private base::NonCopyable
+ class MediaSetAccess : public base::ReferenceCounted, private base::NonCopyable
{
- friend std::ostream & operator<<( std::ostream & str, const SourceMediaAccess & obj );
+ friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
public:
/**
* creates a callback enabled media access for \param url and \param path.
* with only media no verified
*/
- SourceMediaAccess( const Url &url, const Pathname &path );
- ~SourceMediaAccess();
+ MediaSetAccess( const Url &url, const Pathname &path );
+ ~MediaSetAccess();
/**
* the media change callbacks depend on the verifiers given for each media.
*/
void setVerifiers( const std::vector<media::MediaVerifierRef> &verifiers );
const Pathname provideFile(const Pathname & file, const unsigned media_nr = 1 );
-
+ const Pathname tryToProvideFile(const Pathname & file, const unsigned media_nr = 1 );
protected:
+ const Pathname provideFileInternal(const Pathname & file, const unsigned media_nr, bool checkonly, bool cached);
Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
media::MediaAccessId getMediaAccessId (media::MediaNr medianr);
virtual std::ostream & dumpOn( std::ostream & str ) const;
};
///////////////////////////////////////////////////////////////////
- /** \relates SourceMediaAccess Stream output */
- inline std::ostream & operator<<( std::ostream & str, const SourceMediaAccess & obj )
+ /** \relates MediaSetAccess Stream output */
+ inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
{ return obj.dumpOn( str ); }
- /////////////////////////////////////////////////////////////////
- } // namespace source
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_SourceMediaAccess_H
+#endif // ZYPP_SOURCE_MediaSetAccess_H