From: Marius Tomaschewski Date: Mon, 13 Mar 2006 15:53:37 +0000 (+0000) Subject: - Implemented static downloads(url) variant X-Git-Tag: BASE-SuSE-SLE-10-SP2-Branch~1570 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ba281bcf5ac3840eb0d0960903fdf134ed2132c;p=platform%2Fupstream%2Flibzypp.git - Implemented static downloads(url) variant --- diff --git a/zypp/media/MediaAccess.cc b/zypp/media/MediaAccess.cc index 1a7fc2b..61d1680 100644 --- a/zypp/media/MediaAccess.cc +++ b/zypp/media/MediaAccess.cc @@ -95,6 +95,10 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point) MIL << "Trying scheme '" << scheme << "'" << endl; + /* + ** WARNING: Don't forget to update MediaAccess::downloads(url) + ** if you are adding a new url scheme / handler! + */ if (scheme == "cd" || scheme == "dvd") _handler = new MediaCD (url,preferred_attach_point); else if (scheme == "nfs") @@ -125,6 +129,14 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point) MIL << "Opened: " << *this << endl; } +// STATIC +bool +MediaAccess::downloads(const Url &url) +{ + std::string scheme( url.getScheme()); + return (scheme == "ftp" || scheme == "http" || scheme == "https"); +} + // Type of media if open, otherwise NONE. std::string MediaAccess::protocol() const diff --git a/zypp/media/MediaAccess.h b/zypp/media/MediaAccess.h index f2103eb..c4ead43 100644 --- a/zypp/media/MediaAccess.h +++ b/zypp/media/MediaAccess.h @@ -98,10 +98,24 @@ namespace zypp { /** * Hint if files are downloaded or not. + * @return True, if the files are downloaded. */ bool downloads() const; /** + * Hint if files will be downloaded when using the + * specified media \p url. + * + * @note This hint is based on the \p url scheme + * only and does not imply, that the URL is valid. + * + * @param url The media URL to check. + * @return True, if the files are downloaded. + */ + static + bool downloads(const Url &url); + + /** * Used Protocol if media is opened, otherwise 'unknown'. **/ std::string protocol() const; diff --git a/zypp/media/MediaManager.cc b/zypp/media/MediaManager.cc index 2b46dcc..33067c8 100644 --- a/zypp/media/MediaManager.cc +++ b/zypp/media/MediaManager.cc @@ -275,6 +275,14 @@ namespace zypp } // --------------------------------------------------------------- + // STATIC + bool + MediaManager::downloads(const Url &url) + { + return MediaAccess::downloads( url); + } + + // --------------------------------------------------------------- Url MediaManager::url(MediaAccessId accessId) const { diff --git a/zypp/media/MediaManager.h b/zypp/media/MediaManager.h index e659ec8..d78afb0 100644 --- a/zypp/media/MediaManager.h +++ b/zypp/media/MediaManager.h @@ -396,14 +396,27 @@ namespace zypp protocol(MediaAccessId accessId) const; /** - * Hint if files are downloaded or not. + * Hint if files are downloaded or not. * \param accessId The media access id to query. * \return True, if provideFile downloads files. - */ - bool + */ + bool downloads(MediaAccessId accessId) const; /** + * Hint if files will be downloaded when using the + * specified media \p url. + * + * @note This hint is based on the \p url scheme + * only and does not imply, that the URL is valid. + * + * @param url The media URL to check. + * @return True, if the files are downloaded. + */ + static bool + downloads(const Url &url); + + /** * Returns the \ref MediaAccessUrl of the media access id. * * \param accessId The media access id to query.