- Allow to store a media label in MediaSetAccess. This label is
authorMichael Andres <ma@suse.de>
Thu, 3 Apr 2008 10:10:48 +0000 (10:10 +0000)
committerMichael Andres <ma@suse.de>
Thu, 3 Apr 2008 10:10:48 +0000 (10:10 +0000)
  passed to a media change requests to describe which CD is
  requested.

package/libzypp.changes
zypp/MediaSetAccess.cc
zypp/MediaSetAccess.h
zypp/repo/RepoProvideFile.cc

index df5d7b5..3e87d79 100644 (file)
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Thu Apr  3 11:59:13 CEST 2008 - ma@suse.de
+
+- Allow to store a media label in MediaSetAccess. This label is
+  passed to a media change requests to describe which CD is 
+  requested.  (bnc #330094)
+- revision 9347
+
+-------------------------------------------------------------------
 Wed Apr  2 13:48:52 CEST 2008 - schubi@suse.de
 
 - Moved poolItem.status().isSatisfied(),.... to poolItem.isSatisfied()
index e526b43..39a1095 100644 (file)
@@ -30,15 +30,17 @@ IMPL_PTR_TYPE(MediaSetAccess);
 
   MediaSetAccess::MediaSetAccess(const Url &url,
                                  const Pathname & prefered_attach_point)
-      : _url(url),
-        _prefAttachPoint(prefered_attach_point)
-  {
-    MIL << "initializing.." << std::endl;
-    //std::vector<media::MediaVerifierRef> single_media;
-    //single_media[0] = media::MediaVerifierRef(new media::NoVerifier());
-    //_verifiers = single_media;
-  }
+      : _url(url)
+      , _prefAttachPoint(prefered_attach_point)
+  {}
 
+  MediaSetAccess::MediaSetAccess(const std::string & label_r,
+                                 const Url &url,
+                                 const Pathname & prefered_attach_point)
+      : _url(url)
+      , _prefAttachPoint(prefered_attach_point)
+      , _label( label_r )
+  {}
 
   MediaSetAccess::~MediaSetAccess()
   {
@@ -141,7 +143,7 @@ IMPL_PTR_TYPE(MediaSetAccess);
           {
             reason = media::MediaChangeReport::WRONG;
           }
-          else if( typeid(excp) == typeid( media::MediaTimeoutException))  
+          else if( typeid(excp) == typeid( media::MediaTimeoutException))
           {
             reason = media::MediaChangeReport::IO_SOFT;
           }
@@ -156,7 +158,7 @@ IMPL_PTR_TYPE(MediaSetAccess);
           user = report->requestMedia (
               _url,
               media_nr,
-              string(), //! \todo label
+              _label,
               reason,
               excp.asUserString(),
               devices, devindex
@@ -282,7 +284,7 @@ IMPL_PTR_TYPE(MediaSetAccess);
             user = report->requestMedia (
               _url,
               media_nr,
-              string(), //! \todo label
+              _label,
               reason,
               excp.asUserString(),
               devices,
@@ -425,7 +427,7 @@ IMPL_PTR_TYPE(MediaSetAccess);
 
           user = report->requestMedia(_url,
                                       media_nr,
-                                      string(), //! \todo label
+                                      _label,
                                       reason,
                                       excp.asUserString(),
                                       devices,
index 3f1907f..89596a0 100644 (file)
@@ -42,30 +42,30 @@ namespace zypp
      * \ref MediaManager for info on different implemented media backends).
      * Currently it handles URLs containing cdN, CDN, dvdN, and DVDN strings,
      * where N is the number of particular media in the set.
-     * 
+     *
      * Examples:
      * \code
      * "iso:/?iso=/path/to/iso/images/openSUSE-10.3-Alpha2plus-DVD-x86_64-DVD1.iso"
      * "dir:/path/to/cdset/sources/openSUSE-10.3/Alpha2plus/CD1"
      * \endcode
-     * 
+     *
      * MediaSetAccess accesses files on desired media by rewriting
      * the original URL, replacing the digit (usually) 1 with requested media
      * number and uses \ref MediaManager to get the files from the new URL.
-     * 
+     *
      * Additionaly, each media number can be assined a media verifier which
      * checks if the media we are trying to access is the desired one. See
      * \ref MediaVerifierBase for more info.
-     * 
+     *
      * Code example:
      * \code
      * Url url("dir:/path/to/cdset/sources/openSUSE-10.3/Alpha2plus/CD1");
-     * 
+     *
      * MediaSetAccess access(url);
-     * 
+     *
      * access.setVerifier(1, media1VerifierRef);
      * access.setVerifier(2, media2VerifierRef);
-     * 
+     *
      * Pathname file1 = "/some/file/on/media1";
      * access.provideFile(1, file1);
      * Pathname file2 = "/some/file/on/media2";
@@ -81,11 +81,13 @@ namespace zypp
       /**
        * Creates a callback enabled media access for specified \a url.
        *
-       * \param url 
+       * \param url
        * \param prefered_attach_point Prefered attach (mount) point. Use, if
        *        you want to mount the media to a specific directory.
        */
-      MediaSetAccess(const Url &url, const Pathname & prefered_attach_point = "");
+      MediaSetAccess( const Url &url, const Pathname & prefered_attach_point = "" );
+      /** \overload Also taking a \ref label. */
+      MediaSetAccess( const std::string & label_r, const Url &url, const Pathname & prefered_attach_point = "" );
       ~MediaSetAccess();
 
       /**
@@ -94,11 +96,23 @@ namespace zypp
       void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier );
 
       /**
+       * The label identifing this media set and to be sent in a media change request.
+       */
+      const std::string & label() const
+      { return _label; }
+
+      /**
+       * Set the label identifing this media set and to be sent in a media change request.
+       */
+      void setLabel( const std::string & label_r )
+      { _label = label_r; }
+
+      /**
        * Provides a file from a media location.
-       * 
+       *
        * \param on_media_file location of the file on media
        * \return local pathname of the requested file
-       * 
+       *
        * \throws MediaException if a problem occurs,
        *        see \ref media::MediaManager::provideFile()
        */
@@ -106,19 +120,19 @@ namespace zypp
 
       /**
        * Provides \a file from media \a media_nr.
-       *  
+       *
        * \param file path to the file relative to media URL
        * \param media_nr the media number in the media set
        * \return local pathname of the requested file
-       * 
+       *
        * \throws MediaException if a problem occurs,
        *        see \ref media::MediaManager::provideFile()
        */
       Pathname provideFile(const Pathname & file, unsigned media_nr = 1 );
-      
+
       /**
        * Provides direcotry \a dir from media number \a media_nr.
-       * 
+       *
        * \param dir path to the directory relative to media URL
        * \param recursive whether to provide the whole directory subtree
        * \param media_nr the media number in the media set
@@ -126,7 +140,7 @@ namespace zypp
        *
        * \throws MediaException if a problem occurs,
        *        see \ref media::MediaManager::provideDir()
-       *        and \ref media::MediaManager::provideDirTree() 
+       *        and \ref media::MediaManager::provideDirTree()
        */
       Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1);
 
@@ -147,7 +161,7 @@ namespace zypp
 
       /**
        * Replaces media number in specified url with given \a medianr.
-       * 
+       *
        * Media number in the URL is searched for with regex
        * <tt> "^(.*(cd|dvd))([0-9]+)(\\.iso)$" </tt> for iso scheme and
        * with <tt> "^(.*(cd|dvd))([0-9]+)(/?)$" </tt> for other schemes.
@@ -178,6 +192,8 @@ namespace zypp
        */
       Pathname _prefAttachPoint;
 
+      std::string _label;
+
       typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
       typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap;
 
index 587386c..ecb3539 100644 (file)
@@ -114,8 +114,16 @@ namespace zypp
 
       void setVerifierForRepo( RepoInfo repo, shared_ptr<MediaSetAccess> media )
       {
+        // Maybe a good place to also set the MediaSetAccess label.
+        // Would be nice if this info was provided by some media
+        // description like
+        if ( media->label().empty() )
+        {
+          media->setLabel( repo.name() );
+        }
+
         // set a verifier if the repository has it
-         
+
         Pathname mediafile = repo.metadataPath() + "/media.1/media";
         if ( ! repo.metadataPath().empty() )
         {
@@ -203,11 +211,11 @@ namespace zypp
       callback::TempConnect<repo::RepoReport> temp( dumb );
 
       Url url;
-      
+
       RepoException repo_excpt(str::form(_("Can't provide file '%s' from repository '%s'"),
                                loc_r.filename().c_str(),
                                repo_r.alias().c_str() ) );
-      
+
       if ( repo_r.baseUrlsEmpty() )
       {
         repo_excpt.remember(RepoException(_("No url in repository.")));
@@ -216,9 +224,9 @@ namespace zypp
 
       Fetcher fetcher;
       fetcher.addCachePath( repo_r.packagesPath() );
-      
+
       MIL << "Added cache path " << repo_r.packagesPath() << endl;
-            
+
       for ( RepoInfo::urls_const_iterator it = repo_r.baseUrlsBegin();
             it != repo_r.baseUrlsEnd();
             /* incremented in the loop */ )
@@ -231,9 +239,9 @@ namespace zypp
               << "' from " << url << endl;
           shared_ptr<MediaSetAccess> access = _impl->mediaAccessForUrl(url);
           _impl->setVerifierForRepo(repo_r, access);
-         
+
          fetcher.enqueue( loc_r );
-         
+
          // FIXME: works for packages only
          fetcher.start( repo_r.packagesPath(), *access );
 
@@ -291,9 +299,9 @@ namespace zypp
         catch ( const Exception &e )
         {
           ZYPP_CAUGHT( e );
-          
+
           repo_excpt.remember(e);
-          
+
           WAR << "Trying next url" << endl;
           continue;
         }