Author: jkupec Date: Wed Mar 12 11:27:43 2008 New Revision: 9099 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9099&view=rev Log: - enable media API to eject specific device Modified: trunk/libzypp/zypp/MediaProducts.h trunk/libzypp/zypp/MediaSetAccess.cc trunk/libzypp/zypp/ZYppCallbacks.h trunk/libzypp/zypp/media/MediaAccess.cc trunk/libzypp/zypp/media/MediaAccess.h trunk/libzypp/zypp/media/MediaCD.cc trunk/libzypp/zypp/media/MediaCD.h trunk/libzypp/zypp/media/MediaCurl.cc trunk/libzypp/zypp/media/MediaCurl.h trunk/libzypp/zypp/media/MediaDIR.cc trunk/libzypp/zypp/media/MediaDIR.h trunk/libzypp/zypp/media/MediaDISK.cc trunk/libzypp/zypp/media/MediaDISK.h trunk/libzypp/zypp/media/MediaException.h trunk/libzypp/zypp/media/MediaHandler.cc trunk/libzypp/zypp/media/MediaHandler.h trunk/libzypp/zypp/media/MediaISO.cc trunk/libzypp/zypp/media/MediaISO.h trunk/libzypp/zypp/media/MediaManager.cc trunk/libzypp/zypp/media/MediaManager.h trunk/libzypp/zypp/media/MediaNFS.cc trunk/libzypp/zypp/media/MediaNFS.h trunk/libzypp/zypp/media/MediaSMB.cc trunk/libzypp/zypp/media/MediaSMB.h Modified: trunk/libzypp/zypp/MediaProducts.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/MediaProducts.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/MediaProducts.h (original) +++ trunk/libzypp/zypp/MediaProducts.h Wed Mar 12 11:27:43 2008 @@ -102,7 +102,7 @@ ZYPP_CAUGHT(excpt); MIL << "No products description found on the Url" << std::endl; } - media_mgr.release(id); + media_mgr.release(id, ""); } /** Modified: trunk/libzypp/zypp/MediaSetAccess.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/MediaSetAccess.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/MediaSetAccess.cc (original) +++ trunk/libzypp/zypp/MediaSetAccess.cc Wed Mar 12 11:27:43 2008 @@ -142,11 +142,15 @@ reason = media::MediaChangeReport::WRONG; } + unsigned int devindex = excp.deviceCurrent(); + user = report->requestMedia ( _url, media_nr, reason, - excp.asUserString() + excp.asUserString(), + excp.devices(), + devindex ); DBG << "doesFileExist exception caught, callback answer: " << user << endl; @@ -167,7 +171,9 @@ { DBG << "Eject: try to release" << endl; media_mgr.releaseAll(); - media_mgr.release (media, true); // one more release needed for eject + // eject + media_mgr.release (media, + excp.devices().empty() ? "" : excp.devices()[devindex]); } else if ( user == media::MediaChangeReport::RETRY || user == media::MediaChangeReport::CHANGE_URL ) @@ -249,12 +255,16 @@ reason = media::MediaChangeReport::WRONG; } + unsigned int devindex = excp.deviceCurrent(); + user = checkonly ? media::MediaChangeReport::ABORT : report->requestMedia ( _url, media_nr, reason, - excp.asUserString() + excp.asUserString(), + excp.devices(), + devindex ); DBG << "ProvideFile exception caught, callback answer: " << user << endl; @@ -275,7 +285,9 @@ { DBG << "Eject: try to release" << endl; media_mgr.releaseAll(); - media_mgr.release (media, true); // one more release needed for eject + // eject + media_mgr.release (media, + excp.devices().empty() ? "" : excp.devices()[devindex]); } else if ( user == media::MediaChangeReport::RETRY || user == media::MediaChangeReport::CHANGE_URL ) @@ -380,11 +392,15 @@ { reason = media::MediaChangeReport::WRONG; } + + unsigned int devindex = excp.deviceCurrent(); user = report->requestMedia(_url, media_nr, reason, - excp.asUserString()); + excp.asUserString(), + excp.devices(), + devindex); DBG << "ProvideFile exception caught, callback answer: " << user << endl; @@ -397,7 +413,8 @@ { DBG << "Eject: try to release" << endl; media_mgr.releaseAll(); - media_mgr.release (_media, true); // one more release needed for eject + // eject + media_mgr.release (_media, excp.devices().empty() ? "" : excp.devices()[devindex]); } else if (user == media::MediaChangeReport::RETRY || user == media::MediaChangeReport::CHANGE_URL) @@ -518,7 +535,7 @@ DBG << "Releasing all media IDs held by this MediaSetAccess" << endl; media::MediaManager manager; for (MediaMap::const_iterator m = _medias.begin(); m != _medias.end(); ++m) - manager.release(m->second); + manager.release(m->second, ""); } std::ostream & MediaSetAccess::dumpOn( std::ostream & str ) const Modified: trunk/libzypp/zypp/ZYppCallbacks.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZYppCallbacks.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/ZYppCallbacks.h (original) +++ trunk/libzypp/zypp/ZYppCallbacks.h Wed Mar 12 11:27:43 2008 @@ -295,11 +295,25 @@ WRONG // wrong media, need a different one }; + /** + * + * \param url in: url for which the media is requested, + * out: url to use instead of the original one + * \param mediumNr requested medium number + * \param error type of error from \ref Error enum + * \param description + * \param devices list of the available devices (for eject) + * \param dev_current in: index of the currently used device in the \a devices list + * out: index of the devices to be ejected in the \a devices list + * \return \ref Action (ABORT by default) + */ virtual Action requestMedia( Url & /* url (I/O parameter) */ , unsigned /*mediumNr*/ , Error /*error*/ - , const std::string &/*description*/ + , const std::string & /*description*/ + , const std::vectorstd::string & /* devices */ + , unsigned int & /* dev_current (I/O param) */ ) { return ABORT; } }; Modified: trunk/libzypp/zypp/media/MediaAccess.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaAccess.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaAccess.cc (original) +++ trunk/libzypp/zypp/media/MediaAccess.cc Wed Mar 12 11:27:43 2008 @@ -270,13 +270,18 @@ void MediaAccess::release( bool eject ) { + release(""); +} + +void +MediaAccess::release( const std::string & ejectDev ) +{ if ( !_handler ) return; - _handler->release( eject ); + _handler->release( ejectDev ); } - // provide file denoted by path to attach dir // // filename is interpreted relative to the attached url @@ -415,7 +420,7 @@ media.open( u ); media.attach(); media._handler->provideFileCopy( base, to ); - media.release(); + media.release(""); } catch (const MediaException & excpt_r) { Modified: trunk/libzypp/zypp/media/MediaAccess.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaAccess.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaAccess.h (original) +++ trunk/libzypp/zypp/media/MediaAccess.h Wed Mar 12 11:27:43 2008 @@ -20,6 +20,7 @@ #include "zypp/base/ReferenceCounted.h" #include "zypp/base/NonCopyable.h" #include "zypp/base/PtrTypes.h" +#include "zypp/base/Deprecated.h" #include "zypp/Pathname.h" #include "zypp/PathInfo.h" @@ -210,7 +211,16 @@ * \throws MediaException * **/ - void release( bool eject = false ); + void release( bool eject = false ) ZYPP_DEPRECATED; + + /** + * 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 Modified: trunk/libzypp/zypp/media/MediaCD.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaCD.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaCD.cc (original) +++ trunk/libzypp/zypp/media/MediaCD.cc Wed Mar 12 11:27:43 2008 @@ -544,6 +544,10 @@ DBG << _lastdev << " " << count << endl; } + void MediaCD::releaseFrom( bool eject ) + { + releaseFrom(""); + } /////////////////////////////////////////////////////////////////// // @@ -553,7 +557,7 @@ // // DESCRIPTION : Asserted that media is attached. // - void MediaCD::releaseFrom( bool eject ) + void MediaCD::releaseFrom( const std::string & ejectDev ) { Mount mount; try @@ -565,29 +569,29 @@ catch (const Exception & excpt_r) { ZYPP_CAUGHT(excpt_r); - if (eject) + if (!ejectDev.empty()) { #if FORCE_RELEASE_FOREIGN > 0 /* 1 = automounted only, 2 = all */ forceRelaseAllMedia(false, FORCE_RELEASE_FOREIGN == 1); #endif - if(openTray( mediaSourceName())) + if(openTray( ejectDev )) return; } ZYPP_RETHROW(excpt_r); } // eject device - if (eject) + if (!ejectDev.empty()) { #if FORCE_RELEASE_FOREIGN > 0 /* 1 = automounted only, 2 = all */ forceRelaseAllMedia(false, FORCE_RELEASE_FOREIGN == 1); #endif - if( !openTray( mediaSourceName() )) + if( !openTray( ejectDev )) { #if REPORT_EJECT_ERRORS - ZYPP_THROW(MediaNotEjectedException(mediaSourceName())); + ZYPP_THROW(MediaNotEjectedException(ejectDev)); #endif } } @@ -601,7 +605,7 @@ // // Asserted that media is not attached. // - void MediaCD::forceEject() + void MediaCD::forceEject(const std::string & ejectDev) { bool ejected=false; if ( !isAttached()) { // no device mounted in this instance Modified: trunk/libzypp/zypp/media/MediaCD.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaCD.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaCD.h (original) +++ trunk/libzypp/zypp/media/MediaCD.h Wed Mar 12 11:27:43 2008 @@ -45,7 +45,9 @@ protected: virtual void attachTo (bool next = false); - virtual void releaseFrom( bool eject ); + /** \deprecated in favor of releaseFrom(string&) */ + virtual void releaseFrom( bool eject ) ZYPP_DEPRECATED; + virtual void releaseFrom( const std::string & ejectDev ); virtual void getFile( const Pathname & filename ) const; virtual void getDir( const Pathname & dirname, bool recurse_r ) const; virtual void getDirInfo( std::liststd::string & retlist, @@ -54,7 +56,7 @@ const Pathname & dirname, bool dots = true ) const; virtual bool getDoesFileExist( const Pathname & filename ) const; - virtual void forceEject(); + virtual void forceEject(const std::string & ejectDev); virtual bool isAutoMountedMedia(const AttachedMedia &media); Modified: trunk/libzypp/zypp/media/MediaCurl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaCurl.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaCurl.cc (original) +++ trunk/libzypp/zypp/media/MediaCurl.cc Wed Mar 12 11:27:43 2008 @@ -660,15 +660,21 @@ } } +// deprecated +void MediaCurl::releaseFrom( bool eject ) +{ + releaseFrom(""); +} + /////////////////////////////////////////////////////////////////// // // // METHOD NAME : MediaCurl::releaseFrom -// METHOD TYPE : PMError +// METHOD TYPE : void // // DESCRIPTION : Asserted that media is attached. // -void MediaCurl::releaseFrom( bool eject ) +void MediaCurl::releaseFrom( const std::string & ejectDev ) { disconnect(); } Modified: trunk/libzypp/zypp/media/MediaCurl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaCurl.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaCurl.h (original) +++ trunk/libzypp/zypp/media/MediaCurl.h Wed Mar 12 11:27:43 2008 @@ -32,7 +32,9 @@ protected: virtual void attachTo (bool next = false); - virtual void releaseFrom( bool eject ); + /** \deprecated in favor of releaseFrom(string&) */ + virtual void releaseFrom( bool eject ) ZYPP_DEPRECATED; + virtual void releaseFrom( const std::string & ejectDev ); virtual void getFile( const Pathname & filename ) const; virtual void getDir( const Pathname & dirname, bool recurse_r ) const; virtual void getDirInfo( std::liststd::string & retlist, Modified: trunk/libzypp/zypp/media/MediaDIR.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaDIR.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaDIR.cc (original) +++ trunk/libzypp/zypp/media/MediaDIR.cc Wed Mar 12 11:27:43 2008 @@ -113,10 +113,16 @@ // // // METHOD NAME : MediaDIR::releaseFrom - // METHOD TYPE : PMError + // METHOD TYPE : void // // DESCRIPTION : Asserted that media is attached. // + void MediaDIR::releaseFrom( const std::string & ejectDev ) + { + return; + } + + // deprecated void MediaDIR::releaseFrom( bool eject ) { return; Modified: trunk/libzypp/zypp/media/MediaDIR.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaDIR.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaDIR.h (original) +++ trunk/libzypp/zypp/media/MediaDIR.h Wed Mar 12 11:27:43 2008 @@ -30,7 +30,9 @@ protected: virtual void attachTo (bool next = false); - virtual void releaseFrom( bool eject ); + /** \deprecated in favor of releaseFrom(string&) */ + virtual void releaseFrom( bool eject ) ZYPP_DEPRECATED; + virtual void releaseFrom( const std::string & ejectDev ); virtual void getFile( const Pathname & filename ) const; virtual void getDir( const Pathname & dirname, bool recurse_r ) const; virtual void getDirInfo( std::liststd::string & retlist, Modified: trunk/libzypp/zypp/media/MediaDISK.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaDISK.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaDISK.cc (original) +++ trunk/libzypp/zypp/media/MediaDISK.cc Wed Mar 12 11:27:43 2008 @@ -383,12 +383,16 @@ // // DESCRIPTION : Asserted that media is attached. // - void MediaDISK::releaseFrom( bool eject ) + void MediaDISK::releaseFrom( const std::string & ejectDev ) { Mount mount; mount.umount(attachPoint().asString()); } + void MediaDISK::releaseFrom( bool eject ) + { + releaseFrom(""); + } /////////////////////////////////////////////////////////////////// // Modified: trunk/libzypp/zypp/media/MediaDISK.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaDISK.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaDISK.h (original) +++ trunk/libzypp/zypp/media/MediaDISK.h Wed Mar 12 11:27:43 2008 @@ -36,7 +36,9 @@ protected: virtual void attachTo (bool next = false); - virtual void releaseFrom( bool eject ); + /** \deprecated in favor of releaseFrom(string&) */ + virtual void releaseFrom( bool eject ) ZYPP_DEPRECATED; + virtual void releaseFrom( const std::string & ejectDev ); virtual void getFile( const Pathname & filename ) const; virtual void getDir( const Pathname & dirname, bool recurse_r ) const; virtual void getDirInfo( std::liststd::string & retlist, Modified: trunk/libzypp/zypp/media/MediaException.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaException.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaException.h (original) +++ trunk/libzypp/zypp/media/MediaException.h Wed Mar 12 11:27:43 2008 @@ -15,6 +15,7 @@ #include <iosfwd> #include <string> +#include <vector> #include "zypp/base/Exception.h" #include "zypp/Pathname.h" @@ -36,17 +37,39 @@ /** Ctor taking message. * Use \ref ZYPP_THROW to throw exceptions. */ - MediaException() - : Exception( "Media Exception" ) + MediaException() : Exception( "Media Exception" ), + _devices(std::vectorstd::string()), _dev_current(0) {} /** Ctor taking message. * Use \ref ZYPP_THROW to throw exceptions. */ MediaException( const std::string & msg_r ) - : Exception( msg_r ) + : Exception( msg_r ), _devices(std::vectorstd::string()), _dev_current(0) {} + + /** + * Ctor taking the message and detected device list (e.g. for ejecting). + * \param msg_r + * \param devices list of available devices as vector + * \param devCurrent index of the currently used device in the \a devices vector + */ + MediaException( const std::string & msg_r, + const std::vectorstd::string & devices, + unsigned int devCurrent) + : Exception( msg_r ), _devices(devices), _dev_current(devCurrent) + {} + + const std::vectorstd::string & devices() const { return _devices; } + unsigned int deviceCurrent() const { return _dev_current; } + /** Dtor. */ virtual ~MediaException() throw() {}; + + protected: + void operator = (const MediaException & ex) {} + private: + const std::vectorstd::string & _devices; + unsigned int _dev_current; }; class MediaMountException : public MediaException Modified: trunk/libzypp/zypp/media/MediaHandler.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaHandler.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaHandler.cc (original) +++ trunk/libzypp/zypp/media/MediaHandler.cc Wed Mar 12 11:27:43 2008 @@ -700,12 +700,13 @@ // // DESCRIPTION : // -void MediaHandler::release( bool eject ) +void MediaHandler::release( const std::string & ejectDev ) { if ( !isAttached() ) { - DBG << "Request to release media - not attached; eject " << eject << std::endl; - if ( eject ) - forceEject(); + DBG << "Request to release media - not attached; eject '" << ejectDev << "'" + << std::endl; + if ( !ejectDev.empty() ) + forceEject(ejectDev); return; } @@ -718,7 +719,7 @@ { DBG << "Releasing media " << _mediaSource->asString() << std::endl; try { - releaseFrom( eject ); // pass to concrete handler + releaseFrom( ejectDev ); // pass to concrete handler } catch(const MediaNotEjectedException &e) { @@ -734,7 +735,7 @@ _mediaSource.reset(NULL); removeAttachPoint(); } - else if( eject) { + else if( !ejectDev.empty() ) { // // Can't eject a shared media // @@ -749,7 +750,7 @@ setMediaSource(media); DBG << "Releasing media (forced) " << _mediaSource->asString() << std::endl; try { - releaseFrom( eject ); // pass to concrete handler + releaseFrom( ejectDev ); // pass to concrete handler } catch(const MediaNotEjectedException &e) { Modified: trunk/libzypp/zypp/media/MediaHandler.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaHandler.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaHandler.h (original) +++ trunk/libzypp/zypp/media/MediaHandler.h Wed Mar 12 11:27:43 2008 @@ -24,6 +24,7 @@ #include "zypp/media/MediaSource.h" #include "zypp/media/MediaException.h" +#include "zypp/base/Deprecated.h" namespace zypp { namespace media { @@ -322,6 +323,8 @@ **/ virtual void disconnectFrom() { return; } + ZYPP_DEPRECATED virtual void releaseFrom( bool eject = false ) = 0; + /** * Call concrete handler to release the media. * @@ -329,11 +332,12 @@ * instance only, physically eject the media (i.e. CD-ROM). * * Asserted that media is attached. + * \param ejectDev Device to eject. None if empty. * * \throws MediaException * **/ - virtual void releaseFrom( bool eject ) = 0; + virtual void releaseFrom( const std::string & ejectDev = "" ) = 0; /** * Call concrete handler to physically eject the media (i.e. CD-ROM) @@ -341,7 +345,7 @@ * * Asserted that media is not attached. **/ - virtual void forceEject() {} + virtual void forceEject( const std::string & device ) {} /** * Call concrete handler to provide file below attach point. @@ -553,12 +557,11 @@ /** * Use concrete handler to release the media. - * @param eject if true, physically eject the media * (i.e. CD-ROM) + * @param eject Device to physically eject. None if empty. * * \throws MediaException - * **/ - void release( bool eject = false ); + void release( const std::string & ejectDev = ""); /** * Use concrete handler to provide file denoted by path below Modified: trunk/libzypp/zypp/media/MediaISO.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaISO.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaISO.cc (original) +++ trunk/libzypp/zypp/media/MediaISO.cc Wed Mar 12 11:27:43 2008 @@ -233,7 +233,7 @@ try { mount.umount(attachPoint().asString()); - manager.release(_parentId); + manager.release(_parentId, ""); } catch (const MediaException & excpt_r) { @@ -247,7 +247,8 @@ } // --------------------------------------------------------------- - void MediaISO::releaseFrom(bool eject) + + void MediaISO::releaseFrom(const std::string & ejectDev) { Mount mount; mount.umount(attachPoint().asString()); @@ -255,13 +256,19 @@ if( _parentId) { MediaManager manager; - manager.release(_parentId); + manager.release(_parentId, ""); } // else: // the media manager has reset the _parentId // and will destroy the parent handler itself. } + // deprecated + void MediaISO::releaseFrom(bool eject) + { + releaseFrom(); + } + // --------------------------------------------------------------- void MediaISO::getFile(const Pathname &filename) const { Modified: trunk/libzypp/zypp/media/MediaISO.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaISO.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaISO.h (original) +++ trunk/libzypp/zypp/media/MediaISO.h Wed Mar 12 11:27:43 2008 @@ -42,7 +42,9 @@ protected: virtual void attachTo (bool next = false); - virtual void releaseFrom( bool eject ); + /** \deprecated in favor of releaseFrom(string&) */ + virtual void releaseFrom( bool eject ) ZYPP_DEPRECATED; + virtual void releaseFrom( const std::string & ejectDev = "" ); virtual void getFile( const Pathname & filename ) const; virtual void getDir( const Pathname & dirname, bool recurse_r ) const; virtual void getDirInfo( std::liststd::string & retlist, Modified: trunk/libzypp/zypp/media/MediaManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaManager.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaManager.cc (original) +++ trunk/libzypp/zypp/media/MediaManager.cc Wed Mar 12 11:27:43 2008 @@ -597,7 +597,7 @@ ZYPP_RETHROW(ex); if (ref.handler->isAttached()) - ref.handler->release(); + ref.handler->release(""); } MIL << "checkDesired(" << accessId << ") of first device failed," @@ -625,7 +625,7 @@ AttachedMedia media(ref.handler->attachedMedia()); DBG << "Skipping " << media.mediaSource->asString() << ": not desired media." << std::endl; - ref.handler->release(); + ref.handler->release(""); } catch (const MediaException & ex) { @@ -637,22 +637,25 @@ AttachedMedia media(ref.handler->attachedMedia()); DBG << "Skipping " << media.mediaSource->asString() << " because of exception thrown by attach(true)" << std::endl; - if (ref.handler->isAttached()) ref.handler->release(); + if (ref.handler->isAttached()) ref.handler->release(""); } } } // --------------------------------------------------------------- void - MediaManager::release(MediaAccessId accessId, bool eject) + MediaManager::release(MediaAccessId accessId, const std::string & ejectDev) { MutexLock glock(g_Mutex); ManagedMedia &ref( m_impl->findMM(accessId)); - DBG << "release(id=" << accessId - << (eject ? ", eject)" : ")") << std::endl; - if( eject) + DBG << "release(id=" << accessId; + if (!ejectDev.empty()) + DBG << ", " << ejectDev; + DBG << ")" << std::endl; + + if(!ejectDev.empty()) { // // release MediaISO handlers, that are using the one @@ -670,7 +673,7 @@ DBG << "Forcing release of handler depending on access id " << accessId << std::endl; m->second.desired = false; - m->second.handler->release(!eject); + m->second.handler->release(""); } catch(const MediaException &e) { @@ -680,7 +683,7 @@ } } ref.desired = false; - ref.handler->release(eject); + ref.handler->release(ejectDev); } // --------------------------------------------------------------- Modified: trunk/libzypp/zypp/media/MediaManager.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaManager.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaManager.h (original) +++ trunk/libzypp/zypp/media/MediaManager.h Wed Mar 12 11:27:43 2008 @@ -596,11 +596,14 @@ * that are _not_ used by another access id's. * * \param accessId A media access id. - * \param eject Whether to eject the drive. + * \param ejectDev Device to eject. None if empty. * \throws MediaNotOpenException for invalid access id. */ void - release(MediaAccessId accessId, bool eject = false); + release(MediaAccessId accessId, const std::string & ejectDev = ""); + + void + release(MediaAccessId accessId, bool eject = false) ZYPP_DEPRECATED; /** * Release all attached media. Modified: trunk/libzypp/zypp/media/MediaNFS.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaNFS.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaNFS.cc (original) +++ trunk/libzypp/zypp/media/MediaNFS.cc Wed Mar 12 11:27:43 2008 @@ -194,11 +194,23 @@ // void MediaNFS::releaseFrom( bool eject ) { + releaseFrom( "" ); + } + + /////////////////////////////////////////////////////////////////// + // + // + // METHOD NAME : MediaNFS::releaseFrom + // METHOD TYPE : void + // + // DESCRIPTION : Asserted that media is attached. + // + void MediaNFS::releaseFrom( const std::string & ejectDev ) + { Mount mount; mount.umount(attachPoint().asString()); } - /////////////////////////////////////////////////////////////////// // // METHOD NAME : MediaNFS::getFile Modified: trunk/libzypp/zypp/media/MediaNFS.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaNFS.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaNFS.h (original) +++ trunk/libzypp/zypp/media/MediaNFS.h Wed Mar 12 11:27:43 2008 @@ -38,7 +38,10 @@ protected: virtual void attachTo (bool next = false); - virtual void releaseFrom( bool eject ); + + /** \deprecated in favor of releaseFrom(string&) */ + virtual void releaseFrom( bool eject ) ZYPP_DEPRECATED; + virtual void releaseFrom( const std::string & ejectDev ); virtual void getFile( const Pathname & filename ) const; virtual void getDir( const Pathname & dirname, bool recurse_r ) const; virtual void getDirInfo( std::liststd::string & retlist, Modified: trunk/libzypp/zypp/media/MediaSMB.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaSMB.cc?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaSMB.cc (original) +++ trunk/libzypp/zypp/media/MediaSMB.cc Wed Mar 12 11:27:43 2008 @@ -279,12 +279,17 @@ // // DESCRIPTION : Asserted that media is attached. // - void MediaSMB::releaseFrom( bool eject ) + void MediaSMB::releaseFrom( const std::string & ejectDev ) { Mount mount; mount.umount(attachPoint().asString()); } + // deprecated + void MediaSMB::releaseFrom( bool eject ) + { + releaseFrom( "" ); + } /////////////////////////////////////////////////////////////////// // Modified: trunk/libzypp/zypp/media/MediaSMB.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaSMB.h?rev=9099&r1=9098&r2=9099&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaSMB.h (original) +++ trunk/libzypp/zypp/media/MediaSMB.h Wed Mar 12 11:27:43 2008 @@ -42,7 +42,9 @@ protected: virtual void attachTo (bool next = false); - virtual void releaseFrom( bool eject ); + /** \deprecated in favor of releaseFrom(string&) */ + virtual void releaseFrom( bool eject ) ZYPP_DEPRECATED; + virtual void releaseFrom( const std::string & ejectDev ); virtual void getFile( const Pathname & filename ) const; virtual void getDir( const Pathname & dirname, bool recurse_r ) const; virtual void getDirInfo( std::liststd::string & retlist, -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org