Zypp Commits
Threads by month
- ----- 2024 -----
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
February 2009
- 7 participants
- 171 discussions
![](https://seccdn.libravatar.org/avatar/93f26b0fb87f4be0df994e56a8e31107.jpg?s=120&d=mm&r=g)
[zypp-commit] <libzypp> SuSE-Code-11-Branch : Fix installation prompting for the wrong CD/DVD. (bnc #472892)
by Michael Andres 09 Feb '09
by Michael Andres 09 Feb '09
09 Feb '09
ref: refs/heads/SuSE-Code-11-Branch
commit 5f50d0f3a91b16b10fadd709eb5f9dbc95ab3ec1
Author: Michael Andres <ma(a)suse.de>
Date: Mon Feb 9 13:10:50 2009 +0100
Fix installation prompting for the wrong CD/DVD. (bnc #472892)
---
zypp/repo/RepoProvideFile.cc | 111 ++++++++++++++++++++++--------------------
1 files changed, 58 insertions(+), 53 deletions(-)
diff --git a/zypp/repo/RepoProvideFile.cc b/zypp/repo/RepoProvideFile.cc
index 810d55a..76c756e 100644
--- a/zypp/repo/RepoProvideFile.cc
+++ b/zypp/repo/RepoProvideFile.cc
@@ -77,6 +77,7 @@ namespace zypp
return access.provideFile(repo_r, loc_r, policy_r );
}
+ ///////////////////////////////////////////////////////////////////
class RepoMediaAccess::Impl
{
public:
@@ -95,7 +96,14 @@ namespace zypp
}
}
- shared_ptr<MediaSetAccess> mediaAccessForUrl( const Url &url )
+ /** Provide a MediaSetAccess for \c url with label and verifyer adjusted.
+ *
+ * As the same url (e.g. \c 'dvd:///' ) might be used for multiple repos
+ * we must always adjust the repo specific data (label,verifyer).
+ *
+ * \todo This mixture of media and repos specific data is fragile.
+ */
+ shared_ptr<MediaSetAccess> mediaAccessForUrl( const Url &url, RepoInfo repo )
{
std::map<Url, shared_ptr<MediaSetAccess> >::const_iterator it;
it = _medias.find(url);
@@ -109,79 +117,79 @@ namespace zypp
media.reset( new MediaSetAccess(url) );
_medias[url] = media;
}
+ setVerifierForRepo( repo, media );
return media;
}
- void setVerifierForRepo( RepoInfo repo, shared_ptr<MediaSetAccess> media )
- {
- // Maybe a good place to also set the MediaSetAccess label.
- // Would be nice if this info was provided by some media
- // description like
- if ( media->label().empty() )
+ private:
+ void setVerifierForRepo( RepoInfo repo, shared_ptr<MediaSetAccess> media )
{
+ // Always set the MediaSetAccess label.
media->setLabel( repo.name() );
- }
- // set a verifier if the repository has it
+ // set a verifier if the repository has it
- Pathname mediafile = repo.metadataPath() + "/media.1/media";
- if ( ! repo.metadataPath().empty() )
- {
- if ( PathInfo(mediafile).isExist() )
+ Pathname mediafile = repo.metadataPath() + "/media.1/media";
+ if ( ! repo.metadataPath().empty() )
{
- std::map<shared_ptr<MediaSetAccess>, RepoInfo>::const_iterator it;
- it = _verifier.find(media);
- if ( it != _verifier.end() )
+ if ( PathInfo(mediafile).isExist() )
{
- if ( it->second.alias() == repo.alias() )
+ std::map<shared_ptr<MediaSetAccess>, RepoInfo>::const_iterator it;
+ it = _verifier.find(media);
+ if ( it != _verifier.end() )
{
- // this media is already using this repo verifier
- return;
+ if ( it->second.alias() == repo.alias() )
+ {
+ // this media is already using this repo verifier
+ return;
+ }
}
- }
- std::ifstream str(mediafile.asString().c_str());
- std::string vendor;
- std::string mediaid;
- std::string buffer;
- if ( str )
- {
- getline(str, vendor);
- getline(str, mediaid);
- getline(str, buffer);
+ std::ifstream str(mediafile.asString().c_str());
+ std::string vendor;
+ std::string mediaid;
+ std::string buffer;
+ if ( str )
+ {
+ getline(str, vendor);
+ getline(str, mediaid);
+ getline(str, buffer);
- unsigned media_nr = str::strtonum<unsigned>(buffer);
- MIL << "Repository '" << repo.alias() << "' has " << media_nr << " medias"<< endl;
+ unsigned media_nr = str::strtonum<unsigned>(buffer);
+ MIL << "Repository '" << repo.alias() << "' has " << media_nr << " medias"<< endl;
- for ( unsigned i=1; i <= media_nr; ++i )
- {
- media::MediaVerifierRef verifier( new repo::SUSEMediaVerifier( vendor, mediaid, i ) );
+ for ( unsigned i=1; i <= media_nr; ++i )
+ {
+ media::MediaVerifierRef verifier( new repo::SUSEMediaVerifier( vendor, mediaid, i ) );
- media->setVerifier( i, verifier);
+ media->setVerifier( i, verifier);
+ }
+ _verifier[media] = repo;
+ }
+ else
+ {
+ ZYPP_THROW(RepoMetadataException(repo));
}
- _verifier[media] = repo;
}
else
{
- ZYPP_THROW(RepoMetadataException(repo));
+ WAR << "No media verifier for repo '" << repo.alias() << "' media/media.1 does not exist in '" << repo.metadataPath() << "'" << endl;
}
}
else
{
- WAR << "No media verifier for repo '" << repo.alias() << "' media/media.1 does not exist in '" << repo.metadataPath() << "'" << endl;
+ WAR << "'" << repo.alias() << "' metadata path is empty. Can't set verifier. Probably this repository does not come from RepoManager." << endl;
}
}
- else
- {
- WAR << "'" << repo.alias() << "' metadata path is empty. Can't set verifier. Probably this repository does not come from RepoManager." << endl;
- }
- }
- std::map<shared_ptr<MediaSetAccess>, RepoInfo> _verifier;
- std::map<Url, shared_ptr<MediaSetAccess> > _medias;
- ProvideFilePolicy _defaultPolicy;
- };
+ private:
+ std::map<shared_ptr<MediaSetAccess>, RepoInfo> _verifier;
+ std::map<Url, shared_ptr<MediaSetAccess> > _medias;
+ public:
+ ProvideFilePolicy _defaultPolicy;
+ };
+ ///////////////////////////////////////////////////////////////////
RepoMediaAccess::RepoMediaAccess( const ProvideFilePolicy & defaultPolicy_r )
@@ -210,9 +218,7 @@ namespace zypp
ref( policy_r ), _1 );
callback::TempConnect<repo::RepoReport> temp( dumb );
- Url url;
-
- RepoException repo_excpt(repo_r,
+ RepoException repo_excpt(repo_r,
str::form(_("Can't provide file '%s' from repository '%s'"),
loc_r.filename().c_str(),
repo_r.alias().c_str() ) );
@@ -232,14 +238,13 @@ namespace zypp
it != repo_r.baseUrlsEnd();
/* incremented in the loop */ )
{
- url = *it;
+ Url url( *it );
++it;
try
{
MIL << "Providing file of repo '" << repo_r.alias()
<< "' from " << url << endl;
- shared_ptr<MediaSetAccess> access = _impl->mediaAccessForUrl(url);
- _impl->setVerifierForRepo(repo_r, access);
+ shared_ptr<MediaSetAccess> access = _impl->mediaAccessForUrl( url, repo_r );
fetcher.enqueue( loc_r );
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
![](https://seccdn.libravatar.org/avatar/e6d0c9f42625f8f9f45b6bd11ffbb77b.jpg?s=120&d=mm&r=g)
06 Feb '09
ref: refs/heads/master
commit a069b1ef197ed70f9d62b8b37e6edf2af477b141
Author: Michael Calmer <mc(a)suse.de>
Date: Fri Feb 6 17:02:47 2009 +0100
Implement SUSE_HostedRepository
---
mof/CMakeLists.txt | 2 +
mof/SUSE_HostedRepository.mof | 33 ++++
mof/SUSE_HostedRepository.sfcb.reg | 5 +
mof/deploy.mof | 1 +
src/CMakeLists.txt | 2 +
src/SUSE_HostedRepositoryProvider.cc | 269 ++++++++++++++++++++++++++++++++++
src/SUSE_HostedRepositoryProvider.h | 58 ++++++++
7 files changed, 370 insertions(+), 0 deletions(-)
diff --git a/mof/CMakeLists.txt b/mof/CMakeLists.txt
index 4af9285..c1382ed 100644
--- a/mof/CMakeLists.txt
+++ b/mof/CMakeLists.txt
@@ -22,6 +22,8 @@ INSTALL( FILES
SUSE_HostedInstallationService.sfcb.reg
SUSE_SoftwareRepository.mof
SUSE_SoftwareRepository.sfcb.reg
+ SUSE_HostedRepository.mof
+ SUSE_HostedRepository.sfcb.reg
deploy.mof
DESTINATION ${CMPIZYPP_DATA_DIR}/
)
diff --git a/mof/SUSE_HostedRepository.mof b/mof/SUSE_HostedRepository.mof
new file mode 100644
index 0000000..50837ac
--- /dev/null
+++ b/mof/SUSE_HostedRepository.mof
@@ -0,0 +1,33 @@
+//#pragma namespace ("root/cimv2")
+
+
+// -------------------------------------------------------------------
+// *******************************************************************
+// Classes
+// *******************************************************************
+// -------------------------------------------------------------------
+
+
+
+// ===================================================================
+// SUSE_HostedRepository
+// ===================================================================
+
+[ Provider("cmpi:cmpi-zypp"),
+ Description ("Association between System and SoftwareRepository")
+]
+class SUSE_HostedRepository : CIM_HostedAccessPoint
+{
+ [Override ( "Antecedent" ),
+ Min ( 1 ),
+ Max ( 1 ),
+ Description ( "The scoping system." )]
+ CIM_ComputerSystem REF Antecedent;
+
+ [Override ( "Dependent" ),
+ Description (
+ "The repository defined in the context of a system." )]
+ SUSE_SoftwareRepository REF Dependent;
+};
+
+
diff --git a/mof/SUSE_HostedRepository.sfcb.reg b/mof/SUSE_HostedRepository.sfcb.reg
new file mode 100644
index 0000000..fa48910
--- /dev/null
+++ b/mof/SUSE_HostedRepository.sfcb.reg
@@ -0,0 +1,5 @@
+[SUSE_HostedRepository]
+ provider: SUSE_HostedRepositoryProvider
+ location: cmpi-zypp
+ type: instance association
+ namespace: root/cimv2
diff --git a/mof/deploy.mof b/mof/deploy.mof
index 216fd85..fbd1f19 100644
--- a/mof/deploy.mof
+++ b/mof/deploy.mof
@@ -10,4 +10,5 @@
#pragma include ("SUSE_ElementCapabilities.mof")
#pragma include ("SUSE_HostedInstallationService.mof")
#pragma include ("SUSE_SoftwareRepository.mof")
+#pragma include ("SUSE_HostedRepository.mof")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6956fe7..269a2c4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,6 +20,7 @@ SET( CMPIZYPP_SRCS
SUSE_ElementCapabilitiesProvider.cc
SUSE_HostedInstallationServiceProvider.cc
SUSE_SoftwareRepositoryProvider.cc
+ SUSE_HostedRepositoryProvider.cc
)
SET( CMPIZYPP_HEADERS
SUSE_Common.h
@@ -36,6 +37,7 @@ SET( CMPIZYPP_HEADERS
SUSE_ElementCapabilitiesProvider.h
SUSE_HostedInstallationServiceProvider.h
SUSE_SoftwareRepositoryProvider.h
+ SUSE_HostedRepositoryProvider.h
)
ADD_LIBRARY(cmpi-zypp SHARED ${CMPIZYPP_SRCS})
diff --git a/src/SUSE_HostedRepositoryProvider.cc b/src/SUSE_HostedRepositoryProvider.cc
new file mode 100644
index 0000000..1243d0f
--- /dev/null
+++ b/src/SUSE_HostedRepositoryProvider.cc
@@ -0,0 +1,269 @@
+
+#include <iostream>
+
+#include <cmpi/cmpimacs.h>
+#include <cmpi/cmpidt.h>
+#include <cmpi/CmpiResult.h>
+#include <cmpi/CmpiBroker.h>
+#include <cmpi/CmpiArray.h>
+#include <cmpi/CmpiBooleanData.h>
+
+#include <zypp/base/String.h>
+#include <zypp/base/LogTools.h>
+
+#include "SUSE_zypp.h"
+#include "SUSE_Common.h"
+#include "SUSE_HostedRepositoryProvider.h"
+
+using namespace zypp;
+using std::endl;
+
+namespace cmpizypp
+{
+ namespace
+ {
+ const char * _ClassName = "SUSE_HostedRepository";
+ const char * _RefLeft = "Antecedent";
+ const char * _RefRight = "Dependent";
+ const char * _RefLeftClass = "CIM_ComputerSystem";
+ const char * _RefRightClass = "SUSE_SoftwareRepository";
+
+ } // namespace
+
+ SUSE_HostedRepositoryProviderClass::SUSE_HostedRepositoryProviderClass( const CmpiBroker & mbp, const CmpiContext & ctx )
+ : CmpiBaseMI( mbp, ctx )
+ , CmpiInstanceMI( mbp, ctx )
+ , CmpiAssociationMI( mbp, ctx )
+ {
+ }
+
+ CmpiStatus SUSE_HostedRepositoryProviderClass::enumInstanceNames( const CmpiContext& ctx, CmpiResult& rslt, const CmpiObjectPath & cop )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() called",_ClassName));
+
+ CmpiObjectPath csop = get_this_computersystem(*broker, ctx, cop);
+ bool ret = assoc_create_refs_1toN( *broker, ctx, rslt, csop,
+ _ClassName,_RefLeft,_RefRight,
+ _RefLeftClass,_RefRightClass,0,0);
+ if(!ret)
+ {
+ CmpiStatus st( CMPI_RC_ERR_FAILED, "EnumInstanceNames failed." );
+ return st;
+ }
+
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+ CmpiStatus SUSE_HostedRepositoryProviderClass::enumInstances( const CmpiContext & ctx, CmpiResult & rslt, const CmpiObjectPath & cop, const char** properties )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstances() called",_ClassName));
+
+ CmpiObjectPath csop = get_this_computersystem(*broker, ctx, cop);
+ bool ret = assoc_create_refs_1toN( *broker, ctx, rslt, csop,
+ _ClassName,_RefLeft,_RefRight,
+ _RefLeftClass,_RefRightClass,1,0);
+ if(!ret)
+ {
+ CmpiStatus st( CMPI_RC_ERR_FAILED, "EnumInstances failed." );
+ return st;
+ }
+
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstances() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+
+ CmpiStatus SUSE_HostedRepositoryProviderClass::getInstance( const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &cop, const char **properties )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() called",_ClassName));
+
+ CmpiInstance ci = assoc_get_inst( *broker, ctx, cop, _ClassName, _RefLeft, _RefRight);
+
+ rslt.returnData( ci );
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+
+
+ CmpiStatus SUSE_HostedRepositoryProviderClass::associators( const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* assocClass, const char* resultClass,
+ const char* role, const char* resultRole, const char** properties )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI associators() called",_ClassName));
+
+ CmpiObjectPath op( cop.getNameSpace(), _ClassName );
+
+ if ( !assocClass || op.classPathIsA( assocClass ) )
+ {
+ if ( assoc_check_parameter_const( cop, _RefLeft, _RefRight, _RefLeftClass, _RefRightClass,
+ resultClass, role, resultRole ) )
+ {
+ SUSE_HostedRepositoryFilter filter(get_this_computersystem(*broker, ctx, cop));
+ if(! assoc_create_refs_1toN( *broker, ctx, rslt, cop, _ClassName,
+ _RefLeft, _RefRight, _RefLeftClass, _RefRightClass, 1, 1, filter ) )
+ {
+ CmpiStatus st(CMPI_RC_ERR_FAILED, "Create references failed.");
+ _CMPIZYPP_TRACE(1,("--- CMPI associators() failed."));
+ return st;
+ }
+ }
+ }
+
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI associators() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+ CmpiStatus SUSE_HostedRepositoryProviderClass::associatorNames( const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* assocClass, const char* resultClass,
+ const char* role, const char* resultRole )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI associatorNames() called",_ClassName));
+
+ CmpiObjectPath op( cop.getNameSpace(), _ClassName );
+
+ if ( !assocClass || op.classPathIsA( assocClass ) )
+ {
+ if ( assoc_check_parameter_const( cop, _RefLeft, _RefRight, _RefLeftClass, _RefRightClass,
+ resultClass, role, resultRole ) )
+ {
+ SUSE_HostedRepositoryFilter filter(get_this_computersystem(*broker, ctx, cop));
+ if(! assoc_create_refs_1toN( *broker, ctx, rslt, cop, _ClassName,
+ _RefLeft, _RefRight, _RefLeftClass, _RefRightClass, 0, 1, filter ) )
+ {
+ CmpiStatus st(CMPI_RC_ERR_FAILED, "Create references failed.");
+ _CMPIZYPP_TRACE(1,("--- CMPI associatorNames() failed."));
+ return st;
+ }
+ }
+ }
+
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI associatorNames() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+ CmpiStatus SUSE_HostedRepositoryProviderClass::references( const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* resultClass, const char* role,
+ const char** properties )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI references() called",_ClassName));
+
+ CmpiObjectPath op( cop.getNameSpace(), _ClassName );
+
+ if ( !resultClass || op.classPathIsA( resultClass ) )
+ {
+ if ( assoc_check_parameter_const( cop, _RefLeft, _RefRight, _RefLeftClass, _RefRightClass,
+ NULL/*resultClass*/, role, NULL /*resultRole*/ ) )
+ {
+ SUSE_HostedRepositoryFilter filter(get_this_computersystem(*broker, ctx, cop));
+ if(! assoc_create_refs_1toN( *broker, ctx, rslt, cop, _ClassName,
+ _RefLeft, _RefRight, _RefLeftClass, _RefRightClass, 1, 0, filter ) )
+ {
+ CmpiStatus st(CMPI_RC_ERR_FAILED, "Create references failed.");
+ _CMPIZYPP_TRACE(1,("--- CMPI references() failed."));
+ return st;
+ }
+ }
+ }
+
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI references() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+ CmpiStatus SUSE_HostedRepositoryProviderClass::referenceNames( const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* resultClass, const char* role )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI referenceNames() called",_ClassName));
+
+ CmpiObjectPath op( cop.getNameSpace(), _ClassName );
+
+ if ( !resultClass || op.classPathIsA( resultClass ) )
+ {
+ if ( assoc_check_parameter_const( cop, _RefLeft, _RefRight, _RefLeftClass, _RefRightClass,
+ NULL/*resultClass*/, role, NULL /*resultRole*/ ) )
+ {
+ SUSE_HostedRepositoryFilter filter(get_this_computersystem(*broker, ctx, cop));
+ if(! assoc_create_refs_1toN( *broker, ctx, rslt, cop, _ClassName,
+ _RefLeft, _RefRight, _RefLeftClass, _RefRightClass, 0, 0, filter ) )
+ {
+ CmpiStatus st(CMPI_RC_ERR_FAILED, "Create references failed.");
+ _CMPIZYPP_TRACE(1,("--- CMPI referenceNames() failed."));
+ return st;
+ }
+ }
+ }
+
+ rslt.returnDone();
+ _CMPIZYPP_TRACE(1,("--- %s CMPI referenceNames() exited",_ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+ }
+
+/* -------------------------------------------------------------------------- */
+
+ SUSE_HostedRepositoryFilter::SUSE_HostedRepositoryFilter(const CmpiObjectPath &op)
+ : SUSE_AssocFilter()
+ , csop(op)
+ { }
+
+ bool SUSE_HostedRepositoryFilter::filterInstance(const CmpiObjectPath &scop, const char * _RefSource, const CmpiInstance &ci, bool associators) const
+ {
+ _CMPIZYPP_TRACE(1,("--- SUSE_HostedRepositoryFilter::filterInstance called"));
+ return filterObjectPath( scop, _RefSource, ci.getObjectPath(), associators );
+
+ }
+
+ bool SUSE_HostedRepositoryFilter::filterObjectPath(const CmpiObjectPath &scop, const char * _RefSource, const CmpiObjectPath &op, bool associators) const
+ {
+ _CMPIZYPP_TRACE(1,("--- SUSE_HostedRepositoryFilter::filterObjectPath called"));
+ USR << scop << " " <<_RefSource << ": " << op << endl;
+
+ CmpiString CSName = csop.getKey("CreationClassName");
+ CmpiString Name = csop.getKey("Name");
+
+ const char *filterCSName = "";
+ const char *filterName = "";
+ if( ! associators )
+ {
+ CmpiObjectPath filterop = op.getKey( _RefLeft );
+ filterCSName = filterop.getKey("CreationClassName");
+ filterName = filterop.getKey("Name");
+ }
+ else
+ {
+ if ( ::strcmp(_RefSource, _RefLeft ) != 0 )
+ {
+ filterCSName = op.getKey("CreationClassName");
+ filterName = op.getKey("Name");
+ }
+ else
+ {
+ filterCSName = scop.getKey("CreationClassName");
+ filterName = scop.getKey("Name");
+ }
+ }
+
+ if(CSName.equals(filterCSName) && Name.equals(filterName) )
+ {
+ _CMPIZYPP_TRACE(1,("--- SUSE_HostedRepositoryFilter::filterInstance exited: true"));
+ return true;
+ }
+ else
+ {
+ _CMPIZYPP_TRACE(1,("--- SUSE_HostedRepositoryFilter::filterInstance exited: false"));
+ return false;
+ }
+}
+
+} // namespace cmpizypp
+
+CMProviderBase( SUSE_HostedRepositoryProvider );
+
+CMInstanceMIFactory( cmpizypp::SUSE_HostedRepositoryProviderClass, SUSE_HostedRepositoryProvider );
+CMAssociationMIFactory( cmpizypp::SUSE_HostedRepositoryProviderClass, SUSE_HostedRepositoryProvider );
diff --git a/src/SUSE_HostedRepositoryProvider.h b/src/SUSE_HostedRepositoryProvider.h
new file mode 100644
index 0000000..1e16e17
--- /dev/null
+++ b/src/SUSE_HostedRepositoryProvider.h
@@ -0,0 +1,58 @@
+#ifndef SUSE_HOSTEDREPOSITORYPROVIDERCLASS_H
+#define SUSE_HOSTEDREPOSITORYPROVIDERCLASS_H
+
+#include <cmpi/CmpiInstanceMI.h>
+#include <cmpi/CmpiAssociationMI.h>
+
+#include "SUSE_AssocFilter.h"
+
+namespace cmpizypp
+{
+ /**
+ */
+ class SUSE_HostedRepositoryProviderClass : public CmpiInstanceMI, public CmpiAssociationMI
+ {
+ public:
+ SUSE_HostedRepositoryProviderClass( const CmpiBroker & mbp, const CmpiContext & ctx );
+
+ virtual CmpiStatus enumInstanceNames( const CmpiContext& ctx, CmpiResult& rslt, const CmpiObjectPath & cop );
+ virtual CmpiStatus enumInstances( const CmpiContext & ctx, CmpiResult & rslt, const CmpiObjectPath & cop, const char** properties );
+ virtual CmpiStatus getInstance( const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &cop, const char **properties );
+
+ virtual CmpiStatus associators
+ (const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* assocClass, const char* resultClass,
+ const char* role, const char* resultRole, const char** properties);
+
+ virtual CmpiStatus associatorNames
+ (const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* assocClass, const char* resultClass,
+ const char* role, const char* resultRole);
+
+ virtual CmpiStatus references
+ (const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* resultClass, const char* role,
+ const char** properties);
+
+ virtual CmpiStatus referenceNames
+ (const CmpiContext& ctx, CmpiResult& rslt,
+ const CmpiObjectPath& cop, const char* resultClass, const char* role);
+ };
+
+
+ class SUSE_HostedRepositoryFilter: public SUSE_AssocFilter
+ {
+ private:
+ CmpiObjectPath csop;
+
+ public:
+ SUSE_HostedRepositoryFilter(const CmpiObjectPath &op);
+ virtual ~SUSE_HostedRepositoryFilter() {};
+
+ virtual bool filterInstance(const CmpiObjectPath &scop, const char * _RefSource, const CmpiInstance &ci, bool associators) const;
+ virtual bool filterObjectPath(const CmpiObjectPath &scop, const char * _RefSource, const CmpiObjectPath &op, bool associators) const;
+ };
+
+} // namespace cmpizypp
+
+#endif // SUSE_HOSTEDREPOSITORYPROVIDERCLASS_H
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
![](https://seccdn.libravatar.org/avatar/e6d0c9f42625f8f9f45b6bd11ffbb77b.jpg?s=120&d=mm&r=g)
06 Feb '09
ref: refs/heads/master
commit c53c15d0e262ba0fec77354a3afaf13dace6dfa2
Author: Michael Calmer <mc(a)suse.de>
Date: Fri Feb 6 16:20:17 2009 +0100
Implement new method "refresh"
---
mof/SUSE_SoftwareRepository.mof | 11 ++
src/SUSE_SoftwareRepositoryProvider.cc | 271 ++++++++++++++++++++++----------
src/SUSE_SoftwareRepositoryProvider.h | 7 +
3 files changed, 209 insertions(+), 80 deletions(-)
diff --git a/mof/SUSE_SoftwareRepository.mof b/mof/SUSE_SoftwareRepository.mof
index 4486969..d3bbc25 100644
--- a/mof/SUSE_SoftwareRepository.mof
+++ b/mof/SUSE_SoftwareRepository.mof
@@ -83,4 +83,15 @@ class SUSE_SoftwareRepository : CIM_RemoteServiceAccessPoint {
]
uint16 RepositoryType;
+ [Description (
+ "Refresh this repository and load the new metadata into the pool."),
+ ValueMap { "0", "1", ".." },
+ Values { "Completed with no Errors", "Error", "Vendor Specific" }]
+ uint32 Refresh(
+ [IN, Description (
+ "Refresh Policy"),
+ ValueMap { "0", "1", "2" },
+ Values { "RefreshIfNeeded", "RefreshForced", "RefreshIfNeededIgnoreDelay" }]
+ uint16 RefreshPolicy);
+
};
diff --git a/src/SUSE_SoftwareRepositoryProvider.cc b/src/SUSE_SoftwareRepositoryProvider.cc
index 2be092d..458db47 100644
--- a/src/SUSE_SoftwareRepositoryProvider.cc
+++ b/src/SUSE_SoftwareRepositoryProvider.cc
@@ -382,86 +382,11 @@ CmpiStatus SUSE_SoftwareRepositoryProviderClass::invokeMethod (const CmpiContext
if( ::strcasecmp( methodName, "RequestStateChange" ) == 0)
{
- const char *lsccn = ref.getKey("SystemCreationClassName");
- const char *lsn = ref.getKey("SystemName");
- const char *lccn = ref.getKey("CreationClassName");
- const char *ln = ref.getKey("Name");
-
- CmpiObjectPath csop = get_this_computersystem(*broker, ctx, ref);
- const char *sccn = csop.getKey("CreationClassName");
- const char *sn = csop.getKey("Name");
-
- if( lsccn== NULL || lsn == NULL || lccn == NULL || ln == NULL ||
- ::strcmp(lccn, _ClassName) != 0 ||
- ::strcmp(lsccn, sccn) != 0 || ::strcmp(lsn, sn) != 0)
- {
- CmpiStatus rc( CMPI_RC_ERR_FAILED, "Could not find this instance." );
- _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() failed : %s", _ClassName, rc.msg()));
- return rc;
- }
-
- CMPIUint16 reqState = 0;
- try
- {
- reqState = in.getArg("RequestedState");
- }
- catch(CmpiStatus rc)
- {
- CmpiStatus rc( CMPI_RC_ERR_FAILED, "Missing parameter RequestedState." );
- _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() failed : %s", _ClassName, rc.msg()));
- return rc;
- }
- // zypp init
- zypp::scoped_ptr<ZyppAC> zyppac;
- try
- {
- zyppac.reset( new ZyppAC() );
- }
- catch ( const zypp::Exception & err )
- {
- CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not list software identities: " ).c_str() );
- _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() failed : %s", _ClassName, rc.msg()));
- return rc;
- }
- bool newStateEnabled = true;
-
- if( reqState == 2 )
- newStateEnabled = true;
- else if( reqState == 3 )
- newStateEnabled = false;
- else
- {
- _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() failed : Invalid Parameter.", _ClassName ));
- rslt.returnData( CMPIUint32(5) ); // invalid Parameter
- rslt.returnDone();
- return CmpiStatus ( CMPI_RC_OK );
- }
-
- RepoManager repoManager( zyppac->getSysRoot() );
- if( ! repoManager.hasRepo( ln ) )
- {
- _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() failed : Could not find this instance.", _ClassName ));
- rslt.returnData( CMPIUint32(2) ); // unknown Error
- rslt.returnDone();
- return CmpiStatus ( CMPI_RC_OK );
- }
- try
- {
- RepoInfo repo( repoManager.getRepo( ln ) );
- repo.setEnabled( newStateEnabled );
- repoManager.modifyRepository( repo );
- }
- catch( const zypp::Exception & err )
- {
- _CMPIZYPP_TRACE(1,("--- %s CMPI InvokeMethod() failed : %s ", _ClassName,
- ZyppAC::exceptionString( err, "" ).c_str() ));
- rslt.returnData( CMPIUint32(2) ); // unknown Error
- rslt.returnDone();
- return CmpiStatus ( CMPI_RC_OK );
- }
- rslt.returnData( CmpiData(CMPIUint32(0)) ); // Completed with No Error
- rslt.returnDone();
- return CmpiStatus ( CMPI_RC_OK );
+ st = requestStateChange(ctx, rslt, ref, in, out);
+ }
+ else if( ::strcasecmp( methodName, "Refresh" ) == 0)
+ {
+ st = refresh(ctx, rslt, ref, in, out);
}
_CMPIZYPP_TRACE(1,("--- %s CMPI invokeMethod() exited",_ClassName));
@@ -590,6 +515,192 @@ void SUSE_SoftwareRepositoryProviderClass::setRepoInfo( zypp::RepoInfo &repoinfo
}
}
+CmpiStatus SUSE_SoftwareRepositoryProviderClass::requestStateChange(const CmpiContext &ctx, CmpiResult &rslt,
+ const CmpiObjectPath &ref,
+ const CmpiArgs &in, CmpiArgs &out)
+{
+ const char *lsccn = ref.getKey("SystemCreationClassName");
+ const char *lsn = ref.getKey("SystemName");
+ const char *lccn = ref.getKey("CreationClassName");
+ const char *ln = ref.getKey("Name");
+
+ CmpiObjectPath csop = get_this_computersystem(*broker, ctx, ref);
+ const char *sccn = csop.getKey("CreationClassName");
+ const char *sn = csop.getKey("Name");
+
+ if( lsccn== NULL || lsn == NULL || lccn == NULL || ln == NULL ||
+ ::strcmp(lccn, _ClassName) != 0 ||
+ ::strcmp(lsccn, sccn) != 0 || ::strcmp(lsn, sn) != 0)
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Could not find this instance." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ CMPIUint16 reqState = 0;
+ try
+ {
+ reqState = in.getArg("RequestedState");
+ }
+ catch(CmpiStatus rc)
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Missing parameter RequestedState." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not list software identities: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI EnumInstanceNames() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+ bool newStateEnabled = true;
+
+ if( reqState == 2 )
+ newStateEnabled = true;
+ else if( reqState == 3 )
+ newStateEnabled = false;
+ else
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() failed : Invalid Parameter.", _ClassName ));
+ rslt.returnData( CMPIUint32(5) ); // invalid Parameter
+ rslt.returnDone();
+ return CmpiStatus ( CMPI_RC_OK );
+ }
+
+ RepoManager repoManager( zyppac->getSysRoot() );
+ if( ! repoManager.hasRepo( ln ) )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI GetInstance() failed : Could not find this instance.", _ClassName ));
+ rslt.returnData( CMPIUint32(2) ); // unknown Error
+ rslt.returnDone();
+ return CmpiStatus ( CMPI_RC_OK );
+ }
+ try
+ {
+ RepoInfo repo( repoManager.getRepo( ln ) );
+ repo.setEnabled( newStateEnabled );
+ repoManager.modifyRepository( repo );
+ }
+ catch( const zypp::Exception & err )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI InvokeMethod() failed : %s ", _ClassName,
+ ZyppAC::exceptionString( err, "" ).c_str() ));
+ rslt.returnData( CMPIUint32(2) ); // unknown Error
+ rslt.returnDone();
+ return CmpiStatus ( CMPI_RC_OK );
+ }
+ rslt.returnData( CmpiData(CMPIUint32(0)) ); // Completed with No Error
+ rslt.returnDone();
+ return CmpiStatus ( CMPI_RC_OK );
+}
+
+
+CmpiStatus SUSE_SoftwareRepositoryProviderClass::refresh(const CmpiContext &ctx, CmpiResult &rslt,
+ const CmpiObjectPath &ref,
+ const CmpiArgs &in, CmpiArgs &out)
+{
+ const char *lsccn = ref.getKey("SystemCreationClassName");
+ const char *lsn = ref.getKey("SystemName");
+ const char *lccn = ref.getKey("CreationClassName");
+ const char *ln = ref.getKey("Name");
+
+ CmpiObjectPath csop = get_this_computersystem(*broker, ctx, ref);
+ const char *sccn = csop.getKey("CreationClassName");
+ const char *sn = csop.getKey("Name");
+
+ if( lsccn== NULL || lsn == NULL || lccn == NULL || ln == NULL ||
+ ::strcmp(lccn, _ClassName) != 0 ||
+ ::strcmp(lsccn, sccn) != 0 || ::strcmp(lsn, sn) != 0)
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Could not find this instance." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI InvokeMethod() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ CMPIUint16 policy = 0;
+ try
+ {
+ policy = in.getArg("RefreshPolicy");
+ }
+ catch(CmpiStatus rc)
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Missing parameter RefreshPolicy." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI InvokeMethod() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not initialize zypp: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI InvokeMethod() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+ RepoManager::RawMetadataRefreshPolicy pol = RepoManager::RefreshIfNeeded;
+
+ switch( policy )
+ {
+ case 0:
+ pol = RepoManager::RefreshIfNeeded;
+ break;
+ case 1:
+ pol = RepoManager::RefreshForced;
+ break;
+ case 2:
+ pol = RepoManager::RefreshIfNeededIgnoreDelay;
+ break;
+ }
+
+ RepoManager repoManager( zyppac->getSysRoot() );
+ if( ! repoManager.hasRepo( ln ) )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI InvokeMethod() failed : Could not find this instance.", _ClassName ));
+ rslt.returnData( CMPIUint32(1) ); // Error
+ rslt.returnDone();
+ return CmpiStatus ( CMPI_RC_OK );
+ }
+ try
+ {
+ RepoInfo repo( repoManager.getRepo( ln ) );
+
+ if( pol != RepoManager::RefreshForced && !repo.enabled() )
+ {
+ rslt.returnData( CmpiData(CMPIUint32(0)) ); // Completed with No Error
+ rslt.returnDone();
+ return CmpiStatus ( CMPI_RC_OK );
+ }
+ if ( repoManager.isCached( repo ) )
+ {
+ repoManager.cleanCache( repo );
+ }
+ repoManager.refreshMetadata( repo, pol );
+ repoManager.buildCache( repo );
+ repoManager.loadFromCache( repo );
+ }
+ catch( const zypp::Exception & err )
+ {
+ _CMPIZYPP_TRACE(1,("--- %s CMPI InvokeMethod() failed : %s ", _ClassName,
+ ZyppAC::exceptionString( err, "" ).c_str() ));
+ rslt.returnData( CMPIUint32(1) ); // Error
+ rslt.returnDone();
+ return CmpiStatus ( CMPI_RC_OK );
+ }
+ rslt.returnData( CmpiData(CMPIUint32(0)) ); // Completed with No Error
+ rslt.returnDone();
+ return CmpiStatus ( CMPI_RC_OK );
+}
+
} // namespace cmpizypp
CMProviderBase( SUSE_SoftwareRepositoryProvider );
diff --git a/src/SUSE_SoftwareRepositoryProvider.h b/src/SUSE_SoftwareRepositoryProvider.h
index 551e909..2e9eecf 100644
--- a/src/SUSE_SoftwareRepositoryProvider.h
+++ b/src/SUSE_SoftwareRepositoryProvider.h
@@ -31,6 +31,13 @@ namespace cmpizypp
const CmpiObjectPath &csop, const char ** properties );
void setRepoInfo( zypp::RepoInfo &repoinfo, const CmpiInstance &inst );
+
+ CmpiStatus requestStateChange(const CmpiContext &ctx, CmpiResult &rslt,
+ const CmpiObjectPath &ref,
+ const CmpiArgs &in, CmpiArgs &out);
+ CmpiStatus refresh(const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &ref,
+ const CmpiArgs &in, CmpiArgs &out);
+
};
} // namespace cmpizypp
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
![](https://seccdn.libravatar.org/avatar/e6d0c9f42625f8f9f45b6bd11ffbb77b.jpg?s=120&d=mm&r=g)
[zypp-commit] <cmpi-zypp> master : implement create, modify and delete; add some more infos
by Michael Calmer 06 Feb '09
by Michael Calmer 06 Feb '09
06 Feb '09
ref: refs/heads/master
commit 0e1fdda2256278e32d7cc17bd46b9d2171e4ed6e
Author: Michael Calmer <mc(a)suse.de>
Date: Fri Feb 6 15:01:01 2009 +0100
implement create, modify and delete; add some more infos
Add some more repository informations to the class:
* Autorefresh
* Priority
* signatureCheck
* RepositoryType
Implement createInstance, modifyInstance and deleteInstance to
add, modify and remove a repository.
---
mof/SUSE_SoftwareRepository.mof | 96 +++++++----
src/SUSE_SoftwareRepositoryProvider.cc | 296 ++++++++++++++++++++++++++++++++
src/SUSE_SoftwareRepositoryProvider.h | 6 +
3 files changed, 361 insertions(+), 37 deletions(-)
diff --git a/mof/SUSE_SoftwareRepository.mof b/mof/SUSE_SoftwareRepository.mof
index b376678..4486969 100644
--- a/mof/SUSE_SoftwareRepository.mof
+++ b/mof/SUSE_SoftwareRepository.mof
@@ -1,64 +1,86 @@
// ==================================================================
// SUSE_SoftwareRepository
// ==================================================================
- [Experimental, Version ( "2.10.0" ),
- Description (
+ [Experimental, Version ( "2.10.0" ),
+ Description (
"SoftwareRepository describes the URL of a repository "
"containing SoftwareIdentities "
"for use by the SoftwareInstallationService. " )]
class SUSE_SoftwareRepository : CIM_RemoteServiceAccessPoint {
- [Override ( "InfoFormat" ),
- Description (
+ [Override ( "InfoFormat" ),
+ Description (
"A SoftwareRepository will always be a URL." )]
uint16 InfoFormat = 200;
- [Description (
+ [Description (
"An enumerated integer that specifies the type of "
"resource referenced by the "
- "RemoteServiceAccessPoint.AccessInfo property." ),
- ValueMap { "0", "1", "2", "3", "4", "5", "6", "7", "9", "10",
- "11", "12", "..", "0x8000..0xFFFF" },
- Values { "Unknown", "Other", "Installer and Payload",
- "Installer", "Payload", "Installability checker",
- "Security Advisory", "Engineering Advisory",
- "Technical release notes", "Change notification",
- "Whitepaper", "Marketing Documentation", "DMTF Reserved",
- "Vendor Reserved" },
- ModelCorrespondence {
- "CIM_SoftwareIdentityResource.OtherResourceType",
+ "RemoteServiceAccessPoint.AccessInfo property." ),
+ ValueMap { "0", "1", "2", "3", "4", "5", "6", "7", "9", "10",
+ "11", "12", "..", "0x8000..0xFFFF" },
+ Values { "Unknown", "Other", "Installer and Payload",
+ "Installer", "Payload", "Installability checker",
+ "Security Advisory", "Engineering Advisory",
+ "Technical release notes", "Change notification",
+ "Whitepaper", "Marketing Documentation", "DMTF Reserved",
+ "Vendor Reserved" },
+ ModelCorrespondence {
+ "CIM_SoftwareIdentityResource.OtherResourceType",
"CIM_SoftwareIdentityResource.ExtendedResourceType" }]
uint16 ResourceType = 1;
- [Description (
+ [Description (
"A enumerated integer that provides further information "
"for ResourceType. It will set to 2 (\'Not Applicable\') "
- "if there is no extended information available." ),
- ValueMap { "0", "2", // Binary format types
- "3",
- "4", "5", "6", "7", "8", "9..100", "101..200",
- //Text formats
- "201", "202", "203",
- "204..0x7FFF", "0x8000..0xFFFF" },
- Values { "Unknown", "Not Applicable",
- // Binary format types
- "Linux RPM",
- "HP-UX Depot", "Windows MSI", "Solaris Package",
- "Macintosh Disk Image", "Debian linux Package",
- "DMTF Reserved", "Vendor Reserved",
- //Text formats
- "HTML", "PDF", "Text File",
- "DMTF Reserved", "Vendor Reserved" },
- ModelCorrespondence {
+ "if there is no extended information available." ),
+ ValueMap { "0", "2", // Binary format types
+ "3",
+ "4", "5", "6", "7", "8", "9..100", "101..200",
+ //Text formats
+ "201", "202", "203",
+ "204..0x7FFF", "0x8000..0xFFFF" },
+ Values { "Unknown", "Not Applicable",
+ // Binary format types
+ "Linux RPM",
+ "HP-UX Depot", "Windows MSI", "Solaris Package",
+ "Macintosh Disk Image", "Debian linux Package",
+ "DMTF Reserved", "Vendor Reserved",
+ //Text formats
+ "HTML", "PDF", "Text File",
+ "DMTF Reserved", "Vendor Reserved" },
+ ModelCorrespondence {
"CIM_SoftwareIdentityResource.ResourceType" }]
uint16 ExtendedResourceType;
- [Description (
+ [Description (
"A string describing the file type when the instance\'s "
- "ResourceType property is 1 (\"Other\")." ),
- ModelCorrespondence {
+ "ResourceType property is 1 (\"Other\")." ),
+ ModelCorrespondence {
"CIM_SoftwareIdentityResource.ResourceType" }]
string OtherResourceType = "Software Repository";
+ [Description (
+ "A boolean which say, if this repository should be "
+ "automatically refreshed or not." )]
+ boolean Autorefresh;
+
+ [Description (
+ " A boolean which say, if the sgignature check of "
+ " this repository should be enabled or not.")]
+ boolean SignatureCheck = true;
+
+ [Description (
+ " Define the priority of the repository. "
+ " Some number. 1 (highest priority), "
+ " 99 is the defaultPriority." )]
+ uint16 Priority = 99;
+
+ [Description (
+ " The type of this repository. " ),
+ ValueMap { "0", "1", "2", "3", "4", ".." },
+ Values { "Unknown", "Other", "rpm-md", "susetags", "rpmplaindir", "Vendor Reserved" }
+ ]
+ uint16 RepositoryType;
};
diff --git a/src/SUSE_SoftwareRepositoryProvider.cc b/src/SUSE_SoftwareRepositoryProvider.cc
index 7b2d311..2be092d 100644
--- a/src/SUSE_SoftwareRepositoryProvider.cc
+++ b/src/SUSE_SoftwareRepositoryProvider.cc
@@ -10,6 +10,7 @@
#include <zypp/base/String.h>
#include <zypp/base/LogTools.h>
+#include <zypp/repo/RepoType.h>
#include "SUSE_zypp.h"
#include "SUSE_Common.h"
@@ -156,6 +157,217 @@ CmpiStatus SUSE_SoftwareRepositoryProviderClass::getInstance( const CmpiContext
return CmpiStatus(CMPI_RC_OK);
}
+CmpiStatus SUSE_SoftwareRepositoryProviderClass::setInstance (const CmpiContext &ctx, CmpiResult &rslt,
+ const CmpiObjectPath &cop, const CmpiInstance &inst,
+ const char **properties)
+{
+ _CMPIZYPP_TRACE(1,("--- %s CMPI setInstance() called.", _ClassName));
+
+ CmpiInstance orig( broker->getInstance(ctx, cop, NULL ) );
+
+ const char *oldsccn = orig.getProperty("SystemCreationClassName");
+ const char *oldsn = orig.getProperty("SystemName");
+ const char *oldccn = orig.getProperty("CreationClassName");
+ const char *oldn = orig.getProperty("Name");
+
+ const char *newsccn = inst.getProperty("SystemCreationClassName");
+ const char *newsn = inst.getProperty("SystemName");
+ const char *newccn = inst.getProperty("CreationClassName");
+ const char *newn = inst.getProperty("Name");
+
+ if( newsccn== NULL || newsn == NULL || newccn == NULL || newn == NULL ||
+ oldsccn== NULL || oldsn == NULL || oldccn == NULL || oldn == NULL ||
+ ::strcmp(newccn, oldccn) != 0 ||
+ ::strcmp(newsccn, oldsccn) != 0 || ::strcmp(newsn, oldsn) != 0)
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Invalid Instance." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI setInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+ if( ::strcmp(newn, oldn) != 0 )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Name cannot be changed." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI setInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not initialize libzypp: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI setInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ RepoManager repoManager( zyppac->getSysRoot() );
+ // Check, if repo exists
+ if( ! repoManager.hasRepo( newn ) )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Instance do not exist." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI setInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ RepoInfo repoinfo( repoManager.getRepo( newn ) );
+ setRepoInfo( repoinfo, inst );
+
+ try
+ {
+ repoManager.modifyRepository( repoinfo );
+ }
+ catch( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Building repository info data failed: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI setInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ CmpiInstance newci( broker->getInstance( ctx, cop, NULL ) );
+
+ _CMPIZYPP_TRACE(1,("--- %s CMPI setInstance() exited.", _ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+}
+
+CmpiStatus SUSE_SoftwareRepositoryProviderClass::deleteInstance (const CmpiContext &ctx, CmpiResult &rslt,
+ const CmpiObjectPath &cop)
+{
+ _CMPIZYPP_TRACE(1,("--- %s CMPI deleteInstance() called.", _ClassName));
+
+ CmpiObjectPath csop = get_this_computersystem(*broker, ctx, cop);
+ const char *sccn = csop.getKey("CreationClassName");
+ const char *sn = csop.getKey("Name");
+
+ const char *newsccn = cop.getKey("SystemCreationClassName");
+ const char *newsn = cop.getKey("SystemName");
+ const char *newccn = cop.getKey("CreationClassName");
+ const char *newn = cop.getKey("Name");
+
+ if( newsccn== NULL || newsn == NULL || newccn == NULL || newn == NULL ||
+ ::strcmp(newccn, _ClassName) != 0 ||
+ ::strcmp(newsccn, sccn) != 0 || ::strcmp(newsn, sn) != 0)
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Invalid Instance." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI deleteInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not initialize zypp: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI deleteInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ RepoManager repoManager( zyppac->getSysRoot() );
+ // Check, if repo exists
+ if( ! repoManager.hasRepo( newn ) )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Instance does not exist." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI deleteInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ RepoInfo repoinfo( repoManager.getRepo( newn ) );
+
+ try
+ {
+ repoManager.removeRepository( repoinfo );
+ }
+ catch( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Removing repository failed: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI deleteInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ _CMPIZYPP_TRACE(1,("--- %s CMPI deleteInstance() exited.", _ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+}
+
+CmpiStatus SUSE_SoftwareRepositoryProviderClass::createInstance (const CmpiContext &ctx, CmpiResult &rslt,
+ const CmpiObjectPath &cop, const CmpiInstance &inst)
+{
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() called.", _ClassName));
+
+ CmpiObjectPath csop = get_this_computersystem(*broker, ctx, cop);
+ const char *sccn = csop.getKey("CreationClassName");
+ const char *sn = csop.getKey("Name");
+
+ //const char *ns = cop.getNameSpace().charPtr();
+ CmpiObjectPath newcop = inst.getObjectPath();
+
+ const char *newsccn = newcop.getKey("SystemCreationClassName");
+ const char *newsn = newcop.getKey("SystemName");
+ const char *newccn = newcop.getKey("CreationClassName");
+ const char *newn = newcop.getKey("Name");
+
+ if( newsccn== NULL || newsn == NULL || newccn == NULL || newn == NULL ||
+ ::strcmp(newccn, _ClassName) != 0 ||
+ ::strcmp(newsccn, sccn) != 0 || ::strcmp(newsn, sn) != 0)
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Invalid Instance." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ // zypp init
+ zypp::scoped_ptr<ZyppAC> zyppac;
+ try
+ {
+ zyppac.reset( new ZyppAC() );
+ }
+ catch ( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Could not list software identities: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ RepoManager repoManager( zyppac->getSysRoot() );
+ // Check, if repo exists
+ if( repoManager.hasRepo( newn ) )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Instance already exists." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ RepoInfo repoinfo;
+ repoinfo.setAlias( newn );
+
+ setRepoInfo( repoinfo, inst );
+
+ try
+ {
+ repoManager.addRepository( repoinfo );
+ }
+ catch( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Building repository info data failed: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() failed : %s", _ClassName, rc.msg()));
+ return rc;
+ }
+
+ CmpiInstance newci( broker->getInstance( ctx, newcop, NULL ) );
+
+ rslt.returnData( newci.getObjectPath() );
+ rslt.returnDone();
+
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() exited.", _ClassName));
+ return CmpiStatus(CMPI_RC_OK);
+}
+
CmpiStatus SUSE_SoftwareRepositoryProviderClass::invokeMethod (const CmpiContext &ctx, CmpiResult &rslt,
const CmpiObjectPath &ref, const char *methodName,
const CmpiArgs &in, CmpiArgs &out)
@@ -291,9 +503,93 @@ CmpiInstance SUSE_SoftwareRepositoryProviderClass::makeInstance( const RepoInfo
ci.setProperty( "EnabledState", (repo.enabled())?CMPIUint16(2):CMPIUint16(3) );
ci.setProperty( "ExtendedResourceType", CMPIUint16(2) );
+ ci.setProperty( "Autorefresh", (repo.autorefresh())?CmpiTrue:CmpiFalse );
+ ci.setProperty( "SignatureCheck", (repo.gpgCheck())?CmpiTrue:CmpiFalse );
+ ci.setProperty( "Priority", CMPIUint16(repo.priority()) );
+
+ switch( repo.type().toEnum() )
+ {
+ case repo::RepoType::RPMMD_e:
+ ci.setProperty( "RepositoryType", CMPIUint16(2) );
+ break;
+ case repo::RepoType::YAST2_e:
+ ci.setProperty( "RepositoryType", CMPIUint16(3) );
+ break;
+ case repo::RepoType::RPMPLAINDIR_e:
+ ci.setProperty( "RepositoryType", CMPIUint16(4) );
+ break;
+ case repo::RepoType::NONE_e:
+ ci.setProperty( "RepositoryType", CMPIUint16(0) );
+ break;
+ default:
+ ci.setProperty( "RepositoryType", CMPIUint16(1) );
+ break;
+ }
+
+
return ci;
}
+void SUSE_SoftwareRepositoryProviderClass::setRepoInfo( zypp::RepoInfo &repoinfo,
+ const CmpiInstance &inst )
+{
+ const char* name = inst.getProperty("ElementName");
+ CMPIUint16 enabledState = inst.getProperty("EnabledState");
+ bool enabled = true ;
+ if( enabledState == 2)
+ enabled = true;
+ else if( enabledState == 3 )
+ enabled = false;
+ else
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Invalid EnabledState value." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() failed : %s", _ClassName, rc.msg()));
+ throw rc;
+ }
+
+ bool autorefresh = true;
+ unsigned char ar = inst.getProperty("Autorefresh");
+ if( ar == 0 )
+ autorefresh = false;
+
+ CMPIUint16 priority = inst.getProperty("Priority");
+ bool gpgcheck = true;
+ unsigned char gc = inst.getProperty("SignatureCheck");
+ if( gc == 0 )
+ gpgcheck = false;
+
+ if( CMPIUint16(inst.getProperty("InfoFormat")) != CMPIUint16(200) )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Invalid InfoFormat value." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() failed : %s", _ClassName, rc.msg()));
+ throw rc;
+ }
+
+ const char* url = inst.getProperty("AccessInfo");
+ if( url == NULL )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, "Invalid AccessValue value." );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() failed : %s", _ClassName, rc.msg()));
+ throw rc;
+ }
+
+ try
+ {
+ repoinfo.setName( name );
+ repoinfo.setEnabled( enabled );
+ repoinfo.setAutorefresh( autorefresh );
+ repoinfo.setPriority( priority );
+ repoinfo.setGpgCheck( gpgcheck );
+ repoinfo.setBaseUrl( Url( url ) );
+ }
+ catch( const zypp::Exception & err )
+ {
+ CmpiStatus rc( CMPI_RC_ERR_FAILED, ZyppAC::exceptionString( err, "Building repository info data failed: " ).c_str() );
+ _CMPIZYPP_TRACE(1,("--- %s CMPI createInstance() failed : %s", _ClassName, rc.msg()));
+ throw rc;
+ }
+}
+
} // namespace cmpizypp
CMProviderBase( SUSE_SoftwareRepositoryProvider );
diff --git a/src/SUSE_SoftwareRepositoryProvider.h b/src/SUSE_SoftwareRepositoryProvider.h
index 80e1985..551e909 100644
--- a/src/SUSE_SoftwareRepositoryProvider.h
+++ b/src/SUSE_SoftwareRepositoryProvider.h
@@ -18,6 +18,10 @@ namespace cmpizypp
virtual CmpiStatus enumInstances( const CmpiContext & ctx, CmpiResult & rslt, const CmpiObjectPath & cop, const char** properties );
virtual CmpiStatus getInstance( const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &cop, const char **properties );
+ virtual CmpiStatus createInstance (const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &cop, const CmpiInstance &inst);
+ virtual CmpiStatus setInstance (const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &cop, const CmpiInstance &inst, const char **properties);
+ virtual CmpiStatus deleteInstance (const CmpiContext &ctx, CmpiResult &rslt, const CmpiObjectPath &cop);
+
virtual CmpiStatus invokeMethod (const CmpiContext &ctx, CmpiResult &rslt,
const CmpiObjectPath &ref, const char *methodName,
const CmpiArgs &in, CmpiArgs &out);
@@ -25,6 +29,8 @@ namespace cmpizypp
private:
CmpiInstance makeInstance( const zypp::RepoInfo &repo, const CmpiObjectPath &cop,
const CmpiObjectPath &csop, const char ** properties );
+
+ void setRepoInfo( zypp::RepoInfo &repoinfo, const CmpiInstance &inst );
};
} // namespace cmpizypp
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
![](https://seccdn.libravatar.org/avatar/93f26b0fb87f4be0df994e56a8e31107.jpg?s=120&d=mm&r=g)
[zypp-commit] <libzypp> master : Fix ProductFile parser to use parseDefAssign end_element callbacks.
by Michael Andres 06 Feb '09
by Michael Andres 06 Feb '09
06 Feb '09
ref: refs/heads/master
commit 1b677fb9e2247ebbd64b24771d7f772a7d6fd0fe
Author: Michael Andres <ma(a)suse.de>
Date: Fri Feb 6 13:25:24 2009 +0100
Fix ProductFile parser to use parseDefAssign end_element callbacks.
---
tests/parser/ProductFileReader_test.cc | 2 +-
zypp/parser/ProductFileReader.cc | 60 +++++++++++++++-----------------
2 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/tests/parser/ProductFileReader_test.cc b/tests/parser/ProductFileReader_test.cc
index 6c7cd18..b050458 100644
--- a/tests/parser/ProductFileReader_test.cc
+++ b/tests/parser/ProductFileReader_test.cc
@@ -23,7 +23,7 @@ BOOST_AUTO_TEST_CASE(basic)
BOOST_CHECK_EQUAL( data.registerRelease(), "whatever" );
BOOST_CHECK_EQUAL( data.updaterepokey(), "A43242DKD" );
- BOOST_CHECK_EQUAL( data.upgrades().size(), 2 );
+ BOOST_REQUIRE_EQUAL( data.upgrades().size(), 2 );
BOOST_CHECK_EQUAL( data.upgrades()[0].name(), "openSUSE_11.1" );
BOOST_CHECK_EQUAL( data.upgrades()[0].summary(), "openSUSE 11.1" );
diff --git a/zypp/parser/ProductFileReader.cc b/zypp/parser/ProductFileReader.cc
index 1f5bdfb..d3c8ec3 100644
--- a/zypp/parser/ProductFileReader.cc
+++ b/zypp/parser/ProductFileReader.cc
@@ -124,7 +124,7 @@ namespace zypp
//
/////////////////////////////////////////////////////////////////
- struct ProductNode : public xml::ParseDef, public xml::ParseDefConsume
+ struct ProductNode : public xml::ParseDef
{
ProductNode( ProductFileData::Impl & pdata_r )
: ParseDef( "product", MANDTAORY )
@@ -148,7 +148,8 @@ namespace zypp
;
(*this)["upgrades"]
- ("upgrade", MULTIPLE_OPTIONAL)
+ ("upgrade", MULTIPLE_OPTIONAL, xml::parseDefAssign()
+ >> bind( &ProductNode::doneUpgrade, this, _1 ))
;
(*this)["upgrades"]["upgrade"]
@@ -159,37 +160,32 @@ namespace zypp
("status", OPTIONAL, xml::parseDefAssign( _upgrade._status ) )
;
- // Not a clean way to collect the END_ELEMENT calls, but
- // works for this case. NEEDS CLEANUP!
-
+ // </product> callback to build edition.
+ setConsumer( xml::parseDefAssign() >> bind( &ProductNode::done, this, _1 ) );
// xml::ParseDef::_debug = true;
- setConsumer( *this );
- (*this)["upgrades"].setConsumer( *this );
- }
-
- virtual void done ( const xml::Node & _node )
- {
- // SEC << "DONE.... " << _node.localName() << endl;
- if ( _node.localName() == name() )
- {
- // this END node
- _pdata._edition = Edition( _version, _release );
- }
- else if ( _node.localName() == "upgrade" )
- {
- // collect upgrade
- ProductFileData::Upgrade cdata( new ProductFileData::Upgrade::Impl( _upgrade ) );
- _pdata._upgrades.push_back( cdata );
- _upgrade = ProductFileData::Upgrade::Impl();
- }
- }
-
- ProductFileData::Impl & _pdata;
-
- std::string _version;
- std::string _release;
-
- ProductFileData::Upgrade::Impl _upgrade;
+ }
+
+ /** collect _upgrade */
+ void doneUpgrade( const xml::Node & _node )
+ {
+ ProductFileData::Upgrade cdata( new ProductFileData::Upgrade::Impl( _upgrade ) );
+ _pdata._upgrades.push_back( cdata );
+ _upgrade = ProductFileData::Upgrade::Impl();
+ }
+
+ /** finaly */
+ void done( const xml::Node & _node )
+ {
+ _pdata._edition = Edition( _version, _release );
+ }
+
+ private:
+ ProductFileData::Impl & _pdata;
+
+ std::string _version;
+ std::string _release;
+
+ ProductFileData::Upgrade::Impl _upgrade;
};
bool ProductFileReader::parse( const InputStream & input_r ) const
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
![](https://seccdn.libravatar.org/avatar/93f26b0fb87f4be0df994e56a8e31107.jpg?s=120&d=mm&r=g)
[zypp-commit] <libzypp> master : Add xml::rnParse, a simple and lightweight xml::Reader interface.
by Michael Andres 06 Feb '09
by Michael Andres 06 Feb '09
06 Feb '09
ref: refs/heads/master
commit 5c1bff19b78e1ec25dc4a6e0b10846be50950667
Author: Michael Andres <ma(a)suse.de>
Date: Thu Feb 5 19:32:14 2009 +0100
Add xml::rnParse, a simple and lightweight xml::Reader interface.
---
zypp/CMakeLists.txt | 1 +
zypp/parser/xml/Parse.h | 115 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 116 insertions(+), 0 deletions(-)
diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt
index 97a5cec..d6c5239 100644
--- a/zypp/CMakeLists.txt
+++ b/zypp/CMakeLists.txt
@@ -384,6 +384,7 @@ SET( zypp_parser_xml_SRCS
)
SET( zypp_parser_xml_HEADERS
+ parser/xml/Parse.h
parser/xml/Node.h
parser/xml/ParseDef.h
parser/xml/ParseDefConsume.h
diff --git a/zypp/parser/xml/Parse.h b/zypp/parser/xml/Parse.h
new file mode 100644
index 0000000..85ffc86
--- /dev/null
+++ b/zypp/parser/xml/Parse.h
@@ -0,0 +1,115 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/xml/Parse.h
+ *
+*/
+#ifndef ZYPP_PARSER_XML_PARSE_H
+#define ZYPP_PARSER_XML_PARSE_H
+
+#include <iosfwd>
+
+#include "zypp/parser/xml/Reader.h"
+#include "zypp/parser/xml/ParseDef.h"
+#include "zypp/parser/xml/ParseDefConsume.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace xml
+ { /////////////////////////////////////////////////////////////////
+
+ /** Parse xml \c input_r and store data in \c data_r.
+ *
+ * \c _Data must be defaultconstructible and assignable.
+ *
+ * \c _Data::RootNode must be a \ref xml::ParseDef constructible
+ * from \c _Data&.
+ *
+ * \throws ParseDefException on parse errors.
+ *
+ * To parse a xml file like this:
+ * \code
+ * <test>
+ * <setup attr="13">value</setup>
+ * <list name="A"/>
+ * <list name="b"/>
+ * </test>
+ * \endcode
+ *
+ * You need something like this:
+ * \code
+ * struct XmlData
+ * {
+ * // data
+ * unsigned attr;
+ * std::string value;
+ * std:list<std::string> names;
+ *
+ * public:
+ * // Convenience parsing to *this.
+ * void parse( const Pathname & path_r )
+ * { xml::rnParse( path_r, *this ); }
+ *
+ * public:
+ * // Parser description
+ * struct RootNode : public xml::ParseDef
+ * {
+ * RootNode( XmlData & data )
+ * : ParseDef( "test", MANDTAORY )
+ * , _data( data )
+ * {
+ * (*this)
+ * ("setup", MANDTAORY,
+ * xml::parseDefAssign( data.value )
+ * ( "attr", data.attr ) )
+ * // Each individual list entry is collected locally
+ * // and appended to the list after the node is done.
+ * ("list", MULTIPLE_OPTIONAL,
+ * xml::parseDefAssign( "name", _cname )
+ * >> bind( &RootNode::cdone, this, _1 ) )
+ * ;
+ * }
+ *
+ * void cdone( const xml::Node & node_r )
+ * {
+ * _data.push_back( _cname );
+ * _cname.clear(); // prepare for next
+ * }
+ *
+ * private:
+ * XmlData & _data; // stored just because notification callbacks are used.
+ * std::string _cname;
+ * };
+ * };
+ *
+ * XmlData xmlData;
+ * xmlData.parse( "/tmp/mytest.xml" );
+ * \endcode
+ */
+ template<class _Data>
+ inline void rnParse( const InputStream & input_r, _Data & data_r )
+ {
+ typedef typename _Data::RootNode RootNode;
+ _Data pdata;
+
+ xml::Reader reader( input_r );
+ RootNode rootNode( pdata );
+ rootNode.take( reader );
+
+ data_r = pdata;
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace xml
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_XML_PARSEDEF_H
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
![](https://seccdn.libravatar.org/avatar/93f26b0fb87f4be0df994e56a8e31107.jpg?s=120&d=mm&r=g)
06 Feb '09
ref: refs/heads/master
commit 8c5593f6e00911d352dbf27a20f64313bea1a4c0
Author: Michael Andres <ma(a)suse.de>
Date: Fri Feb 6 11:57:51 2009 +0100
Fix wrong callback redirection
---
zypp/parser/xml/ParseDef.cc | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/zypp/parser/xml/ParseDef.cc b/zypp/parser/xml/ParseDef.cc
index 04dcdae..59c73ce 100644
--- a/zypp/parser/xml/ParseDef.cc
+++ b/zypp/parser/xml/ParseDef.cc
@@ -100,13 +100,13 @@ namespace zypp
virtual void startSubnode( const Node & node_r )
{
debuglog( "---> ", node_r );
- ParseDefConsumeRedirect::start( node_r );
+ ParseDefConsumeRedirect::startSubnode( node_r );
}
virtual void doneSubnode( const Node & node_r )
{
debuglog( "<--- ", node_r );
- ParseDefConsumeRedirect::done( node_r );
+ ParseDefConsumeRedirect::doneSubnode( node_r );
}
void debuglog( const char *const tag_r, const Node & node_r )
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
ref: refs/heads/master
commit cd65468d5386822363bab78b92411432d4eeb99e
Author: Michael Andres <ma(a)suse.de>
Date: Fri Feb 6 11:57:12 2009 +0100
convenience added
---
zypp/base/LogTools.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/zypp/base/LogTools.h b/zypp/base/LogTools.h
index 5bedb6a..953da5c 100644
--- a/zypp/base/LogTools.h
+++ b/zypp/base/LogTools.h
@@ -27,6 +27,8 @@
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
+
+ using std::endl;
/** Print range defined by iterators (multiline style).
* \code
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
![](https://seccdn.libravatar.org/avatar/93f26b0fb87f4be0df994e56a8e31107.jpg?s=120&d=mm&r=g)
[zypp-commit] <libzypp> master : Enhance xml::parseDefAssign to support Node attribute consumption and pre/post-processing.
by Michael Andres 06 Feb '09
by Michael Andres 06 Feb '09
06 Feb '09
ref: refs/heads/master
commit 9ab23d05bb23a284c1b06a28b5516a393746eb36
Author: Michael Andres <ma(a)suse.de>
Date: Thu Feb 5 19:29:16 2009 +0100
Enhance xml::parseDefAssign to support Node attribute consumption and pre/post-processing.
---
zypp/parser/ProductFileReader.cc | 28 ++--
zypp/parser/xml/ParseDef.cc | 33 ----
zypp/parser/xml/ParseDefConsume.h | 300 ++++++++++++++++++++++++++++---------
zypp/parser/xml/Reader.cc | 4 +-
4 files changed, 249 insertions(+), 116 deletions(-)
diff --git a/zypp/parser/ProductFileReader.cc b/zypp/parser/ProductFileReader.cc
index 1e6ef13..1f5bdfb 100644
--- a/zypp/parser/ProductFileReader.cc
+++ b/zypp/parser/ProductFileReader.cc
@@ -131,20 +131,20 @@ namespace zypp
, _pdata( pdata_r )
{
(*this)
- ("vendor", OPTIONAL, xml::parseDefAssignText( _pdata._vendor ) )
- ("name", MANDTAORY, xml::parseDefAssignText( _pdata._name ) )
- ("version", MANDTAORY, xml::parseDefAssignText( _version ) )
- ("release", MANDTAORY, xml::parseDefAssignText( _release ) )
- ("arch", MANDTAORY, xml::parseDefAssignText( _pdata._arch ) )
- ("productline", OPTIONAL, xml::parseDefAssignText( _pdata._productline ) )
+ ("vendor", OPTIONAL, xml::parseDefAssign( _pdata._vendor ) )
+ ("name", MANDTAORY, xml::parseDefAssign( _pdata._name ) )
+ ("version", MANDTAORY, xml::parseDefAssign( _version ) )
+ ("release", MANDTAORY, xml::parseDefAssign( _release ) )
+ ("arch", MANDTAORY, xml::parseDefAssign( _pdata._arch ) )
+ ("productline", OPTIONAL, xml::parseDefAssign( _pdata._productline ) )
("register", OPTIONAL)
- ("updaterepokey", OPTIONAL, xml::parseDefAssignText( _pdata._updaterepokey ) )
+ ("updaterepokey", OPTIONAL, xml::parseDefAssign( _pdata._updaterepokey ) )
("upgrades", OPTIONAL)
;
(*this)["register"]
- ("target", OPTIONAL, xml::parseDefAssignText( _pdata._registerTarget ) )
- ("release", OPTIONAL, xml::parseDefAssignText( _pdata._registerRelease ) )
+ ("target", OPTIONAL, xml::parseDefAssign( _pdata._registerTarget ) )
+ ("release", OPTIONAL, xml::parseDefAssign( _pdata._registerRelease ) )
;
(*this)["upgrades"]
@@ -152,11 +152,11 @@ namespace zypp
;
(*this)["upgrades"]["upgrade"]
- ("name", OPTIONAL, xml::parseDefAssignText( _upgrade._name ) )
- ("summary", OPTIONAL, xml::parseDefAssignText( _upgrade._summary ) )
- ("repository", OPTIONAL, xml::parseDefAssignText( _upgrade._repository ) )
- ("notify", OPTIONAL, xml::parseDefAssignText( _upgrade._notify ) )
- ("status", OPTIONAL, xml::parseDefAssignText( _upgrade._status ) )
+ ("name", OPTIONAL, xml::parseDefAssign( _upgrade._name ) )
+ ("summary", OPTIONAL, xml::parseDefAssign( _upgrade._summary ) )
+ ("repository", OPTIONAL, xml::parseDefAssign( _upgrade._repository ) )
+ ("notify", OPTIONAL, xml::parseDefAssign( _upgrade._notify ) )
+ ("status", OPTIONAL, xml::parseDefAssign( _upgrade._status ) )
;
// Not a clean way to collect the END_ELEMENT calls, but
diff --git a/zypp/parser/xml/ParseDef.cc b/zypp/parser/xml/ParseDef.cc
index 59c73ce..2fdda63 100644
--- a/zypp/parser/xml/ParseDef.cc
+++ b/zypp/parser/xml/ParseDef.cc
@@ -30,39 +30,6 @@ using std::endl;
namespace zypp
{ /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- namespace debug
- { /////////////////////////////////////////////////////////////////
-
- template<class _Derived>
- struct TraceInstance
- {
- TraceInstance()
- { total(1); }
- TraceInstance( const TraceInstance & rhs )
- { total(1); }
- ~TraceInstance()
- { total(-1); }
- static unsigned & total( int cnt_r )
- {
- static unsigned _total = 0;
- _total += cnt_r;
- INT << "total += " << cnt_r << " => " << _total << endl;
- return _total;
- }
- };
-
- /////////////////////////////////////////////////////////////////
- } // namespace debug
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
namespace xml
{ /////////////////////////////////////////////////////////////////
diff --git a/zypp/parser/xml/ParseDefConsume.h b/zypp/parser/xml/ParseDefConsume.h
index c34a9e0..2f75dc9 100644
--- a/zypp/parser/xml/ParseDefConsume.h
+++ b/zypp/parser/xml/ParseDefConsume.h
@@ -14,6 +14,7 @@
#include "zypp/base/PtrTypes.h"
#include "zypp/base/Function.h"
+#include "zypp/base/Tr1hash.h"
#include "zypp/base/String.h"
#include "zypp/base/DefaultIntegral.h"
@@ -121,86 +122,249 @@ namespace zypp
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ParseDefAssignText<_Type>
- //
- /** Assign a \ref Node text to types constructible from \c char*.
- * \code
- * struct ProductNode : public xml::ParseDef
- * {
- * ProductNode( ProductFileData::Impl & pdata_r )
- * : ParseDef( "product", MANDTAORY )
- * {
- * (*this)
- * ("vendor", OPTIONAL, parseDefAssignText( _vendor ) )
- * ("name", MANDTAORY, parseDefAssignText( _name ) )
- * ...
- * }
- *
- * std::string _vendor;
- * std::string _name;
- * };
- * \endcode
- */
- template <class _Type>
- struct ParseDefAssignText : public xml::ParseDefConsume
- {
- ParseDefAssignText( _Type & value_r )
- : _value( &value_r )
- {}
+ /** \ref parseDefAssign exposed details */
+ namespace parse_def_assign
+ { /////////////////////////////////////////////////////////////////
+ template <class _Type> struct Assigner;
+
+ typedef shared_ptr<Assigner<void> > AssignerRef;
- virtual void text( const xml::Node & node_r )
+ /** Common interface to all Assigner types. */
+ template <>
+ struct Assigner<void>
{
- *_value = _Type( node_r.value().c_str() );
- }
+ virtual ~Assigner()
+ {}
+ virtual void assign( const char * text_r )
+ {}
+ };
- private:
- _Type * _value;
- };
+ /** Assigner assigns text to types constructible from \c char*.
+ * \see \ref assigner consvenience constructor.
+ */
+ template <class _Type>
+ struct Assigner : public Assigner<void>
+ {
+ Assigner(_Type & value_r )
+ : _value( &value_r )
+ {}
- /** \name ParseDefAssignText specialisation for numeric and boolean values.
- * \relates ParseDefAssignText
- */
- //@{
- template <>
- inline void ParseDefAssignText<short>::text( const xml::Node & node_r ) { str::strtonum( node_r.value().c_str(), *_value ); }
- template <>
- inline void ParseDefAssignText<int>::text( const xml::Node & node_r ) { str::strtonum( node_r.value().c_str(), *_value ); }
- template <>
- inline void ParseDefAssignText<long>::text( const xml::Node & node_r ) { str::strtonum( node_r.value().c_str(), *_value ); }
- template <>
- inline void ParseDefAssignText<long long>::text( const xml::Node & node_r ) { str::strtonum( node_r.value().c_str(), *_value ); }
- template <>
- inline void ParseDefAssignText<unsigned short>::text( const xml::Node & node_r ) { str::strtonum( node_r.value().c_str(), *_value ); }
- template <>
- inline void ParseDefAssignText<unsigned>::text( const xml::Node & node_r ) { str::strtonum( node_r.value().c_str(), *_value ); }
- template <>
- inline void ParseDefAssignText<unsigned long>::text( const xml::Node & node_r ) { str::strtonum( node_r.value().c_str(), *_value ); }
- template <>
- inline void ParseDefAssignText<unsigned long long>::text( const xml::Node & node_r ) { str::strtonum( node_r.value().c_str(), *_value ); }
- template <>
- inline void ParseDefAssignText<bool>::text( const xml::Node & node_r ) { str::strToBoolNodefault( node_r.value().c_str(), *_value ); }
- //@}
+ virtual void assign( const char * text_r )
+ { *_value = _Type( text_r ); }
+
+ private:
+ _Type * _value;
+ };
+
+ /** \name Assigner specialisation for numeric and boolean values.
+ * \relates Assigner
+ */
+ //@{
+ template <>
+ inline void Assigner<short>::assign( const char * text_r ) { str::strtonum( text_r, *_value ); }
+ template <>
+ inline void Assigner<int>::assign( const char * text_r ) { str::strtonum( text_r, *_value ); }
+ template <>
+ inline void Assigner<long>::assign( const char * text_r ) { str::strtonum( text_r, *_value ); }
+ template <>
+ inline void Assigner<long long>::assign( const char * text_r ) { str::strtonum( text_r, *_value ); }
+ template <>
+ inline void Assigner<unsigned short>::assign( const char * text_r ) { str::strtonum( text_r, *_value ); }
+ template <>
+ inline void Assigner<unsigned>::assign( const char * text_r ) { str::strtonum( text_r, *_value ); }
+ template <>
+ inline void Assigner<unsigned long>::assign( const char * text_r ) { str::strtonum( text_r, *_value ); }
+ template <>
+ inline void Assigner<unsigned long long>::assign( const char * text_r ) { str::strtonum( text_r, *_value ); }
+
+ template <>
+ inline void Assigner<bool>::assign( const char * text_r ) { str::strToBoolNodefault( text_r, *_value ); }
+ //@}
+
+ /** \name \relates Assigner Convenience constructor */
+ //@{
+ template <class _Type>
+ inline AssignerRef assigner( _Type & value_r )
+ { return AssignerRef( new Assigner<_Type>( value_r ) ); }
+
+ template <class _Tp, _Tp _Initial>
+ inline AssignerRef assigner( DefaultIntegral<_Tp,_Initial> & value_r )
+ { return AssignerRef( new Assigner<_Tp>( value_r.get() ) ); }
+ //@}
+
+
+ /** \ref ParseDef consumer assigning \ref Node text and attribues values to variables.
+ *
+ * This can be used with all types supported by \ref Assigner.
+ * Basically all types constructible from \c char*, or where a
+ * specialisation exists (e.g. numeric and bool).
+ *
+ * You may also set a <tt>void( const Node & )</tt> notification
+ * callback which is invoked after the node was processed.
+ *
+ * \note Use and see \ref xml::parseDefAssign convenience constructor.
+ *
+ * \code
+ * // parsedef for '<setup attr="13">value</setup>'
+ * ParseDef( "attr", MANDTAORY, xml::parseDefAssign( data.value )
+ * ( "attr", data.attr ) )
+ * \endcode
+ */
+ struct Consumer : public ParseDefConsume
+ {
+ /** Extend \ref Consumer. */
+ void add( const AssignerRef & assigner_r )
+ { _text.push_back( assigner_r ); }
+
+ /** Extend \ref Consumer. */
+ void add( const std::string & attr_r, const AssignerRef & assigner_r )
+ { _attr[attr_r].push_back( assigner_r ); }
+
+ /** Set pre notification callback. */
+ void prenotify( function<void ( const Node & )> pre_r )
+ { _pre = pre_r; }
+
+ /** Set post notification callback. */
+ void postnotify( function<void ( const Node & )> post_r )
+ { _post = post_r; }
+
+ virtual void start( const xml::Node & node_r )
+ {
+ if ( _pre )
+ _pre( node_r );
+
+ if ( ! _attr.empty() )
+ for_( it, _attr.begin(), _attr.end() )
+ assign( it->second, node_r.getAttribute( it->first.c_str() ).c_str() );
+ }
- /** \name ParseDefAssignText Convenience constructor.
- * \relates ParseDefAssignText
+ virtual void text( const xml::Node & node_r )
+ {
+ if ( ! _text.empty() )
+ assign( _text, node_r.value().c_str() );
+ }
+
+ virtual void done( const xml::Node & node_r )
+ {
+ if ( _post )
+ _post( node_r );
+ }
+
+ private:
+ void assign( const std::vector<AssignerRef> & vec_r, const char * value_r )
+ {
+ if ( value_r )
+ for_( it, vec_r.begin(), vec_r.end() )
+ (*it)->assign( value_r );
+ }
+
+ private:
+ std::tr1::unordered_map<std::string, std::vector<AssignerRef> > _attr;
+ std::vector<AssignerRef> _text;
+ function<void ( const Node & )> _pre;
+ function<void ( const Node & )> _post;
+ };
+
+ /** Helper class to build a \ref Consumer.
+ * \relates Consumer
+ *
+ * The class constructs the consumer, allows to extend it via
+ * \ref operator(), and provides a conversion to
+ * \c shared_ptr<ParseDefConsume>, so it can be passed as a
+ * node consumer to \ref ParseDef.
+ *
+ * You may also set a <tt>void( const Node & )</tt> notification
+ * callback which is invoked before/after the node was processed.
+ *
+ * \note Use and see \ref xml::parseDefAssign convenience constructor.
+ */
+ struct Builder
+ {
+ /** Contruct \ref Consumer. */
+ Builder()
+ : _ptr( new Consumer )
+ {}
+
+ /** Contruct \ref Consumer. */
+ template <class _Type>
+ Builder( _Type & value_r )
+ : _ptr( new Consumer )
+ { operator()( value_r ); }
+
+ /** Contruct \ref Consumer. */
+ template <class _Type>
+ Builder( const std::string & attr_r, _Type & value_r )
+ : _ptr( new Consumer )
+ { operator()( attr_r, value_r ); }
+
+ /** Extend \ref Consumer. */
+ template <class _Type>
+ Builder & operator()( _Type & value_r )
+ { _ptr->add( assigner( value_r ) ); return *this; }
+
+ /** Extend \ref Consumer. */
+ template <class _Type>
+ Builder & operator()( const std::string & attr_r, _Type & value_r )
+ { _ptr->add( attr_r, assigner( value_r ) ); return *this; }
+
+ /** Set pre notification callback. */
+ Builder & operator<<( function<void ( const Node & )> done_r )
+ { _ptr->prenotify( done_r ); return *this; }
+
+ /** Set post notification callback. */
+ Builder & operator>>( function<void ( const Node & )> done_r )
+ { _ptr->postnotify( done_r ); return *this; }
+
+ /** Type conversion so this can be passed as node consumer to \ref ParseDef. */
+ operator shared_ptr<ParseDefConsume> () const
+ { return _ptr; }
+
+ private:
+ shared_ptr<Consumer> _ptr;
+ };
+ /////////////////////////////////////////////////////////////////
+ } // namespace parse_def_assign
+ ///////////////////////////////////////////////////////////////////
+
+ /** \name \ref ParseDef consumer assigning \ref Node text and attribues values to variables.
+ * \relates parse_def_assign::Consumer
+ * \relates parse_def_assign::Builder
+ *
+ * This function allows convenient contruction of a \ref parse_def_assign::Consumer
+ * to be passed as \ref Node conssumer to \ref ParseDef. Simply list each attributes
+ * name together with the variable it's value should be assigned to. If the attribute
+ * name is omitted, the nodes text value gets assigned.
+ *
+ * Target variables can be of any type tsupported by \ref Assigner.
+ * Basically all types constructible from \c char*, or where a
+ * specialisation exists (e.g. numeric and bool).
*
- * This returns a \c shared_ptr<xml::ParseDefConsume> ready to be passed
- * to a \ref ParseDef node.
+ * \code
+ * void setupDone( const xml::Node & _node )
+ * { ... }
+ *
+ * // parsedef for '<setup attr="13">value</setup>'
+ * ParseDef( "attr", MANDTAORY,
+ * xml::parseDefAssign( data.value )
+ * ( "attr", data.attr )
+ * >> &setupDone );
+ * \endcode
+ *
+ * \see \ref xml::rnParse for more example.
*/
//@{
+ inline parse_def_assign::Builder parseDefAssign()
+ { return parse_def_assign::Builder(); }
+
template <class _Type>
- shared_ptr<xml::ParseDefConsume> parseDefAssignText( _Type & value_r )
- { return shared_ptr<xml::ParseDefConsume>( new ParseDefAssignText<_Type>( value_r ) ); }
+ inline parse_def_assign::Builder parseDefAssign( _Type & value_r )
+ { return parse_def_assign::Builder( value_r ); }
- template<class _Tp, _Tp _Initial>
- shared_ptr<xml::ParseDefConsume> parseDefAssignText( DefaultIntegral<_Tp,_Initial> & value_r )
- { return shared_ptr<xml::ParseDefConsume>( new ParseDefAssignText<_Tp>( value_r.get() ) ); }
+ template <class _Type>
+ inline parse_def_assign::Builder parseDefAssign( const std::string & attr_r, _Type & value_r )
+ { return parse_def_assign::Builder( attr_r, value_r ); }
//@}
- ///////////////////////////////////////////////////////////////////
-
-
/////////////////////////////////////////////////////////////////
} // namespace xml
///////////////////////////////////////////////////////////////////
diff --git a/zypp/parser/xml/Reader.cc b/zypp/parser/xml/Reader.cc
index c8e9fd0..5f7c155 100644
--- a/zypp/parser/xml/Reader.cc
+++ b/zypp/parser/xml/Reader.cc
@@ -90,6 +90,7 @@ namespace zypp
stream_r.path().asString().c_str(), "utf-8", XML_PARSE_PEDANTIC ) )
, _node( _reader )
{
+ MIL << "Start Parsing " << _stream << endl;
if ( ! _reader || ! stream_r.stream().good() )
ZYPP_THROW( Exception( "Bad input stream" ) );
// set error handler
@@ -111,6 +112,7 @@ namespace zypp
{
xmlFreeTextReader( _reader );
}
+ MIL << "Done Parsing " << _stream << endl;
}
XmlString Reader::nodeText()
@@ -127,7 +129,7 @@ namespace zypp
}
return XmlString();
}
-
+
///////////////////////////////////////////////////////////////////
//
// METHOD NAME : Reader::nextNode
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0
![](https://seccdn.libravatar.org/avatar/93f26b0fb87f4be0df994e56a8e31107.jpg?s=120&d=mm&r=g)
[zypp-commit] <libzypp> master : Protect Edition against construction with NULL pointer.
by Michael Andres 06 Feb '09
by Michael Andres 06 Feb '09
06 Feb '09
ref: refs/heads/master
commit 08c168c2d4c8ffd94d238c3bc79a050622d885c1
Author: Michael Andres <ma(a)suse.de>
Date: Fri Feb 6 00:20:23 2009 +0100
Protect Edition against construction with NULL pointer.
---
zypp/Edition.cc | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/zypp/Edition.cc b/zypp/Edition.cc
index ca66296..e3c3bb3 100644
--- a/zypp/Edition.cc
+++ b/zypp/Edition.cc
@@ -40,6 +40,13 @@ namespace zypp
: ret );
}
+ inline std::string makeevrstr( const char * version_r,
+ const char * release_r,
+ Edition::epoch_t epoch_r )
+ { return makeevrstr( std::string(version_r?version_r:""),
+ std::string(release_r?release_r:""),
+ epoch_r );
+ }
/////////////////////////////////////////////////////////////////
} // namespace
///////////////////////////////////////////////////////////////////
--
To unsubscribe, e-mail: zypp-commit+unsubscribe(a)opensuse.org
For additional commands, e-mail: zypp-commit+help(a)opensuse.org
1
0