}
+void
+MediaAccess::getDetectedDevices(std::vector<std::string> & devices,
+ unsigned int & index) const
+{
+ if (_handler)
+ {
+ _handler->getDetectedDevices(devices, index);
+ return;
+ }
+
+ if (!devices.empty())
+ devices.clear();
+ index = 0;
+}
+
+
// local directory that corresponds to medias url
// If media is not open an empty pathname.
Pathname
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,
// METHOD TYPE : MediaCD::DeviceList
//
MediaCD::DeviceList
- MediaCD::detectDevices(bool supportingDVD)
+ MediaCD::detectDevices(bool supportingDVD) const
{
using namespace zypp::target::hal;
return (unsigned) _lastdev_tried < _devices.size() - 1;
}
+ void
+ MediaCD::getDetectedDevices(std::vector<std::string> & devices,
+ unsigned int & index) const
+ {
+ index = 0;
+ if (!devices.empty())
+ devices.clear();
+
+ for (DeviceList::const_iterator it = _devices.begin();
+ it != _devices.end(); ++it)
+ devices.push_back(it->name);
+
+ if (_lastdev >= 0)
+ index = _lastdev;
+
+ // try to detect again if _devices are empty (maybe this method will be
+ // called before _devices get actually filled)
+ if (devices.empty())
+ {
+ DBG << "no device list so far, trying to detect" << endl;
+
+ DeviceList detected(
+ detectDevices(_url.getScheme() == "dvd" ? true : false));
+
+ for (DeviceList::const_iterator it = detected.begin();
+ it != detected.end(); ++it)
+ devices.push_back(it->name);
+
+ // don't know which one is in use in this case
+ index = 0;
+ }
+
+ MIL << "got " << devices.size() << " detected devices, current: "
+ << (index < devices.size() ? devices[index] : "<none>")
+ << "(" << index << ")" << endl;
+ }
+
} // namespace media
} // namespace zypp
static bool openTray( const std::string & device_r );
static bool closeTray( const std::string & device_r );
- DeviceList detectDevices(bool supportingDVD);
+ DeviceList detectDevices(bool supportingDVD) const;
protected:
virtual bool hasMoreDevices();
+ virtual void
+ getDetectedDevices(std::vector<std::string> & devices,
+ unsigned int & index) const;
+
public:
MediaCD( const Url & url_r,
return false;
}
+void MediaHandler::getDetectedDevices(std::vector<std::string> & devices,
+ unsigned int & index) const
+{
+ // clear the vector by default
+ if (!devices.empty())
+ devices.clear();
+ index = 0;
+
+ DBG << "No devices for this medium" << endl;
+}
+
+
} // namespace media
} // namespace zypp
// vim: set ts=8 sts=2 sw=2 ai noet:
* Check if the media has one more device available for attach(true).
*/
virtual bool hasMoreDevices();
+
+ /**
+ * 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;
};
///////////////////////////////////////////////////////////////////
std::vector<std::string> & devices,
unsigned int & index) const
{
- //! \todo implementation
+ MutexLock glock(g_Mutex);
+ ManagedMedia &ref( m_impl->findMM(accessId));
+ return ref.handler->getDetectedDevices(devices, index);
}
// ---------------------------------------------------------------
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
+ * 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 accessId Medium id.
+ * \param devices vector to load with the device names
+ * \param index index of the currently used device in the devices vector
*/
void
getDetectedDevices(MediaAccessId accessId,