Imported Upstream version 14.47.0
[platform/upstream/libzypp.git] / zypp / media / MediaAccess.h
index 713fa59..4bf4af2 100644 (file)
@@ -20,6 +20,7 @@
 #include "zypp/base/ReferenceCounted.h"
 #include "zypp/base/NonCopyable.h"
 #include "zypp/base/PtrTypes.h"
+#include "zypp/APIConfig.h"
 
 #include "zypp/Pathname.h"
 #include "zypp/PathInfo.h"
@@ -28,9 +29,6 @@
 #include "zypp/media/MediaSource.h"
 
 #include "zypp/Url.h"
-#include "zypp/base/Logger.h"
-
-#include <iostream> // endl
 
 namespace zypp {
   namespace media {
@@ -66,12 +64,17 @@ namespace zypp {
        MediaHandler * _handler;
 
        friend class MediaManager;
+       friend class MediaManager_Impl;
+
        AttachedMedia        attachedMedia() const;
 
        bool                 isSharedMedia() const;
 
-       bool                 dependsOnParent(MediaAccessId parentId) const;
+       void                 resetParentId();
+       bool                 dependsOnParent() const;
 
+       bool                 dependsOnParent(MediaAccessId parentId,
+                                            bool exactIdMatch) const;
     public:
 
        /**
@@ -103,19 +106,6 @@ namespace zypp {
        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;
@@ -155,6 +145,21 @@ namespace zypp {
         **/
        bool isAttached() const;
 
+        bool hasMoreDevices() const;
+
+        /**
+         * Fill in a vector of detected ejectable devices and the index of the
+         * currently attached device within the vector. The contents of the vector
+         * are the device names (/dev/cdrom and such).
+         *
+         * \param devices  vector to load with the device names
+         * \param index    index of the currently used device in the devices vector
+         */
+        virtual void
+        getDetectedDevices(std::vector<std::string> & devices,
+                           unsigned int & index) const;
+
+
        /**
         * Return the local directory that corresponds to medias url,
         * no matter if media isAttached or not. Files requested will
@@ -188,14 +193,14 @@ namespace zypp {
         */
         void disconnect();
 
-       /**
-        * Use concrete handler to release the media.
-        * @param eject if true, physically eject the media * (i.e. CD-ROM)
-        *
-        * \throws MediaException
-        *
-        **/
-       void release( bool eject = false );
+        /**
+         * Use concrete handler to release the media.
+         * @param ejectDev Device to eject. None if empty.
+         *
+         * \throws MediaException
+         *
+         **/
+        void release( const std::string & ejectDev = "" );
 
        /**
         * Use concrete handler to provide file denoted by path below
@@ -214,7 +219,7 @@ namespace zypp {
         * \throws MediaException
         *
         **/
-       void provideFile( const Pathname & filename, bool cached = false, bool checkonly = false ) const;
+       void provideFile( const Pathname & filename, const ByteCount &expectedFileSize ) const;
 
        /**
         * Remove filename below attach point IFF handler downloads files
@@ -269,6 +274,11 @@ namespace zypp {
         **/
        void releasePath( const Pathname & pathname ) const;
 
+       /**
+        * set a deltafile to be used in the next download
+        */
+       void setDeltafile( const Pathname & filename ) const;
+
     public:
 
        /**
@@ -302,6 +312,16 @@ namespace zypp {
        void dirInfo( filesystem::DirContent & retlist,
                       const Pathname & dirname, bool dots = true ) const;
 
+        /**
+         * check if a file exists
+         *
+         * Asserted that url is a file and not a dir.
+         *
+         * \throws MediaException
+         *
+         **/
+        bool doesFileExist( const Pathname & filename ) const;
+
        /**
         * Destructor
         **/
@@ -366,7 +386,7 @@ namespace zypp {
              ZYPP_THROW(MediaBadFilenameException(_file.asString()));
            } else if ( _media ) {
              try {
-               _media->provideFile( _file );
+               _media->provideFile( _file, 0 );
                _local_file = _media->localPath( _file );
              }
              catch (const MediaException & excpt_r)
@@ -387,7 +407,6 @@ namespace zypp {
              catch (const MediaException &excpt_r)
              {
                ZYPP_CAUGHT(excpt_r);
-               INT << "Exception raised while releasing file" << std::endl;
              }
               catch(...) {} // No exception from dtor!
            }