IMPL_PTR_TYPE(SourceImpl);
- class DownloadProgressReceiver
+ class DownloadProgressPackageReceiver
: public callback::ReceiveReport<media::DownloadProgressReport>
{
callback::SendReport <DownloadResolvableReport> & _report;
public:
- DownloadProgressReceiver (
+ DownloadProgressPackageReceiver (
callback::SendReport <DownloadResolvableReport> & report_r,
Resolvable::constPtr resolvable_r
)
, _resolvable (resolvable_r)
{}
- virtual ~DownloadProgressReceiver () {}
+ virtual ~DownloadProgressPackageReceiver () {}
virtual void reportbegin() {}
};
+ class DownloadProgressFileReceiver
+ : public callback::ReceiveReport<media::DownloadProgressReport>
+ {
+ callback::SendReport <DownloadFileReport> & _report;
+
+ public:
+
+ DownloadProgressFileReceiver (
+ callback::SendReport <DownloadFileReport> & report_r
+ )
+ : _report (report_r)
+ {}
+
+ virtual ~DownloadProgressFileReceiver () {}
+
+ virtual void reportbegin() {}
+
+ virtual void reportend() {}
+
+ /**
+ * Inform about progress
+ * Return true on abort
+ */
+ virtual bool progress( int percent, Url url )
+ {
+ return _report->progress( percent, url );
+ }
+ };
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : SourceImpl::SourceImpl
bool digest_ok = false;
Pathname file;
callback::SendReport<source::DownloadResolvableReport> report;
- DownloadProgressReceiver download_report( report, package );
+ DownloadProgressPackageReceiver download_report( report, package );
while (retry)
{
callback::TempConnect<media::DownloadProgressReport> tmp_download( download_report );
- file = package->source().provideFile( package->location(), package->mediaId());
+ file = provideJustFile( package->location(), package->mediaId());
report->finish( package, source::DownloadResolvableReport::NO_ERROR, "" );
const unsigned media_nr,
bool cached,
bool checkonly )
+ {
+ 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 SourceImpl::provideJustFile(const Pathname & file_r,
+ const unsigned media_nr,
+ bool cached,
+ bool checkonly )
{
callback::SendReport<media::MediaChangeReport> report;
* Release all medias attached by the source
*/
void release();
+
/**
- * Get media verifier for the specified media
+ * Get media verifier for the specified medium. In the
+ * default installation, an instance of media::NoVerifier is
+ * returned. The specific implementations of the sources
+ * should overload this method to return a proper verifier.
+ *
+ * \param media_nr number of the medium
+ *
+ * \return instance of a media verifier for the given medium.
*/
virtual media::MediaVerifierRef verifier(unsigned media_nr);
Source_Ref selfSourceRef()
{ return Source_Ref( this ); }
+ /**
+ * Provide a file to local filesystem on the given path,
+ * no checking or progress information redirection.
+ * used by \ref provideFile and \ref providePackage.
+ * If \c checkonly is true, no media change callback
+ * will be invoked.
+ *
+ * \param path file with a path to be provided by the source
+ * \param media_nr number of the media to look for the path
+ * \param cached provide a cached copy of the file, if available
+ * \param checkonly just check if it is possible to provide the file
+ *
+ * \return the local path for the provided file
+ *
+ * \throws Exception
+ *
+ */
+ const Pathname provideJustFile(const Pathname & path,
+ const unsigned media_nr = 1,
+ bool cached = false,
+ bool checkonly = false);
+
+
protected:
/** All resolvables provided by this source. */
ResStore _store;