Author: jkupec Date: Wed Mar 12 17:23:41 2008 New Revision: 9107 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9107&view=rev Log: - passing the detected devices in MediaException was not a good idea, too much code change would be needed, too much overhead - MediaManager::getDetectedDevices() added Modified: trunk/libzypp/zypp/MediaSetAccess.cc trunk/libzypp/zypp/media/MediaException.h trunk/libzypp/zypp/media/MediaManager.cc trunk/libzypp/zypp/media/MediaManager.h Modified: trunk/libzypp/zypp/MediaSetAccess.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/MediaSetAccess.cc?rev=9107&r1=9106&r2=9107&view=diff ============================================================================== --- trunk/libzypp/zypp/MediaSetAccess.cc (original) +++ trunk/libzypp/zypp/MediaSetAccess.cc Wed Mar 12 17:23:41 2008 @@ -142,7 +142,9 @@ reason = media::MediaChangeReport::WRONG; } - unsigned int devindex = excp.deviceCurrent(); + vector<string> devices; + unsigned int devindex; + media_mgr.getDetectedDevices(media, devices, devindex); user = report->requestMedia ( _url, @@ -150,8 +152,7 @@ string(), //! \todo label reason, excp.asUserString(), - excp.devices(), - devindex + devices, devindex ); DBG << "doesFileExist exception caught, callback answer: " << user << endl; @@ -173,8 +174,7 @@ DBG << "Eject: try to release" << endl; media_mgr.releaseAll(); // eject - media_mgr.release (media, - excp.devices().empty() ? "" : excp.devices()[devindex]); + media_mgr.release (media, devices.empty() ? "" : devices[devindex]); } else if ( user == media::MediaChangeReport::RETRY || user == media::MediaChangeReport::CHANGE_URL ) @@ -256,18 +256,25 @@ reason = media::MediaChangeReport::WRONG; } - unsigned int devindex = excp.deviceCurrent(); + unsigned int devindex = 0; + vector<string> devices; + + if (checkonly) + user = media::MediaChangeReport::ABORT; + else + { + media_mgr.getDetectedDevices(media, devices, devindex); - user = checkonly ? media::MediaChangeReport::ABORT : report->requestMedia ( _url, media_nr, string(), //! \todo label reason, excp.asUserString(), - excp.devices(), + devices, devindex ); + } DBG << "ProvideFile exception caught, callback answer: " << user << endl; @@ -288,8 +295,7 @@ DBG << "Eject: try to release" << endl; media_mgr.releaseAll(); // eject - media_mgr.release (media, - excp.devices().empty() ? "" : excp.devices()[devindex]); + media_mgr.release (media, devices.empty() ? "" : devices[devindex]); } else if ( user == media::MediaChangeReport::RETRY || user == media::MediaChangeReport::CHANGE_URL ) @@ -395,14 +401,16 @@ reason = media::MediaChangeReport::WRONG; } - unsigned int devindex = excp.deviceCurrent(); + vector<string> devices; + unsigned int devindex; + media_mgr.getDetectedDevices(_media, devices, devindex); user = report->requestMedia(_url, media_nr, string(), //! \todo label reason, excp.asUserString(), - excp.devices(), + devices, devindex); DBG << "ProvideFile exception caught, callback answer: " << user << endl; @@ -417,7 +425,7 @@ DBG << "Eject: try to release" << endl; media_mgr.releaseAll(); // eject - media_mgr.release (_media, excp.devices().empty() ? "" : excp.devices()[devindex]); + media_mgr.release(_media, devices.empty() ? "" : devices[devindex]); } else if (user == media::MediaChangeReport::RETRY || user == media::MediaChangeReport::CHANGE_URL) Modified: trunk/libzypp/zypp/media/MediaException.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaException.h?rev=9107&r1=9106&r2=9107&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaException.h (original) +++ trunk/libzypp/zypp/media/MediaException.h Wed Mar 12 17:23:41 2008 @@ -37,38 +37,17 @@ /** Ctor taking message. * Use \ref ZYPP_THROW to throw exceptions. */ - MediaException() : Exception( "Media Exception" ), _dev_current(0) + MediaException() : Exception( "Media Exception" ) {} /** Ctor taking message. * Use \ref ZYPP_THROW to throw exceptions. */ MediaException( const std::string & msg_r ) - : Exception( msg_r ), _dev_current(0) + : Exception( msg_r ) {} - /** - * 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() {}; - -// private: -// void operator = (const MediaException & ex) {} - private: - std::vectorstd::string _devices; - unsigned int _dev_current; }; class MediaMountException : public MediaException Modified: trunk/libzypp/zypp/media/MediaManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaManager.cc?rev=9107&r1=9106&r2=9107&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaManager.cc (original) +++ trunk/libzypp/zypp/media/MediaManager.cc Wed Mar 12 17:23:41 2008 @@ -982,7 +982,16 @@ return ref.handler->doesFileExist(filename); } - + + // --------------------------------------------------------------- + void + MediaManager::getDetectedDevices(MediaAccessId accessId, + std::vectorstd::string & devices, + unsigned int & index) const + { + //! \todo implementation + } + // --------------------------------------------------------------- // STATIC time_t Modified: trunk/libzypp/zypp/media/MediaManager.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/media/MediaManager.h?rev=9107&r1=9106&r2=9107&view=diff ============================================================================== --- trunk/libzypp/zypp/media/MediaManager.h (original) +++ trunk/libzypp/zypp/media/MediaManager.h Wed Mar 12 17:23:41 2008 @@ -802,6 +802,17 @@ */ bool doesFileExist(MediaAccessId accessId, const Pathname & filename ) const; + + /** + * Fill in a vector of detected 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). + */ + void + getDetectedDevices(MediaAccessId accessId, + std::vectorstd::string & devices, + unsigned int & index) const; + public: /** * Get the modification time of the /etc/mtab file. @@ -829,7 +840,7 @@ bool isUseableAttachPoint(const Pathname &path, bool mtab=true) const; - + private: friend class MediaHandler; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org