1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
12 Author: Michael Andres <ma@suse.de>
13 Maintainer: Michael Andres <ma@suse.de>
15 Purpose: Manage vendor attributes
23 #include "zypp/base/LogTools.h"
25 #include "zypp/base/String.h"
26 #include "zypp/VendorAttr.h"
30 #undef ZYPP_BASE_LOGGER_LOGGROUP
31 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::VendorAttr"
33 ///////////////////////////////////////////////////////////////////
35 { /////////////////////////////////////////////////////////////////
37 ///////////////////////////////////////////////////////////////////
39 { /////////////////////////////////////////////////////////////////
41 typedef std::map<Vendor,bool> TrustMap;
44 typedef std::set<std::string> VendorList;
45 VendorList _trustedVendors;
47 bool trusted( const Vendor & vendor_r )
49 TrustMap::value_type val( vendor_r, false );
50 pair<TrustMap::iterator, bool> res = _trustMap.insert( val );
54 // check the new vendor in map
55 for ( VendorList::const_iterator it = _trustedVendors.begin();
56 it != _trustedVendors.end(); ++it )
58 if ( str::toLower( res.first->first.substr( 0, it->size() ) )
59 == str::toLower( *it ) )
62 res.first->second = true;
67 return res.first->second;
71 /////////////////////////////////////////////////////////////////
73 ///////////////////////////////////////////////////////////////////
75 const VendorAttr & VendorAttr::instance()
77 static VendorAttr _val;
81 VendorAttr::VendorAttr ()
90 "ati technologies inc.",
93 _trustedVendors.insert( vendors, vendors+(sizeof(vendors)/sizeof(char *)) );
94 MIL << "Trusted Vendors: " << _trustedVendors << endl;
97 bool VendorAttr::isKnown( const Vendor & vendor_r ) const
98 { return trusted( vendor_r ); }
101 bool VendorAttr::autoProtect( const Vendor & vendor_r ) const
102 { return ! trusted( vendor_r ); }
104 /////////////////////////////////////////////////////////////////
106 ///////////////////////////////////////////////////////////////////