+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
#include <fstream>
#include "zypp/repo/SUSEMediaVerifier.h"
namespace repo
{
-SUSEMediaVerifier::SUSEMediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr)
+SUSEMediaVerifier::SUSEMediaVerifier(const std::string & vendor_r,
+ const std::string & id_r,
+ const media::MediaNr media_nr)
: _media_vendor(vendor_r)
, _media_id(id_r)
, _media_nr(media_nr)
{}
+SUSEMediaVerifier::SUSEMediaVerifier( const Pathname &path_r )
+{
+ std::ifstream str(path_r.asString().c_str());
+ std::string vendor;
+ std::string id;
+
+ if ( str )
+ {
+ getline(str, _media_vendor);
+ getline(str, _media_id);
+ }
+ else
+ {
+ ZYPP_THROW(Exception("Can't setup media verifier using file: '"
+ + path_r.asString() + "'"));
+ }
+}
+
bool SUSEMediaVerifier::isDesiredMedia(const media::MediaAccessRef &ref)
{
if (_media_vendor.empty() || _media_id.empty())
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
#ifndef ZYPP_SUSE_MEDIAVERIFIER_H
#define ZYPP_SUSE_MEDIAVERIFIER_H
namespace repo
{
+ /**
+ * \short Implementation of the traditional SUSE media verifier
+ */
class SUSEMediaVerifier : public zypp::media::MediaVerifierBase
{
public:
- /** ctor */
- SUSEMediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr = 1);
/**
+ * \short create a verifier from attributes
+ *
+ * Creates a verifier for the media using
+ * the attributes
+ *
+ * \param vendor_r i.e. "SUSE Linux Products GmbH"
+ * \param id_r i.e. "20070718164719"
+ * \param media_nr media number
+ */
+ SUSEMediaVerifier(const std::string & vendor_r,
+ const std::string & id_r,
+ const media::MediaNr media_nr = 1);
+
+ /**
+ * \short creates a verifier from a media file
+ */
+ SUSEMediaVerifier( const Pathname &path_r );
+
+ /**
+ * \short Check if it is the desider media
+ *
* Check if the specified attached media contains
* the desired media number (e.g. SLES10 CD1).
+ *
+ * Reimplementation of virtual function, will be
+ * called by the component verifying the media.
*/
virtual bool isDesiredMedia(const media::MediaAccessRef &ref);
+
private:
std::string _media_vendor;
std::string _media_id;