- Implemented static downloads(url) variant
authorMarius Tomaschewski <mt@suse.de>
Mon, 13 Mar 2006 15:53:37 +0000 (15:53 +0000)
committerMarius Tomaschewski <mt@suse.de>
Mon, 13 Mar 2006 15:53:37 +0000 (15:53 +0000)
zypp/media/MediaAccess.cc
zypp/media/MediaAccess.h
zypp/media/MediaManager.cc
zypp/media/MediaManager.h

index 1a7fc2b..61d1680 100644 (file)
@@ -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
index f2103eb..c4ead43 100644 (file)
@@ -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;
index 2b46dcc..33067c8 100644 (file)
@@ -275,6 +275,14 @@ namespace zypp
     }
 
     // ---------------------------------------------------------------
+    // STATIC
+    bool
+    MediaManager::downloads(const Url &url)
+    {
+      return MediaAccess::downloads( url);
+    }
+
+    // ---------------------------------------------------------------
     Url
     MediaManager::url(MediaAccessId accessId) const
     {
index e659ec8..d78afb0 100644 (file)
@@ -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.