Imported Upstream version 17.29.0 sandbox/jinwang.an/libzypp-17.29.0_20211227 upstream/17.29.0
authorJinWang An <jinwang.an@samsung.com>
Mon, 27 Dec 2021 00:31:41 +0000 (09:31 +0900)
committerJinWang An <jinwang.an@samsung.com>
Mon, 27 Dec 2021 00:31:41 +0000 (09:31 +0900)
410 files changed:
.gitignore
CMakeLists.txt
VERSION.cmake
devel/devel.ma/MaTest.cc
devel/devel.ma/NewPool.cc
devel/devel.ma/PluginTest.cc
doc/autoinclude/Plugins.doc
libzypp.spec.cmake
package/libzypp.changes
po/CMakeLists.txt
po/af.po
po/ar.po
po/be.po
po/bg.po
po/bn.po
po/bs.po
po/ca.po
po/cs.po
po/cy.po
po/da.po
po/de.po
po/el.po
po/en_GB.po
po/es.po
po/et.po
po/fa.po
po/fi.po
po/fr.po
po/gl.po
po/gu.po
po/he.po
po/hi.po
po/hr.po
po/hu.po
po/id.po
po/it.po
po/ja.po
po/ka.po
po/km.po
po/ko.po
po/ku.po
po/lt.po
po/mk.po
po/mr.po
po/nb.po
po/nl.po
po/nn.po
po/pa.po
po/pl.po
po/pt.po
po/pt_BR.po
po/ro.po
po/ru.po
po/si.po
po/sk.po
po/sl.po
po/sr.po
po/sv.po
po/ta.po
po/th.po
po/tr.po
po/uk.po
po/vi.po
po/wa.po
po/xh.po
po/zh_CN.po
po/zh_TW.po
po/zu.po
po/zypp.pot
tests/lib/TestSetup.h
tests/lib/WebServer.h
tests/media/CredentialFileReader_test.cc
tests/media/CredentialManager_test.cc
tests/media/MetaLinkParser_test.cc
tests/parser/HistoryLogReader_test.cc
tests/parser/inifile/inidict_test.cc
tests/parser/inifile/iniparser_test.cc
tests/zypp/GZStream_test.cc
tests/zypp/PluginFrame_test.cc
tests/zypp/ProgressData_test.cc
tests/zypp/PtrTypes_test.cc
tests/zypp/PurgeKernels_test.cc
tests/zypp/ResStatus_test.cc
tests/zypp/Url_test.cc
tests/zypp/ZChunk_test.cc
tests/zypp/base/Sysconfig_test.cc
tests/zyppng/media/EvDownloader_test.cc
tests/zyppng/media/NetworkRequestDispatcher_test.cc
tools/ScanTwHistory [new file with mode: 0755]
tools/zypp-NameReqPrv.cc
tools/zypp-rpm/main.cc
zypp-core/AutoDispose.h
zypp-core/CMakeLists.txt
zypp-core/KVMap [new file with mode: 0644]
zypp-core/OnMediaLocation [new file with mode: 0644]
zypp-core/base/DefaultIntegral [new file with mode: 0644]
zypp-core/base/DtorReset [new file with mode: 0644]
zypp-core/base/Exception.cc
zypp-core/base/Exception.h
zypp-core/base/GzStream [new file with mode: 0644]
zypp-core/base/InputStream [new file with mode: 0644]
zypp-core/base/ProvideNumericId [new file with mode: 0644]
zypp-core/base/SimpleStreambuf [new file with mode: 0644]
zypp-core/base/UserRequestException [new file with mode: 0644]
zypp-core/base/ZckStream [new file with mode: 0644]
zypp-core/base/defaultintegral.h [new file with mode: 0644]
zypp-core/base/dtorreset.h [new file with mode: 0644]
zypp-core/base/fXstream [new file with mode: 0644]
zypp-core/base/fxstream.h [new file with mode: 0644]
zypp-core/base/gzstream.cc [moved from zypp/base/GzStream.cc with 98% similarity]
zypp-core/base/gzstream.h [new file with mode: 0644]
zypp-core/base/inputstream.cc [moved from zypp/base/InputStream.cc with 96% similarity]
zypp-core/base/inputstream.h [new file with mode: 0644]
zypp-core/base/providenumericid.h [new file with mode: 0644]
zypp-core/base/simplestreambuf.h [new file with mode: 0644]
zypp-core/base/userrequestexception.cc [moved from zypp/base/UserRequestException.cc with 98% similarity]
zypp-core/base/userrequestexception.h [new file with mode: 0644]
zypp-core/base/zckstream.cc [moved from zypp/base/ZckStream.cc with 98% similarity]
zypp-core/base/zckstream.h [new file with mode: 0644]
zypp-core/fs/WatchFile [new file with mode: 0644]
zypp-core/fs/watchfile.h [new file with mode: 0644]
zypp-core/kvmap.h [new file with mode: 0644]
zypp-core/onmedialocation.cc [moved from zypp/OnMediaLocation.cc with 99% similarity]
zypp-core/onmedialocation.h [new file with mode: 0644]
zypp-core/parser/IniDict [new file with mode: 0644]
zypp-core/parser/IniParser [new file with mode: 0644]
zypp-core/parser/ParseException [new file with mode: 0644]
zypp-core/parser/Sysconfig [new file with mode: 0644]
zypp-core/parser/inidict.cc [moved from zypp/parser/IniDict.cc with 98% similarity]
zypp-core/parser/inidict.h [new file with mode: 0644]
zypp-core/parser/iniparser.cc [moved from zypp/parser/IniParser.cc with 94% similarity]
zypp-core/parser/iniparser.h [new file with mode: 0644]
zypp-core/parser/parseexception.cc [moved from zypp/parser/ParseException.cc with 96% similarity]
zypp-core/parser/parseexception.h [new file with mode: 0644]
zypp-core/parser/sysconfig.cc [moved from zypp/base/Sysconfig.cc with 91% similarity]
zypp-core/parser/sysconfig.h [new file with mode: 0644]
zypp-core/ui/ProgressData [new file with mode: 0644]
zypp-core/ui/progressdata.cc [moved from zypp/ProgressData.cc with 95% similarity]
zypp-core/ui/progressdata.h [new file with mode: 0644]
zypp-core/zyppng/async/AsyncOp [new file with mode: 0644]
zypp-core/zyppng/async/asyncop.h [new file with mode: 0644]
zypp-core/zyppng/io/asyncdatasource.h
zypp-core/zyppng/meta/FunctionTraits [new file with mode: 0644]
zypp-core/zyppng/meta/Functional [new file with mode: 0644]
zypp-core/zyppng/meta/TypeTraits [new file with mode: 0644]
zypp-core/zyppng/meta/function_traits.h [new file with mode: 0644]
zypp-core/zyppng/meta/functional.h [new file with mode: 0644]
zypp-core/zyppng/meta/type_traits.h [new file with mode: 0644]
zypp-core/zyppng/pipelines/AsyncResult [new file with mode: 0644]
zypp-core/zyppng/pipelines/Await [new file with mode: 0644]
zypp-core/zyppng/pipelines/Expected [new file with mode: 0644]
zypp-core/zyppng/pipelines/Lift [new file with mode: 0644]
zypp-core/zyppng/pipelines/MTry [new file with mode: 0644]
zypp-core/zyppng/pipelines/Redo [new file with mode: 0644]
zypp-core/zyppng/pipelines/Transform [new file with mode: 0644]
zypp-core/zyppng/pipelines/Wait [new file with mode: 0644]
zypp-core/zyppng/pipelines/asyncresult.h [new file with mode: 0644]
zypp-core/zyppng/pipelines/await.h [new file with mode: 0644]
zypp-core/zyppng/pipelines/expected.h [new file with mode: 0644]
zypp-core/zyppng/pipelines/lift.h [new file with mode: 0644]
zypp-core/zyppng/pipelines/mtry.h [new file with mode: 0644]
zypp-core/zyppng/pipelines/redo.h [new file with mode: 0644]
zypp-core/zyppng/pipelines/transform.h [new file with mode: 0644]
zypp-core/zyppng/pipelines/wait.h [new file with mode: 0644]
zypp-curl/CMakeLists.txt [new file with mode: 0644]
zypp-curl/CurlConfig [new file with mode: 0644]
zypp-curl/ProxyInfo [new file with mode: 0644]
zypp-curl/TransferSettings [moved from zypp/zyppng/media/network/TransferSettings with 100% similarity]
zypp-curl/auth/CurlAuthData [new file with mode: 0644]
zypp-curl/auth/curlauthdata.cc [new file with mode: 0644]
zypp-curl/auth/curlauthdata.h [new file with mode: 0644]
zypp-curl/curlconfig.cc [moved from zypp/media/CurlConfig.cc with 96% similarity]
zypp-curl/curlconfig.h [new file with mode: 0644]
zypp-curl/curlhelper.cc [moved from zypp/media/CurlHelper.cc with 72% similarity]
zypp-curl/ng/network/AuthData [moved from zypp/zyppng/media/network/AuthData with 100% similarity]
zypp-curl/ng/network/DownloadSpec [new file with mode: 0644]
zypp-curl/ng/network/Downloader [new file with mode: 0644]
zypp-curl/ng/network/MirrorControl [new file with mode: 0644]
zypp-curl/ng/network/NetworkRequestDispatcher [new file with mode: 0644]
zypp-curl/ng/network/NetworkRequestError [new file with mode: 0644]
zypp-curl/ng/network/Request [new file with mode: 0644]
zypp-curl/ng/network/TransferSettings [new file with mode: 0644]
zypp-curl/ng/network/authdata.h [moved from zypp/zyppng/media/network/authdata.h with 96% similarity]
zypp-curl/ng/network/downloader.cc [moved from zypp/zyppng/media/network/downloader.cc with 92% similarity]
zypp-curl/ng/network/downloader.h [moved from zypp/zyppng/media/network/downloader.h with 94% similarity]
zypp-curl/ng/network/downloadspec.cc [moved from zypp/zyppng/media/network/downloadspec.cc with 100% similarity]
zypp-curl/ng/network/downloadspec.h [moved from zypp/zyppng/media/network/downloadspec.h with 96% similarity]
zypp-curl/ng/network/mirrorcontrol.cc [moved from zypp/zyppng/media/network/mirrorcontrol.cc with 100% similarity]
zypp-curl/ng/network/networkrequestdispatcher.cc [moved from zypp/zyppng/media/network/networkrequestdispatcher.cc with 89% similarity]
zypp-curl/ng/network/networkrequestdispatcher.h [moved from zypp/zyppng/media/network/networkrequestdispatcher.h with 82% similarity]
zypp-curl/ng/network/networkrequesterror.cc [moved from zypp/zyppng/media/network/networkrequesterror.cc with 98% similarity]
zypp-curl/ng/network/networkrequesterror.h [moved from zypp/zyppng/media/network/networkrequesterror.h with 97% similarity]
zypp-curl/ng/network/private/downloader_p.h [moved from zypp/zyppng/media/network/private/downloader_p.h with 96% similarity]
zypp-curl/ng/network/private/downloaderstates/base_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/base_p.h with 90% similarity]
zypp-curl/ng/network/private/downloaderstates/basicdownloader_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/basicdownloader_p.cc with 96% similarity]
zypp-curl/ng/network/private/downloaderstates/basicdownloader_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/basicdownloader_p.h with 93% similarity]
zypp-curl/ng/network/private/downloaderstates/detectmeta_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/detectmeta_p.cc with 96% similarity]
zypp-curl/ng/network/private/downloaderstates/detectmeta_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/detectmeta_p.h with 91% similarity]
zypp-curl/ng/network/private/downloaderstates/final_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/final_p.cc with 87% similarity]
zypp-curl/ng/network/private/downloaderstates/final_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/final_p.h with 89% similarity]
zypp-curl/ng/network/private/downloaderstates/initial_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/initial_p.cc with 95% similarity]
zypp-curl/ng/network/private/downloaderstates/initial_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/initial_p.h with 93% similarity]
zypp-curl/ng/network/private/downloaderstates/metalink_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/metalink_p.cc with 95% similarity]
zypp-curl/ng/network/private/downloaderstates/metalink_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/metalink_p.h with 91% similarity]
zypp-curl/ng/network/private/downloaderstates/metalinkinfo_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/metalinkinfo_p.cc with 95% similarity]
zypp-curl/ng/network/private/downloaderstates/metalinkinfo_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/metalinkinfo_p.h with 92% similarity]
zypp-curl/ng/network/private/downloaderstates/mirrorhandling_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/mirrorhandling_p.cc with 95% similarity]
zypp-curl/ng/network/private/downloaderstates/mirrorhandling_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/mirrorhandling_p.h with 93% similarity]
zypp-curl/ng/network/private/downloaderstates/normal_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/normal_p.cc with 91% similarity]
zypp-curl/ng/network/private/downloaderstates/normal_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/normal_p.h with 90% similarity]
zypp-curl/ng/network/private/downloaderstates/preparemulti_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/preparemulti_p.cc with 96% similarity]
zypp-curl/ng/network/private/downloaderstates/preparemulti_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/preparemulti_p.h with 92% similarity]
zypp-curl/ng/network/private/downloaderstates/rangedownloader_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/rangedownloader_p.cc with 97% similarity]
zypp-curl/ng/network/private/downloaderstates/rangedownloader_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/rangedownloader_p.h with 95% similarity]
zypp-curl/ng/network/private/downloaderstates/zck_p.cc [moved from zypp/zyppng/media/network/private/downloaderstates/zck_p.cc with 98% similarity]
zypp-curl/ng/network/private/downloaderstates/zck_p.h [moved from zypp/zyppng/media/network/private/downloaderstates/zck_p.h with 94% similarity]
zypp-curl/ng/network/private/mediadebug_p.h [moved from zypp/zyppng/media/network/private/mediadebug_p.h with 98% similarity]
zypp-curl/ng/network/private/mirrorcontrol_p.h [moved from zypp/zyppng/media/network/private/mirrorcontrol_p.h with 93% similarity]
zypp-curl/ng/network/private/networkrequestdispatcher_p.h [moved from zypp/zyppng/media/network/private/networkrequestdispatcher_p.h with 92% similarity]
zypp-curl/ng/network/private/networkrequesterror_p.h [moved from zypp/zyppng/media/network/private/networkrequesterror_p.h with 96% similarity]
zypp-curl/ng/network/private/request_p.h [moved from zypp/zyppng/media/network/private/request_p.h with 97% similarity]
zypp-curl/ng/network/request.cc [moved from zypp/zyppng/media/network/request.cc with 97% similarity]
zypp-curl/ng/network/request.h [moved from zypp/zyppng/media/network/request.h with 98% similarity]
zypp-curl/ng/network/transfersettings.h [moved from zypp/zyppng/media/network/transfersettings.h with 95% similarity]
zypp-curl/parser/MediaBlockList [new file with mode: 0644]
zypp-curl/parser/MetaLinkParser [new file with mode: 0644]
zypp-curl/parser/mediablocklist.cc [moved from zypp/media/MediaBlockList.cc with 99% similarity]
zypp-curl/parser/mediablocklist.h [new file with mode: 0644]
zypp-curl/parser/metalinkparser.cc [moved from zypp/media/MetaLinkParser.cc with 98% similarity]
zypp-curl/parser/metalinkparser.h [new file with mode: 0644]
zypp-curl/private/curlhelper_p.h [new file with mode: 0644]
zypp-curl/proxyinfo.cc [moved from zypp/media/ProxyInfo.cc with 90% similarity]
zypp-curl/proxyinfo.h [new file with mode: 0644]
zypp-curl/proxyinfo/ProxyInfoLibproxy [new file with mode: 0644]
zypp-curl/proxyinfo/ProxyInfoSysconfig [new file with mode: 0644]
zypp-curl/proxyinfo/proxyinfoimpl.h [new file with mode: 0644]
zypp-curl/proxyinfo/proxyinfolibproxy.cc [moved from zypp/media/proxyinfo/ProxyInfoLibproxy.cc with 93% similarity]
zypp-curl/proxyinfo/proxyinfolibproxy.h [new file with mode: 0644]
zypp-curl/proxyinfo/proxyinfos.h [new file with mode: 0644]
zypp-curl/proxyinfo/proxyinfosysconfig.cc [moved from zypp/media/proxyinfo/ProxyInfoSysconfig.cc with 93% similarity]
zypp-curl/proxyinfo/proxyinfosysconfig.h [new file with mode: 0644]
zypp-curl/transfersettings.cc [moved from zypp/media/TransferSettings.cc with 83% similarity]
zypp-curl/transfersettings.h [new file with mode: 0644]
zypp-media/CMakeLists.txt [new file with mode: 0644]
zypp-media/MediaConfig [new file with mode: 0644]
zypp-media/MediaException [new file with mode: 0644]
zypp-media/Mount [new file with mode: 0644]
zypp-media/auth/AuthData [new file with mode: 0644]
zypp-media/auth/CredentialFileReader [new file with mode: 0644]
zypp-media/auth/CredentialManager [new file with mode: 0644]
zypp-media/auth/authdata.cc [new file with mode: 0644]
zypp-media/auth/authdata.h [new file with mode: 0644]
zypp-media/auth/credentialfilereader.cc [moved from zypp/media/CredentialFileReader.cc with 95% similarity]
zypp-media/auth/credentialfilereader.h [new file with mode: 0644]
zypp-media/auth/credentialmanager.cc [moved from zypp/media/CredentialManager.cc with 96% similarity]
zypp-media/auth/credentialmanager.h [new file with mode: 0644]
zypp-media/mediaconfig.cc [new file with mode: 0644]
zypp-media/mediaconfig.h [new file with mode: 0644]
zypp-media/mediaexception.cc [moved from zypp/media/MediaException.cc with 98% similarity]
zypp-media/mediaexception.h [new file with mode: 0644]
zypp-media/mount.cc [moved from zypp/media/Mount.cc with 99% similarity]
zypp-media/mount.h [new file with mode: 0644]
zypp.conf
zypp/APIConfig.h.in
zypp/Arch.cc
zypp/Arch.h
zypp/CMakeLists.txt
zypp/Callback.h
zypp/Capabilities.h
zypp/DiskUsageCounter.cc
zypp/Fetcher.cc
zypp/Fetcher.h
zypp/FileChecker.h
zypp/Glob.h
zypp/HistoryLogData.cc
zypp/KVMap.h
zypp/KeyRing.cc
zypp/Locks.h
zypp/MediaProducts.h
zypp/MediaSetAccess.cc
zypp/MediaSetAccess.h
zypp/OnMediaLocation.h
zypp/PluginScript.cc
zypp/PoolItem.cc
zypp/ProgressData.h
zypp/PublicKey.cc
zypp/PublicKey.h
zypp/PurgeKernels.cc
zypp/RepoInfo.cc
zypp/RepoManager.cc
zypp/RepoManager.h
zypp/ResStatus.h
zypp/Resolver.h
zypp/ServiceInfo.cc
zypp/Target.h
zypp/VendorAttr.cc
zypp/ZConfig.cc
zypp/ZConfig.h
zypp/ZYppCallbacks.h
zypp/ZYppCommitResult.h
zypp/base/Debug.h
zypp/base/DefaultIntegral.h
zypp/base/DtorReset.h
zypp/base/GzStream.h
zypp/base/InputStream.h
zypp/base/ProvideNumericId.h
zypp/base/SimpleStreambuf.h
zypp/base/Sysconfig.h
zypp/base/UserRequestException.h
zypp/base/WatchFile.h
zypp/base/ZckStream.h
zypp/base/fXstream.h
zypp/media/CredentialFileReader.h
zypp/media/CredentialManager.h
zypp/media/CurlConfig.h
zypp/media/CurlHelper.h [deleted file]
zypp/media/MediaBlockList.h
zypp/media/MediaCD.cc
zypp/media/MediaCIFS.cc
zypp/media/MediaCurl.cc
zypp/media/MediaCurl.h
zypp/media/MediaDISK.cc
zypp/media/MediaException.h
zypp/media/MediaHandler.cc
zypp/media/MediaHandler.h
zypp/media/MediaHandlerFactory.cc
zypp/media/MediaISO.cc
zypp/media/MediaManager.cc
zypp/media/MediaManager.h
zypp/media/MediaMultiCurl.cc
zypp/media/MediaMultiCurl.h
zypp/media/MediaNFS.cc
zypp/media/MediaNetworkCommonHandler.h
zypp/media/MediaUserAuth.cc [deleted file]
zypp/media/MediaUserAuth.h
zypp/media/MetaLinkParser.h
zypp/media/Mount.h
zypp/media/ProxyInfo.h
zypp/media/TransferSettings.h
zypp/media/UrlResolverPlugin.cc
zypp/media/ZsyncParser.h
zypp/media/proxyinfo/ProxyInfoImpl.h
zypp/media/proxyinfo/ProxyInfoLibproxy.h
zypp/media/proxyinfo/ProxyInfoSysconfig.h
zypp/media/proxyinfo/ProxyInfos.h
zypp/misc/CheckAccessDeleted.cc
zypp/misc/LoadTestcase.cc
zypp/misc/YamlTestcaseHelpers.h
zypp/parser/HistoryLogReader.cc
zypp/parser/HistoryLogReader.h
zypp/parser/IniDict.h
zypp/parser/IniParser.h
zypp/parser/ParseException.h
zypp/parser/ProductFileReader.h
zypp/parser/RepoFileReader.cc
zypp/parser/RepoFileReader.h
zypp/parser/RepoindexFileReader.cc
zypp/parser/RepoindexFileReader.h
zypp/parser/ServiceFileReader.cc
zypp/parser/ServiceFileReader.h
zypp/parser/susetags/ContentFileReader.cc
zypp/parser/susetags/ContentFileReader.h
zypp/parser/xml/ParseDef.cc
zypp/parser/xml/ParseDefConsume.h
zypp/parser/xml/Reader.h
zypp/parser/yum/RepomdFileReader.cc
zypp/parser/yum/RepomdFileReader.h
zypp/parser/yum/schema/common-inc.rnc
zypp/parser/yum/schema/common-inc.rng
zypp/repo/Downloader.h
zypp/repo/MediaInfoDownloader.cc
zypp/repo/MediaInfoDownloader.h
zypp/repo/PackageDelta.cc
zypp/repo/PackageDelta.h
zypp/repo/PackageProvider.cc
zypp/repo/PluginServices.cc
zypp/repo/PluginServices.h
zypp/repo/RepoException.h
zypp/repo/RepoMirrorList.cc
zypp/repo/RepoProvideFile.cc
zypp/repo/RepoProvideFile.h
zypp/repo/ServiceRepos.cc
zypp/repo/ServiceRepos.h
zypp/repo/susetags/Downloader.cc
zypp/repo/susetags/Downloader.h
zypp/repo/yum/Downloader.cc
zypp/repo/yum/Downloader.h
zypp/sat/LookupAttr.cc
zypp/sat/LookupAttr.h
zypp/sat/Solvable.cc
zypp/sat/SolvableSpec.h
zypp/sat/SolvableType.h
zypp/sat/Transaction.cc
zypp/sat/Transaction.h
zypp/sat/detail/PoolImpl.cc
zypp/solver/detail/SATResolver.cc
zypp/solver/detail/SATResolver.h
zypp/solver/detail/Testcase.cc
zypp/target/CommitPackageCacheReadAhead.h
zypp/target/RpmPostTransCollector.cc
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.commitFindFileConflicts.cc
zypp/target/modalias/Modalias.cc
zypp/target/rpm/BinHeader.cc
zypp/target/rpm/RpmDb.cc
zypp/zyppng/CMakeLists.txt
zypp/zyppng/context.cc
zypp/zyppng/media/medianetwork.cc
zypp/zyppng/media/medianetwork.h
zypp/zyppng/media/medianetworkserver.cc

index 0e3f220..c164043 100644 (file)
@@ -12,3 +12,4 @@ build
 *flymake.h.gch
 CMakeLists.txt.user*
 zypp/APIConfig.h
+.vscode
index 973687d..6638005 100644 (file)
@@ -33,10 +33,10 @@ IF (DEBIAN)
 ENDIF (DEBIAN)
 
 IF ( ENABLE_DEVEL_BUILD )
-       MESSAGE( WARNING "Zypp devel build enabled, do not do this in production" )
-       SET( ZYPP_RPM_BINARY "${CMAKE_BINARY_DIR}/tools/zypp-rpm/zypp-rpm")
+        MESSAGE( WARNING "Zypp devel build enabled, do not do this in production" )
+        SET( ZYPP_RPM_BINARY "${CMAKE_BINARY_DIR}/tools/zypp-rpm/zypp-rpm")
 ELSE()
-       SET( ZYPP_RPM_BINARY "${ZYPP_LIBEXEC_INSTALL_DIR}/zypp-rpm")
+        SET( ZYPP_RPM_BINARY "${ZYPP_LIBEXEC_INSTALL_DIR}/zypp-rpm")
 ENDIF( ENABLE_DEVEL_BUILD )
 
 message ( "Using zypp-rpm from path: ${ZYPP_RPM_BINARY}" )
@@ -152,8 +152,8 @@ ELSE ( NOT RPM_FOUND)
   endif()
 
   if( RPM_LIB_VER VERSION_GREATER_EQUAL "5.0.0" )
-       MESSAGE( STATUS "rpm found: enable rpm-4 compat interface." )
-       ADD_DEFINITIONS(-D_RPM_5)
+        MESSAGE( STATUS "rpm found: enable rpm-4 compat interface." )
+        ADD_DEFINITIONS(-D_RPM_5)
   endif ()
 
 ENDIF( NOT RPM_FOUND)
@@ -344,6 +344,8 @@ ENDIF ( ENABLE_PREVIEW_SINGLE_RPMTRANS_AS_DEFAULT_FOR_ZYPPER )
 ####################################################################
 ADD_SUBDIRECTORY( zypp-proto )
 ADD_SUBDIRECTORY( zypp-core )
+ADD_SUBDIRECTORY( zypp-media )
+ADD_SUBDIRECTORY( zypp-curl )
 ADD_SUBDIRECTORY( zypp )
 # do not build devel by default
 ADD_SUBDIRECTORY( devel EXCLUDE_FROM_ALL )
index f8bc58c..b597738 100644 (file)
@@ -60,9 +60,9 @@
 #
 SET(LIBZYPP_MAJOR "17")
 SET(LIBZYPP_COMPATMINOR "22")
-SET(LIBZYPP_MINOR "28")
-SET(LIBZYPP_PATCH "8")
+SET(LIBZYPP_MINOR "29")
+SET(LIBZYPP_PATCH "0")
 #
-# LAST RELEASED: 17.28.8 (22)
+# LAST RELEASED: 17.29.0 (22)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index 07cd432..a27c917 100644 (file)
@@ -9,8 +9,8 @@
 #include <zypp/base/Debug.h>
 #include <zypp/base/Functional.h>
 #include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/ProvideNumericId>
 #include <zypp/base/Flags.h>
 #include <zypp/AutoDispose.h>
 
index d87b2f1..65c3667 100644 (file)
@@ -9,8 +9,8 @@
 #include <zypp/base/Debug.h>
 #include <zypp/base/Functional.h>
 #include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/ProvideNumericId>
 #include <zypp/base/Flags.h>
 #include <zypp/base/StrMatcher.h>
 #include <zypp/AutoDispose.h>
index 15e8027..8ca1a71 100644 (file)
@@ -16,8 +16,8 @@
 #include <zypp/base/Debug.h>
 #include <zypp/base/Functional.h>
 #include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/ProvideNumericId>
 #include <zypp/base/Flags.h>
 #include <zypp/AutoDispose.h>
 
index 3fa17ab..6da44a9 100644 (file)
@@ -8,7 +8,7 @@
 <HR><!-- ====================================================================== -->
 \section plugins-intro Introduction
 
-Plugins allow to extend the ZYpp package manager without the need to change
+Plugins allow one to extend the ZYpp package manager without the need to change
 code. Plugins are designed as external programs so that they can be written in any language.
 
 \section plugin-protocols Plugin protocols
index 728b087..fa29dd1 100644 (file)
@@ -425,6 +425,10 @@ fi
 %{_datadir}/cmake/Modules/*
 %{_includedir}/zypp
 %{_includedir}/zypp-core
+%{_includedir}/zypp-media
+%{_includedir}/zypp-curl
+%{_libdir}/pkgconfig/libzypp.pc
+%{_libdir}/pkgconfig/libzypp.pc
 %{_libdir}/pkgconfig/libzypp.pc
 
 %files devel-doc
index da6121d..ad77c6d 100644 (file)
@@ -1,4 +1,17 @@
 -------------------------------------------------------------------
+Thu Dec 23 16:01:31 CET 2021 - ma@suse.de
+
+- Use the default zypp.conf settings if no zypp.conf exists
+  (bsc#1193488)
+- Fix wrong encoding of iso: URL components (bsc#954813)
+- Handle armv8l as armv7hl compatible userland.
+- Introduce zypp-curl a sublibrary for CURL related code.
+- zypp-rpm: Increase rpm loglevel if ZYPP_RPM_DEBUG is set.
+- Save all signatures associated with a public key in its
+  PublicKeyData.
+- version 17.29.0 (22)
+
+-------------------------------------------------------------------
 Thu Nov 11 15:12:44 CET 2021 - ma@suse.de
 
 - Disable logger in the child after fork (bsc#1192436)
@@ -4885,7 +4898,7 @@ Tue Mar 31 15:51:32 CEST 2009 - ma@suse.de
 Thu Mar 12 18:38:30 CET 2009 - ma@suse.de
 
 - Add Resolver::setSolveSrcPackages. Per default disable solving
-  of source package dependencies. We will later allow to enable
+  of source package dependencies. We will later allow enabling
   it per package.
 - version 6.3.0 (2)
 
@@ -5041,7 +5054,7 @@ Thu Jan 22 10:41:27 CET 2009 - ma@suse.de
 -------------------------------------------------------------------
 Fri Jan  9 17:01:10 CET 2009 - jkupec@suse.cz
 
-- handle HTTP 503 reponses as temporary errors (bnc #462545)
+- handle HTTP 503 responses as temporary errors (bnc #462545)
 
 -------------------------------------------------------------------
 Thu Dec 18 22:26:18 CET 2008 - ma@suse.de
@@ -6972,7 +6985,7 @@ Wed Apr  2 10:24:17 CEST 2008 - ma@suse.de
 -------------------------------------------------------------------
 Tue Apr  1 21:54:10 CEST 2008 - ma@suse.de
 
-- Extend sat::WhatProvides to allow to query for possible providers
+- Extend sat::WhatProvides allows one to query for possible providers
   of a collection of capabilies. E.g. all providers of a packages
   requirements.
 - Fixed retrieval of translated texts from .solv files, provided the
@@ -7065,7 +7078,7 @@ Fri Mar 14 17:28:39 CET 2008 - ma@suse.de
 Fri Mar 14 14:27:43 CET 2008 - dmacvicar@suse.de
 
 - look for openssl in cmake, actually we build require it
-- explicitely link against openssl and crypto, required to
+- explicitly link against openssl and crypto, required to
   compile in all platforms/distros.
 
 -------------------------------------------------------------------
@@ -11400,7 +11413,7 @@ Tue Apr  4 19:19:39 CEST 2006 - mt@suse.de
 
 - Added flag to MediaManager::isUseableAttachPoint, whether
   to check against system mount entries or not.
-- Disallow to use the attachpoints of another media handlers
+- Disallows one to use the attachpoints of another media handlers
   as source path in MediaDIR.
 - rev 2917
 
@@ -11523,7 +11536,7 @@ Fri Mar 31 16:34:51 CEST 2006 - mt@suse.de
 Fri Mar 31 13:27:09 CEST 2006 - mt@suse.de
 
 - Implemented several hal get/set/removeDeviceProperty wrappers
-- Improved HalException to allow to fetch HAL/DBUS error componets
+- Improved HalException allows one to fetch HAL/DBUS error componets
 - rev 2830
 
 -------------------------------------------------------------------
index a4ae085..8fb6492 100644 (file)
@@ -12,7 +12,7 @@ SET( XGETTEXT_OPTIONS ${XGETTEXT_OPTIONS} --copyright-holder=\"SuSE Linux GmbH,
 SET( XGETTEXT_OPTIONS ${XGETTEXT_OPTIONS} --package-name=${POT_NAME} --default-domain=${POT_NAME} )
 
 SET( _abs_POT_FILE_DEPENDS )
-SET( POT_FILE_DEPENDS ${POT_FILE_DEPENDS_ZYPP} ${POT_FILE_DEPENDS_ZYPP_CORE} )
+SET( POT_FILE_DEPENDS ${POT_FILE_DEPENDS_ZYPP} ${POT_FILE_DEPENDS_ZYPP_CORE} ${POT_FILE_DEPENDS_ZYPP_MEDIA} ${POT_FILE_DEPENDS_ZYPP_CURL} )
 FOREACH( _currentDepends ${POT_FILE_DEPENDS} )
   SET( _abs_POT_FILE_DEPENDS ${_abs_POT_FILE_DEPENDS} ${LIBZYPP_SOURCE_DIR}/${_currentDepends} )
 ENDFOREACH()
index 339c630..ce3fbcb 100644 (file)
--- a/po/af.po
+++ b/po/af.po
@@ -4545,7 +4545,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index f586df4..95a757b 100644 (file)
--- a/po/ar.po
+++ b/po/ar.po
@@ -4614,7 +4614,7 @@ msgstr "بتثبيت %1% على الرغم من أنه تم سحبه"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "تسمح بتثبيت  PTF %1%"
 
 #. translator: %1% is a package name
index d9d83ad..42400ca 100644 (file)
--- a/po/be.po
+++ b/po/be.po
@@ -4623,7 +4623,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 7de8330..d66bacc 100644 (file)
--- a/po/bg.po
+++ b/po/bg.po
@@ -4782,7 +4782,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index eb23ced..7fda4d2 100644 (file)
--- a/po/bn.po
+++ b/po/bn.po
@@ -4545,7 +4545,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 74442ff..44199e2 100644 (file)
--- a/po/bs.po
+++ b/po/bs.po
@@ -5036,7 +5036,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 66eb308..66d7520 100644 (file)
--- a/po/ca.po
+++ b/po/ca.po
@@ -5020,7 +5020,7 @@ msgstr "instal·la %1% tot i que ha estat retret"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "permet instal·lar el PTF %1%"
 
 #. translator: %1% is a package name
index 6405e1a..c73484b 100644 (file)
--- a/po/cs.po
+++ b/po/cs.po
@@ -4831,7 +4831,7 @@ msgstr "instalovat %1%, ačkoli byl odvolán"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "umožnit instalaci PTF %1%"
 
 #. translator: %1% is a package name
index 1fe7eb9..75b35b8 100644 (file)
--- a/po/cy.po
+++ b/po/cy.po
@@ -4839,7 +4839,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index bc403d3..1777076 100644 (file)
--- a/po/da.po
+++ b/po/da.po
@@ -4598,7 +4598,7 @@ msgstr "installér %1%, selvom den er blevet tilbagetrukket"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "giv tillade til installation af PTF'en %1%"
 
 #. translator: %1% is a package name
index 16f5143..51662da 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -4656,7 +4656,7 @@ msgstr "%1% installieren, obwohl es widerrufen wurde"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "Erlauben das PTF %1% zu installieren"
 
 #. translator: %1% is a package name
index a25ad52..00faab3 100644 (file)
--- a/po/el.po
+++ b/po/el.po
@@ -4606,7 +4606,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 9df3d49..7204999 100644 (file)
@@ -4558,7 +4558,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index b944392..ba90e83 100644 (file)
--- a/po/es.po
+++ b/po/es.po
@@ -4657,7 +4657,7 @@ msgstr "instalar %1% aunque se haya retraído"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "permitir la instalación de PTF %1%"
 
 #. translator: %1% is a package name
index fc68852..5a82e2e 100644 (file)
--- a/po/et.po
+++ b/po/et.po
@@ -4600,7 +4600,7 @@ msgstr "paigalda %1%, ehkki see on tagasi tõmmatud"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "lubage paigaldada PTF %1%"
 
 #. translator: %1% is a package name
index 420c32f..1be42af 100644 (file)
--- a/po/fa.po
+++ b/po/fa.po
@@ -4594,7 +4594,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 8a8642e..23bf2b8 100644 (file)
--- a/po/fi.po
+++ b/po/fi.po
@@ -4829,7 +4829,7 @@ msgstr "asenna %1%, vaikka se on vedetty takaisin"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "salli asentaa PTF %1%"
 
 #. translator: %1% is a package name
index a431024..2e4567f 100644 (file)
--- a/po/fr.po
+++ b/po/fr.po
@@ -4654,7 +4654,7 @@ msgstr "installer %1% bien qu'il ait été retiré"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "autoriser l'installation du PTF %1%"
 
 #. translator: %1% is a package name
index de09035..6b9efd8 100644 (file)
--- a/po/gl.po
+++ b/po/gl.po
@@ -4940,7 +4940,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "permitir a instalación de PTF %1%"
 
 #. translator: %1% is a package name
index 2eb8c27..985a3a5 100644 (file)
--- a/po/gu.po
+++ b/po/gu.po
@@ -4547,7 +4547,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 406e7b0..95d8f32 100644 (file)
--- a/po/he.po
+++ b/po/he.po
@@ -5023,7 +5023,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 9d7f6d5..a072bae 100644 (file)
--- a/po/hi.po
+++ b/po/hi.po
@@ -4548,7 +4548,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 97fc241..5ec7b5e 100644 (file)
--- a/po/hr.po
+++ b/po/hr.po
@@ -4679,7 +4679,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 3032930..bce941e 100644 (file)
--- a/po/hu.po
+++ b/po/hu.po
@@ -4890,7 +4890,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index ce1d131..46fcff5 100644 (file)
--- a/po/id.po
+++ b/po/id.po
@@ -5054,7 +5054,7 @@ msgstr "pasang %1% meskipun telah ditarik kembali"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "memungkinkan untuk memasang PTF %1%"
 
 #. translator: %1% is a package name
index 28a1ade..587faf3 100644 (file)
--- a/po/it.po
+++ b/po/it.po
@@ -4620,7 +4620,7 @@ msgstr "installare %1% anche se è stato ritirato"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "consentire installazione di PTF %1%"
 
 #. translator: %1% is a package name
index 5cbdbc7..bb19d5b 100644 (file)
--- a/po/ja.po
+++ b/po/ja.po
@@ -4629,7 +4629,7 @@ msgstr "撤回済みの %1% をインストールする"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "PTF %1% のインストールを許可する"
 
 #. translator: %1% is a package name
index 4fd869c..6fa3a5e 100644 (file)
--- a/po/ka.po
+++ b/po/ka.po
@@ -4526,7 +4526,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 081f8b1..5ac7e03 100644 (file)
--- a/po/km.po
+++ b/po/km.po
@@ -4548,7 +4548,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 3701659..7e16046 100644 (file)
--- a/po/ko.po
+++ b/po/ko.po
@@ -4788,7 +4788,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 6e44bb0..0ef5a1b 100644 (file)
--- a/po/ku.po
+++ b/po/ku.po
@@ -4614,7 +4614,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index bdfee24..2f0fa23 100644 (file)
--- a/po/lt.po
+++ b/po/lt.po
@@ -4700,7 +4700,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index efdbd51..9c4b0cd 100644 (file)
--- a/po/mk.po
+++ b/po/mk.po
@@ -4896,7 +4896,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 4a68727..1704a82 100644 (file)
--- a/po/mr.po
+++ b/po/mr.po
@@ -4546,7 +4546,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index b2b32d5..015dcfd 100644 (file)
--- a/po/nb.po
+++ b/po/nb.po
@@ -4690,7 +4690,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index c1251bd..55d3650 100644 (file)
--- a/po/nl.po
+++ b/po/nl.po
@@ -4641,7 +4641,7 @@ msgstr "%1% installeren hoewel het is ingetrokken"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "toestaan de PTF %1% te installeren"
 
 #. translator: %1% is a package name
index 351b5bf..3b7c2b3 100644 (file)
--- a/po/nn.po
+++ b/po/nn.po
@@ -4572,7 +4572,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index ff7b7e8..569bff4 100644 (file)
--- a/po/pa.po
+++ b/po/pa.po
@@ -4550,7 +4550,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index e174cab..6a5c773 100644 (file)
--- a/po/pl.po
+++ b/po/pl.po
@@ -4606,7 +4606,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index dea316a..f20593d 100644 (file)
--- a/po/pt.po
+++ b/po/pt.po
@@ -4774,7 +4774,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 06a4c7b..b23ed6b 100644 (file)
@@ -4631,7 +4631,7 @@ msgstr "instale %1% apesar de ter sido recolhido"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "permitir instalar o PTF %1%"
 
 #. translator: %1% is a package name
index a0c0c8c..0abd429 100644 (file)
--- a/po/ro.po
+++ b/po/ro.po
@@ -4583,7 +4583,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 66f5ff2..8b48613 100644 (file)
--- a/po/ru.po
+++ b/po/ru.po
@@ -4611,7 +4611,7 @@ msgstr "установить %1%, хоть он и был отозван"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "разрешить установку PTF %1%"
 
 #. translator: %1% is a package name
index 90ed97d..b3cdec6 100644 (file)
--- a/po/si.po
+++ b/po/si.po
@@ -4555,7 +4555,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 231ebe8..599579e 100644 (file)
--- a/po/sk.po
+++ b/po/sk.po
@@ -4624,7 +4624,7 @@ msgstr "inštalovať %1%, aj keď bol stiahnutý späť"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "umožniť inštaláciu PTF %1%"
 
 #. translator: %1% is a package name
index 3e196b2..0475191 100644 (file)
--- a/po/sl.po
+++ b/po/sl.po
@@ -5009,7 +5009,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 0b686d5..5de64a6 100644 (file)
--- a/po/sr.po
+++ b/po/sr.po
@@ -4653,7 +4653,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 53829af..de97767 100644 (file)
--- a/po/sv.po
+++ b/po/sv.po
@@ -4774,7 +4774,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 97bacd4..a3ec97e 100644 (file)
--- a/po/ta.po
+++ b/po/ta.po
@@ -4544,7 +4544,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 85015e4..3bc38ea 100644 (file)
--- a/po/th.po
+++ b/po/th.po
@@ -4661,7 +4661,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 5a53854..b542c9c 100644 (file)
--- a/po/tr.po
+++ b/po/tr.po
@@ -5233,7 +5233,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 83555cc..3d0948f 100644 (file)
--- a/po/uk.po
+++ b/po/uk.po
@@ -4791,7 +4791,7 @@ msgstr "встановити %1% хоч він і був відкладений"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "дозволити встановити PTF %1%"
 
 #. translator: %1% is a package name
index ff97321..6331197 100644 (file)
--- a/po/vi.po
+++ b/po/vi.po
@@ -4527,7 +4527,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 73eb2a0..5729de8 100644 (file)
--- a/po/wa.po
+++ b/po/wa.po
@@ -4570,7 +4570,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 6352ff9..374be59 100644 (file)
--- a/po/xh.po
+++ b/po/xh.po
@@ -4549,7 +4549,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 365f3c0..43ed2c2 100644 (file)
@@ -12,8 +12,8 @@ msgstr ""
 "Project-Id-Version: YaST (@memory@)\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2021-07-26 11:04+0200\n"
-"PO-Revision-Date: 2021-07-26 20:11+0000\n"
-"Last-Translator: Dingzhong Chen <wsxy162@gmail.com>\n"
+"PO-Revision-Date: 2021-11-30 09:11+0000\n"
+"Last-Translator: Hillwood Yang <hillwoodroc@gmail.com>\n"
 "Language-Team: Chinese (China) <https://l10n.opensuse.org/projects/libzypp/"
 "master/zh_CN/>\n"
 "Language: zh_CN\n"
@@ -21,7 +21,7 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 4.7.1\n"
+"X-Generator: Weblate 4.8.1\n"
 
 #: zypp/CountryCode.cc:50
 msgid "Unknown country: "
@@ -4186,7 +4186,7 @@ msgstr "软件源中没有 url。"
 #: zypp/repo/SUSEMediaVerifier.cc:104
 #, boost-format
 msgid "Expected medium %1%/%2% identified by file '%3%' with content:"
-msgstr ""
+msgstr "由'%3%' 文件标识的预期介质 %1%/%2% 内容为:"
 
 #. [lhs][rhs] 0 = installed; 1 = to be installed
 #. TranslatorExplanation %1%(filename) %2%(package1) %3%(package2)
@@ -4596,7 +4596,7 @@ msgstr "尽管 %1% 已收回,仍予以安装"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "允许安装 PTF %1%"
 
 #. translator: %1% is a package name
@@ -4630,6 +4630,8 @@ msgid ""
 "install %1% from vendor %2%\n"
 "  replacing %3% from vendor %4%"
 msgstr ""
+"由供应商 %2% 安装 %1% 代替\n"
+"由供应商 %4% 安装 %3%"
 
 #: zypp/solver/detail/SATResolver.cc:1507
 #, boost-format
@@ -4689,7 +4691,7 @@ msgstr "新更新消息"
 
 #: zypp/target/TargetImpl.cc:2619
 msgid "Executing the transaction failed because of the following problems:"
-msgstr ""
+msgstr "由于以下问题执行操作失败:"
 
 #. TranslatorExplanation after semicolon is error message
 #. TranslatorExplanation the colon is followed by an error message
@@ -4958,11 +4960,11 @@ msgstr "命令退出,未知错误。"
 #: zypp-core/zyppng/io/forkspawnengine.cc:111
 #: zypp-core/zyppng/io/forkspawnengine.cc:359
 msgid "Invalid spawn arguments given."
-msgstr ""
+msgstr "子参数无效。"
 
 #: zypp-core/zyppng/io/forkspawnengine.cc:174
 msgid "Unable to create control pipe."
-msgstr ""
+msgstr "无法创建控制管道。"
 
 #: zypp-core/zyppng/io/forkspawnengine.cc:240
 #, c-format, boost-format
@@ -4994,22 +4996,22 @@ msgstr "无法派生 (%s)。"
 #: zypp-core/zyppng/io/forkspawnengine.cc:306
 #, c-format, boost-format
 msgid "Can't exec '%s', chdir failed (%s)."
-msgstr ""
+msgstr "无法执行 '%s',chdir 失败 (%s) 。"
 
 #: zypp-core/zyppng/io/forkspawnengine.cc:309
 #, c-format, boost-format
 msgid "Can't exec '%s', chroot failed (%s)."
-msgstr ""
+msgstr "无法执行  '%s',chroot 失败 (%s)。"
 
 #: zypp-core/zyppng/io/forkspawnengine.cc:312
 #, c-format, boost-format
 msgid "Can't exec '%s', exec failed (%s)."
-msgstr ""
+msgstr "无法执行 '%s',执行失败 (%s)。"
 
 #: zypp-core/zyppng/io/forkspawnengine.cc:316
 #, c-format, boost-format
 msgid "Can't exec '%s', unexpected error."
-msgstr ""
+msgstr "无法执行 '%s',意外错误。"
 
 #~ msgid "%s does not belong to a distupgrade repository"
 #~ msgstr "%s 不属于发行版升级源"
index 5ce7a29..20a4265 100644 (file)
@@ -4587,7 +4587,7 @@ msgstr "儘管 %1% 已收回,仍予以安裝"
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr "允許安裝 PTF %1%"
 
 #. translator: %1% is a package name
index 4dc13eb..3dbbb62 100644 (file)
--- a/po/zu.po
+++ b/po/zu.po
@@ -4551,7 +4551,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 81211a9..7cb2f3d 100644 (file)
@@ -4496,7 +4496,7 @@ msgstr ""
 #. translator: %1% is a package name
 #: zypp/solver/detail/SATResolver.cc:1452
 #, boost-format
-msgid "allow to install the PTF %1%"
+msgid "allow installing the PTF %1%"
 msgstr ""
 
 #. translator: %1% is a package name
index 79e92e6..bf20355 100644 (file)
@@ -9,7 +9,7 @@ using boost::unit_test::test_case;
 
 #include <zypp/base/LogControl.h>
 #include <zypp/base/LogTools.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/base/IOStream.h>
 #include <zypp/base/Flags.h>
 #include <zypp/ZYppFactory.h>
index 12cbd0b..7509da9 100644 (file)
@@ -5,7 +5,7 @@
 #include <zypp/Url.h>
 #include <zypp/Pathname.h>
 #include <zypp/base/PtrTypes.h>
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/TransferSettings>
 
 #include <functional>
 
index 0902361..76c568d 100644 (file)
@@ -5,9 +5,9 @@
 #include <zypp/Url.h>
 #include <zypp/PathInfo.h>
 #include <zypp/base/Easy.h>
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-media/auth/AuthData>
 
-#include <zypp/media/CredentialFileReader.h>
+#include <zypp-media/auth/CredentialFileReader>
 
 using std::cout;
 using std::endl;
index db12233..094c79d 100644 (file)
@@ -3,8 +3,8 @@
 
 #include <zypp/Url.h>
 #include <zypp/TmpPath.h>
-#include <zypp/media/CredentialFileReader.cc>
-#include <zypp/media/CredentialManager.h>
+#include <zypp-media/auth/CredentialFileReader>
+#include <zypp-media/auth/CredentialManager>
 
 #include <zypp/PathInfo.h>
 
index 3e481e5..703aa70 100644 (file)
@@ -2,7 +2,7 @@
 #include <vector>
 #include <boost/test/unit_test.hpp>
 
-#include <zypp/media/MetaLinkParser.h>
+#include <zypp-curl/parser/MetaLinkParser>
 
 using namespace zypp;
 using namespace zypp::media;
index 231313e..e0eb53f 100644 (file)
@@ -1,6 +1,6 @@
 #include "TestSetup.h"
 #include <zypp/parser/HistoryLogReader.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
 
 using namespace zypp;
 
index 861b7ef..0f67687 100644 (file)
@@ -6,8 +6,8 @@
 #include <boost/test/unit_test.hpp>
 
 #include <zypp/base/Logger.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/parser/IniDict>
 #include <zypp/Url.h>
 #include <zypp/PathInfo.h>
 
index aa96412..0039478 100644 (file)
@@ -6,8 +6,8 @@
 #include <boost/test/unit_test.hpp>
 
 #include <zypp/base/Logger.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/parser/IniParser.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/parser/IniParser>
 #include <zypp/Url.h>
 #include <zypp/PathInfo.h>
 
index 8c18ce6..0f33b88 100644 (file)
@@ -1,9 +1,9 @@
 // Boost.Test
 #include <boost/test/unit_test.hpp>
 
-#include <zypp/base/GzStream.h>
+#include <zypp-core/base/GzStream>
 #include <zypp/Pathname.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 
 BOOST_AUTO_TEST_CASE(gz_simple_read_write)
 {
index c4ee400..0d565b4 100644 (file)
@@ -114,7 +114,7 @@ BOOST_AUTO_TEST_CASE(PluginScriptTest)
   scr.open( "/bin/cat" );
   BOOST_CHECK_EQUAL( scr.isOpen(), true );
   BOOST_CHECK_EQUAL( (scr.getPid() != PluginScript::NotConnected ), true );
-  BOOST_CHECK_EQUAL( scr.script(), "/bin/cat" );                       // set after successfull open
+  BOOST_CHECK_EQUAL( scr.script(), "/bin/cat" );                       // set after successful open
 
   BOOST_CHECK_THROW( scr.open( "/bin/ls" ), PluginScriptException );   // already open
   BOOST_CHECK_EQUAL( scr.isOpen(), true );                             // stay with "/bin/cat"
index 251cd41..ee0f795 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <boost/test/unit_test.hpp>
 
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 
 using boost::unit_test::test_case;
 
index c7bc7fa..dfae8c2 100644 (file)
@@ -5,7 +5,7 @@
 #include <zypp/base/Logger.h>
 #include <zypp/base/PtrTypes.h>
 #include <zypp/base/ReferenceCounted.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/ProvideNumericId>
 
 #define BOOST_TEST_MODULE PtrTypes
 
index a6b7e3a..4f6c0a1 100644 (file)
@@ -180,7 +180,7 @@ namespace  {
         }
       },
       TestSample {
-        //kernel-1-2 is explicitely in the keep spec, it should not be removed
+        //kernel-1-2 is explicitly in the keep spec, it should not be removed
         //kernel-1-5 provides a symbol for a kmp that has a non kernel package depending on it, it should not be removed
         TESTS_SRC_DIR"/zypp/data/PurgeKernels/withdeps",
         "1-1-default",
index 9489bbf..00343a1 100644 (file)
@@ -145,8 +145,8 @@ void testTable( Transition transition, Evaluate evaluate )
 // All tests below should define 3 checks, abbrev. by defines
 //
 //    CHECK_DONE_*:         When does the tranaction succeed? (return if not)
-//    CHECK_STATE( NEXT ):  The state the transition leads to (if successfull)
-//    CHECK_CAUSER_*:       Changes to the remembered causer (if successfull)
+//    CHECK_STATE( NEXT ):  The state the transition leads to (if successful)
+//    CHECK_CAUSER_*:       Changes to the remembered causer (if successful)
 //
 
 #define DOCHECK( FROMSTATE, TOSTATE, C_DONE, C_STATE, C_CAUSER ) \
index 914d06e..00ee9eb 100644 (file)
@@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(test_url1)
 
     BOOST_CHECK_EQUAL( one, url.asString() );
     BOOST_CHECK_EQUAL( two, url.asCompleteString() );
-    // hidden proxypass in the query is available when explicitely asked for
+    // hidden proxypass in the query is available when explicitly asked for
     BOOST_CHECK_EQUAL( url.getQueryParam( "proxypass" ), "@PROXYPASS@" );
 
     // absolute path defaults to 'file://'
index 573e4d3..7789f82 100644 (file)
@@ -1,9 +1,9 @@
 // Boost.Test
 #include <boost/test/unit_test.hpp>
 
-#include <zypp/base/ZckStream.h>
+#include <zypp-core/base/ZckStream>
 #include <zypp/Pathname.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/PathInfo.h>
 
 BOOST_AUTO_TEST_CASE(zchunk_simple_read_write)
index 705c8d5..f934555 100644 (file)
@@ -13,7 +13,7 @@
 #include <zypp/PathInfo.h>
 #include <zypp/ExternalProgram.h>
 
-#include <zypp/base/Sysconfig.h>
+#include <zypp-core/parser/Sysconfig>
 
 using boost::unit_test::test_suite;
 using boost::unit_test::test_case;
index 2f335b2..d24131b 100644 (file)
@@ -1,11 +1,11 @@
 #include <zypp-core/zyppng/base/EventLoop>
 #include <zypp-core/zyppng/base/EventDispatcher>
-#include <zypp/zyppng/media/network/downloader.h>
-#include <zypp/zyppng/media/network/downloadspec.h>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/media/CredentialManager.h>
+#include <zypp-curl/ng/network/Downloader>
+#include <zypp-curl/ng/network/DownloadSpec>
+#include <zypp-curl/ng/network/NetworkRequestError>
+#include <zypp-curl/ng/network/NetworkRequestDispatcher>
+#include <zypp-curl/ng/network/Request>
+#include <zypp-media/auth/CredentialManager>
 #include <zypp/Digest.h>
 #include <zypp/TmpPath.h>
 #include <zypp/PathInfo.h>
@@ -43,6 +43,7 @@ BOOST_DATA_TEST_CASE( dltest_basic, bdata::make( withSSL ), withSSL)
   auto ev = zyppng::EventLoop::create();
 
   zyppng::Downloader::Ptr downloader = std::make_shared<zyppng::Downloader>();
+  downloader->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
 
   //make sure the data here is big enough to cross the threshold of 256 bytes so we get a progress signal emitted and not only the alive signal.
   std::string dummyContent = "This is just some dummy content,\nto test downloading and signals.\n"
@@ -371,6 +372,7 @@ BOOST_DATA_TEST_CASE( test1, bdata::make( generateMirr() ) * bdata::make( withSS
 
   zypp::filesystem::TmpFile targetFile;
   std::shared_ptr<zyppng::Downloader> downloader = std::make_shared<zyppng::Downloader>();
+  downloader->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
   downloader->requestDispatcher()->setMaximumConcurrentConnections( maxDLs );
 
   //first metalink download, generate a fully valid one
@@ -537,6 +539,7 @@ BOOST_DATA_TEST_CASE( dltest_auth, bdata::make( withSSL ), withSSL )
   auto ev = zyppng::EventLoop::create();
 
   std::shared_ptr<zyppng::Downloader> downloader = std::make_shared<zyppng::Downloader>();
+  downloader->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
 
   WebServer web((zypp::Pathname(TESTS_SRC_DIR)/"/zyppng/data/downloader").c_str(), 10001, withSSL );
   BOOST_REQUIRE( web.start() );
@@ -651,6 +654,7 @@ BOOST_DATA_TEST_CASE( dltest_auth_basic, bdata::make( withSSL ), withSSL )
   auto ev = zyppng::EventLoop::create();
 
   std::shared_ptr<zyppng::Downloader> downloader = std::make_shared<zyppng::Downloader>();
+  downloader->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
 
   WebServer web((zypp::Pathname(TESTS_SRC_DIR)/"/zyppng/data/downloader").c_str(), 10001, withSSL );
   BOOST_REQUIRE( web.start() );
@@ -674,7 +678,7 @@ BOOST_DATA_TEST_CASE( dltest_auth_basic, bdata::make( withSSL ), withSSL )
   web.addRequestHandler( "quit", [ &ev ]( WebServer::Request & ){ ev->quit();} );
 
   {
-    // simply check by request count if the test was successfull:
+    // simply check by request count if the test was successful:
     // if the proactive code adding the credentials to the first request is not executed we will
     // have more than 1 request.
     int reqCount = 0;
index ca57c39..d101b74 100644 (file)
@@ -1,10 +1,10 @@
 #include <boost/test/unit_test.hpp>
 #include <boost/test/data/test_case.hpp>
 #include <zypp-core/zyppng/base/EventLoop>
-#include <zypp/media/MetaLinkParser.h> // for hexstr2bytes
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
+#include <zypp-curl/parser/MetaLinkParser> // for hexstr2bytes
+#include <zypp-curl/ng/network/Request>
+#include <zypp-curl/ng/network/NetworkRequestDispatcher>
+#include <zypp-curl/ng/network/NetworkRequestError>
 #include <zypp/TmpPath.h>
 #include <zypp/base/String.h>
 #include <zypp/Digest.h>
diff --git a/tools/ScanTwHistory b/tools/ScanTwHistory
new file mode 100755 (executable)
index 0000000..0a7b6df
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/env python3
+
+import urllib3
+import sys
+import re
+
+p = re.compile('.*debuginfo.*')
+
+http = urllib3.PoolManager()
+r = http.request('GET', 'http://download.opensuse.org/history/list')
+if ( r.status != 200 ):
+  print("Failed to download history list\n")
+  sys.exit(1)
+
+html = r.data.decode("utf-8")
+list = html.split("\n")  
+
+for i in list:
+  if ( len(i) == 0 ):
+    continue
+  print ( "Searching for history in: "+i )
+  rEntries = http.request('GET', "http://download.opensuse.org/history/"+i.strip()+"/rpm.list", preload_content=False )
+  if ( rEntries.status != 200 ):
+    print("Failed to download history database for "+i+"\n")
+    continue
+  
+  for line in rEntries:
+    if ( p.search( line.decode() ) ):
+       print("Found match: "+line.decode()+" in: "+"http://download.opensuse.org/history/"+i.strip() )
+
+
+print("Done")
\ No newline at end of file
index c0b5e3f..6a9a6bc 100644 (file)
@@ -126,8 +126,8 @@ struct Table
     #define fmtREPO "(%2d)%-*s"
     #define argREPO slv.repository().info().priority(), _maxREPO, slv.repository().name().c_str()
 
-    #define fmtTIME "%10ld"
-    #define argTIME time_t( slv.isSystem() ? slv.installtime() : slv.buildtime() )
+    #define fmtTIME "%s%10ld"
+    #define argTIME  ( slv.isSystem() && slv.installtime() ? "i" : "b" ), time_t( slv.isSystem() && slv.installtime() ? slv.installtime() : slv.buildtime() )
 
     #define fmtVEND "%s"
     #define argVEND slv.vendor().c_str()
@@ -279,6 +279,7 @@ int main( int argc, char * argv[] )
 
   ///////////////////////////////////////////////////////////////////
 
+  auto _ { getZYpp() };
   ZConfig::instance();
   Pathname sysRoot("/");
   sat::Pool satpool( sat::Pool::instance() );
index 50a4574..0ce4cb1 100644 (file)
@@ -29,6 +29,22 @@ extern "C"
 #include <signal.h>
 #include <unistd.h>
 
+// Messages to the zypp log sent on stdout/stderr
+#define ZDBG std::cout
+#define ZERR std::cerr
+
+namespace env
+{
+  /// Allows to increase rpm loglevel
+  inline bool ZYPP_RPM_DEBUG()
+  {
+    static bool val = [](){
+      const char * env = getenv("ZYPP_RPM_DEBUG");
+      return( env && zypp::str::strToBool( env, true ) );
+    }();
+    return val;
+  }
+} // namespace env
 
 // this is the order we expect the FDs we need to communicate to be set up
 // by the parent. This is not pretty but it works and is less effort than
@@ -73,7 +89,7 @@ bool recvBytes ( int fd, char *buf, size_t n ) {
 }
 
 bool sendBytes ( int fd, const void *buf, size_t n ) {
-  const auto written =  zyppng::eintrSafeCall( ::write, fd, buf, n );
+  const size_t written =  zyppng::eintrSafeCall( ::write, fd, buf, n );
   return written == n;
 }
 
@@ -118,14 +134,14 @@ std::pair<RpmHeader, int> readPackage( rpmts ts_r, const zypp::filesystem::Pathn
 {
   zypp::PathInfo file( path_r );
   if ( ! file.isFile() ) {
-    std::cerr << "Not a file: " << path_r << std::endl;
+    ZERR << "Not a file: " << path_r << std::endl;
     return std::make_pair( RpmHeader(), -1 );
   }
 
   FD_t fd = ::Fopen( path_r.c_str(), "r.ufdio" );
   if ( fd == 0  || ::Ferror(fd) )
   {
-    std::cerr << "Can't open file for reading: " << path_r << " (" << ::Fstrerror(fd) << ")" << std::endl;
+    ZERR << "Can't open file for reading: " << path_r << " (" << ::Fstrerror(fd) << ")" << std::endl;
     if ( fd )
       ::Fclose( fd );
     return std::make_pair( RpmHeader(), -1 );
@@ -137,7 +153,7 @@ std::pair<RpmHeader, int> readPackage( rpmts ts_r, const zypp::filesystem::Pathn
 
   if ( ! nh )
   {
-    std::cerr << "Error reading header from " << path_r << " error(" << res << ")" << std::endl;
+    ZERR << "Error reading header from " << path_r << " error(" << res << ")" << std::endl;
     return std::make_pair( RpmHeader(), res );
   }
 
@@ -161,27 +177,27 @@ int main( int, char ** )
 
   // check if our env is set up correctly
   if ( ::isatty(STDIN_FILENO) || ::isatty(STDOUT_FILENO) || ::isatty(STDERR_FILENO) ) {
-    std::cerr << "Running zypp-rpm directly from the console is not supported. This is just a internal helper tool for libzypp." << std::endl;
+    ZERR << "Running zypp-rpm directly from the console is not supported. This is just a internal helper tool for libzypp." << std::endl;
     return OtherError;
   }
 
   // make sure the expected FDs are around too
   struct stat sb;
   if ( fstat( static_cast<int>(ExpectedFds::MessageFd), &sb) == -1 ) {
-    std::cerr << "Expected message fd is not valid, aborting" << std::endl;
+    ZERR << "Expected message fd is not valid, aborting" << std::endl;
     return OtherError;
   }
   if ( (sb.st_mode & S_IFMT) != S_IFIFO ){
-    std::cerr << "Expected message fd is not a pipe, aborting" << std::endl;
+    ZERR << "Expected message fd is not a pipe, aborting" << std::endl;
     return OtherError;
   }
 
   if ( fstat( static_cast<int>(ExpectedFds::ScriptFd), &sb) == -1 ) {
-    std::cerr << "Expected script fd is not valid, aborting" << std::endl;
+    ZERR << "Expected script fd is not valid, aborting" << std::endl;
     return OtherError;
   }
   if ( (sb.st_mode & S_IFMT) != S_IFIFO ){
-    std::cerr << "Expected script fd is not a pipe, aborting" << std::endl;
+    ZERR << "Expected script fd is not a pipe, aborting" << std::endl;
     return OtherError;
   }
 
@@ -192,7 +208,7 @@ int main( int, char ** )
   // lets read our todo from stdin
   zyppng::rpc::HeaderSizeType msgSize = 0;
   if ( !recvBytes( STDIN_FILENO, reinterpret_cast<char *>(&msgSize), sizeof(zyppng::rpc::HeaderSizeType) ) ) {
-    std::cerr << "Wrong Header size, aborting" << std::endl;
+    ZERR << "Wrong Header size, aborting" << std::endl;
     return WrongHeaderSize;
   }
 
@@ -202,7 +218,7 @@ int main( int, char ** )
   {
     zyppng::FileInputStream in( STDIN_FILENO );
     if ( !msg.ParseFromBoundedZeroCopyStream( &in, msgSize ) ) {
-      std::cerr << "Wrong commit message format, aborting" << std::endl;
+      ZERR << "Wrong commit message format, aborting" << std::endl;
       return WrongMessageFormat;
     }
 
@@ -212,7 +228,7 @@ int main( int, char ** )
   // first we initialize the rpmdb
   int rc = ::rpmReadConfigFiles( NULL, NULL );
   if ( rc ) {
-    std::cerr << "rpmReadConfigFiles returned " << rc << std::endl;
+    ZERR << "rpmReadConfigFiles returned " << rc << std::endl;
     return RpmInitFailed;
   }
 
@@ -263,7 +279,7 @@ int main( int, char ** )
   if ( rpmtsGetRdb(ts) == NULL ) {
     int res = ::rpmtsOpenDB( ts, O_RDWR );
     if ( res ) {
-      std::cerr << "rpmdbOpen error(" << res << "): " << std::endl;
+      ZERR << "rpmdbOpen error(" << res << "): " << std::endl;
       return FailedToOpenDb;
     }
   }
@@ -286,36 +302,36 @@ int main( int, char ** )
         case RPMRC_OK:
           break;
         case RPMRC_NOTTRUSTED:
-          std::cerr << zypp::str::Format( "Failed to verify key for %s" ) % file << std::endl;
+          ZERR << zypp::str::Format( "Failed to verify key for %s" ) % file << std::endl;
           if ( !allowUntrusted )
             return FailedToReadPackage;
           break;
         case RPMRC_NOKEY:
-          std::cerr << zypp::str::Format( "Public key unavailable for %s" ) % file << std::endl;
+          ZERR << zypp::str::Format( "Public key unavailable for %s" ) % file << std::endl;
           if ( !allowUntrusted )
             return FailedToReadPackage;
           break;
         case RPMRC_NOTFOUND:
-          std::cerr << zypp::str::Format( "Signature not found for %s" ) % file << std::endl;
+          ZERR << zypp::str::Format( "Signature not found for %s" ) % file << std::endl;
           if ( !allowUntrusted )
             return FailedToReadPackage;
           break;
         case RPMRC_FAIL:
-          std::cerr << zypp::str::Format( "Signature does not verify for %s" ) % file << std::endl;
+          ZERR << zypp::str::Format( "Signature does not verify for %s" ) % file << std::endl;
           return FailedToReadPackage;
         default:
-          std::cerr << zypp::str::Format( "Failed to open(generic error): %1%" ) % file << std::endl;
+          ZERR << zypp::str::Format( "Failed to open(generic error): %1%" ) % file << std::endl;
           return FailedToReadPackage;
       }
 
       if ( !rpmHeader.first ) {
-        std::cerr << zypp::str::Format( "Failed to read rpm header from: %1%" )% file << std::endl;
+        ZERR << zypp::str::Format( "Failed to read rpm header from: %1%" )% file << std::endl;
         return FailedToReadPackage;
       }
 
       const auto res = ::rpmtsAddInstallElement( ts, rpmHeader.first.get(), &step, !step.install().multiversion(), nullptr  );
       if ( res ) {
-        std::cerr << zypp::str::Format( "Failed to add %1% to the transaction." )% file << std::endl;
+        ZERR << zypp::str::Format( "Failed to add %1% to the transaction." )% file << std::endl;
         return FailedToAddStepToTransaction;
       }
 
@@ -339,7 +355,7 @@ int main( int, char ** )
 
           const auto res = ::rpmtsAddEraseElement( ts, hdr.get(), 0  );
           if ( res ) {
-            std::cerr << zypp::str::Format( "Failed to add removal of %1% to the transaction." ) % name << std::endl;
+            ZERR << zypp::str::Format( "Failed to add removal of %1% to the transaction." ) % name << std::endl;
             return FailedToAddStepToTransaction;
           }
 
@@ -349,11 +365,11 @@ int main( int, char ** )
       }
 
       if ( !found ) {
-        std::cerr << "Unable to remove " << name << " it was not found!" << std::endl;
+        ZERR << "Unable to remove " << name << " it was not found!" << std::endl;
       }
 
     } else {
-      std::cerr << "Ignoring step that is neither a remove, nor a install." << std::endl;
+      ZERR << "Ignoring step that is neither a remove, nor a install." << std::endl;
     }
 
   }
@@ -362,7 +378,7 @@ int main( int, char ** )
   ::rpmtsSetNotifyCallback( ts, rpmLibCallback, &data );
 
   // make sure we get da log
-  ::rpmlogSetMask( RPMLOG_UPTO( RPMLOG_PRI(RPMLOG_INFO) ) );
+  ::rpmlogSetMask( RPMLOG_UPTO( RPMLOG_PRI(env::ZYPP_RPM_DEBUG() ? RPMLOG_DEBUG : RPMLOG_INFO) ) );
   ::rpmlogSetCallback( rpmLogCallback, nullptr );
 
   // redirect the script output to a fd ( log level MUST be at least INFO )
@@ -372,10 +388,10 @@ int main( int, char ** )
   );
 
   if ( data.rpmFd.value() ) {
-    std::cerr << "Assigning script FD" << std::endl;
+    //ZDBG << "Assigning script FD" << std::endl;
     ::rpmtsSetScriptFd( ts,  data.rpmFd );
   } else {
-    std::cerr << "Failed to assign script FD" << std::endl;
+    ZERR << "Failed to assign script FD" << std::endl;
   }
 
 
@@ -407,7 +423,7 @@ int main( int, char ** )
       const auto &rpmMsg = sstr.str();
 
       // TranslatorExplanation the colon is followed by an error message
-      std::cerr << std::string("RPM failed: ") + rpmMsg << std::endl;
+      ZERR << std::string("RPM failed: ") + rpmMsg << std::endl;
       return RpmFinishedWithTransactionError;
     }
   }
@@ -437,7 +453,7 @@ int main( int, char ** )
 
   const auto orderRes = rpmtsOrder( ts );
   if ( orderRes ) {
-    std::cerr << zypp::str::Format( "Failed with error %1% while ordering transaction." )% orderRes << std::endl;
+    ZERR << zypp::str::Format( "Failed with error %1% while ordering transaction." )% orderRes << std::endl;
     return RpmOrderFailed;
   }
 
@@ -476,11 +492,11 @@ int main( int, char ** )
     sstr << "rpm output:" << std::endl << errMsg << std::endl;
     //HistoryLog().comment(sstr.str());
 
-    std::cerr << "RPM transaction failed: " + errMsg << std::endl;
+    ZERR << "RPM transaction failed: " + errMsg << std::endl;
     return err;
   }
 
-  std::cerr << "Success !!!!" << std::endl;
+  //ZDBG << "Success !!!!" << std::endl;
 
   return NoError;
 }
@@ -537,7 +553,7 @@ void *rpmLibCallback( const void *h, const rpmCallbackType what, const rpm_loff_
   }
 
   const auto &sendEndOfScriptTag = [&](){
-    std::cerr << "Send end of script" << std::endl;
+    //ZDBG << "Send end of script" << std::endl;
     ::sendBytes( static_cast<int>( ExpectedFds::ScriptFd ), endOfScriptTag.data(), endOfScriptTag.size() );
   };
 
@@ -547,10 +563,10 @@ void *rpmLibCallback( const void *h, const rpmCallbackType what, const rpm_loff_
       if ( !iStep || !iStep->has_install() || iStep->install().pathname().empty() )
         return NULL;
       if ( fd != NULL )
-        std::cerr << "ERR opening a file before closing the old one?  Really ? " << std::endl;
+        ZERR << "ERR opening a file before closing the old one?  Really ? " << std::endl;
       fd = Fopen( iStep->install().pathname().data(), "r.ufdio" );
       if (fd == NULL || Ferror(fd)) {
-        std::cerr << "Error when opening file " << iStep->install().pathname().data() << std::endl;
+        ZERR << "Error when opening file " << iStep->install().pathname().data() << std::endl;
         if (fd != NULL) {
           Fclose(fd);
           fd = NULL;
@@ -586,7 +602,7 @@ void *rpmLibCallback( const void *h, const rpmCallbackType what, const rpm_loff_
       if ( !iStep ) {
 
         if ( header.empty() ) {
-          std::cerr << "No header and no transaction step for a uninstall start, not sending anything" << std::endl;
+          ZERR << "No header and no transaction step for a uninstall start, not sending anything" << std::endl;
           return rc;
         }
 
@@ -598,7 +614,7 @@ void *rpmLibCallback( const void *h, const rpmCallbackType what, const rpm_loff_
       } else {
 
         if ( !iStep->has_remove() ) {
-          std::cerr << "Could not find package in removables " << header << " in transaction elements" << std::endl;
+          ZERR << "Could not find package in removables " << header << " in transaction elements" << std::endl;
           return rc;
         }
 
@@ -612,7 +628,7 @@ void *rpmLibCallback( const void *h, const rpmCallbackType what, const rpm_loff_
     case RPMCALLBACK_INST_STOP: {
 
       if ( !iStep ) {
-        std::cerr << "Could not find package " << header << " in transaction elements for " << what << std::endl;
+        ZERR << "Could not find package " << header << " in transaction elements for " << what << std::endl;
         return rc;
       }
 
@@ -629,7 +645,7 @@ void *rpmLibCallback( const void *h, const rpmCallbackType what, const rpm_loff_
 
       if ( !iStep ) {
         if ( header.empty() ) {
-          std::cerr << "No header and no transaction step for a uninstall stop, not sending anything" << std::endl;
+          ZERR << "No header and no transaction step for a uninstall stop, not sending anything" << std::endl;
           return rc;
         }
 
@@ -654,7 +670,7 @@ void *rpmLibCallback( const void *h, const rpmCallbackType what, const rpm_loff_
     case RPMCALLBACK_UNPACK_ERROR: {
 
       if ( !iStep ) {
-        std::cerr << "Could not find package " << header << " in transaction elements for " << what << std::endl;
+        ZERR << "Could not find package " << header << " in transaction elements for " << what << std::endl;
         return rc;
       }
 
@@ -688,7 +704,7 @@ void *rpmLibCallback( const void *h, const rpmCallbackType what, const rpm_loff_
                                         : 100.0);
       if ( !iStep  ) {
         if ( header.empty() ) {
-          std::cerr << "No header and no transaction step for a uninstall progress, not sending anything" << std::endl;
+          ZERR << "No header and no transaction step for a uninstall progress, not sending anything" << std::endl;
           return rc;
         }
 
@@ -745,7 +761,7 @@ void *rpmLibCallback( const void *h, const rpmCallbackType what, const rpm_loff_
       break;
     }
     case RPMCALLBACK_CPIO_ERROR:
-      std::cerr << "CPIO Error when installing package" << std::endl;
+      ZERR << "CPIO Error when installing package" << std::endl;
       break;
     case RPMCALLBACK_SCRIPT_START: {
       zypp::proto::target::ScriptBegin script;
@@ -800,7 +816,6 @@ int rpmLogCallback ( rpmlogRec rec, rpmlogCallbackData )
   zypp::proto::target::RpmLog log;
   log.set_level( rpmlogRecPriority(rec)  );
   log.set_line( zypp::str::asString( ::rpmlogRecMessage(rec) ) );
-  std::cerr << "Pushing log message: " << log.line() << std::endl;
   pushMessage( log );
 
   return logRc;
index 01547d1..7107301 100644 (file)
@@ -116,15 +116,25 @@ namespace zypp
       {}
 
       /** Ctor taking value and no dispose function. */
-      explicit AutoDispose( param_type value_r )
+      explicit AutoDispose( const value_type & value_r )
       : _pimpl( new Impl( value_r ) )
       {}
 
       /** Ctor taking value and dispose function. */
-      AutoDispose( param_type value_r, const Dispose & dispose_r )
+      AutoDispose( const value_type & value_r, const Dispose & dispose_r )
       : _pimpl( new Impl( value_r, dispose_r ) )
       {}
 
+      /** Ctor taking rvalue and no dispose function. */
+      explicit AutoDispose( value_type &&value_r )
+        : _pimpl( new Impl( std::move(value_r) ) )
+      {}
+
+      /** Ctor taking rvalue and dispose function. */
+      AutoDispose( value_type &&value_r, const Dispose & dispose_r )
+        : _pimpl( new Impl( std::move(value_r), dispose_r ) )
+      {}
+
     public:
 
       /** Provide implicit conversion to \c Tp\&. */
@@ -171,12 +181,14 @@ namespace zypp
     private:
       struct Impl : private base::NonCopyable
       {
-        Impl( param_type value_r )
-        : _value( value_r )
+        template <typename T>
+        Impl( T &&value_r )
+          : _value( std::forward<T>(value_r) )
         {}
-        Impl( param_type value_r, const Dispose & dispose_r )
-        : _value( value_r )
-        , _dispose( dispose_r )
+        template <typename T, typename D>
+        Impl( T &&value_r, D &&dispose_r )
+          : _value( std::forward<T>(value_r) )
+          , _dispose( std::forward<D>(dispose_r) )
         {}
         ~Impl()
         {
index 915166b..c355064 100644 (file)
@@ -15,7 +15,11 @@ SET( zypp_toplevel_headers
   Digest.h
   ExternalProgram.h
   Globals.h
+  KVMap
+  kvmap.h
   ManagedFile.h
+  onmedialocation.h
+  OnMediaLocation
   Pathname.h
   TriBool.h
   Url.h
@@ -27,12 +31,17 @@ SET( zypp_toplevel_SRCS
   Date.cc
   Digest.cc
   ExternalProgram.cc
+  onmedialocation.cc
   Pathname.cc
   Url.cc
 )
 INSTALL(  FILES ${zypp_toplevel_headers} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core" )
 
 SET( zypp_base_HEADERS
+  base/DefaultIntegral
+  base/defaultintegral.h
+  base/DtorReset
+  base/dtorreset.h
   base/Easy.h
   base/EnumClass.h
   base/Errno.h
@@ -40,8 +49,14 @@ SET( zypp_base_HEADERS
   base/ExternalDataSource.h
   base/Function.h
   base/Flags.h
+  base/fXstream
+  base/fxstream.h
   base/Gettext.h
+  base/GzStream
+  base/gzstream.h
   base/Hash.h
+  base/InputStream
+  base/inputstream.h
   base/IOStream.h
   base/IOTools.h
   base/Iterable.h
@@ -51,12 +66,18 @@ SET( zypp_base_HEADERS
   base/Logger.h
   base/NonCopyable.h
   base/ProfilingFormater.h
+  base/ProvideNumericId
+  base/providenumericid.h
   base/PtrTypes.h
   base/ReferenceCounted.h
   base/Regex.h
+  base/SimpleStreambuf
+  base/simplestreambuf.h
   base/String.h
   base/StringV.h
   base/Unit.h
+  base/UserRequestException
+  base/userrequestexception.h
   base/Xml.h
 )
 
@@ -65,6 +86,8 @@ SET( zypp_base_SRCS
   base/Exception.cc
   base/ExternalDataSource.cc
   base/Gettext.cc
+  base/gzstream.cc
+  base/inputstream.cc
   base/IOStream.cc
   base/IOTools.cc
   base/LogControl.cc
@@ -74,9 +97,23 @@ SET( zypp_base_SRCS
   base/String.cc
   base/StringV.cc
   base/Unit.cc
+  base/userrequestexception.cc
   base/Xml.cc
 )
 
+IF (ENABLE_ZCHUNK_COMPRESSION)
+
+  list( APPEND zypp_base_SRCS
+    base/zckstream.cc
+  )
+
+  list( APPEND zypp_base_HEADERS
+    base/ZckStream
+    base/zckstream.h
+  )
+
+ENDIF(ENABLE_ZCHUNK_COMPRESSION)
+
 INSTALL(  FILES ${zypp_base_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/base" )
 
 
@@ -88,10 +125,23 @@ SET( zypp_fs_SRCS
 SET( zypp_fs_HEADERS
   fs/PathInfo.h
   fs/TmpPath.h
+  fs/WatchFile
+  fs/watchfile.h
 )
 
 INSTALL(  FILES ${zypp_fs_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/fs" )
 
+SET( zypp_ui_SRCS
+  ui/progressdata.cc
+)
+
+SET( zypp_ui_HEADERS
+  ui/ProgressData
+  ui/progressdata.h
+)
+
+INSTALL(  FILES ${zypp_ui_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/ui" )
+
 
 SET( zypp_url_SRCS
   url/UrlUtils.cc
@@ -106,6 +156,26 @@ SET( zypp_url_HEADERS
 
 INSTALL(  FILES ${zypp_url_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/url" )
 
+SET( zypp_parser_SRCS
+  parser/iniparser.cc
+  parser/inidict.cc
+  parser/parseexception.cc
+  parser/sysconfig.cc
+)
+
+SET( zypp_parser_HEADERS
+  parser/IniParser
+  parser/iniparser.h
+  parser/IniDict
+  parser/inidict.h
+  parser/ParseException
+  parser/parseexception.h
+  parser/Sysconfig
+  parser/sysconfig.h
+)
+
+INSTALL(  FILES ${zypp_parser_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/parser" )
+
 SET( zypp_parser_xml_SRCS
   parser/xml/XmlEscape.cc
 )
@@ -116,6 +186,11 @@ SET( zypp_parser_xml_HEADERS
 
 INSTALL(  FILES ${zypp_parser_xml_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-core/parser/xml" )
 
+SET( zyppng_async_HEADERS
+  zyppng/async/AsyncOp
+  zyppng/async/asyncop.h
+)
+
 SET( zyppng_base_SRCS
   zyppng/base/abstracteventsource.cc
   zyppng/base/base.cc
@@ -200,6 +275,34 @@ SET( zyppng_io_HEADERS
   zyppng/io/SockAddr
 )
 
+SET( zyppng_meta_HEADERS
+  zyppng/meta/Functional
+  zyppng/meta/functional.h
+  zyppng/meta/FunctionTraits
+  zyppng/meta/function_traits.h
+  zyppng/meta/TypeTraits
+  zyppng/meta/type_traits.h
+)
+
+SET( zyppng_pipelines_HEADERS
+  zyppng/pipelines/AsyncResult
+  zyppng/pipelines/asyncresult.h
+  zyppng/pipelines/Await
+  zyppng/pipelines/await.h
+  zyppng/pipelines/Expected
+  zyppng/pipelines/expected.h
+  zyppng/pipelines/Lift
+  zyppng/pipelines/lift.h
+  zyppng/pipelines/MTry
+  zyppng/pipelines/mtry.h
+  zyppng/pipelines/Redo
+  zyppng/pipelines/redo.h
+  zyppng/pipelines/Transform
+  zyppng/pipelines/transform.h
+  zyppng/pipelines/Wait
+  zyppng/pipelines/wait.h
+)
+
 SET( zyppng_rpc_HEADERS
   zyppng/rpc/rpc.h
   zyppng/rpc/zerocopystreams.h
@@ -228,15 +331,20 @@ SET( zyppng_thread_private_HEADERS
 
 SET ( zypp_HEADERS
   ${zypp_toplevel_headers}
+  ${zyppng_async_HEADERS}
   ${zypp_base_HEADERS}
   ${zypp_fs_HEADERS}
+  ${zypp_ui_HEADERS}
   ${zypp_url_HEADERS}
+  ${zypp_parser_HEADERS}
   ${zypp_parser_xml_HEADERS}
   ${zyppng_base_HEADERS}
   ${zyppng_base_private_HEADERS}
   ${zyppng_core_HEADERS}
   ${zyppng_io_HEADERS}
   ${zyppng_io_private_HEADERS}
+  ${zyppng_meta_HEADERS}
+  ${zyppng_pipelines_HEADERS}
   ${zyppng_rpc_HEADERS}
   ${zyppng_thread_HEADERS}
   ${zyppng_thread_private_HEADERS}
@@ -246,7 +354,9 @@ SET ( zypp_SRCS
   ${zypp_toplevel_SRCS}
   ${zypp_base_SRCS}
   ${zypp_fs_SRCS}
+  ${zypp_ui_SRCS}
   ${zypp_url_SRCS}
+  ${zypp_parser_SRCS}
   ${zypp_parser_xml_SRCS}
   ${zyppng_base_SRCS}
   ${zyppng_io_SRCS}
diff --git a/zypp-core/KVMap b/zypp-core/KVMap
new file mode 100644 (file)
index 0000000..f4ad6b0
--- /dev/null
@@ -0,0 +1 @@
+#include "kvmap.h"
diff --git a/zypp-core/OnMediaLocation b/zypp-core/OnMediaLocation
new file mode 100644 (file)
index 0000000..504e404
--- /dev/null
@@ -0,0 +1 @@
+#include "onmedialocation.h"
diff --git a/zypp-core/base/DefaultIntegral b/zypp-core/base/DefaultIntegral
new file mode 100644 (file)
index 0000000..6d43a5d
--- /dev/null
@@ -0,0 +1 @@
+#include "defaultintegral.h"
diff --git a/zypp-core/base/DtorReset b/zypp-core/base/DtorReset
new file mode 100644 (file)
index 0000000..ee44b69
--- /dev/null
@@ -0,0 +1 @@
+#include "dtorreset.h"
index 7a8f6a6..d74d923 100644 (file)
@@ -122,6 +122,21 @@ namespace zypp
     }
   }
 
+  void Exception::remember( std::exception_ptr old_r )
+  {
+    try {
+      if (old_r) {
+        std::rethrow_exception(old_r);
+      }
+    } catch( const Exception& e ) {
+      remember( e );
+    } catch ( const std::exception& e ) {
+      addHistory( e.what() );
+    } catch ( ... ) {
+      addHistory( "Remembered unknown exception" );
+    }
+  }
+
   void Exception::addHistory( const std::string & msg_r )
   { _history.push_front( msg_r ); }
 
index 09e48a0..f1d0cac 100644 (file)
@@ -217,6 +217,9 @@ namespace zypp
     /** \overload moving */
     void remember( Exception && old_r );
 
+    /** \overload std::exception_ptr */
+    void remember( std::exception_ptr old_r );
+
     /** Add some message text to the history. */
     void addHistory( const std::string & msg_r );
     /** \overload moving */
@@ -380,6 +383,29 @@ namespace zypp
       Exception::log( excpt_r, where_r, "RETHROW: " );
       throw;
     }
+
+    /** Helper for \ref ZYPP_EXCPT_PTR( Exception ). */
+    template<class TExcpt, EnableIfIsException<TExcpt> = 0>
+    std::exception_ptr do_ZYPP_EXCPT_PTR( const TExcpt & excpt_r, const CodeLocation & where_r );
+    template<class TExcpt, EnableIfIsException<TExcpt>>
+    std::exception_ptr do_ZYPP_EXCPT_PTR( const TExcpt & excpt_r, const CodeLocation & where_r )
+    {
+      excpt_r.relocate( where_r );
+      Exception::log( excpt_r, where_r, "THROW:   " );
+      return std::make_exception_ptr( excpt_r );
+    }
+
+    /** Helper for \ref ZYPP_EXCPT_PTR( not Exception ). */
+    template<class TExcpt, EnableIfNotException<TExcpt> = 0>
+    std::exception_ptr do_ZYPP_EXCPT_PTR( const TExcpt & excpt_r, const CodeLocation & where_r );
+    template<class TExcpt, EnableIfNotException<TExcpt>>
+    std::exception_ptr do_ZYPP_EXCPT_PTR( const TExcpt & excpt_r, const CodeLocation & where_r )
+    {
+      Exception::log( typeid(excpt_r).name(), where_r, "THROW:   " );
+      return std::make_exception_ptr( excpt_r );
+    }
+
+
   } // namespace exception_detail
   ///////////////////////////////////////////////////////////////////
 
@@ -392,6 +418,10 @@ namespace zypp
 #define ZYPP_THROW(EXCPT)\
   ::zypp::exception_detail::do_ZYPP_THROW( EXCPT, ZYPP_EX_CODELOCATION )
 
+  /** Drops a logline and returns Exception as a std::exception_ptr. */
+#define ZYPP_EXCPT_PTR(EXCPT)\
+  ::zypp::exception_detail::do_ZYPP_EXCPT_PTR( EXCPT, ZYPP_EX_CODELOCATION )
+
   /** Drops a logline telling the Exception was caught (in order to handle it). */
 #define ZYPP_CAUGHT(EXCPT)\
   ::zypp::exception_detail::do_ZYPP_CAUGHT( EXCPT, ZYPP_EX_CODELOCATION )
diff --git a/zypp-core/base/GzStream b/zypp-core/base/GzStream
new file mode 100644 (file)
index 0000000..bf45aca
--- /dev/null
@@ -0,0 +1 @@
+#include "gzstream.h"
diff --git a/zypp-core/base/InputStream b/zypp-core/base/InputStream
new file mode 100644 (file)
index 0000000..05489a6
--- /dev/null
@@ -0,0 +1 @@
+#include "inputstream.h"
diff --git a/zypp-core/base/ProvideNumericId b/zypp-core/base/ProvideNumericId
new file mode 100644 (file)
index 0000000..73446ce
--- /dev/null
@@ -0,0 +1 @@
+#include "providenumericid.h"
diff --git a/zypp-core/base/SimpleStreambuf b/zypp-core/base/SimpleStreambuf
new file mode 100644 (file)
index 0000000..2421b3a
--- /dev/null
@@ -0,0 +1 @@
+#include "simplestreambuf.h"
diff --git a/zypp-core/base/UserRequestException b/zypp-core/base/UserRequestException
new file mode 100644 (file)
index 0000000..32bdd8f
--- /dev/null
@@ -0,0 +1 @@
+#include "userrequestexception.h"
diff --git a/zypp-core/base/ZckStream b/zypp-core/base/ZckStream
new file mode 100644 (file)
index 0000000..7350e68
--- /dev/null
@@ -0,0 +1 @@
+#include "zckstream.h"
diff --git a/zypp-core/base/defaultintegral.h b/zypp-core/base/defaultintegral.h
new file mode 100644 (file)
index 0000000..3235f3e
--- /dev/null
@@ -0,0 +1,104 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/base/DefaultIntegral.h
+ *
+*/
+#ifndef ZYPP_CORE_BASE_DEFAULTINTEGRAL_H
+#define ZYPP_CORE_BASE_DEFAULTINTEGRAL_H
+
+#include <iosfwd>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_integral.hpp>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //  CLASS NAME : DefaultIntegral<Tp,TInitial>
+  //
+  /** Integral type with defined initial value when default constructed.
+   *
+   * \code
+   * typedef DefaultIntegral<unsigned,0> Counter;
+   * std::map<KeyType,Counter> stats;
+   * for ( all keys  )
+   *   ++(stats[key]);
+   * \endcode
+   *
+   * \todo maybe specialize for bool, add logical and bit operators
+   * \todo let TInitial default to 0 then remove base/Counter.h
+  */
+  template<class Tp, Tp TInitial>
+    class DefaultIntegral
+    {
+    public:
+      typedef Tp value_type;
+
+    public:
+      DefaultIntegral( Tp val_r = TInitial )
+      : _val( val_r )
+      { BOOST_STATIC_ASSERT(boost::is_integral<Tp>::value); }
+
+      /** Conversion to Tp. */
+      //@{
+      Tp & get()       { return _val; }
+      Tp   get() const { return _val; }
+
+      operator Tp &()       { return get(); }
+      operator Tp  () const { return get(); }
+      //@}
+
+      /** The initial value. */
+      constexpr Tp initial() const { return TInitial; }
+
+      /** Reset to the defined initial value. */
+      DefaultIntegral & reset()        { _val = TInitial; return *this; }
+
+      /** \name Arithmetic operations.
+       * \c + \c - \c * \c / are provided via conversion to Tp.
+      */
+      //@{
+      DefaultIntegral & operator=( Tp rhs )  {  _val = rhs; return *this; }
+      DefaultIntegral & operator+=( Tp rhs ) { _val += rhs; return *this; }
+      DefaultIntegral & operator-=( Tp rhs ) { _val -= rhs; return *this; }
+      DefaultIntegral & operator*=( Tp rhs ) { _val *= rhs; return *this; }
+      DefaultIntegral & operator/=( Tp rhs ) { _val /= rhs; return *this; }
+
+      DefaultIntegral & operator++(/*prefix*/) { ++_val; return *this; }
+      DefaultIntegral & operator--(/*prefix*/) { --_val; return *this; }
+
+      DefaultIntegral operator++(int/*postfix*/) { return _val++; }
+      DefaultIntegral operator--(int/*postfix*/) { return _val--; }
+      //@}
+
+    private:
+      Tp _val;
+    };
+
+    /** \relates DefaultIntegral \c true initialized \c bool  */
+    typedef DefaultIntegral<bool,true>  TrueBool;
+
+    /** \relates DefaultIntegral \c false initialized \c bool */
+    typedef DefaultIntegral<bool,false> FalseBool;
+
+    /** \relates DefaultIntegral \c zero initialized \c integral */
+    template<typename TIntegral>
+    using ZeroInit = DefaultIntegral<TIntegral,TIntegral(0)>;
+
+    template<class Tp, Tp TInitial>
+    std::string asString( const DefaultIntegral<Tp,TInitial> & obj )
+    { return asString( obj.get() ); }
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_DEFAULTINTEGRAL_H
diff --git a/zypp-core/base/dtorreset.h b/zypp-core/base/dtorreset.h
new file mode 100644 (file)
index 0000000..9873b61
--- /dev/null
@@ -0,0 +1,85 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/base/DtorReset.h
+ *
+*/
+#ifndef ZYPP_CORE_BASE_DTORRESET_H
+#define ZYPP_CORE_BASE_DTORRESET_H
+
+#include <zypp-core/base/PtrTypes.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : DtorReset
+  //
+  /** Assign a vaiable a certain value when going out of scope.
+   * Use it e.g. to reset/cleanup in presence of exceptions.
+   * \code
+   * struct Foo
+   * {
+   *   void consume()
+   *   {
+   *     DtorReset x(_inConsume,false);
+   *     _inConsume = true;
+   *     MIL << _inConsume << endl;
+   *   };
+   *
+   *   DefaultIntegral<bool,false> _inConsume;
+   * };
+   *
+   * Foo f;
+   * MIL << f._inConsume << endl; // 0
+   * f.consume();                 // 1
+   * MIL << f._inConsume << endl; // 0
+   * \endcode
+   * \ingroup g_RAII
+   * \todo Check if using call_traits enables 'DtorReset(std::string,"value")',
+   * as this currently would require assignment of 'char[]'.
+   */
+  class DtorReset
+  {
+  public:
+    DtorReset() {}
+
+    template<class TVar>
+      DtorReset( TVar & var_r )
+      : _pimpl( new Impl<TVar,TVar>( var_r, var_r ) )
+      {}
+    template<class TVar, class TVal>
+      DtorReset( TVar & var_r, const TVal & val_r )
+      : _pimpl( new Impl<TVar,TVal>( var_r, val_r ) )
+      {}
+
+  private:
+    /** Requires TVal being copy constructible, and assignment
+     * <tt>TVar = TVal</tt> defined. */
+    template<class TVar, class TVal>
+      struct Impl
+      {
+        Impl( TVar & var_r, const TVal & val_r )
+        : _var( var_r )
+        , _val( val_r )
+        {}
+        ~Impl()
+        { _var = _val; }
+        TVar & _var;
+        TVal   _val;
+      };
+    shared_ptr<void> _pimpl;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_DTORRESET_H
diff --git a/zypp-core/base/fXstream b/zypp-core/base/fXstream
new file mode 100644 (file)
index 0000000..0413c39
--- /dev/null
@@ -0,0 +1 @@
+#include "fxstream.h"
diff --git a/zypp-core/base/fxstream.h b/zypp-core/base/fxstream.h
new file mode 100644 (file)
index 0000000..2ff137c
--- /dev/null
@@ -0,0 +1,96 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+#ifndef ZYPP_CORE_BASE_FXSTREAM_H
+#define ZYPP_CORE_BASE_FXSTREAM_H
+
+#include <iosfwd>
+#include <iostream>
+
+namespace zypp {
+  namespace detail {
+    /**
+     * @short Common template to define ifgzstream/ofgzstream
+     * reading/writing compressed files.
+     *
+     * Don't use fXstream directly, but @ref ifgzstream or
+     * @ref ofgzstream. fXstream is just to avoid almost
+     * duplicate code.
+     **/
+    template<class TBStream,class TStreamBuf>
+    class fXstream : public TBStream
+    {
+    public:
+
+      using ZlibError = typename TStreamBuf::error_type;
+      using stream_type = TBStream;
+      using streambuf_type = TStreamBuf;
+
+      fXstream()
+        : stream_type( nullptr )
+      { this->init( &_streambuf ); }
+
+      explicit
+        fXstream( const char * file_r )
+        : stream_type( nullptr )
+      { this->init( &_streambuf ); this->open( file_r ); }
+
+      virtual
+        ~fXstream()
+      {}
+
+      bool
+      is_open() const
+      { return _streambuf.isOpen(); }
+
+      void
+      open( const char * file_r )
+      {
+        if ( !_streambuf.open( file_r, defMode(*this) ) )
+          this->setstate(std::ios_base::failbit);
+        else
+          this->clear();
+      }
+
+      void
+      close()
+      {
+        if ( !_streambuf.close() )
+          this->setstate(std::ios_base::failbit);
+      }
+
+      /**
+             * The last error returned retuned from zlib.
+             **/
+      ZlibError
+      zError() const
+      { return _streambuf.error(); }
+
+      //! Similar to ios::rdbuf.
+      //! But it returns our specific type, not the generic streambuf *.
+      const streambuf_type&
+      getbuf() const
+      { return _streambuf; }
+
+    private:
+
+      streambuf_type _streambuf;
+
+      std::ios_base::openmode
+      defMode( const std::istream & )
+      { return std::ios_base::in; }
+
+      std::ios_base::openmode
+      defMode( const std::ostream & )
+      { return std::ios_base::out; }
+
+    };
+  }
+}
+
+#endif
similarity index 98%
rename from zypp/base/GzStream.cc
rename to zypp-core/base/gzstream.cc
index df29e01..83bf5c7 100644 (file)
 
 #include <cerrno>
 #include <iostream>
-#include <zypp/base/LogControl.h>
-#include <zypp/base/LogTools.h>
+#include <zypp-core/base/LogControl.h>
+#include <zypp-core/base/LogTools.h>
 using std::endl;
 
-#include <zypp/base/GzStream.h>
+#include <zypp-core/base/GzStream>
 
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/zypp-core/base/gzstream.h b/zypp-core/base/gzstream.h
new file mode 100644 (file)
index 0000000..def7d9d
--- /dev/null
@@ -0,0 +1,168 @@
+/*---------------------------------------------------------------------\
+|                                                                      |
+|                      __   __    ____ _____ ____                      |
+|                      \ \ / /_ _/ ___|_   _|___ \                     |
+|                       \ V / _` \___ \ | |   __) |                    |
+|                        | | (_| |___) || |  / __/                     |
+|                        |_|\__,_|____/ |_| |_____|                    |
+|                                                                      |
+|                               core system                            |
+|                                         (C) SuSE Linux Products GmbH |
+\----------------------------------------------------------------------/
+
+  File:       GzStream.h
+
+  Author:     Michael Andres <ma@suse.de>
+  Maintainer: Michael Andres <ma@suse.de>
+
+  Purpose: Streams reading and writing gzip files.
+
+/-*/
+#ifndef ZYPP_CORE_BASE_GZSTREAM_H
+#define ZYPP_CORE_BASE_GZSTREAM_H
+
+#include <iosfwd>
+#include <streambuf>
+#include <vector>
+#include <zlib.h>
+
+#include <zypp-core/base/SimpleStreambuf>
+#include <zypp-core/base/fXstream>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  namespace gzstream_detail
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : ZlibError
+    /**
+     * @short Helper class to ship zlib errors.
+     **/
+    struct ZlibError
+    {
+      /**
+       * The zlib error code
+       **/
+      int _zError;
+
+      /**
+       * errno, valid if zError is Z_ERRNO
+       **/
+      int _errno;
+
+      ZlibError()
+      : _zError( 0 ), _errno( 0 )
+      {}
+
+      /**
+       * Return string describing the zlib error code
+       **/
+      std::string
+      strerror() const;
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /** \relates ZlibError Stream output. */
+    inline std::ostream & operator<<( std::ostream & str, const ZlibError & obj )
+    { return str << obj.strerror(); }
+
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : gzstreambufimpl
+    /**
+     * @short Streambuffer reading or writing gzip files.
+     *
+     * Read and write mode are mutual exclusive. Seek is supported,
+     * but zlib restrictions appy (only forward seek in write mode;
+     * backward seek in read mode might be expensive).Putback is not
+     * supported.
+     *
+     * Reading plain (no gziped) files is possible as well.
+     *
+     * This streambuf is used in @ref ifgzstream and  @ref ofgzstream.
+     **/
+    class gzstreambufimpl {
+    public:
+
+      using error_type = ZlibError;
+
+      ~gzstreambufimpl()
+      { closeImpl(); }
+
+      bool
+      isOpen   () const
+      { return _file; }
+
+      bool
+      canRead  () const
+      { return( _mode == std::ios_base::in ); }
+
+      bool
+      canWrite () const
+      { return( _mode == std::ios_base::out ); }
+
+      bool
+      canSeek  ( std::ios_base::seekdir way_r ) const
+      { return ( way_r == std::ios_base::beg || way_r == std::ios_base::cur ); }
+
+    protected:
+      bool openImpl( const char * name_r, std::ios_base::openmode mode_r );
+      bool closeImpl ();
+
+      //! Tell the file position in the compressed file.
+      //! Analogous to tell(2), complementary to gztell.
+      off_t compressed_tell() const;
+
+    public:
+      /**
+         * The last error returned fron zlib.
+         **/
+      error_type
+      error() const
+      { return _error; }
+
+      std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r  );
+      bool writeData( const char * buffer_r, std::streamsize count_r );
+      off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r );
+      off_t tell() const;
+
+    private:
+
+      void
+      setZError() const
+      { gzerror( _file, &_error._zError ); }
+
+      //! file descriptor of the compressed file
+      int                       _fd = -1;
+
+      gzFile                   _file = nullptr;
+
+      std::ios_base::openmode  _mode = std::ios_base::openmode(0);
+
+      mutable ZlibError        _error;
+
+    };
+    using fgzstreambuf = detail::SimpleStreamBuf<gzstreambufimpl>;
+  } // namespace gzstream_detail
+
+  /**
+   * istream reading gzip files as well as plain files.
+   **/
+  typedef detail::fXstream<std::istream,gzstream_detail::fgzstreambuf> ifgzstream;
+
+  /**
+   * ostream writing gzip files.
+   **/
+  typedef detail::fXstream<std::ostream,gzstream_detail::fgzstreambuf> ofgzstream;
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+#endif // ZYPP_CORE_BASE_GZSTREAM_H
similarity index 96%
rename from zypp/base/InputStream.cc
rename to zypp-core/base/inputstream.cc
index 5da3e46..f646207 100644 (file)
  *
 */
 #include <iostream>
-#include <zypp/base/LogTools.h>
+#include <zypp-core/base/LogTools.h>
 
-#include <zypp/base/InputStream.h>
-#include <zypp/base/GzStream.h>
+#include "inputstream.h"
+#include <zypp-core/base/GzStream>
 
 #ifdef ENABLE_ZCHUNK_COMPRESSION
-  #include <zypp/base/ZckStream.h>
+  #include <zypp-core/base/ZckStream>
 #endif
 
-#include <zypp/PathInfo.h>
+#include <zypp-core/fs/PathInfo.h>
 
 using std::endl;
 
diff --git a/zypp-core/base/inputstream.h b/zypp-core/base/inputstream.h
new file mode 100644 (file)
index 0000000..4fd87b9
--- /dev/null
@@ -0,0 +1,144 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/base/InputStream.h
+ *
+*/
+#ifndef ZYPP_CORE_BASE_INPUTSTREAM_H
+#define ZYPP_CORE_BASE_INPUTSTREAM_H
+
+#include <iosfwd>
+
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/base/DefaultIntegral>
+#include <zypp-core/Pathname.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : InputStream
+  //
+  /** Helper to create and pass std::istream.
+   * The provided std::istream may either be std::cin,
+   * sone (gziped) file or an aleady existig \c std::istream.
+   *
+   * An optional \c name arument may be passed to the ctor,
+   * to identify the stream in log messages, even if it is
+   * not a file.
+   *
+   * Per default the name is "STDIN", the path to an input file
+   * or empty.
+   *
+   * \code
+   * void parse( const InputStream & input = InputStream() )
+   * {
+   *   // process input.stream() and refer to input.name()
+   *   // in log messages.
+   * }
+   *
+   * parse();                  // std::cin
+   * parse( "/some/file" );    // file
+   * parse( "/some/file.gz" ); // gziped file
+   * std::istream & mystream;
+   * parse( mystream );        // some existing stream
+   * parse( InputStream( mystream,
+   *                     "my stream's name" ) );
+   * \endcode
+  */
+  class InputStream
+  {
+  public:
+    /** Default ctor providing \c std::cin. */
+    InputStream();
+
+    /** Ctor providing an aleady existig \c std::istream. */
+    InputStream( std::istream & stream_r,
+                 const std::string & name_r = std::string() );
+
+    /** Ctor for reading a (gziped) file. */
+    InputStream( const Pathname & file_r );
+
+    /** Ctor for reading a (gziped) file. */
+    InputStream( const Pathname & file_r,
+                 const std::string & name_r );
+
+    /** Ctor for reading a (gziped) file. */
+    InputStream( const std::string & file_r );
+
+    /** Ctor for reading a (gziped) file. */
+    InputStream( const std::string & file_r,
+                 const std::string & name_r );
+
+    /** Ctor for reading a (gziped) file. */
+    InputStream( const char * file_r );
+
+    /** Ctor for reading a (gziped) file. */
+    InputStream( const char * file_r,
+                 const std::string & name_r );
+
+    /** Dtor. */
+    ~InputStream();
+
+    /** The std::istream.
+     * \note The provided std::istream is never \c const.
+    */
+    std::istream & stream() const
+    { return *_stream; }
+
+    /** Allow implicit conversion to std::istream.*/
+    operator std::istream &() const
+    { return *_stream; }
+
+    /** Name of the std::istream.
+     * Per default this is "STDIN", the path to an input file or
+     * empty. A custom string may be provided to the ctor.
+     *
+     * This may be used in log messages to identify the stream even
+     * even if it is not a file.
+    */
+    const std::string & name() const
+    { return _name; }
+
+    /** Path to the input file or empty if no file. */
+    const Pathname & path() const
+    { return _path; }
+
+    /** Size of the input stream (informal).
+     * If constructed from an uncompressed file, the file size.
+     * Otherwise \c -1. See \ref setSize;
+    */
+    std::streamoff size() const
+    { return _size; }
+
+    /** Set the size of the input stream.
+     * You may set it to whatever vaule is appropriate. E.g.
+     * <tt>*=10</tt> to compensate gzip comression. or the
+     * number of items, lines, ... The value is not used here,
+     * just provided.
+    */
+    void setSize( std::streamoff val_r )
+    { _size = val_r; }
+
+  private:
+    Pathname                 _path;
+    shared_ptr<std::istream> _stream;
+    std::string              _name;
+    DefaultIntegral<std::streamoff,-1> _size;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /** \relates InputStream Stream output */
+  std::ostream & operator<<( std::ostream & str, const InputStream & obj );
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_INPUTSTREAM_H
diff --git a/zypp-core/base/providenumericid.h b/zypp-core/base/providenumericid.h
new file mode 100644 (file)
index 0000000..093c7a1
--- /dev/null
@@ -0,0 +1,100 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp-core/base/ProvideNumericId
+ *
+*/
+#ifndef ZYPP_CORE_BASE_PROVIDENUMERICID_H
+#define ZYPP_CORE_BASE_PROVIDENUMERICID_H
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace base
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : ProvideNumericId
+    //
+    /** Base class for objects providing a numeric Id.
+     * The ctor creates a NumericId from some static counter.
+     *
+     * The only assertion is that \c 0 is not used as an Id,
+     * \b unless the derived class explicitly requests this by
+     * using \ref ProvideNumericId( const void *const ).
+     *
+     * Why should you want to use \c 0 as an Id? E.g if your class
+     * provides some (singleton) No-object. Might be desirable to
+     * make the No-object have No-Id.
+     *
+     * \code
+     * struct Foo : public base::ProvideNumericId<Foo,unsigned>
+     * {};
+     * Foo foo;
+     * foo.numericId(); // returns foo's NumericId.
+     * \endcode
+    */
+    template<class TDerived, class TNumericIdType>
+      struct ProvideNumericId
+      {
+      public:
+        /** \return The objects numeric Id. */
+        TNumericIdType numericId() const
+        { return _numericId; }
+
+      protected:
+        /** Default ctor */
+        ProvideNumericId()
+        : _numericId( nextId() )
+        {}
+        /** Copy ctor */
+        ProvideNumericId( const ProvideNumericId & /*rhs*/ )
+        : _numericId( nextId() )
+        {}
+        /** Assign */
+        ProvideNumericId & operator=( const ProvideNumericId & /*rhs*/ )
+        { return *this; }
+        /** Move ctor */
+        ProvideNumericId( ProvideNumericId && rhs )
+        : _numericId( rhs._numericId )
+        { /*rhs._numericId = 0;*/ }
+        /** Move Assign */
+        ProvideNumericId & operator=( ProvideNumericId && rhs )
+        { if ( &rhs != this ) { _numericId = rhs._numericId; /*rhs._numericId = 0;*/ } return *this; }
+        /** Dtor */
+        ~ProvideNumericId()
+        {}
+      protected:
+        /** No-Id ctor (0).
+         * Explicitly request Id \c 0. Use it with care!
+        */
+        ProvideNumericId( const void *const )
+        : _numericId( 0 )
+        {}
+      private:
+        /** Provide the next Id to use. */
+        static TNumericIdType nextId()
+        {
+          static TNumericIdType _staticCounter = 0;
+          // Assert not returning 0
+          return ++_staticCounter;
+        }
+        /**  */
+        const TNumericIdType _numericId;
+      };
+    ///////////////////////////////////////////////////////////////////
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace base
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_PROVIDENUMERICID_H
diff --git a/zypp-core/base/simplestreambuf.h b/zypp-core/base/simplestreambuf.h
new file mode 100644 (file)
index 0000000..d573810
--- /dev/null
@@ -0,0 +1,217 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/base/SimpleStreambuf.h
+ *
+*/
+#ifndef ZYPP_CORE_BASE_SIMPLESTREAMBUF_H_DEFINED
+#define ZYPP_CORE_BASE_SIMPLESTREAMBUF_H_DEFINED
+
+#include <streambuf>
+#include <vector>
+
+namespace zypp {
+  namespace detail {
+
+    /*!
+     * Implementation of a std::streambuf that is using a std::vector<char> as buffer,
+     * relies on a Impl class that must implement the basic i/o functionality:
+     *
+     * \code
+     *  class streambufimpl {
+     *    public:
+     *      using error_type = my_error_type;
+     *
+     *      ~streambufimpl();
+     *
+     *      bool isOpen   () const; // returns true if the file is currently open
+     *      bool canRead  () const; // returns true if in read mode
+     *      bool canWrite () const; // returns true if in write mode
+     *      bool canSeek  ( std::ios_base::seekdir way_r ) const; // returns true if the backend can seek in the given way
+     *
+     *      std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r  ); // reads data from the file and returns it in buffer_r
+     *      bool writeData( const char * buffer_r, std::streamsize count_r ); // writes data ( if in write mode ) to file from buffer
+     *      off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r ); // seeks in file if supported
+     *      off_t tell() const; // returns the current FP
+     *
+     *      error_type error() const; // returns the last error that happend in backend
+     *
+     *    protected:
+     *      bool openImpl( const char * name_r, std::ios_base::openmode mode_r ); // backend implementation of opening the file
+     *      bool closeImpl ();  // closes the file
+     *  };
+     *  using FullStreamBuf = detail::SimpleStreamBuf<streambufimpl>;
+     * \endcode
+     *
+     * \note Currently only supports reading or writing at the same time, but can be extended to support both
+     */
+    template<typename Impl>
+    class SimpleStreamBuf : public std::streambuf, public Impl
+    {
+
+      public:
+
+      SimpleStreamBuf( size_t bufsize_r = 512) : _buffer( bufsize_r ) { }
+      virtual ~SimpleStreamBuf() { close(); }
+
+      SimpleStreamBuf * open( const char * name_r, std::ios_base::openmode mode_r = std::ios_base::in ) {
+
+          if ( !this->openImpl( name_r, mode_r ) )
+            return nullptr;
+
+          if ( this->canRead() ) {
+            setp( NULL, NULL );
+            setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
+          } else {
+            setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) );
+            setg( NULL, NULL, NULL );
+          }
+
+          return this;
+        }
+
+        SimpleStreamBuf * close() {
+
+          if ( !this->isOpen() )
+            return nullptr;
+
+          if ( this->canWrite() )
+            sync();
+
+          if ( !this->closeImpl() )
+            return nullptr;
+
+          return this;
+        }
+
+      protected:
+
+        virtual int sync() {
+          int ret = 0;
+          if ( pbase() < pptr() ) {
+            const int_type res = overflow();
+            if ( traits_type::eq_int_type( res, traits_type::eof() ) )
+              ret = -1;
+          }
+          return ret;
+        }
+
+        virtual int_type overflow( int_type c = traits_type::eof() ) {
+          int_type ret = traits_type::eof();
+          if ( this->canWrite() ) {
+            if ( ! traits_type::eq_int_type( c, traits_type::eof() ) )
+            {
+              *pptr() = traits_type::to_char_type( c );
+              pbump(1);
+            }
+            if ( pbase() <= pptr() )
+            {
+              if ( this->writeData( pbase(), pptr() - pbase() ) )
+              {
+                setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) );
+                ret = traits_type::not_eof( c );
+              }
+              // else: error writing the file
+            }
+          }
+          return ret;
+        }
+
+        virtual int_type underflow() {
+          int_type ret = traits_type::eof();
+          if ( this->canRead() )
+          {
+            if ( gptr() < egptr() )
+              return traits_type::to_int_type( *gptr() );
+
+            const std::streamsize got = this->readData( &(_buffer[0]), _buffer.size() );
+            if ( got > 0 )
+            {
+              setg( &(_buffer[0]), &(_buffer[0]), &(_buffer.data()[got]) );
+              ret = traits_type::to_int_type( *gptr() );
+            }
+            else if ( got == 0 )
+            {
+              // EOF
+              setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
+            }
+            // else: error reading the file
+          }
+          return ret;
+        }
+
+        virtual pos_type seekpos( pos_type pos_r, std::ios_base::openmode openMode ) {
+          return seekoff( off_type(pos_r), std::ios_base::beg, openMode );
+        }
+
+
+        virtual pos_type seekoff( off_type off_r, std::ios_base::seekdir way_r, std::ios_base::openmode openMode ) {
+          pos_type ret = pos_type(off_type(-1));
+          if ( !this->canSeek( way_r) )
+            return ret;
+
+          if ( this->isOpen() ) {
+            if ( openMode == std::ios_base::out ) {
+              //write the buffer out and invalidate it , no need to keep it around
+              if ( !this->canWrite() || sync() != 0 )
+                return ret;
+
+              ret = this->seekTo( off_r, way_r, openMode );
+
+            } else if ( openMode == std::ios_base::in ) {
+              if ( !this->canRead() )
+                return ret;
+
+              //current physical FP, should point to end of buffer
+              const off_type buffEndOff = this->tell();
+
+              if ( buffEndOff != off_type(-1) ) {
+                if ( way_r == std::ios_base::end ) {
+                  setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
+                  ret = this->seekTo( off_r, way_r, openMode );
+                }
+
+                const off_type bufLen    = egptr() - eback();
+                const off_type bufStartFileOff  = buffEndOff - bufLen;
+                const off_type currPtrFileOffset = buffEndOff - ( egptr() - gptr() );
+                off_type newFOff = off_r;
+
+                // Transform into ios_base::beg and seek.
+                if ( way_r == std::ios_base::cur ) {
+                  newFOff += currPtrFileOffset;
+                  way_r = std::ios_base::beg;
+                }
+
+                //check if a seek would go out of the buffers boundaries
+                if ( way_r == std::ios_base::beg ) {
+                  if ( bufStartFileOff <= newFOff && newFOff <= buffEndOff ) {
+                    // Still inside buffer, adjust gptr and
+                    // calculate new position.
+                    setg( eback(),
+                      eback() + ( newFOff - bufStartFileOff ),
+                      egptr() );
+                    ret = pos_type( newFOff );
+                  } else {
+                    // Invalidate buffer and seek.
+                    setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
+                    ret = this->seekTo( off_r, way_r, openMode );
+                  }
+                }
+              }
+            }
+          }
+          return ret;
+        }
+
+      private:
+        typedef std::vector<char> buffer_type;
+        buffer_type              _buffer;
+    };
+  }
+}
+#endif
similarity index 98%
rename from zypp/base/UserRequestException.cc
rename to zypp-core/base/userrequestexception.cc
index 71c8ac8..42f2acf 100644 (file)
@@ -12,7 +12,7 @@
 #include <iostream>
 //#include <zypp/base/Logger.h>
 
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 
 using std::endl;
 
diff --git a/zypp-core/base/userrequestexception.h b/zypp-core/base/userrequestexception.h
new file mode 100644 (file)
index 0000000..115474d
--- /dev/null
@@ -0,0 +1,107 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp-core/base/UserRequestException
+ *
+*/
+#ifndef ZYPP_CORE_BASE_USERREQUESTEXCEPTION_H
+#define ZYPP_CORE_BASE_USERREQUESTEXCEPTION_H
+
+#include <iosfwd>
+
+#include <zypp/base/Exception.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : UserRequestException
+  //
+  /** Base for exceptions caused by explicit user request.
+   *
+   * Use the derived convenience classes to throw exceptions
+   * of a certain kind.
+   * \code
+   *     ProgressData ticks( makeProgressData( input_r ) );
+   *     ticks.sendTo( fnc_r );
+   *     ticks.toMin(); // start sending min (0)
+   *
+   *     iostr::EachLine line( input_r );
+   *     for( ; line; line.next() )
+   *     {
+   *       // process the line
+   *
+   *       if ( ! ticks.set( input_r.stream().tellg() ) )
+   *         ZYPP_THROW( AbortRequestException( "" ) );
+   *     }
+   * \endcode
+   * \code
+   * // either this way
+   * catch ( const AbortRequestException & excpt_r )
+   * {
+   *   ...
+   * }
+   *
+   * // or that
+   * catch ( const UserRequestException & excpt_r )
+   * {
+   *   switch ( excpt_r.kind() )
+   *   {
+   *     case UserRequestException::ABORT:
+   *       ...
+   *       break;
+   *   }
+   * }
+   * \endcode
+  */
+  class UserRequestException : public Exception
+  {
+    public:
+      enum Kind { UNSPECIFIED, IGNORE, SKIP, RETRY, ABORT };
+    public:
+      explicit
+      UserRequestException( const std::string & msg_r = std::string() );
+      UserRequestException( const std::string & msg_r, const Exception & history_r );
+      explicit
+      UserRequestException( Kind kind_r, const std::string & msg_r = std::string() );
+      UserRequestException( Kind kind_r, const std::string & msg_r, const Exception & history_r );
+    public:
+      Kind kind() const
+      { return _kind; }
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      Kind _kind;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /** Convenience macro to declare more specific PluginScriptExceptions. */
+#define declException( EXCP, KIND )                                    \
+  struct EXCP : public UserRequestException {                          \
+    explicit                                                           \
+    EXCP( const std::string & msg_r = std::string() )                  \
+      : UserRequestException( KIND, msg_r )                            \
+    {}                                                                 \
+    EXCP( const std::string & msg_r, const Exception & history_r )     \
+      : UserRequestException( KIND, msg_r, history_r )                 \
+    {}                                                                 \
+  }
+
+  declException( IgnoreRequestException, IGNORE );
+  declException( SkipRequestException, SKIP );
+  declException( RetryRequestException, RETRY );
+  declException( AbortRequestException, ABORT );
+
+#undef declException
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_BASE_USERREQUESTEXCEPTION_H
similarity index 98%
rename from zypp/base/ZckStream.cc
rename to zypp-core/base/zckstream.cc
index e92fe38..6bb3b7e 100644 (file)
@@ -6,8 +6,8 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-#include <zypp/base/ZckStream.h>
-#include <zypp/base/String.h>
+#include "zckstream.h"
+#include <zypp-core/base/String.h>
 
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/zypp-core/base/zckstream.h b/zypp-core/base/zckstream.h
new file mode 100644 (file)
index 0000000..f948bce
--- /dev/null
@@ -0,0 +1,77 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+#ifndef ZYPP_CORE_BASE_ZCKSTREAM_H
+#define ZYPP_CORE_BASE_ZCKSTREAM_H
+
+#include <iosfwd>
+#include <streambuf>
+#include <vector>
+#include <zypp-core/base/SimpleStreambuf>
+#include <zypp-core/base/fXstream>
+
+typedef struct zckCtx zckCtx;
+
+namespace zypp {
+
+  namespace detail {
+
+    /**
+     * @short Streambuffer reading or writing zchunk files.
+     *
+     * Read and write mode are mutual exclusive. Seek is not supported.
+     *
+     * This streambuf is used in @ref ifzckstream and  @ref ofzckstream.
+     **/
+    class zckstreambufimpl {
+      public:
+
+        using error_type = std::string;
+
+        ~zckstreambufimpl();
+
+        bool isOpen   () const;
+        bool canRead  () const;
+        bool canWrite () const;
+        bool canSeek  ( std::ios_base::seekdir way_r ) const;
+
+        std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r  );
+        bool writeData( const char * buffer_r, std::streamsize count_r );
+        off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r );
+        off_t tell() const;
+
+        error_type error() const { return _lastErr; }
+
+      protected:
+        bool openImpl( const char * name_r, std::ios_base::openmode mode_r );
+        bool closeImpl ();
+
+      private:
+        void setError ();
+        int _fd = -1;
+        bool _isReading = false;
+        zckCtx *_zContext = nullptr;
+        off_t _currfp = 0;
+        error_type _lastErr;
+
+    };
+    using ZChunkStreamBuf = detail::SimpleStreamBuf<detail::zckstreambufimpl>;
+  }
+
+  /**
+   * istream reading zchunk files.
+   **/
+  using ifzckstream = detail::fXstream<std::istream,detail::ZChunkStreamBuf>;
+
+  /**
+   * ostream writing zchunk files.
+   **/
+  using ofzckstream = detail::fXstream<std::ostream,detail::ZChunkStreamBuf>;
+}
+
+#endif
diff --git a/zypp-core/fs/WatchFile b/zypp-core/fs/WatchFile
new file mode 100644 (file)
index 0000000..45e02e9
--- /dev/null
@@ -0,0 +1 @@
+#include "watchfile.h"
diff --git a/zypp-core/fs/watchfile.h b/zypp-core/fs/watchfile.h
new file mode 100644 (file)
index 0000000..9cf6028
--- /dev/null
@@ -0,0 +1,102 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp-core/fs/WatchFile
+ *
+*/
+#ifndef ZYPP_CORE_FS_WATCHFILE_H
+#define ZYPP_CORE_FS_WATCHFILE_H
+
+#include <iosfwd>
+
+#include <zypp/PathInfo.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : WatchFile
+  //
+  /** Remember a files attributes to detect content changes.
+   *
+   * Repeatedly call \ref hasChanged to check whether the content has
+   * changed since the last call. Creation or deletion of the file will
+   * be reported as change as well.
+   *
+   * Per default the ctor stats the file, so \ref hasChanged will detect
+   * changes done after \ref WatchFile was created.
+   *
+   * You may omit the initial stat by passing \c NO_INIT as second argument
+   * to the ctor. \ref WatchFile  will behave as if the file did not exist
+   * at the time \ref WatchFile was created.
+   *
+   * \code
+   * static WatchFile sysconfigFile( "/etc/sysconfig/SuSEfirewall2",
+   *                                 WatchFile::NO_INIT );
+   * if ( sysconfigFile.hasChanged() )
+   * {
+   *   // reload the file...
+   * }
+   * \endcode
+  */
+  class WatchFile
+  {
+    public:
+      enum Initial { NO_INIT, INIT };
+
+    public:
+      /** */
+      WatchFile( const Pathname & path_r = Pathname(),
+                 Initial mode            = INIT )
+      : _path( path_r )
+      {
+        PathInfo pi( mode == INIT ? path_r : Pathname() );
+        _size  = pi.size();
+        _mtime = pi.mtime();
+      }
+
+      const Pathname & path() const
+      { return _path; }
+
+      off_t  lastSize() const
+      { return _size;}
+
+      time_t lastMtime() const
+      { return _mtime; }
+
+      bool isDirty() const
+      {
+        PathInfo pi( _path );
+        return( _size != pi.size() || _mtime != pi.mtime() );
+      }
+
+      bool hasChanged()
+      {
+        PathInfo pi( _path );
+        if ( _size != pi.size() || _mtime != pi.mtime() )
+        {
+          _size = pi.size();
+          _mtime = pi.mtime();
+          return true;
+        }
+        return false;
+      }
+
+    private:
+      Pathname _path;
+      off_t  _size;
+      time_t _mtime;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_FS_WATCHFILE_H
diff --git a/zypp-core/kvmap.h b/zypp-core/kvmap.h
new file mode 100644 (file)
index 0000000..9fd81f1
--- /dev/null
@@ -0,0 +1,204 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\----------------------------------------------------------------------/
+
+  File:       KVMap.h
+
+  Author:     Michael Andres <ma@suse.de>
+  Maintainer: Michael Andres <ma@suse.de>
+
+  Purpose: Convenience stuff for handling (key,value) pairs
+
+*/
+#ifndef KVMap_h
+#define KVMap_h
+
+#include <iosfwd>
+#include <vector>
+#include <map>
+
+#include <zypp/base/String.h>
+
+namespace zypp {
+  namespace kvmap {
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : KVMapBase::KVMapPolicy
+    /**
+     * @short KVMapPolicy for conversion of KVMaps to/from string.
+     *
+     * <b>_kvsplit</b>: The string separating key from value
+     *
+     * <b>_fsplit</b>:  (key,value) pairs are separated by any nonempty
+     * sequence of characers occurring in _fsplit
+     *
+     * <b>_kvjoin</b>: The string used to join key and value.
+     *
+     * <b>_fjoin</b>: The string used to separate (key,value) pairs.
+     *
+     * TODO: Maybe options for exact _fsplit handling and timming of values.
+     *
+     **/
+    struct KVMapPolicy {
+      std::string _kvsplit;
+      std::string _fsplit;
+      std::string _kvjoin;
+      std::string _fjoin;
+      KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r )
+        : _kvsplit( kvsplit_r )
+        , _fsplit ( fsplit_r )
+        , _kvjoin ( _kvsplit )
+        , _fjoin  ( _fsplit )
+      {}
+      KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r,
+             const std::string & kvjoin_r )
+        : _kvsplit( kvsplit_r )
+        , _fsplit ( fsplit_r )
+        , _kvjoin ( kvjoin_r )
+        , _fjoin  ( _fsplit )
+      {}
+      KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r,
+             const std::string & kvjoin_r, const std::string & fjoin_r )
+        : _kvsplit( kvsplit_r )
+        , _fsplit ( fsplit_r )
+        , _kvjoin ( kvjoin_r )
+        , _fjoin  ( fjoin_r )
+      {}
+    };
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : KVMapBase
+    /**
+     * @short Base class for KVMaps, (key,value) pairs
+     **/
+    struct KVMapBase : public std::map<std::string,std::string> {
+
+      /**
+       * (key,value) map type
+       **/
+      typedef std::map<std::string,std::string> map_type;
+
+      KVMapBase()
+      {}
+      KVMapBase( const map_type & kvmap_r )
+        : std::map<std::string,std::string>( kvmap_r )
+      {}
+
+      /**
+       * Test whether key is set.
+       **/
+      bool has( const std::string & key_r ) const {
+        return( find( key_r ) != end() );
+      }
+
+      /**
+       * @short KVMapPolicy for KVMaps using a single char as separator (e.g. mount options).
+       **/
+      template<char kv, char f>
+      struct CharSep : public KVMapPolicy { CharSep() : KVMapPolicy( std::string(1,kv), std::string(1,f) ) {} };
+
+      ///////////////////////////////////////////////////////////////////
+
+      /**
+       * Split str_r into (key,value) map, using the separators defined
+       * by opts_r.
+       **/
+      static map_type split( const std::string & str_r,
+                         const KVMapPolicy & opts_r ) {
+        map_type ret;
+        std::vector<std::string> fields;
+        str::split( str_r, std::back_inserter(fields), opts_r._fsplit );
+
+        for ( unsigned i = 0; i < fields.size(); ++i ) {
+          std::string::size_type pos = fields[i].find( opts_r._kvsplit );
+          if ( pos == std::string::npos ) {
+        ret[fields[i]] = "";
+          } else {
+        ret[fields[i].substr( 0, pos )] = fields[i].substr( pos+1 );
+          }
+        }
+
+        return ret;
+      }
+
+      /**
+       * Join (key,value) map into string, using the separators defined
+       * by opts_r.
+       **/
+      static std::string join( const map_type & kvmap_r,
+                           const KVMapPolicy & opts_r ) {
+        std::string ret;
+
+        for ( map_type::const_iterator it = kvmap_r.begin(); it != kvmap_r.end(); ++it ) {
+          if ( ! ret.empty() ) {
+        ret += opts_r._fjoin;
+          }
+          ret += it->first;
+          if ( !it->second.empty() ) {
+        ret += opts_r._kvjoin + it->second;
+          }
+        }
+
+        return ret;
+      }
+
+    };
+
+
+
+  } // namespace kvmap
+
+  ///////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : KVMap<KVMapOpts>
+  /**
+   * @short A map of (key,value) strings.
+   *
+   * The template argument defines the @ref kvmap::Options for
+   * split and join.
+   *
+   * E.g. mount options (a comma separated list of key[=value] pairs)
+   * could be handled by KVMap<kvmap::KVMapBase::Comma>.
+   **/
+  template<typename KVMapOpts>
+  struct KVMap : public kvmap::KVMapBase {
+
+    KVMap()
+    {}
+    KVMap( const char * str_r )
+      : kvmap::KVMapBase( split( (str_r?str_r:""), KVMapOpts() ) )
+    {}
+    KVMap( const std::string & str_r )
+      : kvmap::KVMapBase( split( str_r, KVMapOpts() ) )
+    {}
+    KVMap( const map_type & map_r )
+      : kvmap::KVMapBase( map_r )
+    {}
+
+    ~KVMap() {}
+
+    std::string asString() const {
+      return join( *this, KVMapOpts() );
+    }
+
+  };
+
+  ///////////////////////////////////////////////////////////////////
+
+  template<typename KVMapOpts>
+  std::ostream & operator<<( std::ostream & str, const KVMap<KVMapOpts> & obj )
+  { return str << obj.asString(); }
+
+///////////////////////////////////////////////////////////////////
+} // namespace zypp
+
+#endif // KVMap_h
similarity index 99%
rename from zypp/OnMediaLocation.cc
rename to zypp-core/onmedialocation.cc
index 84b250d..dcad5a8 100644 (file)
@@ -12,7 +12,7 @@
 #include <iostream>
 //#include <zypp/base/Logger.h>
 
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 
 using std::endl;
 
diff --git a/zypp-core/onmedialocation.h b/zypp-core/onmedialocation.h
new file mode 100644 (file)
index 0000000..6755c45
--- /dev/null
@@ -0,0 +1,137 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/source/OnMediaLocation.h
+ */
+#ifndef ZYPP_SOURCE_ONMEDIALOCATION_H
+#define ZYPP_SOURCE_ONMEDIALOCATION_H
+
+#include <iosfwd>
+
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/ByteCount.h>
+#include <zypp-core/CheckSum.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{
+  ///////////////////////////////////////////////////////////////////
+  /// \class OnMediaLocation
+  /// \brief Describes a resource file located on a medium.
+  ///
+  /// Holds the path of a resource on a medium and contains additional
+  /// info required to retrieve and verify it (like media number,
+  /// checksum, size,...)
+  ///
+  /// It does not specify the \ref Url of the medium itself.
+  ///
+  /// Media number \c 0 usually indicates no media access.
+  ///////////////////////////////////////////////////////////////////
+  class OnMediaLocation
+  {
+    friend std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj );
+    friend std::ostream & dumpOn( std::ostream & str, const OnMediaLocation & obj );
+
+  public:
+    /** Default Ctor indicating no media access. */
+    OnMediaLocation();
+
+    /** Ctor taking a \a filename_r and \a medianr_r (defaults to \c 1). */
+    OnMediaLocation( Pathname filename_r, unsigned medianr_r = 1 );
+
+    /** Dtor */
+    ~OnMediaLocation();
+
+  public:
+    /** The path to the resource on the medium. */
+    const Pathname & filename() const;
+
+    /** The media number the resource is located on. */
+    unsigned medianr() const;
+
+
+    /** Set \a filename_r and \a medianr_r (defaults to \c 1). */
+    OnMediaLocation & setLocation( Pathname filename_r, unsigned medianr_r = 1 );
+
+    /** Unset \c filename and set \c medianr to \c 0. */
+    OnMediaLocation & unsetLocation();
+
+
+    /** Individual manipulation of \c filename (prefer \ref setLocation). */
+    OnMediaLocation & changeFilename( Pathname filename_r );
+
+    /** Individual manipulation of \c medianr (prefer \ref setLocation). */
+    OnMediaLocation & changeMedianr( unsigned medianr_r );
+
+    /** Prepend the filename with \a prefix_r */
+    OnMediaLocation & prependPath( const Pathname & prefix_r );
+
+  public:
+    /** Whether this is an optional resource.
+     * This is a hint to the downloader not to report an error if
+     * the resource is not present on the server.
+     */
+    bool optional() const;
+    /** Set whether the resource is \ref optional. */
+    OnMediaLocation & setOptional( bool val );
+
+  public:
+    /** The size of the resource on the server. */
+    const ByteCount & downloadSize() const;
+    /** Set the \ref downloadSize. */
+    OnMediaLocation & setDownloadSize( ByteCount val_r );
+
+    /** The checksum of the resource on the server. */
+    const CheckSum & checksum() const;
+    /** Set the \ref checksum. */
+    OnMediaLocation & setChecksum( CheckSum val_r );
+
+  public:
+    /** The size of the resource once it has been uncompressed or unpacked. */
+    const ByteCount & openSize() const;
+    /** Set the \ref openSize. */
+    OnMediaLocation & setOpenSize( ByteCount val_r );
+
+    /** The checksum of the resource once it has been uncompressed or unpacked. */
+    const CheckSum & openChecksum() const;
+    /** Set the \ref openChecksum. */
+    OnMediaLocation & setOpenChecksum( CheckSum val_r );
+
+  public:
+    /** The size of the header prepending the resource (e.g. for zchunk). */
+    const ByteCount & headerSize() const;
+    /** Set the \ref headerSize. */
+    OnMediaLocation & setHeaderSize( ByteCount val_r );
+
+    /** The checksum of the header prepending the resource (e.g. for zchunk). */
+    const CheckSum & headerChecksum() const;
+    /** Set the \ref headerChecksum. */
+    OnMediaLocation & setHeaderChecksum( CheckSum val_r );
+
+    /** The existing deltafile that can be used to reduce download size ( zchunk or metalink ) */
+    const Pathname & deltafile() const;
+    /** Set the \ref deltafile. */
+    OnMediaLocation & setDeltafile( Pathname path );
+
+
+  public:
+    class Impl;                 ///< Implementation class.
+  private:
+    RWCOW_pointer<Impl> _pimpl; ///< Pointer to implementation.
+  };
+
+  /** \relates OnMediaLocation Stream output */
+  std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj );
+
+  /** \relates OnMediaLocation Verbose stream output */
+  std::ostream & dumOn( std::ostream & str, const OnMediaLocation & obj );
+
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_ONMEDIALOCATION_H
diff --git a/zypp-core/parser/IniDict b/zypp-core/parser/IniDict
new file mode 100644 (file)
index 0000000..57eb9f0
--- /dev/null
@@ -0,0 +1 @@
+#include "inidict.h"
diff --git a/zypp-core/parser/IniParser b/zypp-core/parser/IniParser
new file mode 100644 (file)
index 0000000..2ecce9b
--- /dev/null
@@ -0,0 +1 @@
+#include "iniparser.h"
diff --git a/zypp-core/parser/ParseException b/zypp-core/parser/ParseException
new file mode 100644 (file)
index 0000000..cc3cb37
--- /dev/null
@@ -0,0 +1 @@
+#include "parseexception.h"
diff --git a/zypp-core/parser/Sysconfig b/zypp-core/parser/Sysconfig
new file mode 100644 (file)
index 0000000..411b8f0
--- /dev/null
@@ -0,0 +1 @@
+#include "sysconfig.h"
similarity index 98%
rename from zypp/parser/IniDict.cc
rename to zypp-core/parser/inidict.cc
index 3341ed1..5c7596b 100644 (file)
@@ -6,14 +6,17 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file      zypp/parser/IniDict.cc
+/** \file      zypp-core/parser/inidict.cc
  *
 */
+
+#include "inidict.h"
+
 #include <iostream>
-#include <zypp/base/Logger.h>
 #include <map>
 #include <string>
-#include <zypp/parser/IniDict.h>
+
+#include <zypp-core/base/Logger.h>
 
 using std::endl;
 
diff --git a/zypp-core/parser/inidict.h b/zypp-core/parser/inidict.h
new file mode 100644 (file)
index 0000000..d729134
--- /dev/null
@@ -0,0 +1,172 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp-core/parser/IniDict
+ *
+*/
+#ifndef ZYPP_PARSER_INIDICT_H
+#define ZYPP_PARSER_INIDICT_H
+
+#include <iosfwd>
+#include <map>
+#include <string>
+
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/Iterator.h>
+#include <zypp-core/base/Iterable.h>
+#include <zypp-core/parser/IniParser>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace parser
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : IniDict
+    //
+    /**
+     * Parses a INI file and offers its structure as a
+     * dictionary.
+     *
+     */
+    class IniDict : public IniParser
+    {
+      friend std::ostream & operator<<( std::ostream & str, const IniDict & obj );
+    public:
+      typedef std::map<std::string, std::string> EntrySet;
+      typedef std::map<std::string, EntrySet> SectionSet;
+      typedef MapKVIteratorTraits<SectionSet>::Key_const_iterator section_const_iterator;
+      typedef EntrySet::const_iterator entry_const_iterator;
+
+      /**
+       * \name Section Iterators
+       * Iterate trough ini file sections
+       * \code
+       * for ( IniDict::section_const_iterator it = dict.sectionsBegin();
+       *       it != dict.sectionsEnd();
+       *       ++it )
+       * {
+       *   MIL << (*it) << endl;
+       * }
+       * \endcode
+       */
+       //@{
+      section_const_iterator sectionsBegin() const;
+      section_const_iterator sectionsEnd() const;
+      Iterable<section_const_iterator> sections() const;
+      //@}
+
+      /**
+       * \name Entries Iterators
+       * Iterate trough ini file entries in a section
+       * \code
+       * for ( IniDict::entry_const_iterator it = dict.entriesBegin("updates");
+       *       it != dict.entriesEnd("updates");
+       *       ++it )
+       * {
+       *   MIL << (*it).first << endl;
+       * }
+       * \endcode
+       */
+
+      //@{
+      entry_const_iterator entriesBegin(const std::string &section) const;
+      entry_const_iterator entriesEnd(const std::string &section) const;
+      Iterable<entry_const_iterator> entries(const std::string &section) const;
+      //@{
+
+      /**
+       * Creates a dictionary from a InputStream
+       * containing a ini structured file
+       */
+      IniDict( const InputStream &is,
+               const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
+
+      /**
+       * Creates a mepty dictionary
+       */
+      IniDict();
+
+      /** Dtor */
+      ~IniDict();
+
+      /**
+       * Fill a dictionary from a InputStream
+       * containing a ini structured file
+       */
+      void read( const InputStream &is,
+                 const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
+
+      /**
+       * \short add an entry
+       * \param section
+       * \param key
+       * \param value
+       */
+      void insertEntry( const std::string &section,
+                        const std::string &key,
+                        const std::string &value );
+
+      /**
+       * \short add an entry
+       * \param section
+       * \param key
+       * \param value
+       */
+      void deleteSection( const std::string &section );
+
+      /**
+       * \short True if there is a section with that name
+       * \param section Section Name
+       */
+      bool hasSection( const std::string &section ) const;
+
+      /**
+       * \short True if an entry exists in the section
+       * \param section Section name
+       * \param entry entry name
+       *
+       * \note If the given section does not exist, this will
+       * of course return false.
+       */
+      bool hasEntry( const std::string &section,
+                     const std::string &entry ) const;
+    public:
+
+      /** Called when a section is found. */
+      virtual void consume( const std::string &section );
+      /** Called when a key value is found. */
+      virtual void consume( const std::string &section,
+                            const std::string &key,
+                            const std::string &value );
+
+    private:
+      SectionSet _dict;
+      /**
+       * empty map used to simulate
+       * iteration in non existant
+       * sections
+       */
+      EntrySet _empty_map;
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /** \relates IniDict Stream output */
+    std::ostream & operator<<( std::ostream & str, const IniDict & obj );
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace parser
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_PARSER_INIDICT_H
similarity index 94%
rename from zypp/parser/IniParser.cc
rename to zypp-core/parser/iniparser.cc
index a785d83..219fac9 100644 (file)
@@ -9,17 +9,19 @@
 /** \file      zypp/parser/IniParser.cc
  *
 */
+
+#include "iniparser.h"
+
 #include <iostream>
 #include <sstream>
 
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/base/IOStream.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/base/IOStream.h>
+#include <zypp-core/base/UserRequestException>
 
-#include <zypp/parser/ParseException.h>
-#include <zypp/parser/IniParser.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/parser/ParseException>
+#include <zypp-core/ui/ProgressData>
 
 using std::endl;
 
diff --git a/zypp-core/parser/iniparser.h b/zypp-core/parser/iniparser.h
new file mode 100644 (file)
index 0000000..da7e289
--- /dev/null
@@ -0,0 +1,96 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/parser/IniParser.h
+ *
+*/
+#ifndef ZYPP_CORE_PARSER_INIPARSER_H
+#define ZYPP_CORE_PARSER_INIPARSER_H
+
+#include <iosfwd>
+#include <string>
+#include <list>
+
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/base/NonCopyable.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/ui/ProgressData>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace parser
+{ /////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+/// \class IniParser
+/// \brief Simple INI-file parser
+///
+/// Lines staring with \c ; or \c # are treated as comment. Section
+/// names are enclosed by <tt>[]</tt>. Key and value are separated by \c =.
+///
+/// Lines without \c = or with a key containing any of "<tt>,|\\/</tt>"
+/// or section lines without closing \c ] are considered garbage.
+///
+class IniParser : private base::NonCopyable
+{
+public:
+  /** Default ctor */
+  IniParser();
+  /** Dtor */
+  virtual ~IniParser();
+  /** Parse the stream.
+   * \throw ParseException on errors. Invoke \ref consume
+   * for each tag. \ref consume might throw other exceptions
+   * as well.
+  */
+  void parse( const InputStream & imput_r, const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
+
+public:
+  /** Called when start parsing. */
+  virtual void beginParse();
+  /** Called when a section is found. */
+  virtual void consume( const std::string &section );
+  /** Called when a key value is found. */
+  virtual void consume( const std::string &section, const std::string &key, const std::string &value );
+  /** Called when the parse is done. */
+  virtual void endParse();
+
+  /** Called whenever a garbage line is found.
+   *
+   * \throw ParseException if not overloaded.
+   *
+   * Derived parsers may overload this to examine the line
+   * and call this method to actually throw the exception.
+   *
+   * Used by some parsers to accept multi-line entires.
+   */
+  virtual void garbageLine( const std::string &section, const std::string &line );
+
+public:
+  /** Name of the current InputStream. */
+  const std::string & inputname() const
+  {
+    return _inputname;
+  }
+
+private:
+  std::string _inputname;
+  std::string _current_section;
+  int _line_nr;
+  //ProgressData _ticks;
+};
+
+/////////////////////////////////////////////////////////////////
+} // namespace parser
+///////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_PARSER_INIPARSER_H
similarity index 96%
rename from zypp/parser/ParseException.cc
rename to zypp-core/parser/parseexception.cc
index dcb1a1e..bcc6463 100644 (file)
@@ -10,9 +10,7 @@
  *
 */
 #include <iostream>
-//#include <zypp/base/Logger.h>
-
-#include <zypp/parser/ParseException.h>
+#include "parseexception.h"
 
 using std::endl;
 
diff --git a/zypp-core/parser/parseexception.h b/zypp-core/parser/parseexception.h
new file mode 100644 (file)
index 0000000..08300c3
--- /dev/null
@@ -0,0 +1,53 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/parser/tagfile/ParseException.h
+ *
+*/
+#ifndef ZYPP_CORE_PARSER_PARSEEXCEPTION_H
+#define ZYPP_CORE_PARSER_PARSEEXCEPTION_H
+
+#include <iosfwd>
+#include <string>
+
+#include <zypp-core/base/Exception.h>
+#include <zypp-core/base/UserRequestException>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace parser
+  { /////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : ParseException
+    //
+    /** */
+    class ParseException : public Exception
+    {
+    public:
+      /** Default ctor */
+      ParseException();
+      /** Ctor */
+      ParseException( const std::string & msg_r );
+        /** Dtor */
+      virtual ~ParseException() throw();
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    };
+    ///////////////////////////////////////////////////////////////////
+
+    /////////////////////////////////////////////////////////////////
+  } // namespace parser
+  ///////////////////////////////////////////////////////////////////
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_PARSER_PARSEEXCEPTION_H
similarity index 91%
rename from zypp/base/Sysconfig.cc
rename to zypp-core/parser/sysconfig.cc
index d01f46f..00142fc 100644 (file)
@@ -6,23 +6,23 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file zypp/base/Sysconfig.cc
+/** \file zypp-core/parser/sysconfig.cc
  *
 */
 
+#include "sysconfig.h"
+
 #include <iostream>
 #include <fstream>
 
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/base/StrMatcher.h>
-#include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/Pathname.h>
-#include <zypp/PathInfo.h>
-#include <zypp/TmpPath.h>
-
-#include <zypp/base/Sysconfig.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/base/Regex.h>
+#include <zypp-core/base/IOStream.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/fs/PathInfo.h>
+#include <zypp-core/fs/TmpPath.h>
 
 using std::endl;
 using namespace zypp::base;
@@ -94,12 +94,12 @@ namespace zypp {
         bool found = false;
         filesystem::TmpFile tmpf( filesystem::TmpFile::makeSibling( path_r ) );
         {
-          StrMatcher matches( "^[ \t]*"+key_r+"[ \t]*=", Match::REGEX );
+          str::regex regex( "^[ \t]*"+key_r+"[ \t]*=" );
           std::ofstream o( tmpf.path().c_str() );
           iostr::forEachLine( InputStream( path_r ),
                               [&]( int num_r, std::string line_r )->bool
                               {
-                                if ( !found && matches( line_r ) )
+                                if ( !found && regex.matches( line_r ) )
                                 {
                                   o << key_r << '=' << val_r << endl;
                                   found = true;
diff --git a/zypp-core/parser/sysconfig.h b/zypp-core/parser/sysconfig.h
new file mode 100644 (file)
index 0000000..23305c5
--- /dev/null
@@ -0,0 +1,72 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-core/parser/Sysconfig
+ *
+*/
+#ifndef ZYPP_CORE_PARSER_SYSCONFIG_H
+#define ZYPP_CORE_PARSER_SYSCONFIG_H
+
+#include <string>
+#include <map>
+#include <zypp-core/Pathname.h>
+
+namespace zypp {
+  namespace base {
+    namespace sysconfig {
+
+      /** Read sysconfig file \a path_r and return <tt>(key,valye)</tt> pairs. */
+      std::map<std::string,std::string> read( const Pathname & _path );
+
+      /** Add or change a value in sysconfig file \a path_r.
+       *
+       * If \a key_r already exists, only the \a val_r is changed accordingly.
+       *
+       * In case \a key_r is not yet present in the file, a new entry may be created
+       * at the end of the file, using the lines in \a newcomment_r as comment
+       * block. If \a newcomment_r is not provided or empty, a new value is not
+       * created and \c false is returned.
+       *
+       * \returns \c TRUE if an entry was changed or created.
+       *
+       * \throws Exception if \a path_r can not be read or written.
+       *
+       * \note \a val_r is written as it is. The caller is responsible for escaping and
+       * enclosing in '"', in case this is needed (\see \ref writeStringVal and \ref str::escape).
+       *
+       * \note Lines in \a newcomment_r which do not already start with a '#',
+       * are prefixes with "# ".
+       *
+       * \code
+       *  ## Type: string
+       *  ## Default: ""
+       *  #
+       *  # A multiline description of
+       *  # the options purpose.
+       *  #
+       *  KEY="value"
+       * \endcode
+       */
+      bool write( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
+                  const std::string & newcomment_r = std::string() );
+
+      /** Convenience to add or change a string-value in sysconfig file \a path_r.
+       *
+       * \a val_r is expected to be a plain string value, so it is propery escaped and enclosed in
+       * double quotes before it is written to the sysconfig file \a path_r.
+       *
+       * \see \ref write
+       */
+      bool writeStringVal( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
+                           const std::string & newcomment_r = std::string() );
+
+    } // namespace sysconfig
+  } // namespace base
+} // namespace zypp
+
+#endif // ZYPP_CORE_PARSER_SYSCONFIG_H
diff --git a/zypp-core/ui/ProgressData b/zypp-core/ui/ProgressData
new file mode 100644 (file)
index 0000000..9285d77
--- /dev/null
@@ -0,0 +1 @@
+#include "progressdata.h"
similarity index 95%
rename from zypp/ProgressData.cc
rename to zypp-core/ui/progressdata.cc
index db72c82..82dc68e 100644 (file)
 */
 #include <iostream>
 #include <zypp/base/Logger.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/base/String.h>
 
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 
 using std::endl;
 
@@ -67,6 +67,7 @@ namespace zypp
     if ( _d->_state == INIT )
     {
       _d->_state = RUN;
+      DBG << str::form( "{#%u|%s} START", numericId(), name().c_str() ) << endl;
     }
     // XXX << str::form( "{#%u|%s}(%lld%s)", numericId(), name().c_str(), _d->_last_val, ( hasRange() ? "%" : "!" ) ) << endl;
 
@@ -85,7 +86,7 @@ namespace zypp
     }
     else if ( _d->_state == END )
     {
-      DBG << str::form( "{#%u|%s}END", numericId(), name().c_str() ) << endl;
+      DBG << str::form( "{#%u|%s} END", numericId(), name().c_str() ) << endl;
     }
 
     return true;       // continue per default
diff --git a/zypp-core/ui/progressdata.h b/zypp-core/ui/progressdata.h
new file mode 100644 (file)
index 0000000..f2241f3
--- /dev/null
@@ -0,0 +1,425 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp-core/ui/ProgressData
+ *
+*/
+#ifndef ZYPP_CORE_UI_PROGRESSDATA_H
+#define ZYPP_CORE_UI_PROGRESSDATA_H
+
+#include <iosfwd>
+#include <string>
+
+#include <zypp/base/PtrTypes.h>
+#include <zypp/base/Function.h>
+#include <zypp-core/base/ProvideNumericId>
+
+#include <zypp/Date.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  ///////////////////////////////////////////////////////////////////
+  //
+  //   CLASS NAME : ProgressData
+  //
+  /** Maintain <tt>[min,max]</tt> and counter <tt>(value)</tt> for progress counting.
+   *
+   * This class should provide everything the producer of progress data
+   * needs. As a convention, a zero sizes range indicates that you are just
+   * able to send <em>'still alive'</em> triggers.
+   *
+   * The counter should be updated in reasonable intervals. Don't mind whether
+   * the counter value actually increased or not. ProgressData will recognize
+   * your triggers and knows when to actually send notification to a consumer.
+   *
+   * Each ProgressData object provides a unique numeric id and you may assign
+   * it a name.
+   *
+   * \code
+   *      bool exampleReceiver( const ProgressData & ticks_r )
+   *      {
+   *        DBG << "got ->" << ticks_r.reportValue() << " (" << ticks_r.val() << ")" << endl;
+   *        return( ticks_r.val() <= 100 ); // Abort if ( val > 100 )
+   *      }
+   *
+   *      class Example
+   *      {
+   *        public:
+   *
+   *          Example( const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() )
+   *          : _fnc( fnc_r )
+   *          {}
+   *
+   *          void SendTo( const ProgressData::ReceiverFnc & fnc_r )
+   *          { _fnc = fnc_r; }
+   *
+   *        public:
+   *
+   *          void action()
+   *          {
+   *            ProgressData tics( 10 );    // Expect range 0 -> 10
+   *            tics.name( "test ticks" );  // Some arbitrary name
+   *            tics.sendTo( _fnc );        // Send reports to _fnc
+   *            tics.toMin();               // start sending min (0)
+   *
+   *            for ( int i = 0; i < 10; ++i )
+   *            {
+   *              if ( ! tics.set( i ) )
+   *                return; // user requested abort
+   *            }
+   *
+   *            tics.toMax(); // take care 100% are reported on success
+   *          }
+   *
+   *          void action2()
+   *          {
+   *            ProgressData tics;          // Just send 'still alive' messages
+   *            tics.name( "test ticks" );  // Some arbitrary name
+   *            tics.sendTo( _fnc );        // Send reports to _fnc
+   *            tics.toMin();               // start sending min (0)
+   *
+   *            for ( int i = 0; i < 10; ++i )
+   *            {
+   *              if ( ! tics.set( i ) )
+   *                return; // user requested abort
+   *            }
+   *
+   *            tics.toMax(); //
+   *          }
+   *
+   *        private:
+   *          ProgressData::ReceiverFnc _fnc;
+   *      };
+   * \endcode
+   * \code
+   *   Example t( exampleReceiver );
+   *   DBG << "Reporting %:" << endl;
+   *   t.action();
+   *   DBG << "Reporting 'still alive':" << endl;
+   *   t.action2();
+   * \endcode
+   * \code
+   * Reporting %:
+   * got ->0 (0)
+   * got ->10 (1)
+   * got ->20 (2)
+   * got ->30 (3)
+   * got ->40 (4)
+   * got ->50 (5)
+   * got ->60 (6)
+   * got ->70 (7)
+   * got ->80 (8)
+   * got ->90 (9)
+   * got ->100 (10)
+   * got ->100 (10)
+   * Reporting 'still alive':
+   * got ->-1 (0)
+   * got ->-1 (9)
+   * \endcode
+   *
+   * The different ammount of triggers is due to different rules for sending
+   * percent or 'still alive' messages.
+   */
+  class ProgressData : public base::ProvideNumericId<ProgressData,unsigned>
+  {
+    public:
+      typedef long long value_type;
+      /** Most simple version of progress reporting
+       * The percentage in most cases. Sometimes just keepalive.
+       * \p sender ProgressData object who sends the progress info
+       * \p
+       */
+      typedef function<bool( const ProgressData & )> ReceiverFnc;
+
+    private:
+      enum State { INIT, RUN, END };
+
+      class Data
+      {
+        public:
+          Data( value_type min_r, value_type max_r, value_type val_r )
+          : _state( INIT ), _min( min_r ), _max( max_r ), _val( val_r )
+          , _last_val( 0 ), _last_send( 0 )
+          {}
+
+        public:
+          State       _state;
+          std::string _name;
+          value_type  _min;
+          value_type  _max;
+          value_type  _val;
+
+          ReceiverFnc _receiver;
+          value_type  _last_val;
+          Date        _last_send;
+
+        private:
+          /** clone for RWCOW_pointer */
+          friend Data * rwcowClone<Data>( const Data * rhs );
+          Data * clone() const { return new Data( *this ); }
+      };
+
+    public:
+      /** Ctor no range <tt>[0,0](0)</tt>. */
+      ProgressData()
+      : _d( new Data( 0, 0, 0 ) )
+      {}
+
+      /** Ctor <tt>[0,max](0)</tt>. */
+      ProgressData( value_type max_r )
+      : _d( new Data( 0, max_r, 0 ) )
+      {}
+
+      /** Ctor <tt>[min,max](min)</tt>. */
+      ProgressData( value_type min_r, value_type max_r )
+      : _d( new Data( min_r, max_r, min_r ) )
+      {}
+
+      /** Ctor <tt>[min,max](val)</tt>. */
+      ProgressData( value_type min_r, value_type max_r, value_type val_r )
+      : _d( new Data( min_r, max_r, val_r ) )
+      {}
+
+      ~ProgressData()
+      {
+        if ( _d->_state == RUN )
+        {
+          _d->_state = END;
+          report();
+        }
+      }
+
+    public:
+      /** Set new \c min value. */
+      void min( value_type min_r )
+      { _d->_min = min_r; }
+
+      /** Set new \c max value. */
+      void max( value_type max_r )
+      { _d->_max = max_r; }
+
+      /** Set no range <tt>[0,0]</tt>. */
+      void noRange()
+      { range( 0, 0 ); }
+
+      /** Set new <tt>[0,max]</tt>. */
+      void range( value_type max_r )
+      { range( 0, max_r ); }
+
+      /** Set new <tt>[min,max]</tt>. */
+      void range( value_type min_r, value_type max_r )
+      { min( min_r ); max( max_r ); }
+
+    public:
+      /** Set counter name. */
+      void name( const std::string & name_r )
+      { _d->_name = name_r; }
+
+      /** Set ReceiverFnc. */
+      void sendTo( const ReceiverFnc & fnc_r )
+      { _d->_receiver = fnc_r; }
+
+      /** Set no ReceiverFnc. */
+      void noSend()
+      { _d->_receiver = ReceiverFnc(); }
+
+    public:
+      /** \name Progress reporting.
+       *
+       * These methods may actually cause a progress report to be sent.
+       *
+       * All methods return \c bool, because a progress receiver may
+       * return \c false to indicate the desire to abort the pending
+       * action. The incident is logged, but it's finaly up to the caller
+       * to honor this.
+       */
+      //@{
+
+      /** Set new counter \c value. */
+      bool set( value_type val_r )
+      {
+        _d->_val = val_r;
+        return report();
+      }
+
+      /** Set range and counter from an other \ref ProgressData. */
+      bool set( const ProgressData & rhs )
+      {
+        min( rhs.min() );
+        max( rhs.max() );
+        return set( rhs.val() );
+      }
+
+      /** Increment counter \c value (default by 1). */
+      bool incr( value_type val_r = 1 )
+      { return set( val() + val_r ); }
+
+      /** Decrement counter \c value (default by 1). */
+      bool decr( value_type val_r = 1 )
+      { return set( val() - val_r ); }
+
+      /** Set counter value to current \c min value. */
+      bool toMin()
+      { return set( min() ); }
+
+      /** Set counter value to current \c max value (unless no range). */
+      bool toMax()
+      { return hasRange() ? set( max() ) : tick(); }
+
+      /** Leave counter value unchanged (still alive). */
+      bool tick()
+      { return report(); }
+
+      //@}
+
+    public:
+      /** \name Progress receiving.
+       */
+      //@{
+      /** @return Current \c min value. */
+      value_type min() const
+      { return _d->_min; }
+
+      /** @return Current \c max value. */
+      value_type max() const
+      { return _d->_max; }
+
+      /** @return Current counter \c value. */
+      value_type val() const
+      { return _d->_val; }
+
+      /** @return Whether <tt>[min,max]</tt> defines a nonempty range. */
+      bool hasRange() const
+      { return min() != max(); }
+
+      /** @return Whether \ref reportValue will return a percent value.
+       * Same as \ref hasRange.
+       *  \see \ref reportAlive
+       */
+      bool reportPercent() const
+      { return hasRange(); }
+
+      /** @return Whether \ref reportValue always returns -1, because we
+       * trigger 'still alive' messages. I.e. \ref hasrange is \c false.
+       * \see \ref reportPercent
+      */
+      bool reportAlive() const
+      { return ! hasRange(); }
+
+      /** @return Either a a percent value or -1.
+       * \see \ref reportPercent and \ref reportAlive.
+      */
+      value_type reportValue() const
+      {        return hasRange() ? val() * 100 / ( max() - min() ) : -1; }
+
+      /** @return The counters name. */
+      const std::string & name() const
+      { return _d->_name; }
+
+      /** @return The ReceiverFnc. */
+      const ReceiverFnc & receiver() const
+      { return _d->_receiver; }
+
+      /** @return Return \c true if this is the final report sent by the
+       *  ProgressData dtor.
+       */
+      bool finalReport() const
+      { return( _d->_state == END ); }
+
+      //@}
+
+    private:
+      /** Send report if necessary. */
+      bool report();
+
+      /** Pointer to data. */
+      RWCOW_pointer<Data> _d;
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /** \relates ProgressData Stream output */
+  std::ostream & operator<<( std::ostream & str, const ProgressData & obj );
+
+  ///////////////////////////////////////////////////////////////////
+
+  class InputStream;
+  /** \relates ProgressData Setup from \ref InputStream. */
+  ProgressData makeProgressData( const InputStream & input_r );
+
+  ///////////////////////////////////////////////////////////////////
+
+  /**
+   * \short Progress callback from another progress
+   *
+   * This class allows you to pass a progress callback to a
+   * subtask based on a current progress data, plus a weight
+   * value. Every progress reported by the subtask via
+   * this callback will be forwarded to the main progress
+   * data, with the corresponding weight.
+   *
+   * Example:
+   *
+   * \code
+   *
+   * // receiver for main task
+   * void task_receiver( ProgressData &progress );
+   *
+   * // subtask prototypes
+   * void do_subtask_one( ProgressData::ReceiverFnc &fnc );
+   * void do_subtask_two( ProgressData::ReceiverFnc &fnc );
+   *
+   * // main task
+   * ProgressData progress;
+   * //progress for subtask 1
+   * // which is 80%
+   * CombinedProgressData sub1(pd, 80);
+   * // the second is only 20%
+   * CombinedProgressData sub2(pd, 20);
+   * do_subtask_one( sub1 );
+   * do_subtask_two( sub2 );
+   *
+   * \endcode
+   */
+  class CombinedProgressData
+  {
+  public:
+    /**
+     * \short Ctor
+     *
+     * Creates a \ref ProgressData::ReceiverFnc
+     * from a \ref ProgressData object
+     *
+     * \param pd \ref ProgressData object
+     * \param weight Weight of the subtask
+     * relative to the main task range.
+     *
+     * If weight is 0, or \param pd only reports
+     * keepalives. then only ticks are sent.
+     *
+     */
+    CombinedProgressData( ProgressData &pd,
+                          ProgressData::value_type weight = 0 );
+
+    /**
+     * Implements the \ref ProgressData::ReceiverFnc
+     * callback interface
+     */
+    bool operator()( const ProgressData &progress );
+
+  private:
+    ProgressData::value_type _weight;
+    ProgressData::value_type _last_value;
+    ProgressData &_pd;
+  };
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_CORE_UI_PROGRESSDATA_H
diff --git a/zypp-core/zyppng/async/AsyncOp b/zypp-core/zyppng/async/AsyncOp
new file mode 100644 (file)
index 0000000..a3dadb9
--- /dev/null
@@ -0,0 +1 @@
+#include "asyncop.h"
diff --git a/zypp-core/zyppng/async/asyncop.h b/zypp-core/zyppng/async/asyncop.h
new file mode 100644 (file)
index 0000000..0fcbd54
--- /dev/null
@@ -0,0 +1,178 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_ASYNC_ASYNCOP_H_INCLUDED
+#define ZYPPNG_ASYNC_ASYNCOP_H_INCLUDED
+
+
+#include <zypp-core/base/Exception.h>
+#include <zypp-core/zyppng/base/Signals>
+#include <boost/optional.hpp>
+#include <memory>
+
+namespace zyppng {
+
+  /*!
+   * Thrown if code tries to access the result of a async operation
+   * that is not ready.
+   */
+  class AsyncOpNotReadyException : public zypp::Exception
+  {
+  public:
+    AsyncOpNotReadyException()
+      : Exception( "AsyncOp instance not ready" )
+    {}
+    virtual ~AsyncOpNotReadyException();
+  };
+
+  AsyncOpNotReadyException::~AsyncOpNotReadyException()
+  { }
+
+  /*!
+   *\class AsyncOp
+   * The \a AsyncOp template class is the basic building block for the asynchronous pipelines.
+   * Its the base for all async callbacks as well as the async result type. That basically means
+   * every pipeline is just a AsyncOp that contains all previous operations that were defined in the pipeline.
+   *
+   * When implementing a async operation it is required to add a operator() to the class taking the
+   * input parameter. After the operation is finished the implementation must call setReady(). Calling
+   * setReady() must be treated like calling return in a normal function and not execute anymore code on the
+   * AsyncOp instance afterwards, since the next operation in the pipeline is allowed to free the previous operation
+   * as soon as it gets ready.
+   *
+   * In case no next operation is defined on the AsyncOp ( when the instance is used as result object ) the return value
+   * is cached internally and can be retrieved with \sa get().
+   *
+   * A async operation can be cancelled by releasing the result object ( the resulting combinatory object ), this will
+   * destroy all previous operations that are either running or pending as well.
+   */
+  template <typename Result>
+  struct AsyncOp {
+
+    using value_type = Result;
+
+    AsyncOp () = default;
+
+    AsyncOp ( const AsyncOp &other ) = delete;
+    AsyncOp& operator= ( const AsyncOp &other ) = delete;
+
+    AsyncOp& operator= ( AsyncOp &&other ) = default;
+    AsyncOp ( AsyncOp &&other ) = default;
+
+    virtual ~AsyncOp(){}
+
+    /*!
+     * Sets the async operation ready, in case a callback
+     * is registered the \a val is directly forwarded without
+     * storing it.
+     */
+    void setReady ( value_type && val ) {
+      if ( _readyCb )
+        _readyCb( std::move( val ) );
+      else { //we need to cache the value because no callback is available
+        _maybeValue = std::move(val);
+        _sigReady.emit();
+      }
+    }
+
+    /*!
+     * Checks if the async operation already has finished.
+     *
+     * \note This can only be used when no callback is registered.
+     */
+    bool isReady () const {
+      return _maybeValue.is_initialized();
+    }
+
+    /*!
+     * Registeres a callback that is immediately called
+     * when the object gets into ready state. In case the
+     * object is in ready state when registering the callback
+     * it is called right away.
+     */
+    template< typename Fun >
+    void onReady ( Fun cb ) {
+      this->_readyCb =  std::forward<Fun>(cb);
+
+      if ( isReady() ) {
+        _readyCb( std::move( _maybeValue.get()) );
+        _maybeValue = boost::optional<value_type>();
+      }
+    }
+
+    /*!
+     * Returns the internally cached value if there is one.
+     * \throws AsyncOpNotReadyException if called before the operation is ready
+     */
+    value_type &get (){
+      if ( !isReady() )
+        ZYPP_THROW(AsyncOpNotReadyException());
+      return _maybeValue.get();
+    }
+
+    /*!
+     * Signal that is emitted once the AsyncOp is ready and no
+     * callback was registered with \ref onReady
+     */
+    SignalProxy<void()> sigReady () {
+      return _sigReady;
+    }
+
+  private:
+    Signal<void()> _sigReady;
+    std::function<void(value_type &&)> _readyCb;
+    boost::optional<value_type> _maybeValue;
+  };
+
+  template <typename T>
+  using AsyncOpPtr = std::unique_ptr<AsyncOp<T>>;
+
+  namespace detail {
+
+#if 0
+    template <typename T>
+    using has_value_type_t = typename T::value_type;
+
+    template <typename T, typename AsyncRet>
+    using is_asyncop_type = std::is_convertible<T*, AsyncOp<AsyncRet>*>;
+
+
+    template <typename T>
+    using is_async_op = typename std::conjunction<
+        std::is_detected< has_value_type_t, T >,
+        std::is_detected< is_asyncop_type, T, typename T::value_type >
+      >;
+
+#else
+
+    /*!
+     * Checks if a type T is a asynchronous operation type
+     */
+    template < typename T, typename = std::void_t<> >
+    struct is_async_op : public std::false_type{};
+
+    template < typename T >
+    struct is_async_op<T,
+      std::void_t< typename T::value_type, //needs to have a value_type
+        std::enable_if_t<std::is_convertible< T*, AsyncOp<typename T::value_type>* >::value>>> //needs to be convertible to AsyncOp<T::value_type>
+      : public std::true_type{};
+
+#endif
+
+  }
+
+}
+
+
+
+#endif
index 0aa0fbf..20c2179 100644 (file)
@@ -59,6 +59,9 @@ namespace zyppng {
     off_t writeData(const char *data, off_t count) override;
     off_t readData(char *buffer, off_t bufsize) override;
     size_t rawBytesAvailable() const override;
+
+  private:
+    using IODevice::open;
   };
 }
 
diff --git a/zypp-core/zyppng/meta/FunctionTraits b/zypp-core/zyppng/meta/FunctionTraits
new file mode 100644 (file)
index 0000000..9ca6429
--- /dev/null
@@ -0,0 +1 @@
+#include "function_traits.h"
diff --git a/zypp-core/zyppng/meta/Functional b/zypp-core/zyppng/meta/Functional
new file mode 100644 (file)
index 0000000..e910f69
--- /dev/null
@@ -0,0 +1 @@
+#include "functional.h"
diff --git a/zypp-core/zyppng/meta/TypeTraits b/zypp-core/zyppng/meta/TypeTraits
new file mode 100644 (file)
index 0000000..a7648c8
--- /dev/null
@@ -0,0 +1 @@
+#include "type_traits.h"
diff --git a/zypp-core/zyppng/meta/function_traits.h b/zypp-core/zyppng/meta/function_traits.h
new file mode 100644 (file)
index 0000000..be84530
--- /dev/null
@@ -0,0 +1,77 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+* //Code based on a blogpost on https://functionalcpp.wordpress.com/2013/08/05/function-traits/
+*
+*/
+#ifndef ZYPPNG_META_FUNCTION_TRAITS_H_INCLUDED
+#define ZYPPNG_META_FUNCTION_TRAITS_H_INCLUDED
+
+#include <cstddef>
+#include <tuple>
+#include <zypp-core/zyppng/meta/TypeTraits>
+
+namespace zyppng {
+
+template<class F, class = void >
+struct function_traits;
+
+template<class R, class... Args>
+struct function_traits<R(Args...)>
+{
+    using return_type = R;
+
+    static constexpr std::size_t arity = sizeof...(Args);
+
+    template <std::size_t N>
+    struct argument
+    {
+        static_assert(N >= 0 && N < arity, "error: invalid parameter index.");
+        using type = typename std::tuple_element<N,std::tuple<Args...>>::type;
+    };
+};
+
+// function pointer
+template<class R, class... Args>
+struct function_traits<R(*)(Args...)> : public function_traits<R(Args...)>
+{ };
+
+// function ref
+template<class R, class... Args>
+struct function_traits<R(&)(Args...)> : public function_traits<R(Args...)>
+{ };
+
+// member function pointer
+template<class C, class R, class... Args>
+struct function_traits<R(C::*)(Args...)> : public function_traits<R(C&,Args...)>
+{};
+
+// const member function pointer, this will match lambdas too
+template<class C, class R, class... Args>
+struct function_traits<R(C::*)(Args...) const>  : public function_traits<R(C&,Args...)>
+{};
+
+// member object pointer
+template<class C, class R>
+struct function_traits<R(C::*)> : public function_traits<R(C&)>
+{};
+
+template <typename T>
+using has_call_operator = decltype (&T::operator());
+
+//functor with one overload
+template<class F>
+struct function_traits<F, std::void_t<decltype (&F::operator())>> : public function_traits<decltype (&F::operator())>
+{};
+
+}
+#endif
diff --git a/zypp-core/zyppng/meta/functional.h b/zypp-core/zyppng/meta/functional.h
new file mode 100644 (file)
index 0000000..4b76972
--- /dev/null
@@ -0,0 +1,49 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_META_FUNCTIONAL_H_INCLUDED
+#define ZYPPNG_META_FUNCTIONAL_H_INCLUDED
+
+#include <functional>
+
+#if __cplusplus <= 201402L || !defined ( __cpp_lib_invoke )
+
+#include <type_traits>
+
+// this is a workaround for std::invoke not being available in C++14
+// and the proposed minimal implementation in
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4169.html
+
+namespace std {
+  template<typename Functor, typename... Args>
+  typename std::enable_if<
+    std::is_member_pointer<typename std::decay<Functor>::type>::value,
+    typename std::result_of<Functor&&(Args&&...)>::type
+  >::type invoke(Functor&& f, Args&&... args)
+  {
+    return std::mem_fn(f)(std::forward<Args>(args)...);
+  }
+
+  template<typename Functor, typename... Args>
+  typename std::enable_if<
+    !std::is_member_pointer<typename std::decay<Functor>::type>::value,
+    typename std::result_of<Functor&&(Args&&...)>::type
+  >::type invoke(Functor&& f, Args&&... args)
+  {
+    return std::forward<Functor>(f)(std::forward<Args>(args)...);
+  }
+}
+
+#endif
+
+#endif
diff --git a/zypp-core/zyppng/meta/type_traits.h b/zypp-core/zyppng/meta/type_traits.h
new file mode 100644 (file)
index 0000000..2e4a58b
--- /dev/null
@@ -0,0 +1,124 @@
+#ifndef ZYPPNG_META_TYPE_TRAITS_INCLUDED
+#define ZYPPNG_META_TYPE_TRAITS_INCLUDED
+
+#include <type_traits>
+#include <memory>
+
+#if !defined ( __cpp_lib_void_t )
+
+namespace std {
+  //define void_t since its only available starting with C++17 in some compilers
+  template<typename... Ts> struct make_void { typedef void type;};
+  template<typename... Ts> using void_t = typename make_void<Ts...>::type;
+}
+
+#endif
+
+
+#if __cplusplus < 201703L
+
+namespace std {
+
+//implementation of the detector idiom, used to help with SFINAE
+//from https://en.cppreference.com/w/cpp/experimental/is_detected
+
+namespace detail {
+template <class Default, class AlwaysVoid,
+  template<class...> class Op, class... Args>
+struct detector {
+  using value_t = std::false_type;
+  using type = Default;
+};
+
+template <class Default, template<class...> class Op, class... Args>
+struct detector<Default, std::void_t<Op<Args...>>, Op, Args...> {
+  using value_t = std::true_type;
+  using type = Op<Args...>;
+};
+
+struct nonesuch{
+  ~nonesuch( )                     = delete;
+  nonesuch( nonesuch const& )      = delete;
+  void operator = ( nonesuch const& ) = delete;
+};
+
+} // namespace detail
+
+template <bool B> using bool_constant = integral_constant<bool, B>;
+
+template <template<class...> class Op, class... Args>
+using is_detected = typename detail::detector<detail::nonesuch, void, Op, Args...>::value_t;
+
+template <template<class...> class Op, class... Args>
+using detected_t = typename detail::detector<detail::nonesuch, void, Op, Args...>::type;
+
+template <class Default, template<class...> class Op, class... Args>
+using detected_or = detail::detector<Default, void, Op, Args...>;
+
+template< template<class...> class Op, class... Args >
+constexpr bool is_detected_v = is_detected<Op, Args...>::value;
+
+template< class Default, template<class...> class Op, class... Args >
+using detected_or_t = typename detected_or<Default, Op, Args...>::type;
+
+template <class Expected, template<class...> class Op, class... Args>
+using is_detected_exact = std::is_same<Expected, detected_t<Op, Args...>>;
+
+template <class Expected, template<class...> class Op, class... Args>
+constexpr bool is_detected_exact_v = is_detected_exact<Expected, Op, Args...>::value;
+
+template <class To, template<class...> class Op, class... Args>
+using is_detected_convertible = std::is_convertible<detected_t<Op, Args...>, To>;
+
+template <class To, template<class...> class Op, class... Args>
+constexpr bool is_detected_convertible_v = is_detected_convertible<To, Op, Args...>::value_t::value;
+
+//https://en.cppreference.com/w/cpp/types/conjunction)
+template<class...> struct conjunction : std::true_type { };
+template<class B1> struct conjunction<B1> : B1 { };
+template<class B1, class... Bn>
+struct conjunction<B1, Bn...>
+    : std::conditional_t<bool(B1::value), conjunction<Bn...>, B1> {};
+
+//https://en.cppreference.com/w/cpp/types/disjunction
+template<class...> struct disjunction : std::false_type { };
+template<class B1> struct disjunction<B1> : B1 { };
+template<class B1, class... Bn>
+struct disjunction<B1, Bn...>
+    : std::conditional_t<bool(B1::value), B1, disjunction<Bn...>>  { };
+
+//https://en.cppreference.com/w/cpp/types/negation
+template<class B>
+struct negation : std::bool_constant< !bool(B::value)> { };
+
+}
+#endif
+
+
+namespace zyppng {
+  //check wether something is a instance of a template type
+  template < template< class ... > class Templ, class Type >
+  struct is_instance_of : std::false_type{};
+
+  template < template< typename ... > class Templ, typename... Args >
+  struct is_instance_of<Templ, Templ<Args...>> : std::true_type{};
+
+  //Provides the member typedef type which is the type pointed to by T, or, if T is not a pointer, then type is the same as T.
+  template< typename T>
+  struct remove_smart_ptr{ using type = typename std::remove_cv<T>::type; };
+
+  template< typename T>
+  struct remove_smart_ptr<std::shared_ptr<T>>{ using type = typename std::remove_cv<T>::type; };
+
+  template< typename T>
+  struct remove_smart_ptr<std::unique_ptr<T>>{ using type = typename std::remove_cv<T>::type; };
+
+  template< typename T>
+  using remove_smart_ptr_t = typename remove_smart_ptr<T>::type;
+
+  //helper template to print type parameters
+  template <typename T>
+  class myerror_t;
+}
+
+#endif
diff --git a/zypp-core/zyppng/pipelines/AsyncResult b/zypp-core/zyppng/pipelines/AsyncResult
new file mode 100644 (file)
index 0000000..f18a9f5
--- /dev/null
@@ -0,0 +1 @@
+#include "asyncresult.h"
diff --git a/zypp-core/zyppng/pipelines/Await b/zypp-core/zyppng/pipelines/Await
new file mode 100644 (file)
index 0000000..e810934
--- /dev/null
@@ -0,0 +1 @@
+#include "await.h"
diff --git a/zypp-core/zyppng/pipelines/Expected b/zypp-core/zyppng/pipelines/Expected
new file mode 100644 (file)
index 0000000..88660ed
--- /dev/null
@@ -0,0 +1 @@
+#include "expected.h"
diff --git a/zypp-core/zyppng/pipelines/Lift b/zypp-core/zyppng/pipelines/Lift
new file mode 100644 (file)
index 0000000..21b7993
--- /dev/null
@@ -0,0 +1 @@
+#include "lift.h"
diff --git a/zypp-core/zyppng/pipelines/MTry b/zypp-core/zyppng/pipelines/MTry
new file mode 100644 (file)
index 0000000..dd9e772
--- /dev/null
@@ -0,0 +1 @@
+#include "mtry.h"
diff --git a/zypp-core/zyppng/pipelines/Redo b/zypp-core/zyppng/pipelines/Redo
new file mode 100644 (file)
index 0000000..373b4f9
--- /dev/null
@@ -0,0 +1 @@
+#include "redo.h"
diff --git a/zypp-core/zyppng/pipelines/Transform b/zypp-core/zyppng/pipelines/Transform
new file mode 100644 (file)
index 0000000..070a973
--- /dev/null
@@ -0,0 +1 @@
+#include "transform.h"
diff --git a/zypp-core/zyppng/pipelines/Wait b/zypp-core/zyppng/pipelines/Wait
new file mode 100644 (file)
index 0000000..bc9e384
--- /dev/null
@@ -0,0 +1 @@
+#include "wait.h"
diff --git a/zypp-core/zyppng/pipelines/asyncresult.h b/zypp-core/zyppng/pipelines/asyncresult.h
new file mode 100644 (file)
index 0000000..15d072f
--- /dev/null
@@ -0,0 +1,283 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_MONADIC_ASYNCRESULT_H_INCLUDED
+#define ZYPPNG_MONADIC_ASYNCRESULT_H_INCLUDED
+
+#include <zypp-core/zyppng/meta/TypeTraits>
+#include <zypp-core/zyppng/meta/FunctionTraits>
+#include <zypp-core/zyppng/meta/Functional>
+#include <zypp-core/zyppng/async/AsyncOp>
+
+
+namespace zyppng {
+
+
+  namespace detail {
+
+    /*!
+     * Checks if a Callable object is of type async_op and if
+     * it accepts the given MsgType and returns the expected type
+     */
+    template< typename Callback, typename Ret, typename MsgType, typename = std::void_t<> >
+    struct is_future_monad_cb : public std::false_type{};
+
+    template< typename Callback, typename Ret, typename MsgType >
+    struct is_future_monad_cb<Callback, Ret, MsgType,
+      std::void_t<
+        typename Callback::value_type,
+        std::enable_if_t< std::is_same< typename Callback::value_type, Ret >::value >,
+        std::enable_if_t< is_async_op<Callback>::value >,
+        decltype ( std::declval<Callback>()( std::declval<MsgType>()) )//check if the callback has a operator() member with the correct signature
+        >
+      > : public std::true_type{};
+
+    /*!
+     * Checks if a Callable object is a syncronous callback type with the expected signature
+     */
+    template< typename Callback, typename MsgType, typename = std::void_t<> >
+    struct is_sync_monad_cb : public std::false_type{};
+
+    template< typename Callback, typename MsgType >
+    struct is_sync_monad_cb<Callback, MsgType
+      , std::void_t<
+        std::enable_if_t< !is_async_op<Callback>::value >,
+        std::enable_if_t< !std::is_same< void, decltype ( std::declval<Callback>()(std::declval<MsgType>())) >::value > > //check if the callback has the correct signature:  cb( MsgType )
+      > : public std::true_type{};
+
+
+    /*!
+     * The AsyncResult class is used to bind previous operations to a new operation and to carry
+     * the result of the full pipeline. It has a pointer to the _prevTask, which is usually
+     * a AsyncResult too, and to the task it should execute once the previous task enters ready state.
+     *
+     * In theory this is a single linked list, but each node owns all the previous nodes, means that once
+     * a node is destroyed all previous ones are destroyed as well. Basically the async results are nested objects, where
+     * the outermost object is the last to be executed. While executing the nodes they are cleaned up right away
+     * after they enter finished or ready state.
+     *
+     * When returned to the code the AsyncResult is casted into the AsyncOp base class, otherwise the type
+     * information gets too complex and matching the pipe operator functions is a nightmare. This could be revisited
+     * with newer C++ versions.
+     *
+     */
+    template <typename Prev, typename AOp, typename = void>
+    struct AsyncResult;
+
+    template <typename Prev, typename AOp >
+    struct AsyncResult<Prev,AOp> : public zyppng::AsyncOp< typename AOp::value_type > {
+
+      AsyncResult ( std::unique_ptr<Prev> && prevTask, std::unique_ptr<AOp> &&cb )
+        : _prevTask( std::move(prevTask) )
+        , _myTask( std::move(cb) ) {
+        connect();
+      }
+
+      AsyncResult ( const AsyncResult &other ) = delete;
+      AsyncResult& operator= ( const AsyncResult &other ) = delete;
+
+      AsyncResult ( AsyncResult &&other ) = delete;
+      AsyncResult& operator= ( AsyncResult &&other ) = delete;
+
+      virtual ~AsyncResult() {}
+
+      void connect () {
+        //not using a lambda here on purpose, binding this into a lambda that is stored in the _prev
+        //object causes segfaults on gcc when the lambda is cleaned up with the _prev objects signal instance
+        _prevTask->onReady( std::bind( &AsyncResult::readyWasCalled, this, std::placeholders::_1) );
+        _myTask->onReady( [this] ( typename AOp::value_type && res ){
+          this->setReady( std::move( res ) );
+        });
+      }
+
+    private:
+      void readyWasCalled ( typename Prev::value_type && res ) {
+        //we need to force the passed argument into our stack, otherwise we
+        //run into memory issues if the argument is moved out of the _prevTask object
+        typename Prev::value_type resStore = std::move(res);
+
+        if ( _prevTask ) {
+          //dumpInfo();
+          _prevTask.reset(nullptr);
+        }
+
+        _myTask->operator()(std::move(resStore));
+      }
+
+      std::unique_ptr<Prev> _prevTask;
+      std::unique_ptr<AOp> _myTask;
+    };
+
+    template<typename AOp, typename In>
+    struct AsyncResult<void, AOp, In> : public zyppng::AsyncOp< typename AOp::value_type > {
+
+      AsyncResult ( std::unique_ptr<AOp> &&cb )
+        : _myTask( std::move(cb) ) {
+        connect();
+      }
+
+      virtual ~AsyncResult() { }
+
+      void run ( In &&val ) {
+        _myTask->operator()( std::move(val) );
+      }
+
+      AsyncResult ( const AsyncResult &other ) = delete;
+      AsyncResult& operator= ( const AsyncResult &other ) = delete;
+
+      AsyncResult ( AsyncResult &&other ) = delete;
+      AsyncResult& operator= ( AsyncResult &&other ) = delete;
+
+    private:
+      void connect () {
+        _myTask->onReady( [this] ( typename AOp::value_type && in ){
+          this->setReady( std::move( in ) );
+        });
+      }
+      std::unique_ptr<AOp> _myTask;
+    };
+
+    //A async result that is ready right away
+    template <typename T>
+    struct ReadyResult : public zyppng::AsyncOp< T >
+    {
+      ReadyResult( T &&val ) {
+        this->setReady( std::move(val) );
+      }
+    };
+
+    //need a wrapper to connect a sync callback to a async one
+    template < typename Callback, typename In, typename Out >
+    struct SyncCallbackWrapper : public AsyncOp<Out>
+    {
+      using value_type = Out;
+
+      template< typename C = Callback >
+      SyncCallbackWrapper( C &&c ) : _c( std::forward<C>(c) ){}
+
+      virtual ~SyncCallbackWrapper(){ }
+
+      void operator() ( In &&value ) {
+        this->setReady( std::invoke( _c, std::move(value)) );
+      }
+
+    private:
+      Callback _c;
+    };
+
+    /*!
+     * Simple AsyncOperator wrapper that accepts a Async result
+     * forwarding the actual value when it gets ready. This is used to
+     * simplify nested asyncronous results.
+     */
+    template< typename AOp, typename Ret = typename AOp::value_type >
+    struct SimplifyHelper : public AsyncOp<Ret>
+    {
+
+      virtual ~SimplifyHelper(){}
+
+      void operator() ( std::unique_ptr<AOp> &&op ) {
+        assert( !_task );
+        _task = std::move(op);
+        _task->onReady( [this]( Ret &&val ){
+          this->setReady( std::move(val) );
+        });
+      }
+    private:
+      std::unique_ptr<AOp> _task;
+    };
+
+    /*!
+     * Takes a possibly nested future and simplifies it,
+     * so instead of AsyncResult<AsyncResult<int>> we get AsyncResult<int>.
+     * Usually we do not want to wait on the future of a future but get the nested result immediately
+     */
+    template < typename Res >
+    inline std::unique_ptr<AsyncOp<Res>> simplify ( std::unique_ptr< AsyncOp<Res> > &&res ) {
+      return std::move(res);
+    }
+
+    template < typename Res,
+      typename AOp =  AsyncOp< std::unique_ptr< AsyncOp<Res>> > >
+    inline std::unique_ptr<AsyncOp<Res>> simplify ( std::unique_ptr< AsyncOp< std::unique_ptr< AsyncOp<Res>> > > &&res ) {
+      std::unique_ptr<AsyncOp<Res>> op = std::make_unique< detail::AsyncResult< AOp, SimplifyHelper< AsyncOp<Res>>> >( std::move(res), std::make_unique<SimplifyHelper< AsyncOp<Res>>>() );
+      return detail::simplify( std::move(op) );
+    }
+  }
+
+  template <typename T>
+  AsyncOpPtr<T> makeReadyResult ( T && result ) {
+    return std::make_unique<detail::ReadyResult<T>>( std::move(result) );
+  }
+
+  namespace operators {
+
+    //case 1 : binding a async message to a async callback
+    template< typename PrevOp
+      , typename Callback
+      , typename Ret =  typename Callback::value_type
+      , std::enable_if_t< detail::is_async_op<PrevOp>::value, int> = 0
+      //is the callback signature what we want?
+      , std::enable_if_t< detail::is_future_monad_cb< Callback, Ret, typename PrevOp::value_type >::value, int> = 0
+      >
+    auto operator| ( std::unique_ptr<PrevOp> &&future, std::unique_ptr<Callback> &&c )
+    {
+      std::unique_ptr<AsyncOp<Ret>> op = std::make_unique<detail::AsyncResult< PrevOp, Callback>>( std::move(future), std::move(c) );
+      return detail::simplify( std::move(op) );
+    }
+
+    //case 2: binding a async message to a sync callback
+    template< typename PrevOp
+      , typename Callback
+      , typename Ret = std::result_of_t< Callback( typename PrevOp::value_type&& ) >
+      , std::enable_if_t< detail::is_async_op<PrevOp>::value, int> = 0
+      , std::enable_if_t< detail::is_sync_monad_cb< Callback, typename PrevOp::value_type >::value, int> = 0
+      >
+    auto operator| ( std::unique_ptr<PrevOp> &&future, Callback &&c )
+    {
+      std::unique_ptr<AsyncOp<Ret>> op(std::make_unique<detail::AsyncResult< PrevOp, detail::SyncCallbackWrapper<Callback, typename PrevOp::value_type, Ret> >>(
+        std::move(future)
+          ,  std::make_unique<detail::SyncCallbackWrapper<Callback, typename PrevOp::value_type, Ret>>( std::forward<Callback>(c) ) ));
+
+      return detail::simplify( std::move(op) );
+    }
+
+    //case 3: binding a sync message to a async callback
+    template< typename SyncRes
+      , typename Callback
+      , typename Ret = typename Callback::value_type
+      , std::enable_if_t< !detail::is_async_op< remove_smart_ptr_t<SyncRes> >::value, int> = 0
+      , std::enable_if_t< detail::is_future_monad_cb< Callback, Ret, SyncRes >::value, int> = 0
+      >
+    auto  operator| ( SyncRes &&in, std::unique_ptr<Callback> &&c )
+    {
+      AsyncOpPtr<Ret> op( std::make_unique<detail::AsyncResult<void, Callback, SyncRes>>( std::move(c) ) );
+      static_cast< detail::AsyncResult<void, Callback, SyncRes>* >(op.get())->run( std::move(in) );
+      return detail::simplify( std::move(op) );
+    }
+
+    //case 4: binding a sync message to a sync callback
+    template< typename SyncRes
+      , typename Callback
+      , std::enable_if_t< !detail::is_async_op< remove_smart_ptr_t<SyncRes> >::value, int > = 0
+      , std::enable_if_t< detail::is_sync_monad_cb< Callback, SyncRes >::value, int > = 0
+      >
+    auto operator| ( SyncRes &&in, Callback &&c )
+    {
+      return std::forward<Callback>(c)(std::forward<SyncRes>(in));
+    }
+
+  }
+}
+
+#endif
diff --git a/zypp-core/zyppng/pipelines/await.h b/zypp-core/zyppng/pipelines/await.h
new file mode 100644 (file)
index 0000000..730c60a
--- /dev/null
@@ -0,0 +1,71 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_MONADIC_AWAIT_H_INCLUDED
+#define ZYPPNG_MONADIC_AWAIT_H_INCLUDED
+
+
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+#include <zypp-core/zyppng/base/Signals>
+
+namespace zyppng {
+
+  namespace detail
+  {
+  template <typename T, typename SigGetter> struct AwaitImpl;
+
+  template <typename ArgType, typename SigR, typename ...SigT >
+  struct AwaitImpl<std::shared_ptr<ArgType>, SignalProxy<SigR(SigT...)> (ArgType::*)()> : public zyppng::AsyncOp< std::shared_ptr<ArgType> > {
+
+    using SigGetter = SignalProxy<SigR(SigT...)> (ArgType::*)();
+
+    template<typename S>
+    AwaitImpl ( S&& sigGet ) : _sigGet( std::forward<S>(sigGet ) ) {}
+
+    virtual ~AwaitImpl(){ }
+
+    void operator() ( std::shared_ptr<ArgType> &&req ) {
+      _req = std::move(req);
+      std::invoke( _sigGet, _req ).connect( sigc::mem_fun(this, &AwaitImpl::sigHandler<SigR>) );
+    }
+
+  private:
+    template < typename RetType = SigR >
+    std::enable_if_t< std::is_same<void,RetType>::value, RetType >
+    sigHandler ( SigT... ) {
+      this->setReady( std::move(_req) );
+    }
+
+    template < typename RetType = SigR >
+    std::enable_if_t< !std::is_same<void,RetType>::value, RetType >
+    sigHandler ( SigT... ) {
+      this->setReady( std::move(_req) );
+      return {};
+    }
+
+    std::shared_ptr<ArgType> _req;
+    SigGetter _sigGet;
+  };
+  }
+
+  //return a async op that waits for a signal to emitted by a object
+  template <typename T,
+            typename SignalGetter >
+  auto await ( SignalGetter &&sigGet )
+  {
+    return  std::make_unique<detail::AwaitImpl<T, SignalGetter>>( std::forward<SignalGetter>(sigGet) );
+  }
+
+}
+
+#endif
diff --git a/zypp-core/zyppng/pipelines/expected.h b/zypp-core/zyppng/pipelines/expected.h
new file mode 100644 (file)
index 0000000..4726dda
--- /dev/null
@@ -0,0 +1,409 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+* Based on code by Ivan Čukić (BSD/MIT licensed) from the functional cpp book
+*/
+
+#ifndef ZYPP_ZYPPNG_MONADIC_EXPECTED_H
+#define ZYPP_ZYPPNG_MONADIC_EXPECTED_H
+
+#include <zypp-core/zyppng/meta/Functional>
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+
+namespace zyppng {
+
+  template<typename T, typename E = std::exception_ptr>
+  class expected {
+  protected:
+      union {
+          T m_value;
+          E m_error;
+      };
+
+      bool m_isValid;
+
+      expected() // used internally
+      {
+      }
+
+  public:
+
+    using value_type = T;
+    using error_type = E;
+
+      ~expected()
+      {
+          if (m_isValid) {
+              m_value.~T();
+          } else {
+              m_error.~E();
+          }
+      }
+
+      expected(const expected &other)
+          : m_isValid(other.m_isValid)
+      {
+          if (m_isValid) {
+              new (&m_value) T(other.m_value);
+          } else {
+              new (&m_error) E(other.m_error);
+          }
+      }
+
+      expected(expected &&other)
+          : m_isValid(other.m_isValid)
+      {
+          if (m_isValid) {
+              new (&m_value) T( std::move(other.m_value) );
+          } else {
+              new (&m_error) E( std::move(other.m_error) );
+          }
+      }
+
+      expected &operator= (expected other)
+      {
+          swap(other);
+          return *this;
+      }
+
+      void swap(expected &other)
+      {
+          using std::swap;
+          if (m_isValid) {
+              if (other.m_isValid) {
+                  // Both are valid, just swap the values
+                  swap(m_value, other.m_value);
+
+              } else {
+                  // We are valid, but the other one is not
+                  // we need to do the whole dance
+                  auto temp = std::move(other.m_error);       // moving the error into the temp
+                  other.m_error.~E();                         // destroying the original error object
+                  new (&other.m_value) T(std::move(m_value)); // moving our value into the other
+                  m_value.~T();                               // destroying our value object
+                  new (&m_error) E(std::move(temp));          // moving the error saved to the temp into us
+                  std::swap(m_isValid, other.m_isValid);      // swap the isValid flags
+              }
+
+          } else {
+              if (other.m_isValid) {
+                  // We are not valid, but the other one is,
+                  // just call swap on other and rely on the
+                  // implementation in the previous case
+                  other.swap(*this);
+
+              } else {
+                  // Everything is rotten, just swap the errors
+                  swap(m_error, other.m_error);
+                  std::swap(m_isValid, other.m_isValid);
+              }
+          }
+      }
+
+      template <typename... ConsParams>
+      static expected success(ConsParams && ...params)
+      {
+          expected result;
+          result.m_isValid = true;
+          new(&result.m_value) T(std::forward<ConsParams>(params)...);
+          return result;
+      }
+
+      template <typename... ConsParams>
+      static expected error(ConsParams && ...params)
+      {
+          expected result;
+          result.m_isValid = false;
+          new(&result.m_error) E(std::forward<ConsParams>(params)...);
+          return result;
+      }
+
+      operator bool() const
+      {
+          return m_isValid;
+      }
+
+      bool is_valid() const
+      {
+          return m_isValid;
+      }
+
+      #ifdef NO_EXCEPTIONS
+      #    define THROW_IF_EXCEPTIONS_ARE_ENABLED(WHAT) std::terminate()
+      #else
+      #    define THROW_IF_EXCEPTIONS_ARE_ENABLED(WHAT) throw std::logic_error(WHAT)
+      #endif
+
+      T &get()
+      {
+          if (!m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("expected<T, E> contains no value");
+          return m_value;
+      }
+
+      const T &get() const
+      {
+          if (!m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("expected<T, E> contains no value");
+          return m_value;
+      }
+
+
+
+      T *operator-> ()
+      {
+          return &get();
+      }
+
+      const T *operator-> () const
+      {
+          return &get();
+      }
+
+      E &error()
+      {
+          if (m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("There is no error in this expected<T, E>");
+          return m_error;
+      }
+
+      const E &error() const
+      {
+          if (m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("There is no error in this expected<T, E>");
+          return m_error;
+      }
+
+      #undef THROW_IF_EXCEPTIONS_ARE_ENABLED
+
+      template <typename F>
+      void visit(F f) {
+          if (m_isValid) {
+              f(m_value);
+          } else {
+              f(m_error);
+          }
+      }
+  };
+
+
+  template<typename E>
+  class expected<void, E> {
+  private:
+      union {
+          void* m_value;
+          E m_error;
+      };
+
+      bool m_isValid;
+
+      expected() {} //used internally
+
+  public:
+      ~expected()
+      {
+          if (m_isValid) {
+              // m_value.~T();
+          } else {
+              m_error.~E();
+          }
+      }
+
+      expected(const expected &other)
+          : m_isValid(other.m_isValid)
+      {
+          if (m_isValid) {
+              // new (&m_value) T(other.m_value);
+          } else {
+              new (&m_error) E(other.m_error);
+          }
+      }
+
+      expected(expected &&other)
+          : m_isValid(other.m_isValid)
+      {
+          if (m_isValid) {
+              // new (&m_value) T(std::move(other.m_value));
+          } else {
+              new (&m_error) E(std::move(other.m_error));
+          }
+      }
+
+      expected &operator= (expected other)
+      {
+          swap(other);
+          return *this;
+      }
+
+      void swap(expected &other)
+      {
+          using std::swap;
+          if (m_isValid) {
+              if (other.m_isValid) {
+                  // Both are valid, we do not have any values
+                  // to swap
+
+              } else {
+                  // We are valid, but the other one is not.
+                  // We need to move the error into us
+                  auto temp = std::move(other.m_error);    // moving the error into the temp
+                  other.m_error.~E();                      // destroying the original error object
+                  new (&m_error) E(std::move(temp));       // moving the error into us
+                  std::swap(m_isValid, other.m_isValid);   // swapping the isValid flags
+              }
+
+          } else {
+              if (other.m_isValid) {
+                  // We are not valid, but the other one is,
+                  // just call swap on other and rely on the
+                  // implementation in the previous case
+                  other.swap(*this);
+
+              } else {
+                  // Everything is rotten, just swap the errors
+                  swap(m_error, other.m_error);
+                  std::swap(m_isValid, other.m_isValid);
+              }
+          }
+      }
+
+      static expected success()
+      {
+          expected result;
+          result.m_isValid = true;
+          result.m_value = nullptr;
+          return result;
+      }
+
+      template <typename... ConsParams>
+      static expected error(ConsParams && ...params)
+      {
+          expected result;
+          result.m_isValid = false;
+          new(&result.m_error) E(std::forward<ConsParams>(params)...);
+          return result;
+      }
+
+      operator bool() const
+      {
+          return m_isValid;
+      }
+
+      bool is_valid() const
+      {
+          return m_isValid;
+      };
+
+      #ifdef NO_EXCEPTIONS
+      #    define THROW_IF_EXCEPTIONS_ARE_ENABLED(WHAT) std::terminate()
+      #else
+      #    define THROW_IF_EXCEPTIONS_ARE_ENABLED(WHAT) throw std::logic_error(WHAT)
+      #endif
+
+      E &error()
+      {
+          if (m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("There is no error in this expected<T, E>");
+          return m_error;
+      }
+
+      const E &error() const
+      {
+          if (m_isValid) THROW_IF_EXCEPTIONS_ARE_ENABLED("There is no error in this expected<T, E>");
+          return m_error;
+      }
+
+  };
+
+
+  template < typename T
+           , typename E
+           , typename Function
+           , typename ResultType = decltype(std::declval<Function>()(std::declval<T>()))
+           >
+  std::enable_if_t< !detail::is_async_op< remove_smart_ptr_t<ResultType> >::value, ResultType> mbind( const expected<T, E>& exp, Function f)
+  {
+      if (exp) {
+        return std::invoke( f, exp.get() );
+      } else {
+          return ResultType::error(exp.error());
+      }
+  }
+
+  template < typename T
+    , typename E
+    , typename Function
+    , typename ResultType = decltype(std::declval<Function>()(std::declval<T>()))
+    >
+  std::enable_if_t< !detail::is_async_op< remove_smart_ptr_t<ResultType> >::value, ResultType> mbind( expected<T, E>&& exp, Function f)
+  {
+    if (exp) {
+      return std::invoke( f, std::move(exp.get()) );
+    } else {
+      return ResultType::error( std::move(exp.error()) );
+    }
+  }
+
+  template < typename T
+    , typename E
+    , typename Function
+    , typename ResultType = decltype(std::declval<Function>()(std::declval<T>()))
+    >
+  std::enable_if_t< detail::is_async_op< remove_smart_ptr_t<ResultType> >::value, ResultType> mbind( const expected<T, E>& exp, Function f)
+  {
+    if (exp) {
+      return std::invoke( f, exp.get() );
+    } else {
+      return  makeReadyResult( remove_smart_ptr_t<ResultType>::value_type::error(exp.error()) );
+    }
+  }
+
+  template < typename T
+    , typename E
+    , typename Function
+    , typename ResultType = decltype(std::declval<Function>()(std::declval<T>()))
+    >
+  std::enable_if_t< detail::is_async_op< remove_smart_ptr_t<ResultType> >::value, ResultType> mbind( expected<T, E>&& exp, Function f)
+  {
+    if (exp) {
+      return std::invoke( f, std::move(exp.get()) );
+    } else {
+      return  makeReadyResult( remove_smart_ptr_t<ResultType>::value_type::error( std::move(exp.error()) ) );
+    }
+  }
+
+  namespace detail {
+    template <typename Callback>
+    struct mbind_helper {
+      Callback function;
+
+      template< typename T
+        , typename E >
+      auto operator()( const expected<T, E>& exp ) {
+        return mbind( exp, function );
+      }
+
+      template< typename T
+        , typename E >
+      auto operator()( expected<T, E>&& exp ) {
+        return mbind( std::move(exp), function );
+      }
+    };
+  }
+
+  namespace operators {
+    template <typename Fun>
+    auto mbind ( Fun && function ) {
+      return detail::mbind_helper<Fun> {
+        std::forward<Fun>(function)
+      };
+    }
+  }
+}
+
+#endif
+
diff --git a/zypp-core/zyppng/pipelines/lift.h b/zypp-core/zyppng/pipelines/lift.h
new file mode 100644 (file)
index 0000000..49a316f
--- /dev/null
@@ -0,0 +1,80 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_MONADIC_LIFT_H_INCLUDED
+#define ZYPPNG_MONADIC_LIFT_H_INCLUDED
+
+#include <utility>
+#include <memory>
+#include <iostream>
+
+#include <zypp-core/zyppng/meta/Functional>
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+
+namespace zyppng {
+
+  namespace detail {
+  template <typename LiftedFun, typename extra = void >
+  struct lifter {
+
+    lifter( LiftedFun &&fun ) : _fun(std::move(fun)) {}
+    lifter( lifter && ) = default;
+    ~lifter(){}
+
+    template< typename T1
+      , typename T2
+      , typename Ret = std::pair<std::result_of_t<LiftedFun(T1)>, T2>
+      >
+    Ret operator()( std::pair<T1, T2> &&data ) {
+      return std::make_pair( std::invoke( _fun, std::move(data.first) ), std::move(data.second) );
+    }
+  private:
+    LiftedFun _fun;
+  };
+
+  template < typename AsyncOp >
+  struct lifter< std::unique_ptr<AsyncOp>, std::void_t< std::enable_if_t< zyppng::detail::is_async_op<AsyncOp>::value > > > {
+
+    using LiftedFun = std::unique_ptr<AsyncOp>;
+
+    lifter( LiftedFun &&fun ) : _fun(std::move(fun)) {}
+    lifter( lifter && ) = default;
+    ~lifter(){}
+
+    template< typename T1
+      , typename T2
+      >
+    auto operator()( std::pair<T1, T2> &&data ) {
+
+      using namespace zyppng;
+      using namespace zyppng::operators;
+
+      return std::move(data.first)
+             | ( std::move(_fun) )
+             | [ other = std::move(data.second)]( auto && res ) mutable {
+                 return std::make_pair( std::forward<decltype (res)>(res), std::move(other) );
+               };
+    }
+  private:
+    LiftedFun _fun;
+  };
+  }
+
+  template< typename Fun >
+  auto lift ( Fun && func ) {
+    return detail::lifter<Fun>( std::forward<Fun>(func) );
+  }
+
+}
+
+#endif
diff --git a/zypp-core/zyppng/pipelines/mtry.h b/zypp-core/zyppng/pipelines/mtry.h
new file mode 100644 (file)
index 0000000..dd9675b
--- /dev/null
@@ -0,0 +1,38 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+* Based on code by Ivan Čukić (BSD/MIT licensed) from the functional cpp book
+*/
+
+#ifndef ZYPP_ZYPPNG_MONADIC_MTRY_H
+#define ZYPP_ZYPPNG_MONADIC_MTRY_H
+
+#include "expected.h"
+
+namespace zyppng {
+
+  template < typename F
+           , typename Ret = typename std::result_of<F()>::type
+           , typename Exp = expected<Ret, std::exception_ptr>
+           >
+  Exp mtry(F f)
+  {
+      try {
+          return Exp::success(f());
+      } catch (...) {
+          return Exp::error(std::current_exception());
+      }
+  }
+
+}
+
+#endif /* !MTRY_H */
diff --git a/zypp-core/zyppng/pipelines/redo.h b/zypp-core/zyppng/pipelines/redo.h
new file mode 100644 (file)
index 0000000..92bad92
--- /dev/null
@@ -0,0 +1,150 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPPNG_MONADIC_REDO_H_INCLUDED
+#define ZYPPNG_MONADIC_REDO_H_INCLUDED
+
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+#include <zypp-core/zyppng/meta/FunctionTraits>
+#include <zypp-core/zyppng/meta/TypeTraits>
+#include <zypp-core/zyppng/meta/Functional>
+
+namespace zyppng {
+
+  namespace detail {
+
+
+    template< typename Task, typename Pred, typename = void >
+  struct RedoWhileImpl
+  {
+
+      static_assert ( !is_async_op< zyppng::remove_smart_ptr<Pred> >::value, "" );
+
+      template <typename T, typename P>
+      RedoWhileImpl( T &&t, P &&p ) :
+        _task( std::forward<T>(t) )
+        , _pred( std::forward<P>(p) ) {}
+
+      template <typename Arg>
+      std::enable_if_t< is_async_op< remove_smart_ptr_t<std::result_of_t<Task(Arg)>> >::value == false, Arg > operator()( Arg &&arg ) {
+        Arg store = std::forward<Arg>(arg);
+        do {
+          auto res = _task ( Arg(store) );
+          if ( !_pred( res ) )
+            return std::move(res);
+        } while( true );
+      }
+
+      template <typename T, typename P>
+      static auto create ( T &&t, P &&p ) {
+        return RedoWhileImpl( std::forward<T>(t), std::forward<P>(p));
+      }
+
+    private:
+      Task _task;
+      Pred _pred;
+    };
+
+    template< typename MyAsyncOp, typename Pred >
+    struct RedoWhileImpl< std::unique_ptr<MyAsyncOp>,Pred, std::enable_if_t< is_async_op< MyAsyncOp >::value > > : public AsyncOp<typename MyAsyncOp::value_type> {
+
+      using Task = std::unique_ptr<MyAsyncOp>;
+      using OutType  = typename MyAsyncOp::value_type;
+
+      template <typename T, typename P>
+      RedoWhileImpl( T &&t, P &&p ) :
+        _task( std::forward<T>(t) )
+        , _pred( std::forward<P>(p) ) {}
+
+      static_assert ( !is_async_op< remove_smart_ptr<Pred> >::value, "" );
+
+      template<typename InType>
+      void operator()( InType &&arg ) {
+        _task->onReady(
+          [this, inArg = arg]( OutType &&a) mutable {
+            if ( _pred(a) )
+              this->operator()(std::move(inArg));
+            else
+              this->setReady( std::move(a) );
+          }
+        );
+        _task->operator()(  InType(arg) );
+      }
+
+      template <typename T, typename P>
+      static auto create ( T &&t, P &&p ) {
+        return std::make_unique<RedoWhileImpl>( std::forward<T>(t), std::forward<P>(p));
+      }
+
+    private:
+
+      Task _task;
+      Pred _pred;
+      std::unique_ptr<AsyncOp<OutType>> _pipeline;
+    };
+
+    //implementation for a function returning a asynchronous result
+    template< typename Task, typename Pred >
+    struct RedoWhileImpl< Task,Pred, std::enable_if_t< is_async_op< remove_smart_ptr_t<typename function_traits<Task>::return_type> >::value > > : public AsyncOp< typename remove_smart_ptr_t<typename function_traits<Task>::return_type>::value_type> {
+
+      using FunRet = remove_smart_ptr_t<typename function_traits<Task>::return_type>;
+
+      //the task function needs to return the same type it takes
+      using OutType = typename FunRet::value_type;
+
+      template <typename T, typename P>
+      RedoWhileImpl( T &&t, P &&p ) :
+        _task( std::forward<T>(t) )
+        , _pred( std::forward<P>(p) ) {}
+
+      template<typename InType>
+      void operator() ( InType &&arg ) {
+        _asyncRes.reset(nullptr);
+        _asyncRes = _task( InType( arg ) );
+        _asyncRes->onReady(
+          [this, inArg = arg ]( OutType &&arg ) mutable {
+            if ( _pred(arg) )
+              this->operator()( std::move(inArg) );
+            else
+              this->setReady( std::move(arg) );
+          });
+      }
+
+      template <typename T, typename P>
+      static auto create ( T &&t, P &&p ) {
+        return std::make_unique<RedoWhileImpl>( std::forward<T>(t), std::forward<P>(p));
+      }
+
+    private:
+      std::unique_ptr<AsyncOp<OutType>> _asyncRes;
+
+      Task _task;
+      Pred _pred;
+    };
+
+    //check if its possible to query the given type for function_traits
+    template <typename T>
+    using has_func_trait = typename function_traits<T>::return_type;
+
+  }
+
+  template <typename Task, typename Pred>
+  auto redo_while ( Task &&todo, Pred &&until )
+  {
+    static_assert ( std::is_detected_v< detail::has_func_trait, Task >, "Not possible to deduce the function_traits for Task, maybe a generic lambda?" );
+    return detail::RedoWhileImpl<Task,Pred>::create( std::forward<Task>(todo), std::forward<Pred>(until) );
+  }
+
+}
+
+#endif
diff --git a/zypp-core/zyppng/pipelines/transform.h b/zypp-core/zyppng/pipelines/transform.h
new file mode 100644 (file)
index 0000000..841377f
--- /dev/null
@@ -0,0 +1,61 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*/
+
+
+#ifndef ZYPP_ZYPPNG_MONADIC_TRANSFORM_H
+#define ZYPP_ZYPPNG_MONADIC_TRANSFORM_H
+
+#include <zypp-core/zyppng/meta/TypeTraits>
+#include <zypp-core/zyppng/meta/Functional>
+#include <algorithm>
+#include <vector>
+
+namespace zyppng {
+
+template < template< class, class... > class Container,
+  typename Msg,
+  typename Transformation,
+  typename Ret = std::result_of_t<Transformation(Msg)>,
+  typename ...CArgs >
+Container<Ret> transform( Container<Msg, CArgs...>&& val, Transformation transformation )
+{
+  Container<Ret> res;
+  std::transform( std::make_move_iterator(val.begin()), std::make_move_iterator(val.end()), std::back_inserter(res), transformation );
+  return std::move(res);
+}
+
+namespace detail {
+    template <typename Transformation>
+    struct transform_helper {
+        Transformation function;
+
+        template<template< class, class... > class Container, typename Msg, typename ...CArgs>
+        auto operator()( Container<Msg, CArgs...>&& arg ) {
+          return zyppng::transform( std::forward< Container<Msg,CArgs...> >(arg), function );
+        }
+    };
+}
+
+namespace operators {
+
+    template <typename Transformation>
+    auto transform(Transformation&& transformation)
+    {
+        return detail::transform_helper<Transformation>{
+            std::forward<Transformation>(transformation)};
+    }
+}
+
+}
+
+#endif
diff --git a/zypp-core/zyppng/pipelines/wait.h b/zypp-core/zyppng/pipelines/wait.h
new file mode 100644 (file)
index 0000000..703ab49
--- /dev/null
@@ -0,0 +1,74 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*/
+
+#ifndef ZYPP_ZYPPNG_MONADIC_WAIT_H
+#define ZYPP_ZYPPNG_MONADIC_WAIT_H
+
+#include <zypp-core/zyppng/pipelines/AsyncResult>
+
+namespace detail {
+
+  template < class AsyncOp,
+    class InnerResult = typename AsyncOp::value_type
+    >
+  struct WaitForImpl : public zyppng::AsyncOp< std::vector<InnerResult> > {
+
+    WaitForImpl () = default;
+
+    WaitForImpl ( const WaitForImpl &other ) = delete;
+    WaitForImpl& operator= ( const WaitForImpl &other ) = delete;
+
+    WaitForImpl& operator= ( WaitForImpl &&other ) = default;
+    WaitForImpl ( WaitForImpl &&other ) = default;
+
+    void operator()( std::vector< std::unique_ptr< AsyncOp > > &&ops ) {
+      assert( _allOps.empty() );
+
+      _allOps = std::move( ops );
+      for ( auto &op : _allOps ) {
+        op->onReady( [ this ](  typename AsyncOp::value_type &&res  )  {
+          this->resultReady( std::move(res));
+        });
+      }
+
+    }
+
+  private:
+
+    void resultReady ( InnerResult &&res ) {
+      _allResults.push_back( std::move( res ) );
+      if ( _allOps.size() == _allResults.size() ) {
+        //release all ops we waited on
+        _allOps.clear();
+
+        this->setReady( std::move(_allResults) );
+      }
+    }
+
+    std::vector< std::unique_ptr<zyppng::AsyncOp<InnerResult>> > _allOps;
+    std::vector< InnerResult > _allResults;
+  };
+
+}
+
+/*!
+ *  Returns a async operation that waits for all async operations that are passed to it and collects their results,
+ *  forwarding them as one
+ */
+template < class Res  >
+auto waitFor () {
+  return std::make_unique<detail::WaitForImpl<zyppng::AsyncOp<Res>>>();
+}
+
+
+#endif
diff --git a/zypp-curl/CMakeLists.txt b/zypp-curl/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ebe1d91
--- /dev/null
@@ -0,0 +1,155 @@
+# Collect all files that may contain translatable texts
+FILE( GLOB_RECURSE POT_FILE_DEPENDS RELATIVE ${LIBZYPP_SOURCE_DIR} "*.h" "*.cc" )
+SET( POT_FILE_DEPENDS_ZYPP_CURL ${POT_FILE_DEPENDS} PARENT_SCOPE )
+
+INCLUDE_DIRECTORIES ( ${LIBZYPP_SOURCE_DIR} )
+
+ADD_DEFINITIONS( -DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale" -DTEXTDOMAIN="zypp" -DZYPP_DLL )
+
+SET( zypp_curl_HEADERS
+  CurlConfig
+  curlconfig.h
+  ProxyInfo
+  proxyinfo.h
+  TransferSettings
+  transfersettings.h
+)
+
+SET( zypp_curl_private_HEADERS
+  private/curlhelper_p.h
+)
+
+SET( zypp_curl_SRCS
+  curlconfig.cc
+  proxyinfo.cc
+  curlhelper.cc
+  transfersettings.cc
+)
+
+INSTALL(  FILES ${zypp_curl_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-curl" )
+
+SET( zypp_curl_auth_HEADERS
+  auth/CurlAuthData
+  auth/curlauthdata.h
+)
+
+SET( zypp_curl_auth_private_HEADERS
+)
+
+SET( zypp_curl_auth_SRCS
+  auth/curlauthdata.cc
+)
+
+INSTALL(  FILES ${zypp_curl_auth_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-curl/auth" )
+
+IF ( LIBPROXY_FOUND )
+  SET(zypp_curl_proxyinfo_libproxy_SRCS proxyinfo/proxyinfolibproxy.cc)
+  SET(zypp_curl_proxyinfo_libproxy_HEADERS proxyinfo/ProxyInfoLibproxy proxyinfo/proxyinfolibproxy.h)
+ENDIF( LIBPROXY_FOUND )
+
+SET( zypp_curl_proxyinfo_SRCS
+  proxyinfo/proxyinfosysconfig.cc
+  ${zypp_curl_proxyinfo_libproxy_SRCS}
+)
+
+SET( zypp_curl_proxyinfo_HEADERS
+  proxyinfo/proxyinfoimpl.h
+  proxyinfo/ProxyInfoSysconfig
+  proxyinfo/proxyinfosysconfig.h
+  ${zypp_curl_proxyinfo_libproxy_HEADERS}
+  proxyinfo/proxyinfos.h
+)
+
+INSTALL(  FILES ${zypp_curl_proxyinfo_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/zypp-curl/proxyinfo )
+
+SET( zypp_curl_ng_network_SRCS
+  ng/network/downloader.cc
+  ng/network/downloadspec.cc
+  ng/network/mirrorcontrol.cc
+  ng/network/networkrequestdispatcher.cc
+  ng/network/networkrequesterror.cc
+  ng/network/request.cc
+)
+
+SET( zypp_curl_ng_network_HEADERS
+  ng/network/AuthData
+  ng/network/authdata.h
+  ng/network/Downloader
+  ng/network/downloader.h
+  ng/network/DownloadSpec
+  ng/network/downloadspec.h
+  ng/network/NetworkRequestDispatcher
+  ng/network/networkrequestdispatcher.h
+  ng/network/NetworkRequestError
+  ng/network/networkrequesterror.h
+  ng/network/Request
+  ng/network/request.h
+  ng/network/TransferSettings
+  ng/network/transfersettings.h
+)
+
+SET( zypp_curl_ng_network_private_HEADERS
+  ng/network/private/downloader_p.h
+  ng/network/private/mediadebug_p.h
+  ng/network/private/mirrorcontrol_p.h
+  ng/network/private/networkrequestdispatcher_p.h
+  ng/network/private/networkrequesterror_p.h
+  ng/network/private/request_p.h
+  ng/network/private/downloaderstates/base_p.h
+  ng/network/private/downloaderstates/basicdownloader_p.h
+  ng/network/private/downloaderstates/detectmeta_p.h
+  ng/network/private/downloaderstates/final_p.h
+  ng/network/private/downloaderstates/initial_p.h
+  ng/network/private/downloaderstates/metalinkinfo_p.h
+  ng/network/private/downloaderstates/metalink_p.h
+  ng/network/private/downloaderstates/mirrorhandling_p.h
+  ng/network/private/downloaderstates/normal_p.h
+  ng/network/private/downloaderstates/preparemulti_p.h
+  ng/network/private/downloaderstates/rangedownloader_p.h
+  ng/network/private/downloaderstates/zck_p.h
+)
+
+SET( zypp_curl_ng_network_private_SOURCES
+  ng/network/private/downloaderstates/basicdownloader_p.cc
+  ng/network/private/downloaderstates/detectmeta_p.cc
+  ng/network/private/downloaderstates/final_p.cc
+  ng/network/private/downloaderstates/initial_p.cc
+  ng/network/private/downloaderstates/metalinkinfo_p.cc
+  ng/network/private/downloaderstates/metalink_p.cc
+  ng/network/private/downloaderstates/mirrorhandling_p.cc
+  ng/network/private/downloaderstates/normal_p.cc
+  ng/network/private/downloaderstates/preparemulti_p.cc
+  ng/network/private/downloaderstates/rangedownloader_p.cc
+  ng/network/private/downloaderstates/zck_p.cc
+)
+
+# ng files are not installed yet
+# INSTALL(  FILES ${zypp_curl_ng_network_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/zypp-curl/ng/network )
+
+SET( zypp_curl_parser_HEADERS
+  parser/MediaBlockList
+  parser/mediablocklist.h
+  parser/MetaLinkParser
+  parser/metalinkparser.h
+)
+
+SET( zypp_curl_parser_private_HEADERS
+)
+
+SET( zypp_curl_parser_SRCS
+  parser/mediablocklist.cc
+  parser/metalinkparser.cc
+)
+
+INSTALL(  FILES ${zypp_curl_parser_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-curl/parser" )
+
+
+ADD_LIBRARY( zypp-curl STATIC
+  ${zypp_curl_SRCS} ${zypp_curl_private_HEADERS} ${zypp_curl_HEADERS}
+  ${zypp_curl_auth_SRCS} ${zypp_curl_auth_private_HEADERS} ${zypp_curl_auth_HEADERS}
+  ${zypp_curl_ng_network_SRCS} ${zypp_curl_ng_network_HEADERS} ${zypp_curl_ng_network_private_HEADERS} ${zypp_curl_ng_network_private_SOURCES}
+  ${zypp_curl_parser_SRCS} ${zypp_curl_parser_private_HEADERS} ${zypp_curl_parser_HEADERS}
+  ${zypp_curl_proxyinfo_HEADERS} ${zypp_curl_proxyinfo_SRCS}
+  )
+#we include generated headers, so we need to wait for zypp-protobuf to be ready
+add_dependencies( zypp-curl zypp-protobuf )
diff --git a/zypp-curl/CurlConfig b/zypp-curl/CurlConfig
new file mode 100644 (file)
index 0000000..e951c82
--- /dev/null
@@ -0,0 +1 @@
+#include "curlconfig.h"
diff --git a/zypp-curl/ProxyInfo b/zypp-curl/ProxyInfo
new file mode 100644 (file)
index 0000000..3f6ba49
--- /dev/null
@@ -0,0 +1 @@
+#include "proxyinfo.h"
diff --git a/zypp-curl/auth/CurlAuthData b/zypp-curl/auth/CurlAuthData
new file mode 100644 (file)
index 0000000..f3bbe6b
--- /dev/null
@@ -0,0 +1 @@
+#include "curlauthdata.h"
diff --git a/zypp-curl/auth/curlauthdata.cc b/zypp-curl/auth/curlauthdata.cc
new file mode 100644 (file)
index 0000000..d464744
--- /dev/null
@@ -0,0 +1,129 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/auth/curlauthdata.cc
+ *
+*/
+
+#include "curlauthdata.h"
+
+#include <zypp-core/base/Gettext.h>
+#include <zypp-core/base/String.h>
+#include <zypp-media/MediaException>
+
+#include <curl/curl.h>
+
+
+using std::endl;
+
+namespace zypp::media {
+
+  CurlAuthData::CurlAuthData()
+    : AuthData()
+    , _auth_type_str()
+    , _auth_type(CURLAUTH_NONE)
+  {}
+
+  CurlAuthData::CurlAuthData(const AuthData & authData)
+    : AuthData(authData)
+    , _auth_type_str()
+    , _auth_type(CURLAUTH_NONE)
+  {}
+
+  bool CurlAuthData::valid() const
+  {
+    return username().size() && password().size();
+  }
+
+  std::ostream & CurlAuthData::dumpOn( std::ostream & str ) const
+  {
+    AuthData::dumpOn(str) << endl
+                            << " auth_type: " << _auth_type_str << " (" << _auth_type << ")";
+    return str;
+  }
+
+  long CurlAuthData::auth_type_str2long( std::string & auth_type_str )
+  {
+    return auth_type_str2long( const_cast< const std::string &>(auth_type_str) );
+  }
+
+  long CurlAuthData::auth_type_str2long( const std::string & auth_type_str )
+  {
+    curl_version_info_data *curl_info = curl_version_info(CURLVERSION_NOW);
+
+    std::vector<std::string>                  list;
+    std::vector<std::string>::const_iterator  it;
+    long                                      auth_type = CURLAUTH_NONE;
+
+    zypp::str::split(auth_type_str, std::back_inserter(list), ",");
+
+    for(it = list.begin(); it != list.end(); ++it)
+    {
+      if(*it == "basic")
+      {
+        auth_type |= CURLAUTH_BASIC;
+      }
+      else
+        if(*it == "digest")
+        {
+          auth_type |= CURLAUTH_DIGEST;
+        }
+        else
+          if((curl_info && (curl_info->features & CURL_VERSION_NTLM)) &&
+               (*it == "ntlm"))
+          {
+            auth_type |= CURLAUTH_NTLM;
+          }
+          else
+            if((curl_info && (curl_info->features & CURL_VERSION_SPNEGO)) &&
+                 (*it == "spnego" || *it == "negotiate"))
+            {
+              // there is no separate spnego flag for this auth type
+              auth_type |= CURLAUTH_GSSNEGOTIATE;
+            }
+            else
+              if((curl_info && (curl_info->features & CURL_VERSION_GSSNEGOTIATE)) &&
+                   (*it == "gssnego" || *it == "negotiate"))
+              {
+                auth_type |= CURLAUTH_GSSNEGOTIATE;
+              }
+              else
+              {
+                ZYPP_THROW(MediaException(str::Format(_("Unsupported HTTP authentication method '%s'")) % *it));
+              }
+    }
+
+    return auth_type;
+  }
+
+  std::string CurlAuthData::auth_type_long2str(long auth_type)
+  {
+    std::list<std::string> auth_list;
+
+    if(auth_type & CURLAUTH_GSSNEGOTIATE)
+      auth_list.push_back("negotiate");
+
+    if(auth_type & CURLAUTH_NTLM)
+      auth_list.push_back("ntlm");
+
+    if(auth_type & CURLAUTH_DIGEST)
+      auth_list.push_back("digest");
+
+    if(auth_type & CURLAUTH_BASIC)
+      auth_list.push_back("basic");
+
+    return str::join(auth_list, ",");
+  }
+
+  std::ostream & operator << (std::ostream & str, const CurlAuthData & auth_data)
+  {
+    auth_data.dumpOn(str);
+    return str;
+  }
+
+}
diff --git a/zypp-curl/auth/curlauthdata.h b/zypp-curl/auth/curlauthdata.h
new file mode 100644 (file)
index 0000000..6ec92a0
--- /dev/null
@@ -0,0 +1,107 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/auth/CurlAuthData
+ *
+*/
+#ifndef ZYPP_CURL_AUTH_CURLAUTHDATA_H_INCLUDED
+#define ZYPP_CURL_AUTH_CURLAUTHDATA_H_INCLUDED
+
+#include <zypp-media/auth/AuthData>
+
+namespace zypp {
+  namespace media {
+    /**
+     * Curl HTTP authentication data.
+     */
+    class CurlAuthData : public AuthData {
+    public:
+      /**
+       * Default constructor. Initializes username and password to empty strings
+       * and authetication type to CURLAUTH_NONE.
+       */
+      CurlAuthData();
+
+      CurlAuthData(const AuthData & authData);
+
+      CurlAuthData(std::string & username, std::string & password, std::string & auth_type)
+        : AuthData(username,password), _auth_type_str(auth_type)
+      {
+        _auth_type = auth_type_str2long(auth_type);
+      }
+
+      CurlAuthData(std::string & username, std::string & password, long auth_type)
+        : AuthData(username,password), _auth_type(auth_type)
+      {
+        _auth_type_str = auth_type_long2str(auth_type);
+      }
+
+      /**
+       * Checks validity of authentication data.
+       * \return true if the object contains non-empty username,
+       *  non-empty password, and specifies authentication type; false otherwise.
+       */
+      virtual bool valid() const;
+
+      /**
+       * Set HTTP authentication type(s) to use.
+       * \param comma separated list of HTTP authentication type names
+       */
+      void setAuthType(std::string auth_type)
+      {
+        _auth_type_str = auth_type; _auth_type = auth_type_str2long(auth_type);
+      }
+
+      /**
+       * Set HTTP authentication type(s) to use.
+       * \param HTTP authentication type as in long ORed form.
+       * \see curl.h for available auth types
+       */
+      void setAuthType(long auth_type)
+      {
+        _auth_type = auth_type;
+        _auth_type_str = auth_type_long2str(auth_type);
+      }
+
+      long authType() const { return _auth_type; }
+      std::string authTypeAsString() const { return _auth_type_str; }
+
+      std::string getUserPwd() const { return username() + ":" + password(); }
+
+
+      /**
+       * Converts a string of comma separated list of authetication type names
+       * into a long of ORed CURLAUTH_* identifiers.
+       * The method also automatically leaves out any auth types declared
+       * not supported by curl_version_info().
+       *
+       * \throws MediaException if an invalid authentication type name is
+       *         encountered.
+       */
+      static long auth_type_str2long( std::string & auth_type_str );
+      static long auth_type_str2long( const std::string &auth_type_str );
+
+      /**
+       * Converts a long of ORed CURLAUTH_* identifiers into a string of comma
+       * separated list of authentication type names.
+       */
+      static std::string auth_type_long2str(long auth_type);
+
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+
+    private:
+      std::string _auth_type_str;
+      long _auth_type;
+    };
+
+    typedef shared_ptr<CurlAuthData> CurlAuthData_Ptr;
+    std::ostream & operator << (std::ostream & str, const CurlAuthData & auth_data);
+  }
+}
+
+#endif
similarity index 96%
rename from zypp/media/CurlConfig.cc
rename to zypp-curl/curlconfig.cc
index 9adddc9..bfa14d7 100644 (file)
@@ -1,12 +1,12 @@
 #include <iostream>
 #include <fstream>
 
-#include <zypp/base/Logger.h>
-#include <zypp/base/IOStream.h>
-#include <zypp/Pathname.h>
-#include <zypp/PathInfo.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/IOStream.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/fs/PathInfo.h>
 
-#include <zypp/media/CurlConfig.h>
+#include <zypp-curl/CurlConfig>
 
 using std::endl;
 
diff --git a/zypp-curl/curlconfig.h b/zypp-curl/curlconfig.h
new file mode 100644 (file)
index 0000000..a9c466c
--- /dev/null
@@ -0,0 +1,57 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/CurlConfig
+*/
+#ifndef ZYPP_CURL_CURLCONFIG_H_INCLUDED
+#define ZYPP_CURL_CURLCONFIG_H_INCLUDED
+
+//#include <zypp/base/NonCopyable.h>
+#include <zypp-core/base/String.h>
+
+namespace zypp
+{
+  namespace media
+  {
+
+
+  /**
+   * Structure holding values of curlrc options.
+   */
+  struct CurlConfig
+  {
+  public:
+    /**
+     * Parse a curlrc file and store the result in the \a config structure.
+     *
+     * \param config   a CurlConfig structure
+     * \param filename path to the curlrc file. If empty, ~/.curlrc is used.
+     * \return         0 on success, 1 if problem occurs.
+     */
+    static int parseConfig(CurlConfig & config, const std::string & filename = "");
+
+    /**
+     * Stores the \a value of the \a option in the \a config structure or
+     * logs an unknown option.
+     *
+     * \return         0 on success, 1 if problem occurs.
+     */
+    static int setParameter(CurlConfig & config,
+                            const std::string & option,
+                            const std::string & value);
+
+  public:
+    std::string proxyuserpwd;
+    // add more curl config data here as they become needed
+  };
+
+
+  } // namespace media
+} // namespace zypp
+
+#endif /*ZYPP_CURL_CURLCONFIG_H_INCLUDED*/
similarity index 72%
rename from zypp/media/CurlHelper.cc
rename to zypp-curl/curlhelper.cc
index 816d7d1..e0e3dab 100644 (file)
@@ -1,13 +1,25 @@
-#include "CurlHelper.h"
-
-#include <zypp/PathInfo.h>
-#include <zypp/Pathname.h>
-#include <zypp/Target.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/media/MediaException.h>
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/curlhelper.cc
+ *
+*/
+#include "private/curlhelper_p.h"
+
+#include <zypp/APIConfig.h>
+
+#include <zypp-core/fs/PathInfo.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-curl/ProxyInfo>
+#include <zypp-curl/auth/CurlAuthData>
+#include <zypp-media/MediaException>
 #include <list>
 
 using std::endl;
@@ -52,7 +64,7 @@ void globalInitCurlOnce()
   } (), true );
 }
 
-int log_curl(CURL *curl, curl_infotype info,
+int log_curl(CURL *, curl_infotype info,
   char *ptr, size_t len, void *max_lvl)
 {
   if ( max_lvl == nullptr )
@@ -296,51 +308,6 @@ void fillSettingsSystemProxy( const Url& url, media::TransferSettings &s )
   }
 }
 
-
-const char * anonymousIdHeader()
-{
-  // we need to add the release and identifier to the
-  // agent string.
-  // The target could be not initialized, and then this information
-  // is guessed.
-  static const std::string _value(
-    str::trim( str::form(
-      "X-ZYpp-AnonymousId: %s",
-      Target::anonymousUniqueId( Pathname()/*guess root*/ ).c_str() ) )
-    );
-  return _value.c_str();
-}
-
-const char * distributionFlavorHeader()
-{
-  // we need to add the release and identifier to the
-  // agent string.
-  // The target could be not initialized, and then this information
-  // is guessed.
-  static const std::string _value(
-    str::trim( str::form(
-      "X-ZYpp-DistributionFlavor: %s",
-      Target::distributionFlavor( Pathname()/*guess root*/ ).c_str() ) )
-    );
-  return _value.c_str();
-}
-
-const char * agentString()
-{
-  // we need to add the release and identifier to the
-  // agent string.
-  // The target could be not initialized, and then this information
-  // is guessed.
-  static const std::string _value(
-    str::form(
-      "ZYpp " LIBZYPP_VERSION_STRING " (curl %s) %s"
-      , curl_version_info(CURLVERSION_NOW)->version
-      , Target::targetDistribution( Pathname()/*guess root*/ ).c_str()
-      )
-    );
-  return _value.c_str();
-}
-
 void curlEscape( std::string & str_r,
   const char char_r, const std::string & escaped_r ) {
   for ( std::string::size_type pos = str_r.find( char_r );
@@ -389,7 +356,7 @@ Url clearQueryString(const Url &url)
 // bsc#933839: propagate proxy settings passed in the repo URL
 zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r )
 {
-  for ( std::string param : { "proxy", "proxyport", "proxyuser", "proxypass"} )
+  for ( const std::string &param : { "proxy", "proxyport", "proxyuser", "proxypass"} )
   {
     const std::string & value( template_r.getQueryParam( param ) );
     if ( ! value.empty() )
@@ -398,74 +365,4 @@ zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r )
   return url_r;
 }
 
-ProgressData::ProgressData(CURL *_curl, time_t _timeout, const Url &_url, ByteCount expectedFileSize_r, zypp::callback::SendReport< zypp::media::DownloadProgressReport> *_report)
-: curl( _curl )
-, url( _url )
-, timeout( _timeout )
-, reached( false )
-, fileSizeExceeded ( false )
-, report( _report )
-, _expectedFileSize( expectedFileSize_r )
-{}
-
-void ProgressData::updateStats(double dltotal, double dlnow)
-{
-  time_t now = _timeNow = time(0);
-
-  // If called without args (0.0), recompute based on the last values seen
-  if ( dltotal && dltotal != _dnlTotal )
-    _dnlTotal = dltotal;
-
-  if ( dlnow && dlnow != _dnlNow )
-  {
-    _timeRcv = now;
-    _dnlNow = dlnow;
-  }
-  else if ( !_dnlNow && !_dnlTotal )
-  {
-    // Start time counting as soon as first data arrives.
-    // Skip the connection / redirection time at begin.
-    return;
-  }
-
-  // init or reset if time jumps back
-  if ( !_timeStart || _timeStart > now )
-    _timeStart = _timeLast = _timeRcv = now;
-
-  // timeout condition
-  if ( timeout )
-    reached = ( (now - _timeRcv) > timeout );
-
-  // check if the downloaded data is already bigger than what we expected
-  fileSizeExceeded = _expectedFileSize > 0 && _expectedFileSize < static_cast<ByteCount::SizeType>(_dnlNow);
-
-  // percentage:
-  if ( _dnlTotal )
-    _dnlPercent = int(_dnlNow * 100 / _dnlTotal);
-
-  // download rates:
-  _drateTotal = _dnlNow / std::max( int(now - _timeStart), 1 );
-
-  if ( _timeLast < now )
-  {
-    _drateLast = (_dnlNow - _dnlLast) / int(now - _timeLast);
-    // start new period
-    _timeLast  = now;
-    _dnlLast   = _dnlNow;
-  }
-  else if ( _timeStart == _timeLast )
-    _drateLast = _drateTotal;
-}
-
-int ProgressData::reportProgress() const
-{
-  if ( fileSizeExceeded )
-    return 1;
-  if ( reached )
-    return 1;  // no-data timeout
-  if ( report && !(*report)->progress( _dnlPercent, url, _drateTotal, _drateLast ) )
-    return 1;  // user requested abort
-  return 0;
-}
-
 }
diff --git a/zypp-curl/ng/network/DownloadSpec b/zypp-curl/ng/network/DownloadSpec
new file mode 100644 (file)
index 0000000..0902f3c
--- /dev/null
@@ -0,0 +1 @@
+#include "downloadspec.h"
diff --git a/zypp-curl/ng/network/Downloader b/zypp-curl/ng/network/Downloader
new file mode 100644 (file)
index 0000000..fb93454
--- /dev/null
@@ -0,0 +1 @@
+#include "downloader.h"
diff --git a/zypp-curl/ng/network/MirrorControl b/zypp-curl/ng/network/MirrorControl
new file mode 100644 (file)
index 0000000..ccb180e
--- /dev/null
@@ -0,0 +1 @@
+#include "mirrorcontrol.h"
diff --git a/zypp-curl/ng/network/NetworkRequestDispatcher b/zypp-curl/ng/network/NetworkRequestDispatcher
new file mode 100644 (file)
index 0000000..6c7f0ed
--- /dev/null
@@ -0,0 +1 @@
+#include "networkrequestdispatcher.h"
diff --git a/zypp-curl/ng/network/NetworkRequestError b/zypp-curl/ng/network/NetworkRequestError
new file mode 100644 (file)
index 0000000..d2b752b
--- /dev/null
@@ -0,0 +1 @@
+#include "networkrequesterror.h"
diff --git a/zypp-curl/ng/network/Request b/zypp-curl/ng/network/Request
new file mode 100644 (file)
index 0000000..2b671df
--- /dev/null
@@ -0,0 +1 @@
+#include "request.h"
diff --git a/zypp-curl/ng/network/TransferSettings b/zypp-curl/ng/network/TransferSettings
new file mode 100644 (file)
index 0000000..5b45827
--- /dev/null
@@ -0,0 +1 @@
+#include "transfersettings.h"
similarity index 96%
rename from zypp/zyppng/media/network/authdata.h
rename to zypp-curl/ng/network/authdata.h
index a7575c7..c9d9db7 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef ZYPPNG_MEDIA_NETWORK_AUTHDATA_H_INCLUDED
 #define ZYPPNG_MEDIA_NETWORK_AUTHDATA_H_INCLUDED
 
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-curl/auth/CurlAuthData>
 
 namespace zyppng {
 
similarity index 92%
rename from zypp/zyppng/media/network/downloader.cc
rename to zypp-curl/ng/network/downloader.cc
index 565d55b..b97e4bb 100644 (file)
@@ -6,16 +6,14 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 ----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/media/TransferSettings.h>
-#include <zypp/media/CurlHelper.h>
-#include <zypp/media/MediaException.h>
-#include <zypp/base/String.h>
-#include <zypp/media/CredentialManager.h>
-#include <zypp/ZConfig.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/networkrequestdispatcher.h>
+#include <zypp-curl/TransferSettings>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-media/MediaException>
+#include <zypp-core/base/String.h>
 
 namespace zyppng {
 
@@ -32,14 +30,14 @@ namespace zyppng {
 
   bool DownloadPrivateBase::handleRequestAuthError( std::shared_ptr<Request> req, const zyppng::NetworkRequestError &err )
   {
-    //Handle the auth errors explicitely, we need to give the user a way to put in new credentials
+    //Handle the auth errors explicitly, we need to give the user a way to put in new credentials
     //if we get valid new credentials we can retry the request
     bool retry = false;
     if ( err.type() == NetworkRequestError::Unauthorized || err.type() == NetworkRequestError::AuthFailed ) {
 
       MIL << "Authentication failed for " << req->url() << " trying to recover." << std::endl;
 
-      zypp::media::CredentialManager cm( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
+      zypp::media::CredentialManager cm(  _parent ? _parent->credManagerOptions() : zypp::media::CredManagerOptions() );
       auto authDataPtr = cm.getCred( req->url() );
 
       // get stored credentials
@@ -182,7 +180,7 @@ namespace zyppng {
       if ( set.authType() == "basic"
            && set.username().size()
            && !set.password().size() ) {
-        zypp::media::CredentialManager cm( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
+        zypp::media::CredentialManager cm(  _parent ? _parent->credManagerOptions() : zypp::media::CredManagerOptions() );
         const auto cred = cm.getCred( url );
         if ( cred && cred->valid() ) {
           if ( !set.username().size() )
@@ -274,7 +272,7 @@ namespace zyppng {
   void Download::cancel()
   {
     Z_D();
-    d->forceState ( std::make_unique<FinishedState>( NetworkRequestErrorPrivate::customError( NetworkRequestError::Cancelled, "Download was cancelled explicitely" ), *d_func() ) );
+    d->forceState ( std::make_unique<FinishedState>( NetworkRequestErrorPrivate::customError( NetworkRequestError::Cancelled, "Download was cancelled explicitly" ), *d_func() ) );
   }
 
   DownloadSpec &Download::spec()
@@ -380,6 +378,16 @@ namespace zyppng {
     }
   }
 
+  const zypp::media::CredManagerOptions &Downloader::credManagerOptions() const
+  {
+    return d_func()->_credManagerOptions;
+  }
+
+  void Downloader::setCredManagerOptions(const zypp::media::CredManagerOptions &options)
+  {
+    d_func()->_credManagerOptions = options;
+  }
+
   std::shared_ptr<Download> Downloader::downloadFile(const zyppng::DownloadSpec &spec )
   {
     Z_D();
similarity index 94%
rename from zypp/zyppng/media/network/downloader.h
rename to zypp-curl/ng/network/downloader.h
index 8086c32..0eb2aee 100644 (file)
@@ -5,10 +5,11 @@
 #include <zypp-core/zyppng/base/Base>
 #include <zypp-core/zyppng/base/signals.h>
 #include <zypp-core/zyppng/core/Url>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
-#include <zypp/zyppng/media/network/AuthData>
+#include <zypp-media/auth/CredentialManager>
+#include <zypp-curl/ng/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/AuthData>
 
-#include <zypp/ByteCount.h>
+#include <zypp-core/ByteCount.h>
 
 namespace zypp::media {
   class TransferSettings;
@@ -45,6 +46,16 @@ namespace zyppng {
     virtual ~Downloader();
 
     /*!
+     * Returns the currently used CredentialManager options
+     */
+    const zypp::media::CredManagerOptions &credManagerOptions () const;
+
+    /*!
+     * Sets the options for the CredentialManager to retrieve auth data
+     */
+    void setCredManagerOptions ( const zypp::media::CredManagerOptions & options );
+
+    /*!
      * Generates a new Download object in waiting state
      */
     std::shared_ptr<Download> downloadFile ( const DownloadSpec &spec );
similarity index 96%
rename from zypp/zyppng/media/network/downloadspec.h
rename to zypp-curl/ng/network/downloadspec.h
index d8f3979..bfa0034 100644 (file)
 
 #include <zypp-core/zyppng/base/zyppglobal.h>
 #include <zypp-core/zyppng/core/Url>
-#include <zypp/Pathname.h>
-#include <zypp/base/PtrTypes.h>
-#include <zypp/ByteCount.h>
-#include <zypp/CheckSum.h>
-#include <zypp/media/TransferSettings.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/ByteCount.h>
+#include <zypp-core/CheckSum.h>
+#include <zypp-curl/TransferSettings>
 
 #include <optional>
 
@@ -6,20 +6,20 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 ----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/networkrequestdispatcher_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/zyppng/media/network/private/request_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp/APIConfig.h>
+#include <zypp-curl/ng/network/private/networkrequestdispatcher_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/private/request_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
 #include <zypp-core/zyppng/base/Timer>
 #include <zypp-core/zyppng/base/SocketNotifier>
 #include <zypp-core/zyppng/base/EventDispatcher>
-#include <zypp/media/CurlHelper.h>
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-curl/private/curlhelper_p.h>
 #include <assert.h>
 
 #include <zypp/base/Logger.h>
 #include <zypp/base/String.h>
-#include <zypp/base/DtorReset.h>
+#include <zypp-core/base/DtorReset>
 
 using namespace boost;
 
@@ -30,10 +30,27 @@ namespace zypp {
 
 namespace zyppng {
 
+static const std::string & defaultAgentString()
+{
+  // we need to add the release and identifier to the
+  // agent string.
+  // The target could be not initialized, and then this information
+  // is guessed.
+  static const std::string _value(
+    zypp::str::form(
+      "ZYpp " LIBZYPP_VERSION_STRING " (curl %s)"
+      , curl_version_info(CURLVERSION_NOW)->version
+      )
+    );
+  return _value;
+}
+
+
 NetworkRequestDispatcherPrivate::NetworkRequestDispatcherPrivate(  NetworkRequestDispatcher &p  )
     : BasePrivate( p )
     , _timer( Timer::create() )
     , _multi ( curl_multi_init() )
+    , _userAgent( defaultAgentString() )
 {
   ::internal::globalInitCurlOnce();
 
@@ -384,9 +401,44 @@ void NetworkRequestDispatcher::enqueue(const std::shared_ptr<NetworkRequest> &re
   d->dequeuePending();
 }
 
+void NetworkRequestDispatcher::setAgentString( const std::string &agent )
+{
+  Z_D();
+  if ( agent.empty() )
+    d->_userAgent = defaultAgentString();
+  else
+    d->_userAgent = agent;
+}
+
+const std::string &NetworkRequestDispatcher::agentString() const
+{
+  return d_func()->_userAgent;
+}
+
+void NetworkRequestDispatcher::setHostSpecificHeader( const std::string &host, const std::string &headerName, const std::string &value )
+{
+  Z_D();
+  if ( value.empty() ) {
+    if ( auto i = d->_customHeaders.find( host ); i != d->_customHeaders.end() ) {
+      if ( auto v = i->second.find( headerName ); v != i->second.end() )  {
+        i->second.erase (v);
+      }
+      if ( i->second.empty() )
+        d->_customHeaders.erase(i);
+    }
+    return;
+  }
+  d->_customHeaders[host][headerName] = value;
+}
+
+const NetworkRequestDispatcher::SpecificHeaderMap &NetworkRequestDispatcher::hostSpecificHeaders() const
+{
+  return d_func()->_customHeaders;
+}
+
 void NetworkRequestDispatcher::cancel( NetworkRequest &req, std::string reason )
 {
-  cancel( req, NetworkRequestErrorPrivate::customError( NetworkRequestError::Cancelled, reason.size() ? std::move(reason) : "Request explicitely cancelled" ) );
+  cancel( req, NetworkRequestErrorPrivate::customError( NetworkRequestError::Cancelled, reason.size() ? std::move(reason) : "Request explicitly cancelled" ) );
 }
 
 void NetworkRequestDispatcher::cancel(NetworkRequest &req, const NetworkRequestError &err)
@@ -6,8 +6,9 @@
 #include <zypp-core/zyppng/base/signals.h>
 #include <zypp-core/zyppng/core/Url>
 #include <vector>
+#include <unordered_map>
 
-#include <zypp/zyppng/media/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/networkrequesterror.h>
 
 namespace zyppng {
 
@@ -102,6 +103,35 @@ namespace zyppng {
       void enqueue ( const std::shared_ptr<NetworkRequest> &req );
 
       /*!
+       * Changes the agent header valur to \a agent.
+       */
+      void setAgentString ( const std::string &agent );
+
+      /*!
+       * Returns the currenty set agent string
+       */
+      const std::string &agentString () const;
+
+      /*!
+       * Adds a header to each request to a specific host, this is used to send
+       * anonymous statistics to download.opensuse.org.
+       * Setting a host/headerName combination to a empty string removes the header from being send again.
+       *
+       * \note This will add the header to ALL requests that match the given host, for more fine grained control use \ref TransferSettings
+       * \note is empty by default
+       */
+      void setHostSpecificHeader ( const std::string &host, const std::string &headerName, const std::string &value );
+
+
+      using SpecificHeaderMap = std::unordered_map< std::string, std::unordered_map<std::string, std::string >>;
+
+      /*!
+       * Returns the currenty set host specific headers
+       */
+      const SpecificHeaderMap &hostSpecificHeaders() const;
+
+
+      /*!
        * Cancels the request \a req setting the error description to \a reason.
        */
       void cancel  ( NetworkRequest &req , std::string reason = std::string() );
@@ -112,7 +142,7 @@ namespace zyppng {
       void cancel  ( NetworkRequest &req , const NetworkRequestError &err );
 
       /*!
-       * Start dispatching requests, this needs to be done explicitely before any request can be executed.
+       * Start dispatching requests, this needs to be done explicitly before any request can be executed.
        */
       void run ( );
 
@@ -6,11 +6,11 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 ----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/request.h>
+#include <zypp-curl/private/curlhelper_p.h>
 #include <zypp/base/Gettext.h>
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-curl/auth/CurlAuthData>
 #include <curl/curl.h>
 
 namespace zyppng {
similarity index 97%
rename from zypp/zyppng/media/network/networkrequesterror.h
rename to zypp-curl/ng/network/networkrequesterror.h
index 30115b7..66f3881 100644 (file)
@@ -2,7 +2,7 @@
 #define ZYPP_NG_MEDIA_CURL_NETWORK_REQUEST_ERROR_H_INCLUDED
 
 #include <zypp-core/zyppng/base/zyppglobal.h>
-#include <zypp/base/PtrTypes.h>
+#include <zypp-core/base/PtrTypes.h>
 #include <boost/any.hpp>
 #include <string>
 #include <map>
@@ -39,7 +39,7 @@ class NetworkRequestErrorPrivate;
       NotFound,               //< The requested path in the URL does not exist on the server
       Unauthorized,        //<< No auth data given but authorization required
       AuthFailed,          //<< Auth data was given, but authorization failed
-      ServerReturnedError, //<< A error was returned by the server that is not explicitely handled
+      ServerReturnedError, //<< A error was returned by the server that is not explicitly handled
       MissingData          //<< The download was a multirange download and we did not get all data that was requested, if that is returned some ranges might have been downloaded successful
     };
 
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADER_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADER_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADER_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADER_P_H_INCLUDED
 
 #include <zypp-core/zyppng/base/statemachine.h>
 
@@ -110,6 +110,7 @@ namespace zyppng {
     Signal< void ( Downloader &parent, Download& download )> _sigFinished;
     Signal< void ( Downloader &parent )> _queueEmpty;
     std::shared_ptr<MirrorControl> _mirrors;
+    zypp::media::CredManagerOptions _credManagerOptions; //< The credential manager options used to initialize the CredentialManager
   };
 
 }
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
 
 #include <zypp-core/zyppng/base/private/base_p.h>
 #include <zypp-core/zyppng/base/signals.h>
 #include <zypp-core/TriBool.h>
-#include <zypp/zyppng/media/network/downloader.h>
-#include <zypp/zyppng/media/network/downloadspec.h>
+#include <zypp-curl/ng/network/Downloader>
+#include <zypp-curl/ng/network/DownloadSpec>
 #include <zypp-core/zyppng/core/ByteArray>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/zyppng/media/network/TransferSettings>
-#include <zypp/zyppng/media/network/private/mirrorcontrol_p.h>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/request.h>
+#include <zypp-curl/ng/network/TransferSettings>
+#include <zypp-curl/ng/network/private/mirrorcontrol_p.h>
+#include <zypp-curl/ng/network/networkrequesterror.h>
 
 namespace zyppng {
 
@@ -7,10 +7,11 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-core/fs/PathInfo.h>
 
 #include "basicdownloader_p.h"
 
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_BASICDOWNLOADER_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_BASICDOWNLOADER_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASICDOWNLOADER_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASICDOWNLOADER_P_H_INCLUDED
 
 #include "base_p.h"
 #include "mirrorhandling_p.h"
@@ -7,9 +7,9 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/private/curlhelper_p.h>
 
 #include "detectmeta_p.h"
 #include "metalinkinfo_p.h"
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_DETECTMETA_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_DETECTMETA_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_DETECTMETA_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_DETECTMETA_P_H_INCLUDED
 
 #include "base_p.h"
 #include <zypp-core/zyppng/base/statemachine.h>
@@ -27,7 +27,7 @@ namespace zyppng {
   /*!
    * State implementation for the metalink detection phase,
    * this state issues a HEAD request while setting the magic
-   * "Accept: *\/*, application/metalink+xml, application/metalink4+xml"
+   * "Accept: *\/\*, application/metalink+xml, application/metalink4+xml"
    * header in the request to figure out if a metalink file is available or not.
    *
    * In order to use metalink support the server
@@ -7,8 +7,8 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
 #include "final_p.h"
 
 namespace zyppng {
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_FINAL_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_FINAL_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_FINAL_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_FINAL_P_H_INCLUDED
 
 #include "base_p.h"
 #include <zypp-core/zyppng/base/statemachine.h>
@@ -7,8 +7,8 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
 
 #include "initial_p.h"
 #if ENABLE_ZCHUNK_COMPRESSION
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_INITIAL_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_INITIAL_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_INITIAL_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_INITIAL_P_H_INCLUDED
 
 #include "base_p.h"
 #include <zypp-core/zyppng/base/statemachine.h>
@@ -7,10 +7,10 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/PathInfo.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-core/fs/PathInfo.h>
 
 #include "metalink_p.h"
 #include "final_p.h"
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_METALINK_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_METALINK_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_METALINK_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_METALINK_P_H_INCLUDED
 
 #include "base_p.h"
 #include "rangedownloader_p.h"
 #include <zypp-core/zyppng/base/statemachine.h>
 
-#include <zypp/media/MediaBlockList.h>
+#include <zypp-curl/parser/MediaBlockList>
 
 namespace zyppng {
 
@@ -7,10 +7,10 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/request_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/request_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
 
 #include "metalinkinfo_p.h"
 
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_METALINKINFO_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_METALINKINFO_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_METALINKINFO_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_METALINKINFO_P_H_INCLUDED
 
 #include "base_p.h"
 #include "basicdownloader_p.h"
@@ -7,8 +7,8 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
 
 #include "mirrorhandling_p.h"
 
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_MIRRORHANDLING_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_MIRRORHANDLING_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_MIRRORHANDLING_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_MIRRORHANDLING_P_H_INCLUDED
 
 #include <zypp-core/zyppng/base/statemachine.h>
 #include "base_p.h"
@@ -7,8 +7,8 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
 
 #include "normal_p.h"
 #include "final_p.h"
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_NORMAL_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_NORMAL_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_NORMAL_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_NORMAL_P_H_INCLUDED
 
 #include "base_p.h"
 #include "basicdownloader_p.h"
@@ -7,10 +7,11 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-core/fs/PathInfo.h>
 
 #include "preparemulti_p.h"
 
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_PREPAREMULTI_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_PREPAREMULTI_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_PREPAREMULTI_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_PREPAREMULTI_P_H_INCLUDED
 
 #include "base_p.h"
 #include <zypp-core/zyppng/base/statemachine.h>
 
-#include <zypp/media/MediaBlockList.h>
+#include <zypp-curl/parser/MediaBlockList>
 
 namespace zyppng {
 
@@ -7,11 +7,12 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/private/curlhelper_p.h>
 #include <zypp-core/AutoDispose.h>
+#include <zypp-core/fs/PathInfo.h>
 
 #include "rangedownloader_p.h"
 
@@ -109,7 +110,7 @@ namespace zyppng {
     auto &parent = stateMachine();
 
 
-    //Handle the auth errors explicitely, we need to give the user a way to put in new credentials
+    //Handle the auth errors explicitly, we need to give the user a way to put in new credentials
     //if we get valid new credentials we can retry the request
     if ( err.type() == NetworkRequestError::Unauthorized || err.type() == NetworkRequestError::AuthFailed ) {
       retry = parent.handleRequestAuthError( req, err );
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_RANGEDOWNLOADER_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_RANGEDOWNLOADER_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_RANGEDOWNLOADER_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_RANGEDOWNLOADER_P_H_INCLUDED
 
 #include "base_p.h"
 #include "mirrorhandling_p.h"
@@ -9,9 +9,9 @@
 
 #if ENABLE_ZCHUNK_COMPRESSION
 
-#include <zypp/zyppng/media/network/private/downloader_p.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/private/downloader_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
 #include <zypp-core/AutoDispose.h>
 
 #include "zck_p.h"
@@ -11,8 +11,8 @@
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_ZCK_P_H_INCLUDED
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_DOWNLOADERSTATES_ZCK_P_H_INCLUDED
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_ZCK_P_H_INCLUDED
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_ZCK_P_H_INCLUDED
 
 #include "base_p.h"
 #include "basicdownloader_p.h"
@@ -14,7 +14,7 @@
 #ifndef ZYPP_NG_MEDIADEBUG_H_INCLUDED
 #define ZYPP_NG_MEDIADEBUG_H_INCLUDED
 
-#include <zypp/base/LogControl.h>
+#include <zypp-core/base/LogControl.h>
 namespace zypp {
   L_ENV_CONSTR_FWD_DECLARE_FUNC(ZYPP_MEDIA_CURL_DEBUG);
 }
 * You have been warned!
 *
 */
-#ifndef ZYPP_NG_MEDIA_HTTP_PRIVATE_MIRRORCONTROL_P_H
-#define ZYPP_NG_MEDIA_HTTP_PRIVATE_MIRRORCONTROL_P_H
+#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_MIRRORCONTROL_P_H
+#define ZYPP_CURL_NG_NETWORK_PRIVATE_MIRRORCONTROL_P_H
 
 #include <zypp-core/zyppng/core/Url>
 #include <zypp-core/zyppng/base/Signals>
 #include <zypp-core/zyppng/base/Base>
 #include <zypp-core/zyppng/base/Timer>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/media/MetaLinkParser.h>
+#include <zypp-curl/ng/network/networkrequestdispatcher.h>
+#include <zypp-curl/ng/network/request.h>
+#include <zypp-curl/parser/MetaLinkParser>
 #include <vector>
 #include <unordered_map>
 
@@ -129,4 +129,4 @@ namespace zyppng {
 
 }
 
-#endif // ZYPP_NG_MEDIA_HTTP_PRIVATE_MIRRORCONTROL_P_H
+#endif // ZYPP_CURL_NG_NETWORK_PRIVATE_MIRRORCONTROL_P_H
 #ifndef ZYPP_NG_MEDIA_CURL_PRIVATE_CURL_P_H_INCLUDED
 #define ZYPP_NG_MEDIA_CURL_PRIVATE_CURL_P_H_INCLUDED
 
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
+#include <zypp-curl/ng/network/networkrequestdispatcher.h>
 #include <zypp-core/zyppng/base/private/base_p.h>
 #include <curl/curl.h>
 #include <deque>
 #include <set>
+#include <unordered_map>
 
 namespace zyppng {
 
@@ -46,6 +47,9 @@ public:
 
   NetworkRequestError _lastError;
 
+  std::string _userAgent;
+  std::unordered_map< std::string, std::unordered_map<std::string, std::string> > _customHeaders;
+
   //signals
   Signal< void ( NetworkRequestDispatcher &, NetworkRequest & )> _sigDownloadStarted;
   Signal< void ( NetworkRequestDispatcher &, NetworkRequest & )> _sigDownloadFinished;
@@ -14,7 +14,7 @@
 #ifndef ZYPP_NG_MEDIA_CURL_PRIVATE_NETWORKREQUESTERROR_P_H_INCLUDED
 #define ZYPP_NG_MEDIA_CURL_PRIVATE_NETWORKREQUESTERROR_P_H_INCLUDED
 
-#include <zypp/zyppng/media/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/networkrequesterror.h>
 #include <map>
 
 namespace zyppng {
similarity index 97%
rename from zypp/zyppng/media/network/private/request_p.h
rename to zypp-curl/ng/network/private/request_p.h
index dc50431..9fd24be 100644 (file)
 #define ZYPP_NG_MEDIA_CURL_PRIVATE_REQUEST_P_H_INCLUDED
 
 #include <zypp-core/zyppng/base/private/base_p.h>
-#include <zypp/zyppng/media/network/request.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-curl/ng/network/request.h>
+#include <zypp-media/MediaException>
 #include <zypp-core/zyppng/base/Timer>
-#include <zypp/base/Regex.h>
+#include <zypp-core/base/Regex.h>
 #include <curl/curl.h>
 #include <array>
 #include <memory>
-#include <zypp/Digest.h>
-#include <zypp/AutoDispose.h>
+#include <zypp-core/Digest.h>
+#include <zypp-core/AutoDispose.h>
 
 #include <boost/optional.hpp>
 #include <variant>
similarity index 97%
rename from zypp/zyppng/media/network/request.cc
rename to zypp-curl/ng/network/request.cc
index 09e02c6..a9b02c1 100644 (file)
@@ -6,19 +6,19 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 ----------------------------------------------------------------------*/
-#include <zypp/zyppng/media/network/private/request_p.h>
-#include <zypp/zyppng/media/network/private/networkrequesterror_p.h>
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/request_p.h>
+#include <zypp-curl/ng/network/private/networkrequesterror_p.h>
+#include <zypp-curl/ng/network/networkrequestdispatcher.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
 #include <zypp-core/zyppng/base/EventDispatcher>
 #include <zypp-core/zyppng/base/private/linuxhelpers_p.h>
 #include <zypp-core/zyppng/core/String>
-#include <zypp/media/CurlHelper.h>
-#include <zypp/media/CurlConfig.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/ZConfig.h>
-#include <zypp/base/String.h>
-#include <zypp/Pathname.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-curl/CurlConfig>
+#include <zypp-curl/auth/CurlAuthData>
+#include <zypp-media/MediaConfig>
+#include <zypp-core/base/String.h>
+#include <zypp-core/Pathname.h>
 #include <curl/curl.h>
 #include <stdio.h>
 #include <fcntl.h>
@@ -239,20 +239,25 @@ namespace zyppng {
       //make a local copy of the settings, so headers are not added multiple times
       TransferSettings locSet = _settings;
 
-      // add custom headers for download.opensuse.org (bsc#955801)
-      if ( _url.getHost() == "download.opensuse.org" )
-      {
-        locSet.addHeader( ::internal::anonymousIdHeader() );
-        locSet.addHeader( ::internal::distributionFlavorHeader() );
+      if ( _dispatcher ) {
+        locSet.setUserAgentString( _dispatcher->agentString().c_str() );
+
+        // add custom headers as configured (bsc#955801)
+        const auto &cHeaders = _dispatcher->hostSpecificHeaders();
+        if ( auto i = cHeaders.find(_url.getHost()); i != cHeaders.end() ) {
+          for ( const auto &[key, value] : i->second ) {
+            locSet.addHeader( zypp::str::trim( zypp::str::form(
+              "%s: %s", key.c_str(), value.c_str() )
+            ));
+          }
+        }
       }
 
       locSet.addHeader("Pragma:");
 
-      locSet.setTimeout( zypp::ZConfig::instance().download_transfer_timeout() );
+      locSet.setTimeout( zypp::MediaConfig::instance().download_transfer_timeout() );
       locSet.setConnectTimeout( CONNECT_TIMEOUT );
 
-      locSet.setUserAgentString( ::internal::agentString() );
-
       {
         char *ptr = getenv("ZYPP_MEDIA_CURL_DEBUG");
         _curlDebug = (ptr && *ptr) ? zypp::str::strtonum<long>( ptr) : 0L;
@@ -791,7 +796,7 @@ namespace zyppng {
             return 0;
           }
 
-          //we always download a range even if its not explicitely requested
+          //we always download a range even if its not explicitly requested
           if ( _requestedRanges.empty() ) {
             _requestedRanges.push_back( NetworkRequest::Range() );
           }
similarity index 98%
rename from zypp/zyppng/media/network/request.h
rename to zypp-curl/ng/network/request.h
index 35d46a6..e6a73d5 100644 (file)
@@ -1,15 +1,15 @@
 #ifndef ZYPP_NG_MEDIA_CURL_REQUEST_H_INCLUDED
 #define ZYPP_NG_MEDIA_CURL_REQUEST_H_INCLUDED
 
-#include <zypp/zyppng/media/network/networkrequesterror.h>
-#include <zypp/zyppng/media/network/TransferSettings>
+#include <zypp-curl/ng/network/networkrequesterror.h>
+#include <zypp-curl/ng/network/TransferSettings>
 #include <zypp-core/zyppng/base/Base>
 #include <zypp-core/zyppng/core/Url>
 #include <zypp-core/zyppng/core/ByteArray>
 #include <zypp-core/zyppng/base/zyppglobal.h>
 #include <zypp-core/zyppng/base/signals.h>
-#include <zypp/base/Flags.h>
-#include <zypp/ByteCount.h>
+#include <zypp-core/base/Flags.h>
+#include <zypp-core/ByteCount.h>
 #include <optional>
 #include <vector>
 #include <chrono>
similarity index 95%
rename from zypp/zyppng/media/network/transfersettings.h
rename to zypp-curl/ng/network/transfersettings.h
index 3e74676..14a229a 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef ZYPPNG_MEDIA_HTTP_TRANSFERSETTINGS_H_INCLUDED
 #define ZYPPNG_MEDIA_HTTP_TRANSFERSETTINGS_H_INCLUDED
 
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/TransferSettings>
 
 namespace zyppng {
 using TransferSettings = zypp::media::TransferSettings;
diff --git a/zypp-curl/parser/MediaBlockList b/zypp-curl/parser/MediaBlockList
new file mode 100644 (file)
index 0000000..08ac596
--- /dev/null
@@ -0,0 +1 @@
+#include "mediablocklist.h"
diff --git a/zypp-curl/parser/MetaLinkParser b/zypp-curl/parser/MetaLinkParser
new file mode 100644 (file)
index 0000000..d4e060c
--- /dev/null
@@ -0,0 +1 @@
+#include "metalinkparser.h"
similarity index 99%
rename from zypp/media/MediaBlockList.cc
rename to zypp-curl/parser/mediablocklist.cc
index a7e52b6..86e450c 100644 (file)
@@ -6,10 +6,12 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file zypp/media/MediaBlockList.cc
+/** \file zypp-curl/parser/mediablocklist.cc
  *
  */
 
+#include "mediablocklist.h"
+
 #include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -19,9 +21,8 @@
 #include <iostream>
 #include <fstream>
 
-#include <zypp/media/MediaBlockList.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
 
 using namespace zypp::base;
 
diff --git a/zypp-curl/parser/mediablocklist.h b/zypp-curl/parser/mediablocklist.h
new file mode 100644 (file)
index 0000000..7b5c7d0
--- /dev/null
@@ -0,0 +1,157 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/parser/MediaBlockList
+ *
+*/
+#ifndef ZYPP_CURL_PARSER_MEDIABLOCKLIST_H
+#define ZYPP_CURL_PARSER_MEDIABLOCKLIST_H
+
+#include <sys/types.h>
+#include <vector>
+#include <optional>
+
+#include <zypp-core/Digest.h>
+
+namespace zypp {
+  namespace media {
+
+/**
+ * a single block from the blocklist, consisting of an offset and a size
+ **/
+struct MediaBlock {
+  MediaBlock( off_t off_r, size_t size_r )
+  : off( off_r )
+  , size( size_r )
+  {}
+  off_t off;
+  size_t size;
+};
+
+class MediaBlockList {
+public:
+  MediaBlockList(off_t filesize=off_t(-1));
+
+  /**
+   * do we have a blocklist describing the file?
+   * set to true when addBlock() is called
+   **/
+  inline bool haveBlocks() const {
+    return haveblocks;
+  }
+  /**
+   * add a block with offset off and size size to the block list. Note
+   * that blocks must be ordered and must not overlap. returns the
+   * block number.
+   **/
+  size_t addBlock(off_t off, size_t size);
+
+  /**
+   * return the offset/size of a block with number blkno
+   **/
+  inline MediaBlock getBlock(size_t blkno) const {
+    return blocks[blkno];
+  }
+  /**
+   * return the number of blocks in the blocklist
+   **/
+  inline size_t numBlocks() const {
+    return blocks.size();
+  }
+
+  /**
+   * set / return the size of the whole file
+   **/
+  inline void setFilesize(off_t newfilesize=off_t(-1)) {
+    filesize = newfilesize;
+  }
+  inline off_t getFilesize() const {
+    return filesize;
+  }
+  inline bool haveFilesize() const {
+    return filesize != off_t(-1);
+  }
+
+  /**
+   * set / verify the checksum over the whole file
+   **/
+  void setFileChecksum(std::string ctype, int cl, unsigned char *c);
+  std::string fileChecksumType () const;
+
+  const UByteArray &getFileChecksum( );
+  bool createFileDigest(Digest &digest) const;
+  bool verifyFileDigest(Digest &digest) const;
+  inline bool haveFileChecksum() const {
+    return !fsumtype.empty() && fsum.size();
+  }
+
+  /**
+   * set / verify the (strong) checksum over a single block
+   **/
+  void setChecksum(size_t blkno, std::string cstype, int csl, unsigned char *cs, size_t cspad=0);
+  bool checkChecksum(size_t blkno, const unsigned char *buf, size_t bufl) const;
+  UByteArray getChecksum( size_t blkno ) const;
+  std::string getChecksumType( ) const;
+  bool createDigest(Digest &digest) const;
+  bool verifyDigest(size_t blkno, Digest &digest) const;
+  inline bool haveChecksum(size_t blkno) const {
+    return chksumlen && chksums.size() >= chksumlen * (blkno + 1);
+  }
+
+  /**
+   * set / verify the (weak) rolling checksum over a single block
+   **/
+  void setRsum(size_t blkno, int rsl, unsigned int rs, size_t rspad=0);
+  bool checkRsum(size_t blkno, const unsigned char *buf, size_t bufl) const;
+  unsigned int updateRsum(unsigned int rs, const char *bytes, size_t len) const;
+  bool verifyRsum(size_t blkno, unsigned int rs) const;
+  inline bool haveRsum(size_t blkno) const {
+    return rsumlen && rsums.size() >= blkno + 1;
+  }
+
+  /**
+   * scan a file for blocks from our blocklist. if we find a suitable block,
+   * it is removed from the list
+   **/
+  void reuseBlocks(FILE *wfp, std::string filename);
+
+  /**
+   * return block list as string
+   **/
+  std::string asString() const;
+
+private:
+  void writeBlock(size_t blkno, FILE *fp, const unsigned char *buf, size_t bufl, size_t start, std::vector<bool> &found) const;
+  bool checkChecksumRotated(size_t blkno, const unsigned char *buf, size_t bufl, size_t start) const;
+
+  off_t filesize;
+  std::string fsumtype;
+  UByteArray fsum;
+
+  bool haveblocks;
+  std::vector<MediaBlock> blocks;
+
+  std::string chksumtype;
+  int chksumlen;
+  size_t chksumpad;
+  std::vector<unsigned char> chksums;
+
+  std::string rsumtype;
+  int rsumlen;
+  size_t rsumpad;
+  std::vector<unsigned int> rsums;
+};
+
+inline std::ostream & operator<<(std::ostream &str, const MediaBlockList &bl)
+{ return str << bl.asString(); }
+
+  } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_CURL_PARSER_MEDIABLOCKLIST_H
+
similarity index 98%
rename from zypp/media/MetaLinkParser.cc
rename to zypp-curl/parser/metalinkparser.cc
index 3917da2..56ed8d4 100644 (file)
@@ -6,14 +6,14 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file zypp/media/MetaLinkParser.cc
+/** \file zypp-curl/parser/metalinkparser.cc
  *
  */
 
-#include <zypp/media/MetaLinkParser.h>
-#include <zypp/base/Logger.h>
-#include <zypp/ByteArray.h>
-#include <zypp/AutoDispose.h>
+#include "metalinkparser.h"
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/ByteArray.h>
+#include <zypp-core/AutoDispose.h>
 
 #include <stack>
 #include <vector>
diff --git a/zypp-curl/parser/metalinkparser.h b/zypp-curl/parser/metalinkparser.h
new file mode 100644 (file)
index 0000000..4483304
--- /dev/null
@@ -0,0 +1,88 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/parser/MetaLinkParser
+ *
+*/
+#ifndef ZYPP_CURL_PARSER_METALINKPARSER_H_INCLUDED
+#define ZYPP_CURL_PARSER_METALINKPARSER_H_INCLUDED
+
+#include <string>
+
+#include <zypp-core/base/Exception.h>
+#include <zypp-core/base/NonCopyable.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-curl/parser/MediaBlockList>
+#include <zypp-core/Url.h>
+#include <zypp-core/ByteArray.h>
+
+namespace zypp::media {
+
+struct ml_parsedata;
+
+struct MetalinkMirror {
+  int priority = 0;
+  int maxConnections = -1; //< How many connections can be opened to that mirror, -1 means no limit was defined.
+  Url url;
+};
+
+class MetaLinkParser : private zypp::base::NonCopyable {
+public:
+  MetaLinkParser();
+  ~MetaLinkParser();
+
+  /**
+   * parse a file consisting of metalink xml data
+   * \throws Exception
+   **/
+  void parse(const Pathname &filename);
+
+  /**
+   * parse an InputStream consisting of metalink xml data
+   * \throws Exception
+   **/
+  void parse(const InputStream &is);
+
+  /**
+   * parse a chunk of a file consisting of metalink xml data.
+   * \throws Exception
+   **/
+  void parseBytes(const char* bytes, size_t len);
+  /**
+   * tells the parser that all chunks are now processed
+   * \throws Exception
+   **/
+  void parseEnd();
+
+  /**
+   * return the download urls from the parsed metalink data
+   **/
+  std::vector<Url> getUrls() const;
+
+  /**
+   * return the mirrors from the parsed metalink data
+   */
+  const std::vector<MetalinkMirror> &getMirrors() const;
+
+  /**
+   * return the block list from the parsed metalink data
+   **/
+  MediaBlockList getBlockList() const;
+
+  const std::vector<UByteArray> &getZsyncBlockHashes() const;
+  const std::vector<UByteArray> &getSHA1BlockHashes() const;
+
+private:
+  struct ml_parsedata *pd;
+};
+
+UByteArray hexstr2bytes( std::string str );
+
+} // namespace zypp::media
+
+#endif // ZYPP_CURL_PARSER_METALINKPARSER_H_INCLUDED
diff --git a/zypp-curl/private/curlhelper_p.h b/zypp-curl/private/curlhelper_p.h
new file mode 100644 (file)
index 0000000..9a9c016
--- /dev/null
@@ -0,0 +1,68 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+----------------------------------------------------------------------/
+*
+* This file contains private API, this might break at any time between releases.
+* You have been warned!
+*
+*/
+#ifndef ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
+#define ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
+
+#include <curl/curl.h>
+#include <zypp-core/Url.h>
+#include <zypp-curl/TransferSettings>
+
+#define  CONNECT_TIMEOUT        60
+#define  TRANSFER_TIMEOUT_MAX   60 * 60
+#define  DETECT_DIR_INDEX       0
+
+#define EXPLICITLY_NO_PROXY "_none_"
+
+#undef CURLVERSION_AT_LEAST
+#define CURLVERSION_AT_LEAST(M,N,O) LIBCURL_VERSION_NUM >= ((((M)<<8)+(N))<<8)+(O)
+
+namespace zypp
+{
+  namespace env
+  {
+    /** Long number for setting CURLOPT_DEBUGDATA */
+    inline long ZYPP_MEDIA_CURL_DEBUG()
+    {
+      long ret = 0L;
+      if ( char *ptr = ::getenv("ZYPP_MEDIA_CURL_DEBUG"); ptr && *ptr )
+        str::strtonum( ptr, ret );
+      return ret;
+    }
+
+    /** 4/6 to force IPv4/v6 */
+    int ZYPP_MEDIA_CURL_IPRESOLVE();
+  } // namespace env
+} //namespace zypp
+
+//do not export
+namespace internal {
+
+void globalInitCurlOnce();
+int  log_curl(CURL *curl, curl_infotype info,  char *ptr, size_t len, void *max_lvl);
+size_t log_redirects_curl( char *ptr, size_t size, size_t nmemb, void *userdata);
+
+
+void fillSettingsFromUrl( const zypp::Url &url, zypp::media::TransferSettings &s );
+void fillSettingsSystemProxy( const zypp::Url& url, zypp::media::TransferSettings &s );
+
+void curlEscape( std::string & str_r,  const char char_r, const std::string & escaped_r );
+std::string curlEscapedPath( std::string path_r );
+std::string curlUnEscape( std::string text_r );
+
+zypp::Url clearQueryString(const zypp::Url &url);
+zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r );
+
+}
+
+#endif //ZYPP_MEDIA_PRIVATE_CURLHELPER_P_H_INCLUDED
similarity index 90%
rename from zypp/media/ProxyInfo.cc
rename to zypp-curl/proxyinfo.cc
index fb6a4aa..aabc77c 100644 (file)
@@ -6,17 +6,17 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file zypp/media/ProxyInfo.cc
+/** \file zypp-curl/ProxyInfo.cc
  *
 */
 
+#include "proxyinfo.h"
 #include <iostream>
 
 #include <zypp/base/Logger.h>
 
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/proxyinfo/ProxyInfoImpl.h>
-#include <zypp/media/proxyinfo/ProxyInfos.h>
+#include "proxyinfo/proxyinfoimpl.h"
+#include "proxyinfo/proxyinfos.h"
 
 using namespace zypp::base;
 
diff --git a/zypp-curl/proxyinfo.h b/zypp-curl/proxyinfo.h
new file mode 100644 (file)
index 0000000..5645b89
--- /dev/null
@@ -0,0 +1,66 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/ProxyInfo
+ *
+*/
+#ifndef ZYPP_CURL_PROXYINFO_H_INCLUDED
+#define ZYPP_CURL_PROXYINFO_H_INCLUDED
+
+#include <string>
+#include <list>
+
+#include <zypp-core/base/PtrTypes.h>
+
+namespace zypp {
+
+  class Url;
+
+  namespace media {
+
+    ///////////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : ProxyInfo
+    class ProxyInfo
+    {
+    public:
+      typedef intrusive_ptr<ProxyInfo> Ptr;
+      typedef intrusive_ptr<ProxyInfo> constPtr;
+      typedef std::list<std::string> NoProxyList;
+      typedef std::list<std::string>::const_iterator NoProxyIterator;
+
+      /** Implementation */
+      struct Impl;
+      typedef shared_ptr<Impl> ImplPtr;
+
+      /** Default Ctor: guess the best available implementation. */
+      ProxyInfo();
+      /** Ctor taking a specific implementation. */
+      ProxyInfo( ProxyInfo::ImplPtr pimpl_r );
+
+      bool enabled() const;
+      std::string proxy(const Url & url) const;
+      NoProxyList noProxy() const;
+      NoProxyIterator noProxyBegin() const;
+      NoProxyIterator noProxyEnd() const;
+
+      /** Return \c true if  \ref enabled and \a url_r does not match \ref noProxy. */
+      bool useProxyFor( const Url & url_r ) const;
+
+    private:
+      /** Pointer to implementation */
+      RW_pointer<Impl> _pimpl;
+    };
+
+
+///////////////////////////////////////////////////////////////////
+
+  } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_CURL_PROXYINFO_H_INCLUDED
diff --git a/zypp-curl/proxyinfo/ProxyInfoLibproxy b/zypp-curl/proxyinfo/ProxyInfoLibproxy
new file mode 100644 (file)
index 0000000..ce37f68
--- /dev/null
@@ -0,0 +1 @@
+#include "proxyinfolibproxy.h"
diff --git a/zypp-curl/proxyinfo/ProxyInfoSysconfig b/zypp-curl/proxyinfo/ProxyInfoSysconfig
new file mode 100644 (file)
index 0000000..3e75561
--- /dev/null
@@ -0,0 +1 @@
+#include "proxyinfosysconfig.h"
diff --git a/zypp-curl/proxyinfo/proxyinfoimpl.h b/zypp-curl/proxyinfo/proxyinfoimpl.h
new file mode 100644 (file)
index 0000000..9315150
--- /dev/null
@@ -0,0 +1,84 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/proxyinfo/proxyinfoimpl.h
+ *
+*/
+#ifndef ZYPP_CURL_PROXYINFO_PROXYINFOIMPL_H_INCLUDED
+#define ZYPP_CURL_PROXYINFO_PROXYINFOIMPL_H_INCLUDED
+
+#include <string>
+#include <list>
+
+#include <zypp-core/Url.h>
+#include <zypp-core/base/String.h>
+#include <zypp-curl/ProxyInfo>
+
+namespace zypp {
+  namespace media {
+
+    struct ProxyInfo::Impl
+    {
+      /** Ctor */
+      Impl()
+      {}
+
+      /** Dtor */
+      virtual ~Impl()
+      {}
+
+    public:
+      /**  */
+      virtual bool enabled() const = 0;
+      /**  */
+      virtual std::string proxy(const Url & url_r) const = 0;
+      /**  */
+      virtual ProxyInfo::NoProxyList noProxy() const = 0;
+      /**  */
+      virtual ProxyInfo::NoProxyIterator noProxyBegin() const = 0;
+      /**  */
+      virtual ProxyInfo::NoProxyIterator noProxyEnd() const = 0;
+
+      /** Return \c true if  \ref enabled and \a url_r does not match \ref noProxy. */
+      bool useProxyFor( const Url & url_r ) const
+      {
+        if ( ! enabled() || proxy( url_r ).empty() )
+          return false;
+
+        ProxyInfo::NoProxyList noproxy( noProxy() );
+        if ( noproxy.size() == 1 && noproxy.front() == "*" )
+          return false; // just an asterisk disables all.
+
+        // No proxy: Either an exact match, or the previous character
+        // is a '.', so host is within the same domain.
+        // A leading '.' in the pattern is ignored. Some implementations
+        // need '.foo.ba' to prevent 'foo.ba' from matching 'xfoo.ba'.
+        std::string host( str::toLower( url_r.getHost() ) );
+        for_( it, noproxy.begin(), noproxy.end() )
+        {
+          std::string pattern( str::toLower( (*it)[0] == '.' ? it->c_str() + 1 : it->c_str() ) );
+          if ( str::hasSuffix( host, pattern )
+               && ( host.size() == pattern.size()
+                    || host[host.size()-pattern.size()-1] == '.' ) )
+            return false;
+        }
+        return true;
+      }
+
+    public:
+      /** Default Impl: empty sets. */
+      static shared_ptr<Impl> _nullimpl;
+    };
+
+
+///////////////////////////////////////////////////////////////////
+
+  } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
similarity index 93%
rename from zypp/media/proxyinfo/ProxyInfoLibproxy.cc
rename to zypp-curl/proxyinfo/proxyinfolibproxy.cc
index 01955bb..11412ed 100644 (file)
@@ -6,19 +6,19 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfoLibproxy.cc
+/** \file zypp-curl/proxyinfo/proxyinfolibproxy.cc
  *
 */
 
 #include <iostream>
 #include <fstream>
 
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/base/WatchFile.h>
-#include <zypp/Pathname.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/fs/WatchFile>
+#include <zypp-core/Pathname.h>
 
-#include <zypp/media/proxyinfo/ProxyInfoLibproxy.h>
+#include <zypp-curl/proxyinfo/ProxyInfoLibproxy>
 
 using std::endl;
 using namespace zypp::base;
diff --git a/zypp-curl/proxyinfo/proxyinfolibproxy.h b/zypp-curl/proxyinfo/proxyinfolibproxy.h
new file mode 100644 (file)
index 0000000..6769386
--- /dev/null
@@ -0,0 +1,57 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp/media/proxyinfo/ProxyInfoLibproxy.h
+ *
+*/
+#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
+#define ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
+
+#include <string>
+#include <map>
+
+#include <proxy.h>
+
+#include <zypp-core/base/DefaultIntegral>
+#include <zypp-curl/ProxyInfo>
+#include <zypp-curl/proxyinfo/proxyinfoimpl.h>
+
+namespace zypp {
+  namespace media {
+
+
+    class ProxyInfoLibproxy : public ProxyInfo::Impl
+    {
+    public:
+      ProxyInfoLibproxy();
+      /**  */
+      ~ProxyInfoLibproxy();
+      /**  */
+      bool enabled() const
+      { return _enabled; }
+      /**  */
+      std::string proxy(const Url & url_r) const;
+      /**  */
+      ProxyInfo::NoProxyList noProxy() const
+      { return _no_proxy; }
+      /**  */
+      virtual ProxyInfo::NoProxyIterator noProxyBegin() const;
+      /**  */
+      virtual ProxyInfo::NoProxyIterator noProxyEnd() const;
+    private:
+      DefaultIntegral<bool,false> _enabled;
+      ProxyInfo::NoProxyList _no_proxy;
+      pxProxyFactory *_factory;
+    };
+
+///////////////////////////////////////////////////////////////////
+
+  } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
diff --git a/zypp-curl/proxyinfo/proxyinfos.h b/zypp-curl/proxyinfo/proxyinfos.h
new file mode 100644 (file)
index 0000000..0ef455a
--- /dev/null
@@ -0,0 +1,23 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/proxyinfo/proxyinfos.h
+ *
+*/
+#ifndef ZYPP_CURL_PROXYINFO_PROXYINFOS_H_INCLUDED
+#define ZYPP_CURL_PROXYINFO_PROXYINFOS_H_INCLUDED
+
+#include <string>
+#include <list>
+
+#include <zypp-curl/proxyinfo/ProxyInfoSysconfig>
+#ifdef WITH_LIBPROXY_SUPPORT
+#include <zypp-curl/proxyinfo/ProxyInfoLibproxy>
+#endif
+
+#endif // ZYPP_CURL_PROXYINFO_PROXYINFOS_H_INCLUDED
similarity index 93%
rename from zypp/media/proxyinfo/ProxyInfoSysconfig.cc
rename to zypp-curl/proxyinfo/proxyinfosysconfig.cc
index 72333cc..deb59ca 100644 (file)
  *
 */
 
+#include "proxyinfosysconfig.h"
+
 #include <iostream>
 #include <fstream>
 
-#include <zypp/base/Logger.h>
-#include <zypp/base/String.h>
-#include <zypp/Pathname.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/Pathname.h>
 
-#include <zypp/media/proxyinfo/ProxyInfoSysconfig.h>
 
 using namespace zypp::base;
 
diff --git a/zypp-curl/proxyinfo/proxyinfosysconfig.h b/zypp-curl/proxyinfo/proxyinfosysconfig.h
new file mode 100644 (file)
index 0000000..91a729f
--- /dev/null
@@ -0,0 +1,54 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/proxyinfo/ProxyInfoSysconfig
+ *
+*/
+#ifndef ZYPP_CURL_PROXYINFO_PROXYINFOSYSCONFIG_H_INCLUDED
+#define ZYPP_CURL_PROXYINFO_PROXYINFOSYSCONFIG_H_INCLUDED
+
+#include <string>
+#include <map>
+
+#include <zypp-core/parser/Sysconfig>
+#include <zypp-core/base/DefaultIntegral>
+#include <zypp-curl/ProxyInfo>
+#include <zypp-curl/proxyinfo/proxyinfoimpl.h>
+
+namespace zypp {
+  namespace media {
+
+
+    class ProxyInfoSysconfig : public ProxyInfo::Impl
+    {
+    public:
+      ProxyInfoSysconfig(const Pathname & path);
+      /**  */
+      bool enabled() const
+      { return _enabled; }
+      /**  */
+      std::string proxy(const Url & url_r) const;
+      /**  */
+      ProxyInfo::NoProxyList noProxy() const
+      { return _no_proxy; }
+      /**  */
+      virtual ProxyInfo::NoProxyIterator noProxyBegin() const;
+      /**  */
+      virtual ProxyInfo::NoProxyIterator noProxyEnd() const;
+    private:
+      DefaultIntegral<bool,false> _enabled;
+      ProxyInfo::NoProxyList _no_proxy;
+      std::map<std::string,std::string> _proxies;
+    };
+
+///////////////////////////////////////////////////////////////////
+
+  } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_CURL_PROXYINFO_PROXYINFOSYSCONFIG_H_INCLUDED
similarity index 83%
rename from zypp/media/TransferSettings.cc
rename to zypp-curl/transfersettings.cc
index 0d8d487..631982a 100644 (file)
@@ -1,17 +1,31 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/transfersettings.cc
+ *
+*/
+
+#include "transfersettings.h"
 #include <iostream>
 #include <sstream>
 
-#include <zypp/base/String.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/WatchFile.h>
-#include <zypp/base/ReferenceCounted.h>
-#include <zypp/base/NonCopyable.h>
-#include <zypp/ExternalProgram.h>
-#include <zypp/media/TransferSettings.h>
-#include <zypp/ZConfig.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/fs/WatchFile>
+#include <zypp-core/base/ReferenceCounted.h>
+#include <zypp-core/base/NonCopyable.h>
+#include <zypp-core/ExternalProgram.h>
+#include <zypp-media/MediaConfig>
 
 #include <zypp-proto/transfersettings.pb.h>
 
+#include <zypp/APIConfig.h>
+
 using std::endl;
 
 #define CURL_BINARY "/usr/bin/curl"
@@ -25,12 +39,12 @@ namespace zypp
     public:
       Impl() {
         _settingsObj.set_useproxy( false );
-        _settingsObj.set_timeout( ZConfig::instance().download_transfer_timeout() );
+        _settingsObj.set_timeout( MediaConfig::instance().download_transfer_timeout() );
         _settingsObj.set_connect_timeout( 60 );
-        _settingsObj.set_maxconcurrentconnections( ZConfig::instance().download_max_concurrent_connections() );
-        _settingsObj.set_mindownloadspeed(ZConfig::instance().download_min_download_speed());
-        _settingsObj.set_maxdownloadspeed(ZConfig::instance().download_max_download_speed());
-        _settingsObj.set_maxsilenttries(ZConfig::instance().download_max_silent_tries() );
+        _settingsObj.set_maxconcurrentconnections( MediaConfig::instance().download_max_concurrent_connections() );
+        _settingsObj.set_mindownloadspeed(MediaConfig::instance().download_min_download_speed());
+        _settingsObj.set_maxdownloadspeed(MediaConfig::instance().download_max_download_speed());
+        _settingsObj.set_maxsilenttries(MediaConfig::instance().download_max_silent_tries() );
         _settingsObj.set_verify_host(false);
         _settingsObj.set_verify_peer(false);
         _settingsObj.set_ca_path("/etc/ssl/certs");
diff --git a/zypp-curl/transfersettings.h b/zypp-curl/transfersettings.h
new file mode 100644 (file)
index 0000000..ca1c80c
--- /dev/null
@@ -0,0 +1,211 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-curl/TransferSettings
+ *
+ */
+#ifndef ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
+#define ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
+
+#include <string>
+#include <vector>
+#include <zypp-core/base/Flags.h>
+#include <zypp-core/base/PtrTypes.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/Url.h>
+
+namespace zypp::proto {
+  class TransferSettings;
+}
+
+namespace zypp
+{
+  namespace media
+  {
+
+    /**
+     * Holds transfer setting
+     */
+    class TransferSettings
+    {
+    public:
+      /** Constructs a transfer program cmd line access. */
+      TransferSettings();
+
+      TransferSettings( const zypp::proto::TransferSettings &settings );
+
+      typedef std::vector<std::string> Headers;
+
+      /** reset the settings to the defaults */
+      void reset();
+
+
+      /** add a header, on the form "Foo: Bar" */
+      void addHeader( std::string && val_r );
+
+      /** returns a list of all added headers */
+      Headers headers() const;
+
+      /** sets the user agent ie: "Mozilla v3" */
+      void setUserAgentString( std::string && val_r );
+
+      /** user agent string */
+      std::string userAgentString() const;
+
+
+      /** sets the auth username */
+      void setUsername( std::string && val_r );
+
+      /** auth username */
+      std::string username() const;
+
+      /** sets the auth password */
+      void setPassword( std::string && val_r );
+
+      /** auth password */
+      std::string password() const;
+
+      /** returns the user and password as a user:pass string */
+      std::string userPassword() const;
+
+      /** sets anonymous authentication (ie: for ftp) */
+      void setAnonymousAuth();
+
+
+      /** whether the proxy is used or not */
+      void setProxyEnabled( bool enabled );
+
+      /** proxy is enabled */
+      bool proxyEnabled() const;
+
+
+      /** proxy to use if it is enabled */
+      void setProxy( std::string && val_r );
+
+      /** proxy host */
+      std::string proxy() const;
+
+
+      /** sets the proxy user */
+      void setProxyUsername( std::string && val_r );
+
+      /** proxy auth username */
+      std::string proxyUsername() const;
+
+      /** sets the proxy password */
+      void setProxyPassword( std::string && val_r );
+
+      /** proxy auth password */
+      std::string proxyPassword() const;
+
+      /** returns the proxy user and password as a user:pass string */
+      std::string proxyUserPassword() const;
+
+
+      /** set the connect timeout */
+      void setConnectTimeout( long t );
+
+      /** connection timeout */
+      long connectTimeout() const;
+
+
+      /** set the transfer timeout */
+      void setTimeout( long t );
+
+      /** transfer timeout */
+      long timeout() const;
+
+
+      /** Set maximum number of concurrent connections for a single transfer */
+      void setMaxConcurrentConnections(long v);
+
+      /** Maximum number of concurrent connections for a single transfer */
+      long maxConcurrentConnections() const;
+
+
+      /** Set minimum download speed (bytes per second) until the connection is dropped */
+      void setMinDownloadSpeed(long v);
+
+      /** Minimum download speed (bytes per second) until the connection is dropped */
+      long minDownloadSpeed() const;
+
+
+      /** Set max download speed (bytes per second) */
+      void setMaxDownloadSpeed(long v);
+
+      /** Maximum download speed (bytes per second) */
+      long maxDownloadSpeed() const;
+
+
+      /** Set maximum silent retries */
+      void setMaxSilentTries(long v);
+
+      /** Maximum silent retries */
+      long maxSilentTries() const;
+
+
+      /** Sets whether to verify host for ssl */
+      void setVerifyHostEnabled( bool enabled );
+
+      /** Whether to verify host for ssl */
+      bool verifyHostEnabled() const;
+
+
+      /** Sets whether to verify host for ssl */
+      void setVerifyPeerEnabled( bool enabled );
+
+      /** Whether to verify peer for ssl */
+      bool verifyPeerEnabled() const;
+
+
+      /** Sets the SSL certificate authorities path */
+      void setCertificateAuthoritiesPath( Pathname && val_r );
+
+      /** SSL certificate authorities path ( default: /etc/ssl/certs ) */
+      Pathname certificateAuthoritiesPath() const;
+
+
+      /** set the allowed authentication types */
+      void setAuthType( std::string && val_r );
+
+      /** get the allowed authentication types */
+      std::string authType() const;
+
+
+      /** set whether HEAD requests are allowed */
+      void setHeadRequestsAllowed(bool allowed);
+
+      /** whether HEAD requests are allowed */
+      bool headRequestsAllowed() const;
+
+
+      /** Sets the SSL client certificate file */
+      void setClientCertificatePath( Pathname && val_r );
+
+      /** SSL client certificate file */
+      Pathname clientCertificatePath() const;
+
+
+      /** Sets the SSL client key file */
+      void setClientKeyPath( Pathname && val_r );
+
+      /** SSL client key file */
+      Pathname clientKeyPath() const;
+
+      const zypp::proto::TransferSettings &protoData() const;
+      zypp::proto::TransferSettings &protoData();
+
+    protected:
+      class Impl;
+      RWCOW_pointer<Impl> _impl;
+    };
+
+  } // namespace media
+} // namespece zypp
+
+#endif // ZYPP_CURL_TRANSFER_SETTINGS_H_INCLUDED
diff --git a/zypp-media/CMakeLists.txt b/zypp-media/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8ed3c2e
--- /dev/null
@@ -0,0 +1,55 @@
+# Collect all files that may contain translatable texts
+FILE( GLOB_RECURSE POT_FILE_DEPENDS RELATIVE ${LIBZYPP_SOURCE_DIR} "*.h" "*.cc" )
+SET( POT_FILE_DEPENDS_ZYPP_MEDIA ${POT_FILE_DEPENDS} PARENT_SCOPE )
+
+INCLUDE_DIRECTORIES ( ${LIBZYPP_SOURCE_DIR} )
+
+ADD_DEFINITIONS( -DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale" -DTEXTDOMAIN="zypp" -DZYPP_DLL )
+
+SET( zypp_media_HEADERS
+  MediaConfig
+  mediaconfig.h
+  mediaexception.h
+  MediaException
+  mount.h
+  Mount
+)
+
+SET( zypp_media_private_HEADERS
+)
+
+SET( zypp_media_SRCS
+  mediaconfig.cc
+  mediaexception.cc
+  mount.cc
+)
+
+INSTALL(  FILES ${zypp_media_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-media" )
+
+SET( zypp_media_auth_HEADERS
+  auth/AuthData
+  auth/authdata.h
+  auth/CredentialFileReader
+  auth/credentialfilereader.h
+  auth/CredentialManager
+  auth/credentialmanager.h
+)
+
+SET( zypp_media_auth_private_HEADERS
+)
+
+SET( zypp_media_auth_SRCS
+  auth/authdata.cc
+  auth/credentialfilereader.cc
+  auth/credentialmanager.cc
+)
+
+INSTALL(  FILES ${zypp_media_auth_HEADERS} DESTINATION "${INCLUDE_INSTALL_DIR}/zypp-media/auth" )
+
+
+ADD_LIBRARY( zypp-media STATIC
+  ${zypp_media_SRCS} ${zypp_media_private_HEADERS} ${zypp_media_HEADERS}
+  ${zypp_media_auth_SRCS} ${zypp_media_auth_private_HEADERS} ${zypp_media_auth_HEADERS}
+  )
+#we include generated headers, so we need to wait for zypp-protobuf to be ready
+add_dependencies( zypp-media zypp-protobuf )
diff --git a/zypp-media/MediaConfig b/zypp-media/MediaConfig
new file mode 100644 (file)
index 0000000..9d38d63
--- /dev/null
@@ -0,0 +1 @@
+#include "mediaconfig.h"
diff --git a/zypp-media/MediaException b/zypp-media/MediaException
new file mode 100644 (file)
index 0000000..8144aa6
--- /dev/null
@@ -0,0 +1 @@
+#include "mediaexception.h"
diff --git a/zypp-media/Mount b/zypp-media/Mount
new file mode 100644 (file)
index 0000000..584dfa7
--- /dev/null
@@ -0,0 +1 @@
+#include "mount.h"
diff --git a/zypp-media/auth/AuthData b/zypp-media/auth/AuthData
new file mode 100644 (file)
index 0000000..30f2bac
--- /dev/null
@@ -0,0 +1 @@
+#include "authdata.h"
diff --git a/zypp-media/auth/CredentialFileReader b/zypp-media/auth/CredentialFileReader
new file mode 100644 (file)
index 0000000..a89049c
--- /dev/null
@@ -0,0 +1 @@
+#include "credentialfilereader.h"
diff --git a/zypp-media/auth/CredentialManager b/zypp-media/auth/CredentialManager
new file mode 100644 (file)
index 0000000..334f711
--- /dev/null
@@ -0,0 +1 @@
+#include "credentialmanager.h"
diff --git a/zypp-media/auth/authdata.cc b/zypp-media/auth/authdata.cc
new file mode 100644 (file)
index 0000000..05e401b
--- /dev/null
@@ -0,0 +1,80 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/auth/authdata.cc
+ *
+ */
+
+#include "authdata.h"
+#include <zypp-core/base/String.h>
+
+using std::endl;
+
+namespace zypp {
+  namespace media {
+
+
+AuthData::AuthData(const Url & url)
+      : _url(url), _lastChange(0)
+{
+  _username = url.getUsername();
+  _password = url.getPassword();
+}
+
+
+bool AuthData::valid() const
+{
+  return username().size() && password().size();
+}
+
+time_t AuthData::lastDatabaseUpdate() const
+{
+  return _lastChange;
+}
+
+void AuthData::setLastDatabaseUpdate( time_t time )
+{
+  _lastChange = time;
+}
+
+std::ostream & AuthData::dumpOn( std::ostream & str ) const
+{
+  if (_url.isValid())
+    str << "[" << _url.asString( url::ViewOptions() - url::ViewOptions::WITH_USERNAME - url::ViewOptions::WITH_PASSWORD ) << "]" << endl;
+  else
+    str << "[<no-url>]" << endl;
+  str << "username: '" << _username << "'" << std::endl
+      << "password: " << (_password.empty() ? "<empty>" : "<non-empty>");
+  return str;
+}
+
+std::ostream & AuthData::dumpAsIniOn( std::ostream & str ) const
+{
+  if (_url.isValid())
+    str
+      << "[" << _url.asString(
+        url::ViewOptions()
+        - url::ViewOptions::WITH_USERNAME
+        - url::ViewOptions::WITH_PASSWORD)
+      << "]" << endl;
+
+  str
+    << "username = " << _username << endl
+    << "password = " << _password << endl;
+
+  return str;
+}
+
+std::ostream & operator << (std::ostream & str, const AuthData & auth_data)
+{
+  auth_data.dumpOn(str);
+  return str;
+}
+
+  } // namespace media
+} // namespace zypp
diff --git a/zypp-media/auth/authdata.h b/zypp-media/auth/authdata.h
new file mode 100644 (file)
index 0000000..0c5cd11
--- /dev/null
@@ -0,0 +1,83 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/auth/AuthData
+ * Convenience interface for handling authentication data of media user.
+ */
+#ifndef ZYPP_MEDIA_AUTH_DATA_H
+#define ZYPP_MEDIA_AUTH_DATA_H
+
+#include <zypp-core/Url.h>
+#include <zypp-core/base/PtrTypes.h>
+
+namespace zypp {
+  namespace media {
+
+///////////////////////////////////////////////////////////////////
+
+
+/**
+ * Class for handling media authentication data. This is the most generic
+ * class containing only username and password members.
+ */
+class AuthData
+{
+public:
+  AuthData()
+  {}
+
+  AuthData(const Url & url);
+
+  AuthData(const std::string & username, const std::string & password)
+    : _username(username), _password(password), _lastChange(0)
+  {}
+
+  virtual ~AuthData() {};
+
+  /**
+   * Checks validity of authentication data.
+   * \return true if the object contains non-empty username and
+   *  non-empty password, false otherwise.
+   */
+  virtual bool valid() const;
+
+  void setUrl(const Url & url) { _url = url; }
+  void setUsername(const std::string & username) { _username = username; }
+  void setPassword(const std::string & password) { _password = password; }
+
+  Url url() const { return _url; }
+  std::string username() const { return _username; }
+  std::string password() const { return _password; }
+
+  /*!
+   * Returns the timestamp of the last change to the database this
+   * credential is stored in, or 0 if its not known.
+   */
+  time_t lastDatabaseUpdate () const;
+  void setLastDatabaseUpdate ( time_t time );
+
+  virtual std::ostream & dumpOn( std::ostream & str ) const;
+
+  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
+
+private:
+  Url _url;
+  std::string _username;
+  std::string _password;
+  time_t _lastChange; //< timestamp of the last change to the database this credential is stored in
+};
+
+typedef shared_ptr<AuthData> AuthData_Ptr;
+std::ostream & operator << (std::ostream & str, const AuthData & auth_data);
+
+///////////////////////////////////////////////////////////////////
+
+  } // namespace media
+} // namespace zypp
+
+#endif // ZYPP_MEDIA_AUTH_DATA_H
similarity index 95%
rename from zypp/media/CredentialFileReader.cc
rename to zypp-media/auth/credentialfilereader.cc
index 6015d19..0a402e0 100644 (file)
@@ -6,17 +6,18 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file zypp/media/CredentialFileReader.cc
+/** \file zypp-media/auth/credentialfilereader
  *
  */
-#include <iostream>
 
-#include <zypp/base/Logger.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/parser/IniDict.h>
-#include <zypp/PathInfo.h>
+#include "credentialfilereader.h"
+
+#include <iostream>
 
-#include <zypp/media/CredentialFileReader.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/parser/IniDict>
+#include <zypp-core/fs/PathInfo.h>
 
 using std::endl;
 
diff --git a/zypp-media/auth/credentialfilereader.h b/zypp-media/auth/credentialfilereader.h
new file mode 100644 (file)
index 0000000..203f560
--- /dev/null
@@ -0,0 +1,50 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/auth/CredentialFileReader
+ *
+ */
+#ifndef ZYPP_MEDIA_AUTH_CREDENTIALFILEREADER_H
+#define ZYPP_MEDIA_AUTH_CREDENTIALFILEREADER_H
+
+#include <zypp-core/base/Function.h>
+#include <zypp-core/Url.h>
+#include <zypp-core/Pathname.h>
+
+#include <zypp-media/auth/AuthData>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{
+  ///////////////////////////////////////////////////////////////////
+  namespace media
+  {
+    //////////////////////////////////////////////////////////////////////
+    /// \class CredentialFileReader
+    /// \brief Parse credentials files and catalogs
+    class CredentialFileReader
+    {
+    public:
+      /** Callback invoked for each entry found in the file.
+       * Return \c false to abort parsing.
+       */
+      typedef function<bool(AuthData_Ptr &)> ProcessCredentials;
+
+      CredentialFileReader( const Pathname & crfile_r, const ProcessCredentials & callback_r );
+      ~CredentialFileReader();
+    private:
+      ProcessCredentials _callback;
+    };
+    //////////////////////////////////////////////////////////////////////
+
+  } // namespace media
+  ///////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
+#endif /* ZYPP_MEDIA_AUTH_CREDENTIALFILEREADER_H */
similarity index 96%
rename from zypp/media/CredentialManager.cc
rename to zypp-media/auth/credentialmanager.cc
index 91173c8..0a845d2 100644 (file)
@@ -6,21 +6,23 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file zypp/media/CredentialManager.cc
+/** \file zypp-media/auth/credentialmanager.cc
  *
  */
+
+#include "credentialmanager.h"
+
 #include <iostream>
 #include <fstream>
 
-#include <zypp/ZConfig.h>
-#include <zypp/base/Function.h>
-#include <zypp/base/Logger.h>
-#include <zypp/base/Easy.h>
-#include <zypp/PathInfo.h>
+#include <zypp-media/MediaConfig>
+#include <zypp-core/base/Function.h>
+#include <zypp-core/base/Logger.h>
+#include <zypp-core/base/Easy.h>
+#include <zypp-core/fs/PathInfo.h>
 
-#include <zypp/media/CredentialFileReader.h>
-#include <zypp/media/CredentialManager.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/auth/CredentialFileReader>
+#include <zypp-media/MediaException>
 
 #include <boost/interprocess/sync/file_lock.hpp>
 #include <boost/interprocess/sync/scoped_lock.hpp>
@@ -66,8 +68,8 @@ namespace zypp
   //////////////////////////////////////////////////////////////////////
 
   CredManagerOptions::CredManagerOptions(const Pathname & rootdir)
-    : globalCredFilePath(rootdir / ZConfig::instance().credentialsGlobalFile())
-    , customCredFileDir(rootdir / ZConfig::instance().credentialsGlobalDir())
+    : globalCredFilePath(rootdir / MediaConfig::instance().credentialsGlobalFile())
+    , customCredFileDir(rootdir / MediaConfig::instance().credentialsGlobalDir())
   {
     char * homedir = getenv("HOME");
     if (homedir)
diff --git a/zypp-media/auth/credentialmanager.h b/zypp-media/auth/credentialmanager.h
new file mode 100644 (file)
index 0000000..6992093
--- /dev/null
@@ -0,0 +1,187 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/auth/CredentialManager
+ *
+ */
+#ifndef ZYPP_MEDIA_AUTH_CREDENTIALMANAGER_H
+#define ZYPP_MEDIA_AUTH_CREDENTIALMANAGER_H
+
+#include <set>
+
+#include <zypp-core/Pathname.h>
+#include <zypp-media/auth/AuthData>
+
+//////////////////////////////////////////////////////////////////////
+namespace zypp
+{ ////////////////////////////////////////////////////////////////////
+
+  class Url;
+
+  //////////////////////////////////////////////////////////////////////
+  namespace media
+  { ////////////////////////////////////////////////////////////////////
+
+
+  //////////////////////////////////////////////////////////////////////
+  //
+  // CLASS NAME : CredManagerOptions
+  //
+  /**
+   * \todo configurable cred file locations
+   */
+  struct CredManagerOptions
+  {
+    CredManagerOptions(const Pathname & rootdir = "");
+
+    Pathname globalCredFilePath;
+    Pathname userCredFilePath;
+    Pathname customCredFileDir;
+  };
+  //////////////////////////////////////////////////////////////////////
+
+  // comparator for CredentialSet
+  struct AuthDataComparator
+  {
+    bool operator()(const AuthData_Ptr & lhs, const AuthData_Ptr & rhs) const;
+  };
+
+  //////////////////////////////////////////////////////////////////////
+  //
+  // CLASS NAME : CredentialManager
+  //
+  /**
+   * \todo better method names
+   * \todo delete(AuthData) method
+   */
+  class CredentialManager
+  {
+  public:
+    typedef std::set<AuthData_Ptr, AuthDataComparator> CredentialSet;
+    typedef CredentialSet::size_type                   CredentialSize;
+    typedef CredentialSet::const_iterator              CredentialIterator;
+
+
+    CredentialManager(const CredManagerOptions & opts = CredManagerOptions());
+
+    ~CredentialManager()
+    {}
+
+  public:
+    /**
+     * Get credentials for the specified \a url.
+     *
+     * If the URL contains also username, it will be used to find the match
+     * for this user (in case mutliple are available).
+     *
+     * \param url URL to find credentials for.
+     * \return Pointer to retrieved authentication data on success or an empty
+     *         AuthData_Ptr otherwise.
+     * \todo return a copy instead?
+     */
+    AuthData_Ptr getCred(const Url & url);
+
+    /**
+     * Read credentials from a file.
+     */
+    AuthData_Ptr getCredFromFile(const Pathname & file);
+
+    /**
+     * Add new global credentials.
+     */
+    void addGlobalCred(const AuthData & cred);
+
+    /**
+     * Add new user credentials.
+     */
+    void addUserCred(const AuthData & cred);
+
+    /**
+     * Add new credentials with user callbacks.
+     *
+     * If the cred->url() contains 'credentials' query parameter, the
+     * credentials will be automatically saved to the specified file using the
+     * \ref saveInFile() method.
+     *
+     * Otherwise a callback will be called asking whether to save to custom
+     * file, or to global or user's credentials catalog.
+     *
+     * \todo Currently no callback is called, credentials are automatically
+     *       saved to user's credentials.cat if no 'credentials' parameter
+     *       has been specified
+     */
+    void addCred(const AuthData & cred);
+
+    /**
+     * Saves any unsaved credentials added via \ref addUserCred() or
+     * \a addGlobalCred() methods.
+     */
+    void save();
+
+    /**
+     * Saves given \a cred to global credentials file.
+     *
+     * \note Use this method to add just one piece of credentials. To add
+     *       multiple items at once, use addGlobalCred() followed
+     *       by save()
+     */
+    void saveInGlobal(const AuthData & cred);
+
+    /**
+     * Saves given \a cred to user's credentials file.
+     *
+     * \note Use this method to add just one piece of credentials. To add
+     *       multiple items at once, use addUserCred() followed
+     *       by save()
+     */
+    void saveInUser(const AuthData & cred);
+
+    /**
+     * Saves given \a cred to user specified credentials file.
+     *
+     * If the credFile path is absolute, it will be saved at that precise
+     * location. If \a credFile is just a filename, it will be saved
+     * in \ref CredManagerOptions::customCredFileDir. Otherwise the current
+     * working directory will be prepended to the file path.
+     */
+    void saveInFile(const AuthData &, const Pathname & credFile);
+
+    /**
+     * Remove all global or user credentials from memory and disk.
+     *
+     * \param global  Whether to remove global or user credentials.
+     */
+    void clearAll(bool global = false);
+
+
+    CredentialIterator credsGlobalBegin() const;
+    CredentialIterator credsGlobalEnd()   const;
+    CredentialSize     credsGlobalSize()  const;
+    bool               credsGlobalEmpty() const;
+
+    CredentialIterator credsUserBegin() const;
+    CredentialIterator credsUserEnd()   const;
+    CredentialSize     credsUserSize()  const;
+    bool               credsUserEmpty() const;
+
+    struct Impl;
+  private:
+    RW_pointer<Impl> _pimpl;
+  };
+  //////////////////////////////////////////////////////////////////////
+
+
+    ////////////////////////////////////////////////////////////////////
+  } // media
+  //////////////////////////////////////////////////////////////////////
+  ////////////////////////////////////////////////////////////////////
+} // zypp
+//////////////////////////////////////////////////////////////////////
+
+#endif /* ZYPP_MEDIA_AUTH_CREDENTIALMANAGER_H */
+
diff --git a/zypp-media/mediaconfig.cc b/zypp-media/mediaconfig.cc
new file mode 100644 (file)
index 0000000..bf0c473
--- /dev/null
@@ -0,0 +1,118 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/mediaconfig.cc
+ *
+*/
+
+#include "mediaconfig.h"
+#include <zypp-core/Pathname.h>
+#include <zypp-core/base/String.h>
+
+namespace zypp {
+
+  class MediaConfigPrivate {
+  public:
+
+    MediaConfigPrivate()
+      : download_max_concurrent_connections( 5 )
+      , download_min_download_speed    ( 0 )
+      , download_max_download_speed    ( 0 )
+      , download_max_silent_tries      ( 5 )
+      , download_transfer_timeout      ( 180 )
+    { }
+
+    Pathname credentials_global_dir_path;
+    Pathname credentials_global_file_path;
+
+    int download_max_concurrent_connections;
+    int download_min_download_speed;
+    int download_max_download_speed;
+    int download_max_silent_tries;
+    int download_transfer_timeout;
+  };
+
+  MediaConfig::MediaConfig() : d_ptr( new MediaConfigPrivate() )
+  { }
+
+  MediaConfig &MediaConfig::instance()
+  {
+    static MediaConfig instance;
+    return instance;
+  }
+
+  bool MediaConfig::setConfigValue( const std::string &section, const std::string &entry, const std::string &value )
+  {
+    Z_D();
+    if ( section == "main" ) {
+      if ( entry == "credentials.global.dir" ) {
+        d->credentials_global_dir_path = Pathname(value);
+        return true;
+      } else if ( entry == "credentials.global.file" ) {
+        d->credentials_global_file_path = Pathname(value);
+        return true;
+
+      } else if ( entry == "download.max_concurrent_connections" ) {
+        str::strtonum(value, d->download_max_concurrent_connections);
+        return true;
+
+      } else if ( entry == "download.min_download_speed" ) {
+        str::strtonum(value, d->download_min_download_speed);
+        return true;
+
+      } else if ( entry == "download.max_download_speed" ) {
+        str::strtonum(value, d->download_max_download_speed);
+        return true;
+
+      } else if ( entry == "download.max_silent_tries" ) {
+        str::strtonum(value, d->download_max_silent_tries);
+        return true;
+
+      } else if ( entry == "download.transfer_timeout" ) {
+        str::strtonum(value, d->download_transfer_timeout);
+        if ( d->download_transfer_timeout < 0 )                d->download_transfer_timeout = 0;
+        else if ( d->download_transfer_timeout > 3600 )        d->download_transfer_timeout = 3600;
+        return true;
+      }
+    }
+    return false;
+  }
+
+  Pathname MediaConfig::credentialsGlobalDir() const
+  {
+    Z_D();
+    return ( d->credentials_global_dir_path.empty() ?
+               Pathname("/etc/zypp/credentials.d") : d->credentials_global_dir_path );
+  }
+
+  Pathname MediaConfig::credentialsGlobalFile() const
+  {
+    Z_D();
+    return ( d->credentials_global_file_path.empty() ?
+               Pathname("/etc/zypp/credentials.cat") : d->credentials_global_file_path );
+  }
+
+  long MediaConfig::download_max_concurrent_connections() const
+  { return d_func()->download_max_concurrent_connections; }
+
+  long MediaConfig::download_min_download_speed() const
+  { return d_func()->download_min_download_speed; }
+
+  long MediaConfig::download_max_download_speed() const
+  { return d_func()->download_max_download_speed; }
+
+  long MediaConfig::download_max_silent_tries() const
+  { return d_func()->download_max_silent_tries; }
+
+  long MediaConfig::download_transfer_timeout() const
+  { return d_func()->download_transfer_timeout; }
+
+  ZYPP_IMPL_PRIVATE(MediaConfig)
+}
+
+
diff --git a/zypp-media/mediaconfig.h b/zypp-media/mediaconfig.h
new file mode 100644 (file)
index 0000000..ed8bc90
--- /dev/null
@@ -0,0 +1,95 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp-media/MediaConfig
+ *
+*/
+#ifndef ZYPP_MEDIA_MEDIACONFIG_H
+#define ZYPP_MEDIA_MEDIACONFIG_H
+
+#include <zypp-core/base/NonCopyable.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/zyppng/base/zyppglobal.h>
+#include <memory>
+#include <string>
+
+namespace zypp {
+
+  class MediaConfigPrivate;
+
+  /*!
+   * Helper class to collect global options and settings related to zypp-media.
+   * Use it to avoid hardcoded values and calls to getZYpp() just
+   * to retrieve some value like credentials path or download related settings.
+   *
+   * Note, if you add settings to this file, please follow the following
+   * convention:
+   *
+   * namespace.settingname
+   *
+   * should become
+   *
+   * namespace_settingName()
+   *
+   * \ingroup ZyppConfig
+   * \ingroup Singleton
+  */
+  class MediaConfig : private base::NonCopyable
+  {
+    ZYPP_DECLARE_PRIVATE(MediaConfig)
+  public:
+
+    /*! Singleton ctor */
+    static MediaConfig & instance();
+
+    bool setConfigValue ( const std::string &section, const std::string &entry, const std::string &value );
+
+    /*!
+     * Defaults to /etc/zypp/credentials.d
+     */
+    Pathname credentialsGlobalDir() const;
+
+    /*!
+     * Defaults to /etc/zypp/credentials.cat
+     */
+    Pathname credentialsGlobalFile() const;
+
+    /*!
+     * Maximum number of concurrent connections for a single transfer
+     */
+    long download_max_concurrent_connections() const;
+
+    /*!
+     * Minimum download speed (bytes per second)
+     * until the connection is dropped
+     */
+    long download_min_download_speed() const;
+
+    /*!
+     * Maximum download speed (bytes per second)
+     */
+    long download_max_download_speed() const;
+
+    /*!
+     * Maximum silent tries
+     */
+    long download_max_silent_tries() const;
+
+    /*!
+     * Maximum time in seconds that you allow a transfer operation to take.
+     */
+    long download_transfer_timeout() const;
+
+  private:
+    MediaConfig();
+    std::unique_ptr<MediaConfigPrivate> d_ptr;
+  };
+
+}
+
+#endif
similarity index 98%
rename from zypp/media/MediaException.cc
rename to zypp-media/mediaexception.cc
index cb0488a..9e48abd 100644 (file)
@@ -6,16 +6,16 @@
 |                         /_____||_| |_| |_|                           |
 |                                                                      |
 \---------------------------------------------------------------------*/
-/** \file zypp/media/MediaException.cc
+/** \file zypp-media/mediaexception.cc
  *
 */
 
 #include <iostream>
 
-#include <zypp/base/String.h>
-#include <zypp/base/Gettext.h>
+#include <zypp-core/base/String.h>
+#include <zypp-core/base/Gettext.h>
 
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 
 using std::endl;
 using zypp::str::form;
diff --git a/zypp-media/mediaexception.h b/zypp-media/mediaexception.h
new file mode 100644 (file)
index 0000000..522a368
--- /dev/null
@@ -0,0 +1,549 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/MediaException
+ *
+*/
+#ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H
+#define ZYPP_MEDIA_MEDIAEXCEPTION_H
+
+#include <iosfwd>
+
+#include <string>
+#include <vector>
+
+#include <zypp-core/base/Exception.h>
+#include <zypp-core/Pathname.h>
+#include <zypp-core/Url.h>
+#include <zypp-core/ByteCount.h>
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+  namespace media {
+    ///////////////////////////////////////////////////////////////
+    //
+    // CLASS NAME : MediaException
+    /** Just inherits Exception to separate media exceptions
+     *
+     **/
+    class MediaException : public Exception
+    {
+    public:
+      /** Ctor taking message.
+       * Use \ref ZYPP_THROW to throw exceptions.
+      */
+      MediaException() : Exception( "Media Exception" )
+      {}
+      /** Ctor taking message.
+       * Use \ref ZYPP_THROW to throw exceptions.
+      */
+      MediaException( const std::string & msg_r )
+      : Exception( msg_r )
+      {}
+
+      /** Dtor. */
+      virtual ~MediaException() noexcept override;
+    };
+
+    class MediaMountException : public MediaException
+    {
+    public:
+      MediaMountException()
+      : MediaException( "Media Mount Exception" )
+      {}
+
+      /** Ctor taking message.
+       * Use \ref ZYPP_THROW to throw exceptions.
+      */
+      MediaMountException( const std::string & error_r,
+                           const std::string & source_r,
+                           const std::string & target_r,
+                           const std::string & cmdout_r="")
+      : MediaException()
+      , _error(error_r)
+      , _source(source_r)
+      , _target(target_r)
+      , _cmdout(cmdout_r)
+      {}
+      /** Dtor. */
+      virtual ~MediaMountException() noexcept {}
+
+      const std::string & mountError() const
+      { return _error;  }
+      const std::string & mountSource() const
+      { return _source; }
+      const std::string & mountTarget() const
+      { return _target; }
+      const std::string & mountOutput() const
+      { return _cmdout; }
+
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _error;
+      std::string _source;
+      std::string _target;
+      std::string _cmdout;
+    };
+
+    class MediaUnmountException : public MediaException
+    {
+    public:
+      /** Ctor taking message.
+       * Use \ref ZYPP_THROW to throw exceptions.
+      */
+      MediaUnmountException( const std::string & error_r,
+                             const std::string & path_r )
+      : MediaException()
+      , _error(error_r)
+      , _path(path_r)
+      {}
+      /** Dtor. */
+      virtual ~MediaUnmountException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _error;
+      std::string _path;
+    };
+
+    class MediaBadFilenameException : public MediaException
+    {
+    public:
+      MediaBadFilenameException(const std::string & filename_r)
+      : MediaException()
+      , _filename(filename_r)
+      {}
+      virtual ~MediaBadFilenameException() noexcept {}
+      std::string filename() const { return _filename; }
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _filename;
+    };
+
+    class MediaNotOpenException : public MediaException
+    {
+    public:
+      MediaNotOpenException(const std::string & action_r)
+      : MediaException()
+      , _action(action_r)
+      {}
+      virtual ~MediaNotOpenException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _action;
+    };
+
+    class MediaFileNotFoundException : public MediaException
+    {
+    public:
+      MediaFileNotFoundException(const Url & url_r,
+                                 const Pathname & filename_r)
+      : MediaException()
+      , _url(url_r.asString())
+      , _filename(filename_r.asString())
+      {}
+      virtual ~MediaFileNotFoundException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _url;
+      std::string _filename;
+    };
+
+    class MediaWriteException : public MediaException
+    {
+    public:
+      MediaWriteException(const Pathname & filename_r)
+      : MediaException()
+      , _filename(filename_r.asString())
+      {}
+      virtual ~MediaWriteException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _filename;
+    };
+
+    class MediaNotAttachedException : public MediaException
+    {
+    public:
+      MediaNotAttachedException(const Url & url_r)
+      : MediaException()
+      , _url(url_r.asString())
+      {}
+      virtual ~MediaNotAttachedException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _url;
+    };
+
+    class MediaBadAttachPointException : public MediaException
+    {
+    public:
+      MediaBadAttachPointException(const Url & url_r)
+      : MediaException()
+      , _url(url_r.asString())
+      {}
+      virtual ~MediaBadAttachPointException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _url;
+    };
+
+    class MediaCurlInitException : public MediaException
+    {
+    public:
+      MediaCurlInitException(const Url & url_r)
+      : MediaException()
+      , _url(url_r.asString())
+      {}
+      virtual ~MediaCurlInitException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _url;
+    };
+
+    class MediaSystemException : public MediaException
+    {
+    public:
+      MediaSystemException(const Url & url_r,
+                           const std::string & message_r)
+      : MediaException()
+      , _url(url_r.asString())
+      , _message(message_r)
+      {}
+      virtual ~MediaSystemException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _url;
+      std::string _message;
+    };
+
+    class MediaNotAFileException : public MediaException
+    {
+    public:
+      MediaNotAFileException(const Url & url_r,
+                             const Pathname & path_r)
+      : MediaException()
+      , _url(url_r.asString())
+      , _path(path_r.asString())
+      {}
+      virtual ~MediaNotAFileException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _url;
+      std::string _path;
+    };
+
+    class MediaNotADirException : public MediaException
+    {
+    public:
+      MediaNotADirException(const Url & url_r,
+                            const Pathname & path_r)
+      : MediaException()
+      , _url(url_r.asString())
+      , _path(path_r.asString())
+      {}
+      virtual ~MediaNotADirException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _url;
+      std::string _path;
+    };
+
+    class MediaBadUrlException : public MediaException
+    {
+    public:
+      MediaBadUrlException(const Url & url_r,
+                           const std::string &msg_r = std::string())
+      : MediaException()
+      , _url(url_r.asString())
+      , _msg(msg_r)
+      {}
+      virtual ~MediaBadUrlException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+      std::string _msg;
+    };
+
+    class MediaBadUrlEmptyHostException : public MediaBadUrlException
+    {
+    public:
+      MediaBadUrlEmptyHostException(const Url & url_r)
+      : MediaBadUrlException(url_r)
+      {}
+      virtual ~MediaBadUrlEmptyHostException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    };
+
+    class MediaBadUrlEmptyFilesystemException : public MediaBadUrlException
+    {
+    public:
+      MediaBadUrlEmptyFilesystemException(const Url & url_r)
+      : MediaBadUrlException(url_r)
+      {}
+      virtual ~MediaBadUrlEmptyFilesystemException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    };
+
+    class MediaBadUrlEmptyDestinationException : public MediaBadUrlException
+    {
+    public:
+      MediaBadUrlEmptyDestinationException(const Url & url_r)
+      : MediaBadUrlException(url_r)
+      {}
+      virtual ~MediaBadUrlEmptyDestinationException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    };
+
+    class MediaUnsupportedUrlSchemeException : public MediaBadUrlException
+    {
+    public:
+      MediaUnsupportedUrlSchemeException(const Url & url_r)
+      : MediaBadUrlException(url_r)
+      {}
+      virtual ~MediaUnsupportedUrlSchemeException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    };
+
+    class MediaNotSupportedException : public MediaException
+    {
+    public:
+      MediaNotSupportedException(const Url & url_r)
+      : MediaException()
+      , _url(url_r.asString())
+      {}
+      virtual ~MediaNotSupportedException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+    };
+
+    class MediaCurlException : public MediaException
+    {
+    public:
+      MediaCurlException(const Url & url_r,
+                         const std::string & err_r,
+                         const std::string & msg_r)
+      : MediaException()
+      , _url(url_r.asString())
+      , _err(err_r)
+      , _msg(msg_r)
+      {}
+      virtual ~MediaCurlException() noexcept {}
+      std::string errstr() const { return _err; }
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+      std::string _err;
+      std::string _msg;
+    };
+
+    class MediaCurlSetOptException : public MediaException
+    {
+    public:
+      MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
+      : MediaException()
+      , _url(url_r.asString())
+      , _msg(msg_r)
+      {}
+      virtual ~MediaCurlSetOptException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+      std::string _msg;
+    };
+
+    class MediaNotDesiredException : public MediaException
+    {
+    public:
+      MediaNotDesiredException(const Url & url_r)
+      : MediaException()
+      , _url(url_r.asString())
+      {}
+      virtual ~MediaNotDesiredException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string  _url;
+    };
+
+    class MediaIsSharedException : public MediaException
+    {
+    public:
+      /**
+       * \param name A media source as string (see MediaSource class).
+       */
+      MediaIsSharedException(const std::string &name)
+      : MediaException()
+      , _name(name)
+      {}
+      virtual ~MediaIsSharedException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _name;
+    };
+
+    class MediaNotEjectedException: public MediaException
+    {
+    public:
+      MediaNotEjectedException()
+      : MediaException("Can't eject any media")
+      , _name("")
+      {}
+
+      MediaNotEjectedException(const std::string &name)
+      : MediaException("Can't eject media")
+      , _name(name)
+      {}
+      virtual ~MediaNotEjectedException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      std::string _name;
+    };
+
+    class MediaUnauthorizedException: public MediaException
+    {
+    public:
+      MediaUnauthorizedException()
+      : MediaException("Unauthorized media access")
+      , _url("")
+      , _err("")
+      , _hint("")
+      {}
+
+      MediaUnauthorizedException(const Url         &url_r,
+                                 const std::string &msg_r,
+                                 const std::string &err_r,
+                                 const std::string &hint_r)
+      : MediaException(msg_r)
+      , _url(url_r)
+      , _err(err_r)
+      , _hint(hint_r)
+      {}
+
+      virtual ~MediaUnauthorizedException() noexcept {}
+
+      const Url         & url()  const { return _url;  }
+      const std::string & err()  const { return _err;  }
+      /** comma separated list of available authentication types */
+      const std::string & hint() const { return _hint; }
+
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+    private:
+      Url         _url;
+      std::string _err;
+      std::string _hint;
+    };
+
+    class MediaForbiddenException : public MediaException
+    {
+    public:
+      MediaForbiddenException(const Url & url_r, const std::string & msg = "")
+      : MediaException(msg)
+      , _url(url_r.asString()), _msg(msg)
+      {}
+      virtual ~MediaForbiddenException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+      std::string _msg;
+    };
+
+    class MediaTimeoutException : public MediaException
+    {
+    public:
+      MediaTimeoutException(const Url & url_r, const std::string & msg = "")
+      : MediaException(msg)
+      , _url(url_r.asString()), _msg(msg)
+      {}
+      virtual ~MediaTimeoutException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+      std::string _msg;
+    };
+
+    class MediaFileSizeExceededException : public MediaException
+    {
+    public:
+      MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
+      : MediaException(msg)
+      , _url(url_r.asString())
+      , _msg(msg)
+      , _expectedFileSize(cnt_r)
+      {}
+      virtual ~MediaFileSizeExceededException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+      std::string _msg;
+      ByteCount _expectedFileSize;
+    };
+
+    /** For HTTP 503 and similar. */
+    class MediaTemporaryProblemException : public MediaException
+    {
+    public:
+      MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
+      : MediaException(msg)
+      , _url(url_r.asString()), _msg(msg)
+      {}
+      virtual ~MediaTemporaryProblemException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+      std::string _msg;
+    };
+
+    class MediaBadCAException : public MediaException
+    {
+    public:
+      MediaBadCAException(const Url & url_r, const std::string & msg = "")
+      : MediaException(msg)
+      , _url(url_r.asString()), _msg(msg)
+      {}
+      virtual ~MediaBadCAException() noexcept {}
+    protected:
+      virtual std::ostream & dumpOn( std::ostream & str ) const;
+      std::string _url;
+      std::string _msg;
+    };
+
+    class MediaInvalidCredentialsException : public MediaException
+    {
+    public:
+      MediaInvalidCredentialsException( const std::string & msg = "" )
+        : MediaException(msg)
+      {}
+      virtual ~MediaInvalidCredentialsException() noexcept {}
+    };
+
+  /////////////////////////////////////////////////////////////////
+  } // namespace media
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_MEDIA_MEDIAEXCEPTION_H
similarity index 99%
rename from zypp/media/Mount.cc
rename to zypp-media/mount.cc
index 4be699f..a76a024 100644 (file)
 #include <fstream>
 #include <string>
 
+#include <zypp-media/Mount>
 #include <zypp/base/ExternalDataSource.h>
 #include <zypp/base/Logger.h>
-#include <zypp/media/Mount.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 
 #include <zypp/PathInfo.h>
 
diff --git a/zypp-media/mount.h b/zypp-media/mount.h
new file mode 100644 (file)
index 0000000..2a52b9d
--- /dev/null
@@ -0,0 +1,182 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file zypp-media/Mount
+ *
+*/
+
+// -*- C++ -*-
+
+#ifndef ZYPP_MEDIA_MOUNT_H
+#define ZYPP_MEDIA_MOUNT_H
+
+#include <set>
+#include <map>
+#include <string>
+#include <iosfwd>
+
+#include <zypp/ExternalProgram.h>
+#include <zypp-core/KVMap>
+
+namespace zypp {
+  namespace media {
+
+
+    /**
+     * A "struct mntent" like mount entry structure,
+     * but using std::strings.
+     */
+    struct MountEntry
+    {
+        MountEntry(const std::string &source,
+                   const std::string &target,
+                   const std::string &fstype,
+                   const std::string &options,
+                   const int         dumpfreq = 0,
+                   const int         passnum  = 0)
+            : src(source)
+            , dir(target)
+            , type(fstype)
+            , opts(options)
+            , freq(dumpfreq)
+            , pass(passnum)
+        {}
+
+        std::string src;  //!< name of mounted file system
+        std::string dir;  //!< file system path prefix
+        std::string type; //!< filesystem / mount type
+        std::string opts; //!< mount options
+        int         freq; //!< dump frequency in days
+        int         pass; //!< pass number on parallel fsck
+    };
+
+    /** \relates MountEntry
+     * A vector of mount entries.
+     */
+    typedef std::vector<MountEntry> MountEntries;
+
+    /** \relates MountEntry Stream output */
+    std::ostream & operator<<( std::ostream & str, const MountEntry & obj );
+
+    /**
+     * @short Interface to the mount program
+     */
+    class Mount
+    {
+    public:
+
+        /**
+         * For passing additional environment variables
+         * to mount
+         **/
+        typedef ExternalProgram::Environment Environment;
+
+        /**
+         * Mount options. 'key' or 'key=value' pairs, separated by ','
+         **/
+        typedef KVMap<kvmap::KVMapBase::CharSep<'=',','> > Options;
+
+    public:
+
+        /**
+        * Create an new instance.
+        */
+        Mount();
+
+        /**
+        * Clean up.
+        */
+        ~Mount();
+
+        /**
+        * mount device
+        *
+        * @param source what to mount (e.g. /dev/hda3)
+        * @param target where to mount (e.g. /mnt)
+        * @param filesystem which filesystem to use (e.g. reiserfs) (-t parameter)
+        * @param options mount options (e.g. ro) (-o parameter)
+        * @param environment optinal environment to pass (e.g. PASSWD="sennah")
+        *
+        * \throws MediaException
+        *
+        */
+
+        void mount ( const std::string& source,
+                        const std::string& target,
+                        const std::string& filesystem,
+                        const std::string& options,
+                        const Environment& environment = Environment() );
+
+        /** umount device
+         *
+         * @param path device or mountpoint to umount
+        *
+        * \throws MediaException
+        *
+         * */
+        void umount (const std::string& path);
+
+    public:
+
+        /**
+        * Return mount entries from /etc/mtab or /etc/fstab file.
+        *
+        * @param mtab The name of the (mounted) file system description
+        *             file to read from. This file should be one /etc/mtab,
+        *             /etc/fstab or /proc/mounts. Default is to read
+        *             /proc/mounts and /etc/mtab in case is not a symlink
+        *             to /proc/mounts.
+        * @returns A vector with mount entries or empty vector if reading
+        *          or parsing of the mtab file(s) failed.
+        */
+        static MountEntries
+        getEntries(const std::string &mtab = "");
+
+    private:
+
+        /** The connection to the mount process.
+         * */
+        ExternalProgram *process;
+
+        /**
+         * Run mount with the specified arguments and handle stderr.
+         * @param argv Mount arguments
+         * @param environment Addittional environment to set
+         * @param stderr_disp How to handle stderr, merged with stdout by default
+         * */
+        void run( const char *const *argv, const Environment& environment,
+                  ExternalProgram::Stderr_Disposition stderr_disp =
+                  ExternalProgram::Stderr_To_Stdout);
+
+        void run( const char *const *argv,
+                  ExternalProgram::Stderr_Disposition stderr_disp =
+                  ExternalProgram::Stderr_To_Stdout) {
+          Environment notused;
+          run( argv, notused, stderr_disp );
+        }
+
+        /** Return the exit status of the process, closing the connection if
+         * not already done.
+         * */
+        int Status();
+
+        /** Forcably kill the process
+         * */
+        void Kill();
+
+
+        /** The exit code of the process, or -1 if not yet known.
+         * */
+        int exit_code;
+    };
+
+
+  } // namespace media
+} // namespace zypp
+
+#endif
index de9e41c..0393856 100644 (file)
--- a/zypp.conf
+++ b/zypp.conf
 ## Translated package descriptions to download from repos.
 ##
 ## A list of locales for which translated package descriptions should
-## be downloaded, in case they are availavble and the repo supports this.
+## be downloaded, in case they are available and the repo supports this.
 ## Not all repo formats support downloading specific translations only.
 ##
 ## Valid values:  List of locales like 'en', 'en_US'...
 
 ##
 ## EXPERTS ONLY: Cleanup when deleting packages. Whether the solver should
-## per default try to remove packages exclusively required by the ones he's
+## per default try to remove packages exclusively required by the ones it's
 ## asked to delete.
 ##
 ## This option should be used on a case by case basis, enabled via
index a9d2f43..8a7e3cd 100644 (file)
@@ -19,6 +19,6 @@
 #define LIBZYPP_SOVERSION      @LIBZYPP_SO_FIRST@
 #define LIBZYPP_VERSION        @LIBZYPP_NUMVERSION@
 
-#include <zypp/Globals.h>
+#include <zypp-core/Globals.h>
 
 #endif //ZYPP_APICONFIG_H
index 6ceb752..5fb66b9 100644 (file)
@@ -196,9 +196,11 @@ namespace zypp
   DEF_BUILTIN( armv7thl );     /* exists? */
 
   DEF_BUILTIN( armv7hnl );     /* legacy: */DEF_BUILTIN( armv7nhl );
+  DEF_BUILTIN( armv8hl );
   DEF_BUILTIN( armv7hl );
   DEF_BUILTIN( armv6hl );
 
+  DEF_BUILTIN( armv8l );
   DEF_BUILTIN( armv7l );
   DEF_BUILTIN( armv6l );
   DEF_BUILTIN( armv5tejl );
@@ -347,9 +349,11 @@ namespace zypp
         defCompatibleWith( a_armv5tejl(),      a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel() );
         defCompatibleWith( a_armv6l(),         a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl() );
         defCompatibleWith( a_armv7l(),         a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l() );
+        defCompatibleWith( a_armv8l(),         a_noarch(),a_armv3l(),a_armv4l(),a_armv4tl(),a_armv5l(),a_armv5tl(),a_armv5tel(),a_armv5tejl(),a_armv6l(),a_armv7l() );
 
         defCompatibleWith( a_armv6hl(),                a_noarch() );
         defCompatibleWith( a_armv7hl(),                a_noarch(),a_armv6hl() );
+        defCompatibleWith( a_armv8hl(),                a_noarch(),a_armv7hl() );
         defCompatibleWith( a_armv7hnl(),       a_noarch(),a_armv7hl(),a_armv6hl() );
         /*legacy: rpm uses v7hnl */
         defCompatibleWith( a_armv7nhl(),       a_noarch(),a_armv7hnl(),a_armv7hl(),a_armv6hl() );
index 73d1b00..72e3dc6 100644 (file)
@@ -242,6 +242,10 @@ namespace zypp
   extern const Arch Arch_armv6hl;
 
   /** \relates Arch */
+  extern const Arch Arch_armv8hl;
+  /** \relates Arch */
+  extern const Arch Arch_armv8l;
+  /** \relates Arch */
   extern const Arch Arch_armv7l;
   /** \relates Arch */
   extern const Arch Arch_armv6l;
index f65c895..aec8acf 100644 (file)
@@ -47,7 +47,6 @@ SET( zypp_SRCS
   KeyRingContexts.cc
   Locks.cc
   MediaSetAccess.cc
-  OnMediaLocation.cc
   Package.cc
   Patch.cc
   PathInfo.cc
@@ -58,7 +57,6 @@ SET( zypp_SRCS
   PoolQueryResult.cc
   ProblemSolution.cc
   Product.cc
-  ProgressData.cc
   ProvideFilePolicy.cc
   PublicKey.cc
   PurgeKernels.cc
@@ -158,7 +156,6 @@ SET( zypp_HEADERS
   ProblemSolution.h
   ProblemTypes.h
   Product.h
-  ProgressData.h
   ProvideFilePolicy.h
   PublicKey.h
   PurgeKernels.h
@@ -209,13 +206,9 @@ SET( zypp_base_SRCS
   base/SerialNumber.cc
   base/Random.cc
   base/Measure.cc
-  base/GzStream.cc
-  base/InputStream.cc
   base/SetRelationMixin.cc
   base/StrMatcher.h
   base/StrMatcher.cc
-  base/UserRequestException.cc
-  base/Sysconfig.cc
 )
 
 SET( zypp_base_HEADERS
@@ -224,63 +217,37 @@ SET( zypp_base_HEADERS
   base/DrunkenBishop.h
   base/SerialNumber.h
   base/Env.h
-  base/fXstream.h
   base/Random.h
   base/Algorithm.h
   base/Counter.h
   base/Debug.h
-  base/DefaultIntegral.h
-  base/DtorReset.h
-  base/UserRequestException.h
   base/Functional.h
-  base/GzStream.h
-  base/InputStream.h
   base/Json.h
   base/LocaleGuard.h
   base/Measure.h
   base/NamedValue.h
-  base/ProvideNumericId.h
   base/ReferenceCounted.h
   base/SetRelationMixin.h
   base/SetTracker.h
   base/Signal.h
-  base/SimpleStreambuf.h
   base/StrMatcher.h
-  base/Sysconfig.h
   base/TypeTraits.h
   base/ValueTransform.h
-  base/WatchFile.h
 )
 
-IF (ENABLE_ZCHUNK_COMPRESSION)
-
-  list( APPEND zypp_base_SRCS
-    base/ZckStream.cc
-  )
-
-  list( APPEND zypp_base_HEADERS
-    base/ZckStream.h
-  )
-
-ENDIF(ENABLE_ZCHUNK_COMPRESSION)
-
 INSTALL(  FILES
   ${zypp_base_HEADERS}
   DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/base
 )
 
 SET( zypp_media_SRCS
-  media/CurlHelper.cc
-  media/MediaException.cc
   media/MediaHandler.cc
   media/MediaHandlerFactory.cc
-  media/Mount.cc
   media/MediaNFS.cc
   media/MediaCD.cc
   media/MediaDIR.cc
   media/MediaDISK.cc
   media/MediaCIFS.cc
-  media/ProxyInfo.cc
   media/MediaNetworkCommonHandler.h
   media/MediaCurl.cc
   media/MediaMultiCurl.cc
@@ -288,15 +255,8 @@ SET( zypp_media_SRCS
   media/MediaPlugin.cc
   media/MediaSource.cc
   media/MediaManager.cc
-  media/MediaUserAuth.cc
-  media/CredentialFileReader.cc
-  media/CredentialManager.cc
-  media/CurlConfig.cc
-  media/TransferSettings.cc
   media/MediaPriority.cc
-  media/MetaLinkParser.cc
   media/ZsyncParser.cc
-  media/MediaBlockList.cc
   media/UrlResolverPlugin.cc
 )
 
@@ -315,17 +275,8 @@ SET( zypp_media_HEADERS
   media/MediaManager.h
   media/MediaNFS.h
   media/MediaSource.h
-  media/MediaUserAuth.h
-  media/Mount.h
-  media/ProxyInfo.h
-  media/CredentialFileReader.h
-  media/CredentialManager.h
-  media/CurlConfig.h
-  media/TransferSettings.h
   media/MediaPriority.h
-  media/MetaLinkParser.h
   media/ZsyncParser.h
-  media/MediaBlockList.h
   media/UrlResolverPlugin.h
 )
 
@@ -334,32 +285,7 @@ INSTALL(  FILES
   DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/media
 )
 
-IF ( LIBPROXY_FOUND )
-  SET(zypp_media_proxyinfo_libproxy_SRCS media/proxyinfo/ProxyInfoLibproxy.cc)
-  SET(zypp_media_proxyinfo_libproxy_HEADERS media/proxyinfo/ProxyInfoLibproxy.h)
-ENDIF( LIBPROXY_FOUND )
-
-SET( zypp_media_proxyinfo_SRCS
-  media/proxyinfo/ProxyInfoSysconfig.cc
-  ${zypp_media_proxyinfo_libproxy_SRCS}
-)
-
-SET( zypp_media_proxyinfo_HEADERS
-  media/proxyinfo/ProxyInfoImpl.h
-  media/proxyinfo/ProxyInfoSysconfig.h
-  ${zypp_media_proxyinfo_libproxy_HEADERS}
-  media/proxyinfo/ProxyInfos.h
-)
-
-INSTALL(  FILES
-  ${zypp_media_proxyinfo_HEADERS}
-  DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/media/proxyinfo
-)
-
 SET( zypp_parser_SRCS
-  parser/ParseException.cc
-  parser/IniParser.cc
-  parser/IniDict.cc
   parser/HistoryLogReader.cc
   parser/RepoFileReader.cc
   parser/RepoindexFileReader.cc
@@ -368,9 +294,6 @@ SET( zypp_parser_SRCS
 )
 
 SET( zypp_parser_HEADERS
-  parser/ParseException.h
-  parser/IniParser.h
-  parser/IniDict.h
   parser/HistoryLogReader.h
   parser/ParserProgress.h
   parser/RepoFileReader.h
@@ -770,6 +693,7 @@ SET ( zypp_core_compat_HEADERS
   TriBool.h
   Pathname.h
   ByteArray.h
+  ProgressData.h
 )
 
 INSTALL( FILES
@@ -802,14 +726,29 @@ SET ( zypp_core_base_compat_HEADERS
   base/PtrTypes.h
   base/Errno.h
   base/Iterable.h
+  base/DefaultIntegral.h
+  base/DtorReset.h
+  base/GzStream.h
+  base/InputStream.h
+  base/ProvideNumericId.h
+  base/SimpleStreambuf.h
+  base/Sysconfig.h
+  base/UserRequestException.h
+  base/WatchFile.h
+  base/fXstream.h
+)
+
+IF (ENABLE_ZCHUNK_COMPRESSION)
+list( APPEND zypp_core_base_compat_HEADERS
+  base/ZckStream.h
 )
+ENDIF(ENABLE_ZCHUNK_COMPRESSION)
 
 INSTALL( FILES
   ${zypp_core_base_compat_HEADERS}
   DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/base
 )
 
-
 SET ( zypp_core_url_compat_HEADERS
   url/UrlException.h
   url/UrlUtils.h
@@ -821,8 +760,29 @@ INSTALL( FILES
   DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/url
 )
 
+
+SET ( zypp_media_compat_HEADERS
+  media/CredentialFileReader.h
+  media/CredentialManager.h
+  media/MediaBlockList.h
+  media/MediaUserAuth.h
+  media/MetaLinkParser.h
+  media/ProxyInfo.h
+  media/TransferSettings.h
+  media/Mount.h
+  media/CurlConfig.h
+)
+
+INSTALL( FILES
+  ${zypp_media_compat_HEADERS}
+  DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/media
+)
+
 SET ( zypp_core_parser_compat_HEADERS
   parser/xml/XmlEscape.h
+  parser/IniDict.h
+  parser/IniParser.h
+  parser/ParseException.h
 )
 
 INSTALL( FILES
@@ -830,6 +790,22 @@ INSTALL( FILES
   DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/parser/xml
 )
 
+IF ( LIBPROXY_FOUND )
+  SET(zypp_media_proxyinfo_libproxy_HEADERS media/proxyinfo/ProxyInfoLibproxy.h)
+ENDIF( LIBPROXY_FOUND )
+
+SET( zypp_media_compat_proxyinfo_HEADERS
+  media/proxyinfo/ProxyInfoImpl.h
+  media/proxyinfo/ProxyInfoSysconfig.h
+  ${zypp_media_proxyinfo_libproxy_HEADERS}
+  media/proxyinfo/ProxyInfos.h
+)
+
+INSTALL(  FILES
+  ${zypp_media_compat_proxyinfo_HEADERS}
+  DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/media/proxyinfo
+)
+
 add_subdirectory( zyppng )
 
 SET( zypp_lib_SRCS
@@ -869,7 +845,7 @@ ${zypp_parser_xml_HEADERS}
 ${zypp_parser_HEADERS}
 ${zypp_ui_HEADERS}
 ${zypp_media_HEADERS}
-${zypp_media_proxyinfo_HEADERS}
+${zypp_media_compat_proxyinfo_HEADERS}
 ${zypp_base_HEADERS}
 ${zypp_solver_HEADERS}
 ${zypp_solver_detail_HEADERS}
@@ -888,6 +864,7 @@ ${zypp_core_compat_HEADERS}
 ${zypp_core_base_compat_HEADERS}
 ${zypp_core_url_compat_HEADERS}
 ${zypp_core_parser_compat_HEADERS}
+${zypp_media_compat_HEADERS}
 )
 
 #
@@ -940,8 +917,10 @@ macro( ADDZYPPLIB LIBNAME )
   # System libraries
   SET(UTIL_LIBRARY util)
 
-  # CAUTION, link those libs always first and always in that order,
+  # CAUTION, link those libs always first and always in that order,
   # otherwise you get symbol lookup errors when linking against libzypp
+  TARGET_LINK_LIBRARIES(${LIBNAME} zypp-curl )
+  TARGET_LINK_LIBRARIES(${LIBNAME} zypp-media )
   TARGET_LINK_LIBRARIES(${LIBNAME} zypp-core )
   TARGET_LINK_LIBRARIES(${LIBNAME} zypp-protobuf )
 
@@ -990,7 +969,7 @@ ADDZYPPLIB(zypp-allsym)
 ADD_DEPENDENCIES( zypp-allsym zypp )
 
 #this part does nothing yet, only when switching away from using a map file to
-#a approach where symbols are exported explicitely it would make a difference
+#a approach where symbols are exported explicitly it would make a difference
 #ZYPPNG symbols need to be added to the map file to be exported
 IF( EXPORT_NG_API )
 ADD_DEFINITIONS(-DEXPORT_EXPERIMENTAL_API)
index 8b13cf6..4e5f08c 100644 (file)
@@ -43,7 +43,7 @@ namespace zypp
    *
    * That way the sending side does not need to know whether some receiver
    * is listening. And it enables the receiver to return a reasonable value,
-   * in case he's got no idea, what else to return.
+   * in case it's got no idea, what else to return.
    *
    * \code
    *   struct Foo : public callback::ReportBase
@@ -96,7 +96,7 @@ namespace zypp
    *
    * \note In case you must return some value and don't know which,
    * return the task structures default. The author of the task
-   * structure had to provide this value, so it's probabely better
+   * structure had to provide this value, so it's probably better
    * than anything you \e invent.
    * \code
    *   int somefunction()
index 3338942..f8dee2c 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <iosfwd>
 
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 #include <zypp/sat/detail/PoolMember.h>
 #include <zypp/Capability.h>
 
index 822957d..ba5b6b9 100644 (file)
@@ -19,7 +19,7 @@ extern "C"
 
 #include <zypp/base/Easy.h>
 #include <zypp/base/LogTools.h>
-#include <zypp/base/DtorReset.h>
+#include <zypp-core/base/DtorReset>
 #include <zypp/base/String.h>
 
 #include <zypp/DiskUsageCounter.h>
index 111a52d..8e66c2e 100644 (file)
 #include <zypp/base/LogControl.h>
 #include <zypp/base/LogTools.h>
 #include <zypp/base/PtrTypes.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 #include <zypp/base/String.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 #include <zypp/Fetcher.h>
 #include <zypp/ZYppFactory.h>
 #include <zypp/CheckSum.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 #include <zypp/parser/susetags/ContentFileReader.h>
 #include <zypp/parser/susetags/RepoIndex.h>
 
@@ -468,7 +468,7 @@ namespace zypp
       catch ( media::MediaFileNotFoundException & exception )
       {
         ZYPP_CAUGHT( exception );
-        WAR << "Skiping subtree hidden at " << resource.filename() << endl;
+        WAR << "Skipping subtree hidden at " << resource.filename() << endl;
         return;
       }
 
index b9fce4e..9d8d1a7 100644 (file)
 #include <zypp/base/PtrTypes.h>
 #include <zypp/Pathname.h>
 #include <zypp/Url.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/Digest.h>
 #include <zypp/MediaSetAccess.h>
 #include <zypp/FileChecker.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
index 6214de0..4bb716e 100644 (file)
@@ -14,7 +14,7 @@
 
 #include <iosfwd>
 #include <list>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 #include <zypp/base/Exception.h>
 #include <zypp/base/Function.h>
 #include <zypp/PathInfo.h>
index a9c4191..0071d49 100644 (file)
@@ -23,7 +23,7 @@ extern "C"
 #include <zypp/base/Flags.h>
 #include <zypp/base/Iterator.h>
 #include <zypp/base/NonCopyable.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 
 #include <zypp/Pathname.h>
 
index 6b8d71e..d7aa520 100644 (file)
@@ -15,7 +15,7 @@
 #include <zypp/base/PtrTypes.h>
 #include <zypp/base/String.h>
 #include <zypp/base/Logger.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
 
 #include <zypp/HistoryLogData.h>
 
index c739035..5971cf2 100644 (file)
@@ -1,207 +1 @@
-/*---------------------------------------------------------------------\
-|                                                                      |
-|                      __   __    ____ _____ ____                      |
-|                      \ \ / /_ _/ ___|_   _|___ \                     |
-|                       \ V / _` \___ \ | |   __) |                    |
-|                        | | (_| |___) || |  / __/                     |
-|                        |_|\__,_|____/ |_| |_____|                    |
-|                                                                      |
-|                               core system                            |
-|                                                    (C) SuSE Linux AG |
-\----------------------------------------------------------------------/
-
-  File:       KVMap.h
-
-  Author:     Michael Andres <ma@suse.de>
-  Maintainer: Michael Andres <ma@suse.de>
-
-  Purpose: Convenience stuff for handling (key,value) pairs
-
-/-*/
-#ifndef KVMap_h
-#define KVMap_h
-
-#include <iosfwd>
-#include <vector>
-#include <map>
-
-#include <zypp/base/String.h>
-
-namespace zypp {
-  namespace kvmap {
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : KVMapBase::KVMapPolicy
-    /**
-     * @short KVMapPolicy for conversion of KVMaps to/from string.
-     *
-     * <b>_kvsplit</b>: The string separating key from value
-     *
-     * <b>_fsplit</b>:  (key,value) pairs are separated by any nonempty
-     * sequence of characers occurring in _fsplit
-     *
-     * <b>_kvjoin</b>: The string used to join key and value.
-     *
-     * <b>_fjoin</b>: The string used to separate (key,value) pairs.
-     *
-     * TODO: Maybe options for exact _fsplit handling and timming of values.
-     *
-     **/
-    struct KVMapPolicy {
-      std::string _kvsplit;
-      std::string _fsplit;
-      std::string _kvjoin;
-      std::string _fjoin;
-      KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r )
-        : _kvsplit( kvsplit_r )
-        , _fsplit ( fsplit_r )
-        , _kvjoin ( _kvsplit )
-        , _fjoin  ( _fsplit )
-      {}
-      KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r,
-             const std::string & kvjoin_r )
-        : _kvsplit( kvsplit_r )
-        , _fsplit ( fsplit_r )
-        , _kvjoin ( kvjoin_r )
-        , _fjoin  ( _fsplit )
-      {}
-      KVMapPolicy( const std::string & kvsplit_r, const std::string & fsplit_r,
-             const std::string & kvjoin_r, const std::string & fjoin_r )
-        : _kvsplit( kvsplit_r )
-        , _fsplit ( fsplit_r )
-        , _kvjoin ( kvjoin_r )
-        , _fjoin  ( fjoin_r )
-      {}
-    };
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : KVMapBase
-    /**
-     * @short Base class for KVMaps, (key,value) pairs
-     **/
-    struct KVMapBase : public std::map<std::string,std::string> {
-
-      /**
-       * (key,value) map type
-       **/
-      typedef std::map<std::string,std::string> map_type;
-
-      KVMapBase()
-      {}
-      KVMapBase( const map_type & kvmap_r )
-        : std::map<std::string,std::string>( kvmap_r )
-      {}
-
-      /**
-       * Test whether key is set.
-       **/
-      bool has( const std::string & key_r ) const {
-        return( find( key_r ) != end() );
-      }
-
-      /**
-       * @short KVMapPolicy for KVMaps using a single char as separator (e.g. mount options).
-       **/
-      template<char kv, char f>
-      struct CharSep : public KVMapPolicy { CharSep() : KVMapPolicy( std::string(1,kv), std::string(1,f) ) {} };
-
-      ///////////////////////////////////////////////////////////////////
-
-      /**
-       * Split str_r into (key,value) map, using the separators defined
-       * by opts_r.
-       **/
-      static map_type split( const std::string & str_r,
-                         const KVMapPolicy & opts_r ) {
-        map_type ret;
-        std::vector<std::string> fields;
-        str::split( str_r, std::back_inserter(fields), opts_r._fsplit );
-
-        for ( unsigned i = 0; i < fields.size(); ++i ) {
-          std::string::size_type pos = fields[i].find( opts_r._kvsplit );
-          if ( pos == std::string::npos ) {
-        ret[fields[i]] = "";
-          } else {
-        ret[fields[i].substr( 0, pos )] = fields[i].substr( pos+1 );
-          }
-        }
-
-        return ret;
-      }
-
-      /**
-       * Join (key,value) map into string, using the separators defined
-       * by opts_r.
-       **/
-      static std::string join( const map_type & kvmap_r,
-                           const KVMapPolicy & opts_r ) {
-        std::string ret;
-
-        for ( map_type::const_iterator it = kvmap_r.begin(); it != kvmap_r.end(); ++it ) {
-          if ( ! ret.empty() ) {
-        ret += opts_r._fjoin;
-          }
-          ret += it->first;
-          if ( !it->second.empty() ) {
-        ret += opts_r._kvjoin + it->second;
-          }
-        }
-
-        return ret;
-      }
-
-    };
-
-
-
-  } // namespace kvmap
-
-  ///////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : KVMap<KVMapOpts>
-  /**
-   * @short A map of (key,value) strings.
-   *
-   * The template argument defines the @ref kvmap::Options for
-   * split and join.
-   *
-   * E.g. mount options (a comma separated list of key[=value] pairs)
-   * could be handled by KVMap<kvmap::KVMapBase::Comma>.
-   **/
-  template<typename KVMapOpts>
-  struct KVMap : public kvmap::KVMapBase {
-
-    KVMap()
-    {}
-    KVMap( const char * str_r )
-      : kvmap::KVMapBase( split( (str_r?str_r:""), KVMapOpts() ) )
-    {}
-    KVMap( const std::string & str_r )
-      : kvmap::KVMapBase( split( str_r, KVMapOpts() ) )
-    {}
-    KVMap( const map_type & map_r )
-      : kvmap::KVMapBase( map_r )
-    {}
-
-    ~KVMap() {}
-
-    std::string asString() const {
-      return join( *this, KVMapOpts() );
-    }
-
-  };
-
-  ///////////////////////////////////////////////////////////////////
-
-  template<typename KVMapOpts>
-  std::ostream & operator<<( std::ostream & str, const KVMap<KVMapOpts> & obj )
-  { return str << obj.asString(); }
-
-///////////////////////////////////////////////////////////////////
-} // namespace zypp
-
-#endif // KVMap_h
+#include <zypp-core/KVMap>
index 5d28f09..ed39fc6 100644 (file)
@@ -25,7 +25,7 @@
 #include <zypp/base/String.h>
 #include <zypp/base/Regex.h>
 #include <zypp/base/Gettext.h>
-#include <zypp/base/WatchFile.h>
+#include <zypp-core/fs/WatchFile>
 #include <zypp/PathInfo.h>
 #include <zypp/KeyRing.h>
 #include <zypp/ExternalProgram.h>
@@ -537,7 +537,7 @@ namespace zypp
     callback::SendReport<KeyRingReport> report;
     MIL << "Going to verify signature for " << filedesc << " ( " << file << " ) with " << signature << endl;
 
-    // if signature does not exists, ask user if he wants to accept unsigned file.
+    // if signature does not exists, ask user if they want to accept unsigned file.
     if( signature.empty() || (!PathInfo( signature ).isExist()) )
     {
       bool res = report->askUserToAcceptUnsignedFile( filedesc, keyContext );
index 0f58d4b..c550655 100644 (file)
@@ -67,24 +67,24 @@ namespace zypp
     /**
      * unlocks by result of query and add to toRemove.
      *
-     * If unlock non-saved lock (so he is in toAdd list) then both is deleted
-     * and nathing happen during save
+     * If unlock non-saved lock (so it is in toAdd list) then both is deleted
+     * and nothing happens during save
      */
     void removeLock( const PoolQuery& query );
 
     /**
      * remove lock by identifier (e.g. Selectable->ident()
      *
-     * If unlock non-saved lock (so he is in toAdd list) then both is deleted
-     * and nathing happen during save
+     * If unlock non-saved lock (so it is in toAdd list) then both is deleted
+     * and nothing happens during save
      */
     void removeLock( const IdString& ident_r );
 
     /**
      * remove lock by name and kind
      *
-     * If unlock non-saved lock (so he is in toAdd list) then both is deleted
-     * and nathing happen during save
+     * If unlock non-saved lock (so it is in toAdd list) then both is deleted
+     * and nothing happens during save
      */
     void removeLock( const ResKind& kind_r, const IdString& name_r );
     void removeLock( const ResKind& kind_r, const C_Str & name_r );
index 946c8b9..290ea9f 100644 (file)
@@ -18,9 +18,9 @@
 #include <zypp/ZConfig.h>
 #include <zypp/base/Logger.h>
 #include <zypp/media/MediaManager.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 
 namespace zypp
 {
index 9356185..bebd611 100644 (file)
@@ -12,8 +12,8 @@
 
 #include <zypp/base/LogTools.h>
 #include <zypp/base/Regex.h>
-#include <zypp/base/UserRequestException.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-core/base/UserRequestException>
+#include <zypp-media/MediaException>
 #include <zypp/ZYppCallbacks.h>
 #include <zypp/MediaSetAccess.h>
 #include <zypp/PathInfo.h>
index 41a4bd2..5f73e51 100644 (file)
@@ -22,7 +22,7 @@
 #include <zypp/media/MediaManager.h>
 #include <zypp/Pathname.h>
 #include <zypp/CheckSum.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/ManagedFile.h>
 
 ///////////////////////////////////////////////////////////////////
index 7466c1c..643e274 100644 (file)
@@ -1,139 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/source/OnMediaLocation.h
- */
-#ifndef ZYPP_SOURCE_ONMEDIALOCATION_H
-#define ZYPP_SOURCE_ONMEDIALOCATION_H
-
-#include <iosfwd>
-
-#include <zypp/base/PtrTypes.h>
-
-#include <zypp/APIConfig.h>
-#include <zypp/Pathname.h>
-#include <zypp/ByteCount.h>
-#include <zypp/CheckSum.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{
-  ///////////////////////////////////////////////////////////////////
-  /// \class OnMediaLocation
-  /// \brief Describes a resource file located on a medium.
-  ///
-  /// Holds the path of a resource on a medium and contains additional
-  /// info required to retrieve and verify it (like media number,
-  /// checksum, size,...)
-  ///
-  /// It does not specify the \ref Url of the medium itself.
-  ///
-  /// Media number \c 0 usually indicates no media access.
-  ///////////////////////////////////////////////////////////////////
-  class OnMediaLocation
-  {
-    friend std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj );
-    friend std::ostream & dumpOn( std::ostream & str, const OnMediaLocation & obj );
-
-  public:
-    /** Default Ctor indicating no media access. */
-    OnMediaLocation();
-
-    /** Ctor taking a \a filename_r and \a medianr_r (defaults to \c 1). */
-    OnMediaLocation( Pathname filename_r, unsigned medianr_r = 1 );
-
-    /** Dtor */
-    ~OnMediaLocation();
-
-  public:
-    /** The path to the resource on the medium. */
-    const Pathname & filename() const;
-
-    /** The media number the resource is located on. */
-    unsigned medianr() const;
-
-
-    /** Set \a filename_r and \a medianr_r (defaults to \c 1). */
-    OnMediaLocation & setLocation( Pathname filename_r, unsigned medianr_r = 1 );
-
-    /** Unset \c filename and set \c medianr to \c 0. */
-    OnMediaLocation & unsetLocation();
-
-
-    /** Individual manipulation of \c filename (prefer \ref setLocation). */
-    OnMediaLocation & changeFilename( Pathname filename_r );
-
-    /** Individual manipulation of \c medianr (prefer \ref setLocation). */
-    OnMediaLocation & changeMedianr( unsigned medianr_r );
-
-    /** Prepend the filename with \a prefix_r */
-    OnMediaLocation & prependPath( const Pathname & prefix_r );
-
-  public:
-    /** Whether this is an optional resource.
-     * This is a hint to the downloader not to report an error if
-     * the resource is not present on the server.
-     */
-    bool optional() const;
-    /** Set whether the resource is \ref optional. */
-    OnMediaLocation & setOptional( bool val );
-
-  public:
-    /** The size of the resource on the server. */
-    const ByteCount & downloadSize() const;
-    /** Set the \ref downloadSize. */
-    OnMediaLocation & setDownloadSize( ByteCount val_r );
-
-    /** The checksum of the resource on the server. */
-    const CheckSum & checksum() const;
-    /** Set the \ref checksum. */
-    OnMediaLocation & setChecksum( CheckSum val_r );
-
-  public:
-    /** The size of the resource once it has been uncompressed or unpacked. */
-    const ByteCount & openSize() const;
-    /** Set the \ref openSize. */
-    OnMediaLocation & setOpenSize( ByteCount val_r );
-
-    /** The checksum of the resource once it has been uncompressed or unpacked. */
-    const CheckSum & openChecksum() const;
-    /** Set the \ref openChecksum. */
-    OnMediaLocation & setOpenChecksum( CheckSum val_r );
-
-  public:
-    /** The size of the header prepending the resource (e.g. for zchunk). */
-    const ByteCount & headerSize() const;
-    /** Set the \ref headerSize. */
-    OnMediaLocation & setHeaderSize( ByteCount val_r );
-
-    /** The checksum of the header prepending the resource (e.g. for zchunk). */
-    const CheckSum & headerChecksum() const;
-    /** Set the \ref headerChecksum. */
-    OnMediaLocation & setHeaderChecksum( CheckSum val_r );
-
-    /** The existing deltafile that can be used to reduce download size ( zchunk or metalink ) */
-    const Pathname & deltafile() const;
-    /** Set the \ref deltafile. */
-    OnMediaLocation & setDeltafile( Pathname path );
-
-
-  public:
-    class Impl;                 ///< Implementation class.
-  private:
-    RWCOW_pointer<Impl> _pimpl; ///< Pointer to implementation.
-  };
-
-  /** \relates OnMediaLocation Stream output */
-  std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj );
-
-  /** \relates OnMediaLocation Verbose stream output */
-  std::ostream & dumOn( std::ostream & str, const OnMediaLocation & obj );
-
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_ONMEDIALOCATION_H
+#include <zypp-core/onmedialocation.h>
index 68150f9..5fcc06f 100644 (file)
@@ -16,7 +16,7 @@
 #include <sstream>
 
 #include <zypp/base/LogTools.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 #include <zypp/base/String.h>
 #include <zypp/base/Signal.h>
 #include <zypp/base/IOStream.h>
index 1e2db4d..b7a55bf 100644 (file)
@@ -11,7 +11,7 @@
 */
 #include <iostream>
 #include <zypp/base/Logger.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 
 #include <zypp/PoolItem.h>
 #include <zypp/ResPool.h>
index c8ef07b..c78712d 100644 (file)
@@ -1,425 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/ProgressData.h
- *
-*/
-#ifndef ZYPP_PROGRESSDATA_H
-#define ZYPP_PROGRESSDATA_H
-
-#include <iosfwd>
-#include <string>
-
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/Function.h>
-#include <zypp/base/ProvideNumericId.h>
-
-#include <zypp/Date.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : ProgressData
-  //
-  /** Maintain <tt>[min,max]</tt> and counter <tt>(value)</tt> for progress counting.
-   *
-   * This class should provide everything the producer of progress data
-   * needs. As a convention, a zero sizes range indicates that you are just
-   * able to send <em>'still alive'</em> triggers.
-   *
-   * The counter should be updated in reasonable intervals. Don't mind whether
-   * the counter value actually increased or not. ProgressData will recognize
-   * your triggers and knows when to actually send notification to a consumer.
-   *
-   * Each ProgressData object provides a unique numeric id and you may assign
-   * it a name.
-   *
-   * \code
-   *      bool exampleReceiver( const ProgressData & ticks_r )
-   *      {
-   *        DBG << "got ->" << ticks_r.reportValue() << " (" << ticks_r.val() << ")" << endl;
-   *        return( ticks_r.val() <= 100 ); // Abort if ( val > 100 )
-   *      }
-   *
-   *      class Example
-   *      {
-   *        public:
-   *
-   *          Example( const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() )
-   *          : _fnc( fnc_r )
-   *          {}
-   *
-   *          void SendTo( const ProgressData::ReceiverFnc & fnc_r )
-   *          { _fnc = fnc_r; }
-   *
-   *        public:
-   *
-   *          void action()
-   *          {
-   *            ProgressData tics( 10 );    // Expect range 0 -> 10
-   *            tics.name( "test ticks" );  // Some arbitrary name
-   *            tics.sendTo( _fnc );        // Send reports to _fnc
-   *            tics.toMin();               // start sending min (0)
-   *
-   *            for ( int i = 0; i < 10; ++i )
-   *            {
-   *              if ( ! tics.set( i ) )
-   *                return; // user requested abort
-   *            }
-   *
-   *            tics.toMax(); // take care 100% are reported on success
-   *          }
-   *
-   *          void action2()
-   *          {
-   *            ProgressData tics;          // Just send 'still alive' messages
-   *            tics.name( "test ticks" );  // Some arbitrary name
-   *            tics.sendTo( _fnc );        // Send reports to _fnc
-   *            tics.toMin();               // start sending min (0)
-   *
-   *            for ( int i = 0; i < 10; ++i )
-   *            {
-   *              if ( ! tics.set( i ) )
-   *                return; // user requested abort
-   *            }
-   *
-   *            tics.toMax(); //
-   *          }
-   *
-   *        private:
-   *          ProgressData::ReceiverFnc _fnc;
-   *      };
-   * \endcode
-   * \code
-   *   Example t( exampleReceiver );
-   *   DBG << "Reporting %:" << endl;
-   *   t.action();
-   *   DBG << "Reporting 'still alive':" << endl;
-   *   t.action2();
-   * \endcode
-   * \code
-   * Reporting %:
-   * got ->0 (0)
-   * got ->10 (1)
-   * got ->20 (2)
-   * got ->30 (3)
-   * got ->40 (4)
-   * got ->50 (5)
-   * got ->60 (6)
-   * got ->70 (7)
-   * got ->80 (8)
-   * got ->90 (9)
-   * got ->100 (10)
-   * got ->100 (10)
-   * Reporting 'still alive':
-   * got ->-1 (0)
-   * got ->-1 (9)
-   * \endcode
-   *
-   * The different ammount of triggers is due to different rules for sending
-   * percent or 'still alive' messages.
-   */
-  class ProgressData : public base::ProvideNumericId<ProgressData,unsigned>
-  {
-    public:
-      typedef long long value_type;
-      /** Most simple version of progress reporting
-       * The percentage in most cases. Sometimes just keepalive.
-       * \p sender ProgressData object who sends the progress info
-       * \p
-       */
-      typedef function<bool( const ProgressData & )> ReceiverFnc;
-
-    private:
-      enum State { INIT, RUN, END };
-
-      class Data
-      {
-        public:
-          Data( value_type min_r, value_type max_r, value_type val_r )
-          : _state( INIT ), _min( min_r ), _max( max_r ), _val( val_r )
-          , _last_val( 0 ), _last_send( 0 )
-          {}
-
-        public:
-          State       _state;
-          std::string _name;
-          value_type  _min;
-          value_type  _max;
-          value_type  _val;
-
-          ReceiverFnc _receiver;
-          value_type  _last_val;
-          Date        _last_send;
-
-        private:
-          /** clone for RWCOW_pointer */
-          friend Data * rwcowClone<Data>( const Data * rhs );
-          Data * clone() const { return new Data( *this ); }
-      };
-
-    public:
-      /** Ctor no range <tt>[0,0](0)</tt>. */
-      ProgressData()
-      : _d( new Data( 0, 0, 0 ) )
-      {}
-
-      /** Ctor <tt>[0,max](0)</tt>. */
-      ProgressData( value_type max_r )
-      : _d( new Data( 0, max_r, 0 ) )
-      {}
-
-      /** Ctor <tt>[min,max](min)</tt>. */
-      ProgressData( value_type min_r, value_type max_r )
-      : _d( new Data( min_r, max_r, min_r ) )
-      {}
-
-      /** Ctor <tt>[min,max](val)</tt>. */
-      ProgressData( value_type min_r, value_type max_r, value_type val_r )
-      : _d( new Data( min_r, max_r, val_r ) )
-      {}
-
-      ~ProgressData()
-      {
-        if ( _d->_state == RUN )
-        {
-          _d->_state = END;
-          report();
-        }
-      }
-
-    public:
-      /** Set new \c min value. */
-      void min( value_type min_r )
-      { _d->_min = min_r; }
-
-      /** Set new \c max value. */
-      void max( value_type max_r )
-      { _d->_max = max_r; }
-
-      /** Set no range <tt>[0,0]</tt>. */
-      void noRange()
-      { range( 0, 0 ); }
-
-      /** Set new <tt>[0,max]</tt>. */
-      void range( value_type max_r )
-      { range( 0, max_r ); }
-
-      /** Set new <tt>[min,max]</tt>. */
-      void range( value_type min_r, value_type max_r )
-      { min( min_r ); max( max_r ); }
-
-    public:
-      /** Set counter name. */
-      void name( const std::string & name_r )
-      { _d->_name = name_r; }
-
-      /** Set ReceiverFnc. */
-      void sendTo( const ReceiverFnc & fnc_r )
-      { _d->_receiver = fnc_r; }
-
-      /** Set no ReceiverFnc. */
-      void noSend()
-      { _d->_receiver = ReceiverFnc(); }
-
-    public:
-      /** \name Progress reporting.
-       *
-       * These methods may actually cause a progress report to be sent.
-       *
-       * All methods return \c bool, because a progress receiver may
-       * return \c false to indicate the desire to abort the pending
-       * action. The incident is logged, but it's finaly up to the caller
-       * to honor this.
-       */
-      //@{
-
-      /** Set new counter \c value. */
-      bool set( value_type val_r )
-      {
-        _d->_val = val_r;
-        return report();
-      }
-
-      /** Set range and counter from an other \ref ProgressData. */
-      bool set( const ProgressData & rhs )
-      {
-        min( rhs.min() );
-        max( rhs.max() );
-        return set( rhs.val() );
-      }
-
-      /** Increment counter \c value (default by 1). */
-      bool incr( value_type val_r = 1 )
-      { return set( val() + val_r ); }
-
-      /** Decrement counter \c value (default by 1). */
-      bool decr( value_type val_r = 1 )
-      { return set( val() - val_r ); }
-
-      /** Set counter value to current \c min value. */
-      bool toMin()
-      { return set( min() ); }
-
-      /** Set counter value to current \c max value (unless no range). */
-      bool toMax()
-      { return hasRange() ? set( max() ) : tick(); }
-
-      /** Leave counter value unchanged (still alive). */
-      bool tick()
-      { return report(); }
-
-      //@}
-
-    public:
-      /** \name Progress receiving.
-       */
-      //@{
-      /** @return Current \c min value. */
-      value_type min() const
-      { return _d->_min; }
-
-      /** @return Current \c max value. */
-      value_type max() const
-      { return _d->_max; }
-
-      /** @return Current counter \c value. */
-      value_type val() const
-      { return _d->_val; }
-
-      /** @return Whether <tt>[min,max]</tt> defines a nonempty range. */
-      bool hasRange() const
-      { return min() != max(); }
-
-      /** @return Whether \ref reportValue will return a percent value.
-       * Same as \ref hasRange.
-       *  \see \ref reportAlive
-       */
-      bool reportPercent() const
-      { return hasRange(); }
-
-      /** @return Whether \ref reportValue always returns -1, because we
-       * trigger 'still alive' messages. I.e. \ref hasrange is \c false.
-       * \see \ref reportPercent
-      */
-      bool reportAlive() const
-      { return ! hasRange(); }
-
-      /** @return Either a a percent value or -1.
-       * \see \ref reportPercent and \ref reportAlive.
-      */
-      value_type reportValue() const
-      {        return hasRange() ? val() * 100 / ( max() - min() ) : -1; }
-
-      /** @return The counters name. */
-      const std::string & name() const
-      { return _d->_name; }
-
-      /** @return The ReceiverFnc. */
-      const ReceiverFnc & receiver() const
-      { return _d->_receiver; }
-
-      /** @return Return \c true if this is the final report sent by the
-       *  ProgressData dtor.
-       */
-      bool finalReport() const
-      { return( _d->_state == END ); }
-
-      //@}
-
-    private:
-      /** Send report if necessary. */
-      bool report();
-
-      /** Pointer to data. */
-      RWCOW_pointer<Data> _d;
-  };
-  ///////////////////////////////////////////////////////////////////
-
-  /** \relates ProgressData Stream output */
-  std::ostream & operator<<( std::ostream & str, const ProgressData & obj );
-
-  ///////////////////////////////////////////////////////////////////
-
-  class InputStream;
-  /** \relates ProgressData Setup from \ref InputStream. */
-  ProgressData makeProgressData( const InputStream & input_r );
-
-  ///////////////////////////////////////////////////////////////////
-
-  /**
-   * \short Progress callback from another progress
-   *
-   * This class allows you to pass a progress callback to a
-   * subtask based on a current progress data, plus a weight
-   * value. Every progress reported by the subtask via
-   * this callback will be forwarded to the main progress
-   * data, with the corresponding weight.
-   *
-   * Example:
-   *
-   * \code
-   *
-   * // receiver for main task
-   * void task_receiver( ProgressData &progress );
-   *
-   * // subtask prototypes
-   * void do_subtask_one( ProgressData::ReceiverFnc &fnc );
-   * void do_subtask_two( ProgressData::ReceiverFnc &fnc );
-   *
-   * // main task
-   * ProgressData progress;
-   * //progress for subtask 1
-   * // which is 80%
-   * CombinedProgressData sub1(pd, 80);
-   * // the second is only 20%
-   * CombinedProgressData sub2(pd, 20);
-   * do_subtask_one( sub1 );
-   * do_subtask_two( sub2 );
-   *
-   * \endcode
-   */
-  class CombinedProgressData
-  {
-  public:
-    /**
-     * \short Ctor
-     *
-     * Creates a \ref ProgressData::ReceiverFnc
-     * from a \ref ProgressData object
-     *
-     * \param pd \ref ProgressData object
-     * \param weight Weight of the subtask
-     * relative to the main task range.
-     *
-     * If weight is 0, or \param pd only reports
-     * keepalives. then only ticks are sent.
-     *
-     */
-    CombinedProgressData( ProgressData &pd,
-                          ProgressData::value_type weight = 0 );
-
-    /**
-     * Implements the \ref ProgressData::ReceiverFnc
-     * callback interface
-     */
-    bool operator()( const ProgressData &progress );
-
-  private:
-    ProgressData::value_type _weight;
-    ProgressData::value_type _last_value;
-    ProgressData &_pd;
-  };
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PROGRESSDATA_H
+#include <zypp-core/ui/ProgressData>
index ce55f1d..6a30529 100644 (file)
@@ -25,6 +25,7 @@
 #include <zypp/base/LogTools.h>
 #include <zypp/Date.h>
 #include <zypp/KeyManager.h>
+#include <zypp/ZYppFactory.h>
 
 #include <gpgme.h>
 
@@ -197,6 +198,101 @@ namespace zypp
   }
 
   ///////////////////////////////////////////////////////////////////
+  /// \class PublicKeySignatureData::Impl
+  /// \brief  PublicKeySignatureData implementation.
+  ///////////////////////////////////////////////////////////////////
+
+  struct PublicKeySignatureData::Impl
+  {
+    std::string _keyid;
+    std::string _name;
+    Date        _created;
+    Date        _expires;
+
+  public:
+    /** Offer default Impl. */
+    static shared_ptr<Impl> nullimpl();
+
+  private:
+    friend Impl * rwcowClone<Impl>( const Impl * rhs );
+    /** clone for RWCOW_pointer */
+    Impl * clone() const;
+  };
+
+  shared_ptr<zypp::PublicKeySignatureData::Impl> PublicKeySignatureData::Impl::nullimpl()
+  {
+    static shared_ptr<Impl> _nullimpl( new Impl );
+    return _nullimpl;
+  }
+
+  zypp::PublicKeySignatureData::Impl *PublicKeySignatureData::Impl::clone() const
+  {
+    return new Impl( *this );
+  }
+
+  ///////////////////////////////////////////////////////////////////
+  /// class PublicKeySignatureData
+  ///////////////////////////////////////////////////////////////////
+
+  PublicKeySignatureData::PublicKeySignatureData()
+    : _pimpl( Impl::nullimpl() )
+  {}
+
+  PublicKeySignatureData::PublicKeySignatureData(const _gpgme_key_sig *rawKeySignatureData)
+    : _pimpl (new Impl)
+  {
+    _pimpl->_keyid = str::asString(rawKeySignatureData->keyid);
+    _pimpl->_name = str::asString(rawKeySignatureData->uid);
+    _pimpl->_created = zypp::Date(rawKeySignatureData->timestamp);
+    _pimpl->_expires = zypp::Date(rawKeySignatureData->expires);
+  }
+
+  PublicKeySignatureData::~PublicKeySignatureData()
+  {}
+
+  PublicKeySignatureData::operator bool() const
+  { return !_pimpl->_keyid.empty(); }
+
+  std::string PublicKeySignatureData::id() const
+  { return _pimpl->_keyid; }
+
+  std::string PublicKeySignatureData::name() const
+  { return _pimpl->_name; }
+
+  Date PublicKeySignatureData::created() const
+  { return _pimpl->_created; }
+
+  Date PublicKeySignatureData::expires() const
+  { return _pimpl->_expires; }
+
+  bool PublicKeySignatureData::expired() const
+  { return isExpired( _pimpl->_expires ); }
+
+  int PublicKeySignatureData::daysToLive() const
+  { return hasDaysToLive( _pimpl->_expires ); }
+
+  std::string PublicKeySignatureData::asString() const
+  {
+    std::string nameStr;
+    if (!name().empty()) {
+      nameStr = str::Str() << name() << " ";
+    }
+    else {
+      nameStr = "[User ID not found] ";
+    }
+    return str::Str() << nameStr
+                      << id() << " "
+                      << created().printDate()
+                      << " [" << expiresDetail( expires() ) << "]";
+  }
+
+  bool PublicKeySignatureData::inTrustedRing() const
+  { return getZYpp()->keyRing()->isKeyTrusted(id()); }
+
+  bool PublicKeySignatureData::inKnownRing() const
+  { return getZYpp()->keyRing()->isKeyKnown(id()); }
+
+  ///////////////////////////////////////////////////////////////////
   /// \class PublicKeyData::Impl
   /// \brief  PublicKeyData implementation.
   ///////////////////////////////////////////////////////////////////
@@ -211,6 +307,7 @@ namespace zypp
     Date        _expires;
 
     std::vector<PublicSubkeyData> _subkeys;
+    std::vector<PublicKeySignatureData> _signatures;
 
   public:
     bool hasSubkeyId( const std::string & id_r ) const;
@@ -246,7 +343,7 @@ namespace zypp
 
   shared_ptr<PublicKeyData::Impl> PublicKeyData::Impl::fromGpgmeKey(gpgme_key_t rawData)
   {
-    //gpgpme stores almost nothing in the top level key
+    //gpgme stores almost nothing in the top level key
     //the information we look for is stored in the subkey, where subkey[0]
     //is always the primary key
     gpgme_subkey_t sKey = rawData->subkeys;
@@ -259,6 +356,10 @@ namespace zypp
         // versions of the same key are imported. We take the last signature here,
         // the one GPGME_EXPORT_MODE_MINIMAL will later use in export.
         for ( auto t = rawData->uids->signatures->next; t; t = t->next ) {
+            if (t->keyid != nullptr) {
+              data->_signatures.push_back(PublicKeySignatureData(t));
+            }
+
           if ( t->timestamp > data->_created )
             data->_created = t->timestamp;
         }
@@ -367,6 +468,9 @@ namespace zypp
   Iterable<PublicKeyData::SubkeyIterator> PublicKeyData::subkeys() const
   { return makeIterable( &(*_pimpl->_subkeys.begin()), &(*_pimpl->_subkeys.end()) ); }
 
+  Iterable<PublicKeyData::KeySignatureIterator> PublicKeyData::signatures() const
+  { return makeIterable( &(*_pimpl->_signatures.begin()), &(*_pimpl->_signatures.end()) ); }
+
   bool PublicKeyData::providesKey( const std::string & id_r ) const
   {
     if ( not isSafeKeyId( id_r ) )
index f9b80cf..1f46a66 100644 (file)
@@ -28,6 +28,7 @@
 
 struct _gpgme_key;
 struct _gpgme_subkey;
+struct _gpgme_key_sig;
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -128,6 +129,72 @@ namespace zypp
   { return str << obj.asString(); }
 
   ///////////////////////////////////////////////////////////////////
+  /// \class PublicKeySignatureData
+  /// \brief Class representing a signature on a GPG Public Key.
+  /// \see \ref PublicKeyData.
+  ///////////////////////////////////////////////////////////////////
+  class PublicKeySignatureData
+  {
+  public:
+    /** Default constructed: empty data. */
+    PublicKeySignatureData();
+
+    ~PublicKeySignatureData();
+
+    /** Whether this contains valid data (not default constructed). */
+    explicit operator bool() const;
+
+  public:
+    /** The key ID of key used to create the signature. */
+    std::string id() const;
+
+    /** The user ID associated with this key, if present. */
+    std::string name() const;
+
+    /** Creation date. */
+    Date created() const;
+
+    /** Expiry date, or \c Date() if the key never expires. */
+    Date expires() const;
+
+    /**  Whether the key has expired. */
+    bool expired() const;
+
+    /** Number of days (24h) until the key expires (or since it expired).
+     * A value of \c 0 means the key will expire within the next 24h.
+     * Negative values indicate the key has expired less than \c N days ago.
+     * For keys without expiration date \c INT_MAX is returned.
+     */
+    int daysToLive() const;
+
+    /** Whether the signature is trusted in rpmdb. */
+    bool inTrustedRing() const;
+
+    /** Whether the key has been seen before. */
+    bool inKnownRing() const;
+
+    /** Simple string representation.
+     * Encodes \ref id, \ref created and \ref expires
+     * \code
+     * 640DB551 2016-04-12 [expires: 2019-04-12]
+     * \endcode
+     */
+    std::string asString() const;
+
+  private:
+    struct Impl;
+    RWCOW_pointer<Impl> _pimpl;
+    friend class PublicKeyData;
+    friend std::ostream & dumpOn( std::ostream & str, const PublicKeyData & obj );
+    PublicKeySignatureData(const _gpgme_key_sig *rawKeySignatureData);
+  };
+  ///////////////////////////////////////////////////////////////////
+
+  /** \relates PublicKeySignatureData Stream output */
+  inline std::ostream & operator<<( std::ostream & str, const PublicKeySignatureData & obj )
+  { return str << obj.asString(); }
+
+  ///////////////////////////////////////////////////////////////////
   /// \class PublicKeyData
   /// \brief Class representing one GPG Public Keys data.
   /// \ref PublicKeyData are provided e.g. by a \ref PublicKey or
@@ -177,7 +244,7 @@ namespace zypp
     int daysToLive() const;
 
     /** * Expiry info in a human readable form.
-     * The exipry daye plus an annotation if the key has expired, or will
+     * The expiry date plus an annotation if the key has expired, or will
      * expire within 90 days.
      * \code
      * (does not expire)
@@ -213,6 +280,7 @@ namespace zypp
 
   public:
     typedef const PublicSubkeyData * SubkeyIterator;
+    typedef const PublicKeySignatureData * KeySignatureIterator;
 
     /** Whether \ref subkeys is not empty. */
     bool hasSubkeys() const;
@@ -220,6 +288,9 @@ namespace zypp
     /** Iterate any subkeys. */
     Iterable<SubkeyIterator> subkeys() const;
 
+    /** Iterate all key signatures. */
+    Iterable<KeySignatureIterator> signatures() const;
+
     /** Whether \a id_r is the \ref id or \ref fingerprint of the primary key or of a subkey.
      * As a convenience also allows to test the 8byte short ID e.g. rpm uses as version.
      */
@@ -232,6 +303,10 @@ namespace zypp
     { return id_r.size() >= 16; }
 
   public:
+    /** Whether \ref signatures is not empty. */
+    bool hasSignatures() const;
+
+  public:
     /** Random art fingerprint visualization type (\ref base::DrunkenBishop). */
     typedef base::DrunkenBishop AsciiArt;
 
index 19f539e..ed8fced 100644 (file)
@@ -460,7 +460,7 @@ namespace zypp {
           currOff++;
           currROff--;
 
-          // a kernel package might be explicitely locked by version
+          // a kernel package might be explicitly locked by version
           // We need to go over all package name provides ( provides is named like the package ) and match
           // them against the specified version to know which ones to keep. (bsc#1176740  bsc#1176192)
           std::for_each( kernelMap.second.begin(), kernelMap.second.end(), [ & ]( sat::Solvable solv ){
@@ -560,7 +560,7 @@ namespace zypp {
 
       editionToSolvableMap[edToUse].push_back( installedKrnlPck );
 
-      //in the first step we collect all packages in this list, then later we will remove the packages we want to explicitely keep
+      //in the first step we collect all packages in this list, then later we will remove the packages we want to explicitly keep
       packagesToRemove.insert( installedKrnlPck );
     };
 
@@ -604,18 +604,18 @@ namespace zypp {
 
       } else {
 
-        // if adapting the groups do not forget to explicitely handle the group when querying the matches
-        const str::regex explicitelyHandled("kernel-syms(-.*)?|kernel(-.*)?-devel");
+        // if adapting the groups do not forget to explicitly handle the group when querying the matches
+        const str::regex explicitlyHandled("kernel-syms(-.*)?|kernel(-.*)?-devel");
 
         MIL << "Not a kernel package, inspecting more closely " << std::endl;
 
         // we directly handle all noarch packages that export multiversion(kernel)
         if ( installedKrnlPck.arch() == Arch_noarch ) {
 
-          MIL << "Handling package explicitely due to architecture (noarch)."<< std::endl;
+          MIL << "Handling package explicitly due to architecture (noarch)."<< std::endl;
           addPackageToMap( GroupInfo::Sources, installedKrnlPck.name(), "", installedKrnlPck );
 
-        } else if ( str::smatch match; str::regex_match( installedKrnlPck.name(), match, explicitelyHandled ) ) {
+        } else if ( str::smatch match; str::regex_match( installedKrnlPck.name(), match, explicitlyHandled ) ) {
 
           // try to get the flavour from the name
           // if we have a kernel-syms getting no flavour means we have the "default" one, otherwise we use the flavour
@@ -632,10 +632,10 @@ namespace zypp {
           else if ( installedKrnlPck.name() == "kernel-syms" )
             flav = "default";
 
-          MIL << "Handling package explicitely due to name match."<< std::endl;
+          MIL << "Handling package explicitly due to name match."<< std::endl;
           addPackageToMap ( GroupInfo::RelatedBinaries, installedKrnlPck.name(), flav, installedKrnlPck );
         } else {
-          MIL << "Package not explicitely handled" << std::endl;
+          MIL << "Package not explicitly handled" << std::endl;
         }
       }
 
index 5083e1a..648e30b 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <zypp/base/Gettext.h>
 #include <zypp/base/LogTools.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 #include <zypp/parser/xml/XmlEscape.h>
 
 #include <zypp/ManagedFile.h>
@@ -30,7 +30,7 @@
 #include <zypp/ExternalProgram.h>
 
 #include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/parser/xml/Reader.h>
 
 
@@ -815,7 +815,7 @@ namespace zypp
     {
       WAR << "License(" << name_r << ") in " << name() << " contains no fallback text!" << endl;
       // Using the fist locale instead of returning no text at all.
-      // So the user might recognize that there is a license, even if he
+      // So the user might recognize that there is a license, even if they
       // can't read it.
       getLang = *avlocales.begin();
     }
index 28e887e..12e4b66 100644 (file)
 
 #include <solv/solvversion.h>
 
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/base/LogTools.h>
 #include <zypp/base/Gettext.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 #include <zypp/base/Function.h>
 #include <zypp/base/Regex.h>
 #include <zypp/PathInfo.h>
@@ -34,8 +34,8 @@
 #include <zypp/RepoManager.h>
 
 #include <zypp/media/MediaManager.h>
-#include <zypp/media/CredentialManager.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/auth/CredentialManager>
+#include <zypp-media/MediaException>
 #include <zypp/MediaSetAccess.h>
 #include <zypp/ExternalProgram.h>
 #include <zypp/ManagedFile.h>
index e048857..8019053 100644 (file)
@@ -27,7 +27,7 @@
 #include <zypp/repo/ServiceType.h>
 #include <zypp/ServiceInfo.h>
 #include <zypp/RepoStatus.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
index f2ee0b9..f262a52 100644 (file)
@@ -344,7 +344,7 @@ namespace zypp
 
     //------------------------------------------------------------------------
     // get/set functions, returnig \c true if requested status change
-    // was successfull (i.e. leading to the desired transaction).
+    // was successful (i.e. leading to the desired transaction).
     // If a lower level (e.g.SOLVER) wants to transact, but it's
     // already set by a higher level, \c true should be returned.
     // Removing a higher levels transaction bit should fail.
index 1a89977..ce47786 100644 (file)
@@ -215,22 +215,22 @@ namespace zypp
      * Default for all flags is \c false unless overwritten by zypp.conf.
      */
     //@{
-    /** Whether to allow to downgrade installed solvable */
+    /** Whether to allow one to downgrade installed solvable */
     void setAllowDowngrade( bool yesno_r );
     void setDefaultAllowDowngrade();   // Set back to default
     bool allowDowngrade() const;
 
-    /** Whether to allow to change name of installed solvable */
+    /** Whether to allow one to change name of installed solvable */
     void setAllowNameChange( bool yesno_r );
     void setDefaultAllowNameChange();  // Set back to default
     bool allowNameChange() const;
 
-    /** Whether to allow to change architecture of installed solvables */
+    /** Whether to allow one to change architecture of installed solvables */
     void setAllowArchChange( bool yesno_r );
     void setDefaultAllowArchChange();  // Set back to default
     bool allowArchChange() const;
 
-    /**  Whether to allow to change vendor of installed solvables
+    /**  Whether to allow one to change vendor of installed solvables
      * \see \ref VendorAttr for definition of vendor equivalence.
      */
     void setAllowVendorChange( bool yesno_r );
@@ -262,7 +262,7 @@ namespace zypp
 
     /**
      * Cleanup when deleting packages. Whether the solver should per default
-     * try to remove packages exclusively required by the ones he's asked to delete.
+     * try to remove packages exclusively required by the ones it's asked to delete.
      */
     void setCleandepsOnRemove( bool yesno_r );
     void setDefaultCleandepsOnRemove(); // set back to default (in zypp.conf)
@@ -273,22 +273,22 @@ namespace zypp
      * all DUP flags is \c true unless overwritten by zypp.conf.
      */
     //@{
-    /** dup mode: allow to downgrade installed solvable */
+    /** dup mode: allow one to downgrade installed solvable */
     void dupSetAllowDowngrade( bool yesno_r );
     void dupSetDefaultAllowDowngrade();                // Set back to default (in zypp.conf)
     bool dupAllowDowngrade() const;
 
-    /** dup mode: allow to change name of installed solvable */
+    /** dup mode: allow one to change name of installed solvable */
     void dupSetAllowNameChange( bool yesno_r );
     void dupSetDefaultAllowNameChange();       // Set back to default (in zypp.conf)
     bool dupAllowNameChange() const;
 
-    /** dup mode: allow to change architecture of installed solvables */
+    /** dup mode: allow one to change architecture of installed solvables */
     void dupSetAllowArchChange( bool yesno_r );
     void dupSetDefaultAllowArchChange();       // Set back to default (in zypp.conf)
     bool dupAllowArchChange() const;
 
-    /**  dup mode: allow to change vendor of installed solvables*/
+    /**  dup mode: allow one to change vendor of installed solvables*/
     void dupSetAllowVendorChange( bool yesno_r );
     void dupSetDefaultAllowVendorChange();     // Set back to default (in zypp.conf)
     bool dupAllowVendorChange() const;
index a98641c..a20e531 100644 (file)
@@ -13,7 +13,7 @@
 #include <iostream>
 
 #include <zypp/base/String.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 #include <zypp/parser/xml/XmlEscape.h>
 
 #include <zypp/RepoInfo.h>
index 6da25b4..07f0305 100644 (file)
@@ -137,7 +137,7 @@ namespace zypp
   public:
     /** \name Base product and registration.
      *
-     * Static methods herein allow to retrieve the values without explicitly
+     * Static methods herein allow one to retrieve the values without explicitly
      * initializing the \ref Target. They take a targets root directory as
      * argument. If an empty \ref Pathname is passed, an already existing
      * Targets root is used, otherwise \c "/" is assumed.
index 5c1a7eb..e3775cc 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <zypp/ZConfig.h>
 #include <zypp/PathInfo.h>
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/parser/IniDict>
 
 #undef  ZYPP_BASE_LOGGER_LOGGROUP
 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::VendorAttr"
index 4343346..5a71be8 100644 (file)
@@ -23,18 +23,20 @@ extern "C"
 #include <fstream>
 #include <zypp/base/LogTools.h>
 #include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/base/String.h>
 #include <zypp/base/Regex.h>
 
 #include <zypp/ZConfig.h>
 #include <zypp/ZYppFactory.h>
 #include <zypp/PathInfo.h>
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/parser/IniDict>
 
 #include <zypp/sat/Pool.h>
 #include <zypp/sat/detail/PoolImpl.h>
 
+#include <zypp-media/MediaConfig>
+
 using std::endl;
 using namespace zypp::filesystem;
 using namespace zypp::parser;
@@ -133,13 +135,19 @@ namespace zypp
           ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
         }
       }
-      else if ( architecture == Arch_armv7l || architecture == Arch_armv6l )
+      else if ( architecture == Arch_armv8l || architecture == Arch_armv7l || architecture == Arch_armv6l )
       {
         std::ifstream platform( "/etc/rpm/platform" );
         if (platform)
         {
           for( iostr::EachLine in( platform ); in; in.next() )
           {
+            if ( str::hasPrefix( *in, "armv8hl-" ) )
+            {
+              architecture = Arch_armv8hl;
+              WAR << "/etc/rpm/platform contains armv8hl-: architecture upgraded to '" << architecture << "'" << endl;
+              break;
+            }
             if ( str::hasPrefix( *in, "armv7hl-" ) )
             {
               architecture = Arch_armv7hl;
@@ -324,11 +332,6 @@ namespace zypp
         , download_use_deltarpm_always  ( false )
         , download_media_prefer_download( true )
         , download_mediaMountdir       ( "/var/adm/mount" )
-        , download_max_concurrent_connections( 5 )
-        , download_min_download_speed  ( 0 )
-        , download_max_download_speed  ( 0 )
-        , download_max_silent_tries    ( 5 )
-        , download_transfer_timeout    ( 180 )
         , commit_downloadMode          ( DownloadDefault )
         , gpgCheck                     ( true )
         , repoGpgCheck                 ( indeterminate )
@@ -362,6 +365,7 @@ namespace zypp
           INT << "Reconfigure to " << _parsedZyppConf << endl;
           ZConfig::instance()._pimpl.reset( this );
         }
+
         if ( PathInfo(_parsedZyppConf).isExist() )
         {
           parser::IniDict dict( _parsedZyppConf );
@@ -377,6 +381,10 @@ namespace zypp
             {
               std::string entry(it->first);
               std::string value(it->second);
+
+              if ( _mediaConf.setConfigValue( section, entry, value ) )
+                continue;
+
               //DBG << (*it).first << "=" << (*it).second << endl;
               if ( section == "main" )
               {
@@ -452,34 +460,10 @@ namespace zypp
                 {
                   download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 );
                 }
-
                 else if ( entry == "download.media_mountdir" )
                 {
                   download_mediaMountdir.restoreToDefault( Pathname(value) );
                 }
-
-                else if ( entry == "download.max_concurrent_connections" )
-                {
-                  str::strtonum(value, download_max_concurrent_connections);
-                }
-                else if ( entry == "download.min_download_speed" )
-                {
-                  str::strtonum(value, download_min_download_speed);
-                }
-                else if ( entry == "download.max_download_speed" )
-                {
-                  str::strtonum(value, download_max_download_speed);
-                }
-                else if ( entry == "download.max_silent_tries" )
-                {
-                  str::strtonum(value, download_max_silent_tries);
-                }
-                else if ( entry == "download.transfer_timeout" )
-                {
-                  str::strtonum(value, download_transfer_timeout);
-                  if ( download_transfer_timeout < 0 )         download_transfer_timeout = 0;
-                  else if ( download_transfer_timeout > 3600 ) download_transfer_timeout = 3600;
-                }
                 else if ( entry == "commit.downloadMode" )
                 {
                   commit_downloadMode.set( deserializeDownloadMode( value ) );
@@ -594,14 +578,6 @@ namespace zypp
                 {
                   history_log_path = Pathname(value);
                 }
-                else if ( entry == "credentials.global.dir" )
-                {
-                  credentials_global_dir_path = Pathname(value);
-                }
-                else if ( entry == "credentials.global.file" )
-                {
-                  credentials_global_file_path = Pathname(value);
-                }
                 else if ( entry == "techpreview.ZYPP_SINGLE_RPMTRANS" )
                 {
                   DBG << "techpreview.ZYPP_SINGLE_RPMTRANS=" << value << endl;
@@ -678,12 +654,6 @@ namespace zypp
     DefaultOption<bool> download_media_prefer_download;
     DefaultOption<Pathname> download_mediaMountdir;
 
-    int download_max_concurrent_connections;
-    int download_min_download_speed;
-    int download_max_download_speed;
-    int download_max_silent_tries;
-    int download_transfer_timeout;
-
     Option<DownloadMode> commit_downloadMode;
 
     DefaultOption<bool>                gpgCheck;
@@ -712,13 +682,14 @@ namespace zypp
     target::rpm::RpmInstFlags rpmInstallFlags;
 
     Pathname history_log_path;
-    Pathname credentials_global_dir_path;
-    Pathname credentials_global_file_path;
 
     std::string userData;
 
     Option<Pathname> pluginsPath;
 
+    /* Other config singleton instances */
+    MediaConfig &_mediaConf = MediaConfig::instance();
+
   private:
     // HACK for bnc#906096: let pool re-evaluate multiversion spec
     // if target root changes. ZConfig returns data sensitive to
@@ -742,10 +713,13 @@ namespace zypp
 
         if ( ! cacheHit )
         {
-          if ( root_r == "/" )
-            ret.swap( _specMap[Pathname()] );          // original zypp.conf
-          else
-            scanConfAt( root_r, ret, zConfImpl_r );    // scan zypp.conf at root_r
+          // bsc#1193488: If no (/root)/.../zypp.conf exists use the default zypp.conf
+          // multiversion settings. It is a legacy that the packaged multiversion setting
+          // in zypp.conf (the kernel) may differ from the builtin default (empty).
+          // But we want a missing config to behave similar to the default one, otherwise
+          // a bare metal install easily runs into trouble.
+          if ( root_r == "/" || scanConfAt( root_r, ret, zConfImpl_r ) == 0 )
+            ret = _specMap[Pathname()];
           scanDirAt( root_r, ret, zConfImpl_r );       // add multiversion.d at root_r
           using zypp::operator<<;
           MIL << "MultiversionSpec '" << root_r << "' = " << ret << endl;
@@ -757,11 +731,11 @@ namespace zypp
       {        return _specMap[Pathname()]; }
 
     private:
-      void scanConfAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
+      int scanConfAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
       {
         static const str::regex rx( "^multiversion *= *(.*)" );
         str::smatch what;
-        iostr::simpleParseFile( InputStream( Pathname::assertprefix( root_r, _autodetectZyppConfPath() ) ),
+        return iostr::simpleParseFile( InputStream( Pathname::assertprefix( root_r, _autodetectZyppConfPath() ) ),
                                 [&]( int num_r, std::string line_r )->bool
                                 {
                                   if ( line_r[0] == 'm' && str::regex_match( line_r, what, rx ) )
@@ -1066,19 +1040,19 @@ namespace zypp
   { _pimpl->download_media_prefer_download.restoreToDefault(); }
 
   long ZConfig::download_max_concurrent_connections() const
-  { return _pimpl->download_max_concurrent_connections; }
+  { return _pimpl->_mediaConf.download_max_concurrent_connections(); }
 
   long ZConfig::download_min_download_speed() const
-  { return _pimpl->download_min_download_speed; }
+  { return _pimpl->_mediaConf.download_min_download_speed(); }
 
   long ZConfig::download_max_download_speed() const
-  { return _pimpl->download_max_download_speed; }
+  { return _pimpl->_mediaConf.download_max_download_speed(); }
 
   long ZConfig::download_max_silent_tries() const
-  { return _pimpl->download_max_silent_tries; }
+  { return _pimpl->_mediaConf.download_max_silent_tries(); }
 
   long ZConfig::download_transfer_timeout() const
-  { return _pimpl->download_transfer_timeout; }
+  { return _pimpl->_mediaConf.download_transfer_timeout(); }
 
   Pathname ZConfig::download_mediaMountdir() const             { return _pimpl->download_mediaMountdir; }
   void ZConfig::set_download_mediaMountdir( Pathname newval_r )        { _pimpl->download_mediaMountdir.set( std::move(newval_r) ); }
@@ -1189,14 +1163,12 @@ namespace zypp
 
   Pathname ZConfig::credentialsGlobalDir() const
   {
-    return ( _pimpl->credentials_global_dir_path.empty() ?
-        Pathname("/etc/zypp/credentials.d") : _pimpl->credentials_global_dir_path );
+    return _pimpl->_mediaConf.credentialsGlobalDir();
   }
 
   Pathname ZConfig::credentialsGlobalFile() const
   {
-    return ( _pimpl->credentials_global_file_path.empty() ?
-        Pathname("/etc/zypp/credentials.cat") : _pimpl->credentials_global_file_path );
+    return _pimpl->_mediaConf.credentialsGlobalFile();
   }
 
   ///////////////////////////////////////////////////////////////////
index 39ee33f..443838d 100644 (file)
@@ -45,6 +45,8 @@ namespace zypp
    *
    * It reads /etc/zypp/zypp.conf, the filename can be overridden by
    * setting the ZYPP_CONF environment variable to a different file.
+   * Config values for \ref MediaConfig are forwarded to the MediaConfig
+   * singleton.
    *
    * Note, if you add settings to this file, please follow the following
    * convention:
index e2ecfc7..b520719 100644 (file)
@@ -21,8 +21,8 @@
 #include <zypp/Package.h>
 #include <zypp/Patch.h>
 #include <zypp/Url.h>
-#include <zypp/ProgressData.h>
-#include <zypp/media/MediaUserAuth.h>
+#include <zypp-core/ui/ProgressData>
+#include <zypp-media/auth/AuthData>
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -176,7 +176,7 @@ namespace zypp
        *
        *  Userdata accepted:
        * \param "Action"       DownloadResolvableReport::Action user advice how to behave on error (ABORT).
-       *                        If you set just an empty value here, a default probelm report will be triggered.
+       *                        If you set just an empty value here, a default problem report will be triggered.
        *
        * Legacy data:
        * \param "Package"      Replaced by \c "ResObject" in 16.10.0. Package::constPtr of the package (\c nullptr in case of a SrcPackage)
@@ -407,7 +407,7 @@ namespace zypp
        *        data. As an input parameter auth_data can be prefilled with
        *        username (from previous try) or auth_type (available
        *        authentication methods aquired from server (only CurlAuthData)).
-       *        As an output parameter it serves for sending username, pasword
+       *        As an output parameter it serves for sending username, password
        *        or other special data (derived AuthData objects).
        * \return true if user chooses to continue with authentication,
        *         false otherwise
@@ -669,6 +669,37 @@ namespace zypp
       };
 #endif
 
+      ///////////////////////////////////////////////////////////////////
+      /// \brief Report active throughout the whole rpm transaction.
+      ///
+      /// The report covers events not directly related to an individual
+      /// sub-task. Mostly log lines.
+      /// \todo maybe include the sub-task reports here as well, so it
+      /// becomes the only report needed to follow the transaction.
+      ///////////////////////////////////////////////////////////////////
+      struct SingleTransReport : public callback::ReportBase
+      {
+        /** \c "zypp-rpm/logline" report a line suitable to be written to the screen.
+         * UserData:
+         * \c "line"  : std::reference_wrapper<const std::string>; the line to show
+         * \c "level" : enum class loglevel; rendering hint
+         */
+        static const UserData::ContentType contentLogline;
+        /** Rendering hint for log-lines to show. */
+        enum class loglevel { dbg, msg, war, err, crt };
+        /** Suggested prefix for log-lines to show. */
+        static const char *const loglevelPrefix( loglevel level_r )
+        {
+          switch ( level_r ) {
+            case loglevel::crt:  return "fatal error: ";
+            case loglevel::err:  return "error: ";
+            case loglevel::war:  return "warning: ";
+            case loglevel::msg:  return "";
+            case loglevel::dbg:  return "D: ";
+          }
+        }
+      };
+
       // Generic transaction reports, this is used for verifying and preparing tasks, the name param
       // for the start function defines which report we are looking at
       struct TransactionReportSA : public callback::ReportBase
@@ -928,7 +959,7 @@ namespace zypp
      * type of conflict of old and new lock
      */
     enum ConflictState{
-      SAME_RESULTS, /**< locks lock same item in pool but his parameters is different */
+      SAME_RESULTS, /**< locks lock same item in pool but its parameters are different */
       INTERSECT /**< locks lock some file and unlocking lock unlock only part
       * of iti, so removing old lock can unlock more items in pool */
     };
@@ -1008,6 +1039,21 @@ namespace zypp
     //@}
   };
 
+  ///////////////////////////////////////////////////////////////////
+  /// \class UserDataJobReport
+  /// \brief \ref JobReport convenience sending this instance of \ref UserData with each message.
+  ///////////////////////////////////////////////////////////////////
+  struct UserDataJobReport : public JobReport::UserData
+  {
+    using JobReport::UserData::UserData;
+
+    bool debug( const std::string & msg_r )     { return JobReport::debug( msg_r, *this ); }
+    bool info( const std::string & msg_r )      { return JobReport::info( msg_r, *this ); }
+    bool warning( const std::string & msg_r )   { return JobReport::warning( msg_r, *this ); }
+    bool error( const std::string & msg_r )     { return JobReport::error( msg_r, *this ); }
+    bool important( const std::string & msg_r ) { return JobReport::important( msg_r, *this ); }
+    bool data( const std::string & msg_r )      { return JobReport::data( msg_r, *this ); }
+  };
 
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
index d66e540..1344d6a 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <zypp/PoolItem.h>
 #include <zypp/sat/Transaction.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
index e587845..a457e89 100644 (file)
@@ -21,7 +21,7 @@
 #include <zypp/base/Logger.h>
 #include <zypp/base/String.h>
 #include <zypp/ExternalProgram.h>
-#include <zypp/base/ProvideNumericId.h>
+#include <zypp-core/base/ProvideNumericId>
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
index a93c4e7..91edf2d 100644 (file)
@@ -1,104 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/base/DefaultIntegral.h
- *
-*/
-#ifndef ZYPP_BASE_DEFAULTINTEGRAL_H
-#define ZYPP_BASE_DEFAULTINTEGRAL_H
-
-#include <iosfwd>
-#include <boost/static_assert.hpp>
-#include <boost/type_traits/is_integral.hpp>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //  CLASS NAME : DefaultIntegral<Tp,TInitial>
-  //
-  /** Integral type with defined initial value when default constructed.
-   *
-   * \code
-   * typedef DefaultIntegral<unsigned,0> Counter;
-   * std::map<KeyType,Counter> stats;
-   * for ( all keys  )
-   *   ++(stats[key]);
-   * \endcode
-   *
-   * \todo maybe specialize for bool, add logical and bit operators
-   * \todo let TInitial default to 0 then remove base/Counter.h
-  */
-  template<class Tp, Tp TInitial>
-    class DefaultIntegral
-    {
-    public:
-      typedef Tp value_type;
-
-    public:
-      DefaultIntegral( Tp val_r = TInitial )
-      : _val( val_r )
-      { BOOST_STATIC_ASSERT(boost::is_integral<Tp>::value); }
-
-      /** Conversion to Tp. */
-      //@{
-      Tp & get()       { return _val; }
-      Tp   get() const { return _val; }
-
-      operator Tp &()       { return get(); }
-      operator Tp  () const { return get(); }
-      //@}
-
-      /** The initial value. */
-      constexpr Tp initial() const { return TInitial; }
-
-      /** Reset to the defined initial value. */
-      DefaultIntegral & reset()        { _val = TInitial; return *this; }
-
-      /** \name Arithmetic operations.
-       * \c + \c - \c * \c / are provided via conversion to Tp.
-      */
-      //@{
-      DefaultIntegral & operator=( Tp rhs )  {  _val = rhs; return *this; }
-      DefaultIntegral & operator+=( Tp rhs ) { _val += rhs; return *this; }
-      DefaultIntegral & operator-=( Tp rhs ) { _val -= rhs; return *this; }
-      DefaultIntegral & operator*=( Tp rhs ) { _val *= rhs; return *this; }
-      DefaultIntegral & operator/=( Tp rhs ) { _val /= rhs; return *this; }
-
-      DefaultIntegral & operator++(/*prefix*/) { ++_val; return *this; }
-      DefaultIntegral & operator--(/*prefix*/) { --_val; return *this; }
-
-      DefaultIntegral operator++(int/*postfix*/) { return _val++; }
-      DefaultIntegral operator--(int/*postfix*/) { return _val--; }
-      //@}
-
-    private:
-      Tp _val;
-    };
-
-    /** \relates DefaultIntegral \c true initialized \c bool  */
-    typedef DefaultIntegral<bool,true>  TrueBool;
-
-    /** \relates DefaultIntegral \c false initialized \c bool */
-    typedef DefaultIntegral<bool,false> FalseBool;
-
-    /** \relates DefaultIntegral \c zero initialized \c integral */
-    template<typename TIntegral>
-    using ZeroInit = DefaultIntegral<TIntegral,TIntegral(0)>;
-
-    template<class Tp, Tp TInitial>
-    std::string asString( const DefaultIntegral<Tp,TInitial> & obj )
-    { return asString( obj.get() ); }
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_DEFAULTINTEGRAL_H
+#include <zypp-core/base/DefaultIntegral>
index 90798b5..0ba69d8 100644 (file)
@@ -1,85 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/base/DtorReset.h
- *
-*/
-#ifndef ZYPP_BASE_DTORRESET_H
-#define ZYPP_BASE_DTORRESET_H
-
-#include <zypp/base/PtrTypes.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : DtorReset
-  //
-  /** Assign a vaiable a certain value when going out of scope.
-   * Use it e.g. to reset/cleanup in presence of exceptions.
-   * \code
-   * struct Foo
-   * {
-   *   void consume()
-   *   {
-   *     DtorReset x(_inConsume,false);
-   *     _inConsume = true;
-   *     MIL << _inConsume << endl;
-   *   };
-   *
-   *   DefaultIntegral<bool,false> _inConsume;
-   * };
-   *
-   * Foo f;
-   * MIL << f._inConsume << endl; // 0
-   * f.consume();                 // 1
-   * MIL << f._inConsume << endl; // 0
-   * \endcode
-   * \ingroup g_RAII
-   * \todo Check if using call_traits enables 'DtorReset(std::string,"value")',
-   * as this currently would require assignment of 'char[]'.
-   */
-  class DtorReset
-  {
-  public:
-    DtorReset() {}
-
-    template<class TVar>
-      DtorReset( TVar & var_r )
-      : _pimpl( new Impl<TVar,TVar>( var_r, var_r ) )
-      {}
-    template<class TVar, class TVal>
-      DtorReset( TVar & var_r, const TVal & val_r )
-      : _pimpl( new Impl<TVar,TVal>( var_r, val_r ) )
-      {}
-
-  private:
-    /** Requires TVal being copy constructible, and assignment
-     * <tt>TVar = TVal</tt> defined. */
-    template<class TVar, class TVal>
-      struct Impl
-      {
-        Impl( TVar & var_r, const TVal & val_r )
-        : _var( var_r )
-        , _val( val_r )
-        {}
-        ~Impl()
-        { _var = _val; }
-        TVar & _var;
-        TVal   _val;
-      };
-    shared_ptr<void> _pimpl;
-  };
-  ///////////////////////////////////////////////////////////////////
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_DTORRESET_H
+#include <zypp-core/base/DtorReset>
index f4aa59a..0dd438a 100644 (file)
@@ -1,168 +1 @@
-/*---------------------------------------------------------------------\
-|                                                                      |
-|                      __   __    ____ _____ ____                      |
-|                      \ \ / /_ _/ ___|_   _|___ \                     |
-|                       \ V / _` \___ \ | |   __) |                    |
-|                        | | (_| |___) || |  / __/                     |
-|                        |_|\__,_|____/ |_| |_____|                    |
-|                                                                      |
-|                               core system                            |
-|                                         (C) SuSE Linux Products GmbH |
-\----------------------------------------------------------------------/
-
-  File:       GzStream.h
-
-  Author:     Michael Andres <ma@suse.de>
-  Maintainer: Michael Andres <ma@suse.de>
-
-  Purpose: Streams reading and writing gzip files.
-
-/-*/
-#ifndef ZYPP_BASE_GZSTREAM_H
-#define ZYPP_BASE_GZSTREAM_H
-
-#include <iosfwd>
-#include <streambuf>
-#include <vector>
-#include <zlib.h>
-
-#include <zypp/base/SimpleStreambuf.h>
-#include <zypp/base/fXstream.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  namespace gzstream_detail
-  { /////////////////////////////////////////////////////////////////
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : ZlibError
-    /**
-     * @short Helper class to ship zlib errors.
-     **/
-    struct ZlibError
-    {
-      /**
-       * The zlib error code
-       **/
-      int _zError;
-
-      /**
-       * errno, valid if zError is Z_ERRNO
-       **/
-      int _errno;
-
-      ZlibError()
-      : _zError( 0 ), _errno( 0 )
-      {}
-
-      /**
-       * Return string describing the zlib error code
-       **/
-      std::string
-      strerror() const;
-    };
-    ///////////////////////////////////////////////////////////////////
-
-    /** \relates ZlibError Stream output. */
-    inline std::ostream & operator<<( std::ostream & str, const ZlibError & obj )
-    { return str << obj.strerror(); }
-
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : gzstreambufimpl
-    /**
-     * @short Streambuffer reading or writing gzip files.
-     *
-     * Read and write mode are mutual exclusive. Seek is supported,
-     * but zlib restrictions appy (only forward seek in write mode;
-     * backward seek in read mode might be expensive).Putback is not
-     * supported.
-     *
-     * Reading plain (no gziped) files is possible as well.
-     *
-     * This streambuf is used in @ref ifgzstream and  @ref ofgzstream.
-     **/
-    class gzstreambufimpl {
-    public:
-
-      using error_type = ZlibError;
-
-      ~gzstreambufimpl()
-      { closeImpl(); }
-
-      bool
-      isOpen   () const
-      { return _file; }
-
-      bool
-      canRead  () const
-      { return( _mode == std::ios_base::in ); }
-
-      bool
-      canWrite () const
-      { return( _mode == std::ios_base::out ); }
-
-      bool
-      canSeek  ( std::ios_base::seekdir way_r ) const
-      { return ( way_r == std::ios_base::beg || way_r == std::ios_base::cur ); }
-
-    protected:
-      bool openImpl( const char * name_r, std::ios_base::openmode mode_r );
-      bool closeImpl ();
-
-      //! Tell the file position in the compressed file.
-      //! Analogous to tell(2), complementary to gztell.
-      off_t compressed_tell() const;
-
-    public:
-      /**
-         * The last error returned fron zlib.
-         **/
-      error_type
-      error() const
-      { return _error; }
-
-      std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r  );
-      bool writeData( const char * buffer_r, std::streamsize count_r );
-      off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r );
-      off_t tell() const;
-
-    private:
-
-      void
-      setZError() const
-      { gzerror( _file, &_error._zError ); }
-
-      //! file descriptor of the compressed file
-      int                       _fd = -1;
-
-      gzFile                   _file = nullptr;
-
-      std::ios_base::openmode  _mode = std::ios_base::openmode(0);
-
-      mutable ZlibError        _error;
-
-    };
-    using fgzstreambuf = detail::SimpleStreamBuf<gzstreambufimpl>;
-  } // namespace gzstream_detail
-
-  /**
-   * istream reading gzip files as well as plain files.
-   **/
-  typedef detail::fXstream<std::istream,gzstream_detail::fgzstreambuf> ifgzstream;
-
-  /**
-   * ostream writing gzip files.
-   **/
-  typedef detail::fXstream<std::ostream,gzstream_detail::fgzstreambuf> ofgzstream;
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
-#endif // ZYPP_BASE_GZSTREAM_H
+#include <zypp-core/base/GzStream>
index b9a0f91..d00e841 100644 (file)
@@ -1,144 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/base/InputStream.h
- *
-*/
-#ifndef ZYPP_BASE_INPUTSTREAM_H
-#define ZYPP_BASE_INPUTSTREAM_H
-
-#include <iosfwd>
-
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/DefaultIntegral.h>
-#include <zypp/Pathname.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : InputStream
-  //
-  /** Helper to create and pass std::istream.
-   * The provided std::istream may either be std::cin,
-   * sone (gziped) file or an aleady existig \c std::istream.
-   *
-   * An optional \c name arument may be passed to the ctor,
-   * to identify the stream in log messages, even if it is
-   * not a file.
-   *
-   * Per default the name is "STDIN", the path to an input file
-   * or empty.
-   *
-   * \code
-   * void parse( const InputStream & input = InputStream() )
-   * {
-   *   // process input.stream() and refer to input.name()
-   *   // in log messages.
-   * }
-   *
-   * parse();                  // std::cin
-   * parse( "/some/file" );    // file
-   * parse( "/some/file.gz" ); // gziped file
-   * std::istream & mystream;
-   * parse( mystream );        // some existing stream
-   * parse( InputStream( mystream,
-   *                     "my stream's name" ) );
-   * \endcode
-  */
-  class InputStream
-  {
-  public:
-    /** Default ctor providing \c std::cin. */
-    InputStream();
-
-    /** Ctor providing an aleady existig \c std::istream. */
-    InputStream( std::istream & stream_r,
-                 const std::string & name_r = std::string() );
-
-    /** Ctor for reading a (gziped) file. */
-    InputStream( const Pathname & file_r );
-
-    /** Ctor for reading a (gziped) file. */
-    InputStream( const Pathname & file_r,
-                 const std::string & name_r );
-
-    /** Ctor for reading a (gziped) file. */
-    InputStream( const std::string & file_r );
-
-    /** Ctor for reading a (gziped) file. */
-    InputStream( const std::string & file_r,
-                 const std::string & name_r );
-
-    /** Ctor for reading a (gziped) file. */
-    InputStream( const char * file_r );
-
-    /** Ctor for reading a (gziped) file. */
-    InputStream( const char * file_r,
-                 const std::string & name_r );
-
-    /** Dtor. */
-    ~InputStream();
-
-    /** The std::istream.
-     * \note The provided std::istream is never \c const.
-    */
-    std::istream & stream() const
-    { return *_stream; }
-
-    /** Allow implicit conversion to std::istream.*/
-    operator std::istream &() const
-    { return *_stream; }
-
-    /** Name of the std::istream.
-     * Per default this is "STDIN", the path to an input file or
-     * empty. A custom string may be provided to the ctor.
-     *
-     * This may be used in log messages to identify the stream even
-     * even if it is not a file.
-    */
-    const std::string & name() const
-    { return _name; }
-
-    /** Path to the input file or empty if no file. */
-    const Pathname & path() const
-    { return _path; }
-
-    /** Size of the input stream (informal).
-     * If constructed from an uncompressed file, the file size.
-     * Otherwise \c -1. See \ref setSize;
-    */
-    std::streamoff size() const
-    { return _size; }
-
-    /** Set the size of the input stream.
-     * You may set it to whatever vaule is appropriate. E.g.
-     * <tt>*=10</tt> to compensate gzip comression. or the
-     * number of items, lines, ... The value is not used here,
-     * just provided.
-    */
-    void setSize( std::streamoff val_r )
-    { _size = val_r; }
-
-  private:
-    Pathname                 _path;
-    shared_ptr<std::istream> _stream;
-    std::string              _name;
-    DefaultIntegral<std::streamoff,-1> _size;
-  };
-  ///////////////////////////////////////////////////////////////////
-
-  /** \relates InputStream Stream output */
-  std::ostream & operator<<( std::ostream & str, const InputStream & obj );
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_INPUTSTREAM_H
+#include <zypp-core/base/InputStream>
index 482e5e8..87314ea 100644 (file)
@@ -1,100 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/base/ProvideNumericId.h
- *
-*/
-#ifndef ZYPP_BASE_PROVIDENUMERICID_H
-#define ZYPP_BASE_PROVIDENUMERICID_H
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////
-  namespace base
-  { /////////////////////////////////////////////////////////////////
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : ProvideNumericId
-    //
-    /** Base class for objects providing a numeric Id.
-     * The ctor creates a NumericId from some static counter.
-     *
-     * The only assertion is that \c 0 is not used as an Id,
-     * \b unless the derived class explicitly requests this by
-     * using \ref ProvideNumericId( const void *const ).
-     *
-     * Why should you want to use \c 0 as an Id? E.g if your class
-     * provides some (singleton) No-object. Might be desirable to
-     * make the No-object have No-Id.
-     *
-     * \code
-     * struct Foo : public base::ProvideNumericId<Foo,unsigned>
-     * {};
-     * Foo foo;
-     * foo.numericId(); // returns foo's NumericId.
-     * \endcode
-    */
-    template<class TDerived, class TNumericIdType>
-      struct ProvideNumericId
-      {
-      public:
-        /** \return The objects numeric Id. */
-        TNumericIdType numericId() const
-        { return _numericId; }
-
-      protected:
-        /** Default ctor */
-        ProvideNumericId()
-        : _numericId( nextId() )
-        {}
-        /** Copy ctor */
-        ProvideNumericId( const ProvideNumericId & /*rhs*/ )
-        : _numericId( nextId() )
-        {}
-        /** Assign */
-        ProvideNumericId & operator=( const ProvideNumericId & /*rhs*/ )
-        { return *this; }
-        /** Move ctor */
-        ProvideNumericId( ProvideNumericId && rhs )
-        : _numericId( rhs._numericId )
-        { /*rhs._numericId = 0;*/ }
-        /** Move Assign */
-        ProvideNumericId & operator=( ProvideNumericId && rhs )
-        { if ( &rhs != this ) { _numericId = rhs._numericId; /*rhs._numericId = 0;*/ } return *this; }
-        /** Dtor */
-        ~ProvideNumericId()
-        {}
-      protected:
-        /** No-Id ctor (0).
-         * Explicitly request Id \c 0. Use it with care!
-        */
-        ProvideNumericId( const void *const )
-        : _numericId( 0 )
-        {}
-      private:
-        /** Provide the next Id to use. */
-        static TNumericIdType nextId()
-        {
-          static TNumericIdType _staticCounter = 0;
-          // Assert not returning 0
-          return ++_staticCounter;
-        }
-        /**  */
-        const TNumericIdType _numericId;
-      };
-    ///////////////////////////////////////////////////////////////////
-
-    /////////////////////////////////////////////////////////////////
-  } // namespace base
-  ///////////////////////////////////////////////////////////////////
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_PROVIDENUMERICID_H
+#include <zypp-core/base/ProvideNumericId>
index e88acb3..fbe9c09 100644 (file)
@@ -1,217 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/SimpleStreambuf.h
- *
-*/
-#ifndef ZYPP_BASE_SIMPLESTREAMBUF_H_DEFINED
-#define ZYPP_BASE_SIMPLESTREAMBUF_H_DEFINED
-
-#include <streambuf>
-#include <vector>
-
-namespace zypp {
-  namespace detail {
-
-    /*!
-     * Implementation of a std::streambuf that is using a std::vector<char> as buffer,
-     * relies on a Impl class that must implement the basic i/o functionality:
-     *
-     * \code
-     *  class streambufimpl {
-     *    public:
-     *      using error_type = my_error_type;
-     *
-     *      ~streambufimpl();
-     *
-     *      bool isOpen   () const; // returns true if the file is currently open
-     *      bool canRead  () const; // returns true if in read mode
-     *      bool canWrite () const; // returns true if in write mode
-     *      bool canSeek  ( std::ios_base::seekdir way_r ) const; // returns true if the backend can seek in the given way
-     *
-     *      std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r  ); // reads data from the file and returns it in buffer_r
-     *      bool writeData( const char * buffer_r, std::streamsize count_r ); // writes data ( if in write mode ) to file from buffer
-     *      off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r ); // seeks in file if supported
-     *      off_t tell() const; // returns the current FP
-     *
-     *      error_type error() const; // returns the last error that happend in backend
-     *
-     *    protected:
-     *      bool openImpl( const char * name_r, std::ios_base::openmode mode_r ); // backend implementation of opening the file
-     *      bool closeImpl ();  // closes the file
-     *  };
-     *  using FullStreamBuf = detail::SimpleStreamBuf<streambufimpl>;
-     * \endcode
-     *
-     * \note Currently only supports reading or writing at the same time, but can be extended to support both
-     */
-    template<typename Impl>
-    class SimpleStreamBuf : public std::streambuf, public Impl
-    {
-
-      public:
-
-      SimpleStreamBuf( size_t bufsize_r = 512) : _buffer( bufsize_r ) { }
-      virtual ~SimpleStreamBuf() { close(); }
-
-      SimpleStreamBuf * open( const char * name_r, std::ios_base::openmode mode_r = std::ios_base::in ) {
-
-          if ( !this->openImpl( name_r, mode_r ) )
-            return nullptr;
-
-          if ( this->canRead() ) {
-            setp( NULL, NULL );
-            setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
-          } else {
-            setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) );
-            setg( NULL, NULL, NULL );
-          }
-
-          return this;
-        }
-
-        SimpleStreamBuf * close() {
-
-          if ( !this->isOpen() )
-            return nullptr;
-
-          if ( this->canWrite() )
-            sync();
-
-          if ( !this->closeImpl() )
-            return nullptr;
-
-          return this;
-        }
-
-      protected:
-
-        virtual int sync() {
-          int ret = 0;
-          if ( pbase() < pptr() ) {
-            const int_type res = overflow();
-            if ( traits_type::eq_int_type( res, traits_type::eof() ) )
-              ret = -1;
-          }
-          return ret;
-        }
-
-        virtual int_type overflow( int_type c = traits_type::eof() ) {
-          int_type ret = traits_type::eof();
-          if ( this->canWrite() ) {
-            if ( ! traits_type::eq_int_type( c, traits_type::eof() ) )
-            {
-              *pptr() = traits_type::to_char_type( c );
-              pbump(1);
-            }
-            if ( pbase() <= pptr() )
-            {
-              if ( this->writeData( pbase(), pptr() - pbase() ) )
-              {
-                setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) );
-                ret = traits_type::not_eof( c );
-              }
-              // else: error writing the file
-            }
-          }
-          return ret;
-        }
-
-        virtual int_type underflow() {
-          int_type ret = traits_type::eof();
-          if ( this->canRead() )
-          {
-            if ( gptr() < egptr() )
-              return traits_type::to_int_type( *gptr() );
-
-            const std::streamsize got = this->readData( &(_buffer[0]), _buffer.size() );
-            if ( got > 0 )
-            {
-              setg( &(_buffer[0]), &(_buffer[0]), &(_buffer.data()[got]) );
-              ret = traits_type::to_int_type( *gptr() );
-            }
-            else if ( got == 0 )
-            {
-              // EOF
-              setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
-            }
-            // else: error reading the file
-          }
-          return ret;
-        }
-
-        virtual pos_type seekpos( pos_type pos_r, std::ios_base::openmode openMode ) {
-          return seekoff( off_type(pos_r), std::ios_base::beg, openMode );
-        }
-
-
-        virtual pos_type seekoff( off_type off_r, std::ios_base::seekdir way_r, std::ios_base::openmode openMode ) {
-          pos_type ret = pos_type(off_type(-1));
-          if ( !this->canSeek( way_r) )
-            return ret;
-
-          if ( this->isOpen() ) {
-            if ( openMode == std::ios_base::out ) {
-              //write the buffer out and invalidate it , no need to keep it around
-              if ( !this->canWrite() || sync() != 0 )
-                return ret;
-
-              ret = this->seekTo( off_r, way_r, openMode );
-
-            } else if ( openMode == std::ios_base::in ) {
-              if ( !this->canRead() )
-                return ret;
-
-              //current physical FP, should point to end of buffer
-              const off_type buffEndOff = this->tell();
-
-              if ( buffEndOff != off_type(-1) ) {
-                if ( way_r == std::ios_base::end ) {
-                  setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
-                  ret = this->seekTo( off_r, way_r, openMode );
-                }
-
-                const off_type bufLen    = egptr() - eback();
-                const off_type bufStartFileOff  = buffEndOff - bufLen;
-                const off_type currPtrFileOffset = buffEndOff - ( egptr() - gptr() );
-                off_type newFOff = off_r;
-
-                // Transform into ios_base::beg and seek.
-                if ( way_r == std::ios_base::cur ) {
-                  newFOff += currPtrFileOffset;
-                  way_r = std::ios_base::beg;
-                }
-
-                //check if a seek would go out of the buffers boundaries
-                if ( way_r == std::ios_base::beg ) {
-                  if ( bufStartFileOff <= newFOff && newFOff <= buffEndOff ) {
-                    // Still inside buffer, adjust gptr and
-                    // calculate new position.
-                    setg( eback(),
-                      eback() + ( newFOff - bufStartFileOff ),
-                      egptr() );
-                    ret = pos_type( newFOff );
-                  } else {
-                    // Invalidate buffer and seek.
-                    setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) );
-                    ret = this->seekTo( off_r, way_r, openMode );
-                  }
-                }
-              }
-            }
-          }
-          return ret;
-        }
-
-      private:
-        typedef std::vector<char> buffer_type;
-        buffer_type              _buffer;
-    };
-  }
-}
-#endif
+#include <zypp-core/base/SimpleStreambuf>
index e10df58..c16b25b 100644 (file)
@@ -1,72 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/base/Sysconfig.h
- *
-*/
-#ifndef ZYPP_BASE_SYSCONFIG_H
-#define ZYPP_BASE_SYSCONFIG_H
-
-#include <string>
-#include <map>
-#include <zypp/Pathname.h>
-
-namespace zypp {
-  namespace base {
-    namespace sysconfig {
-
-      /** Read sysconfig file \a path_r and return <tt>(key,valye)</tt> pairs. */
-      std::map<std::string,std::string> read( const Pathname & _path );
-
-      /** Add or change a value in sysconfig file \a path_r.
-       *
-       * If \a key_r already exists, only the \a val_r is changed accordingly.
-       *
-       * In case \a key_r is not yet present in the file, a new entry may be created
-       * at the end of the file, using the lines in \a newcomment_r as comment
-       * block. If \a newcomment_r is not provided or empty, a new value is not
-       * created and \c false is returned.
-       *
-       * \returns \c TRUE if an entry was changed or created.
-       *
-       * \throws Exception if \a path_r can not be read or written.
-       *
-       * \note \a val_r is written as it is. The caller is responsible for escaping and
-       * enclosing in '"', in case this is needed (\see \ref writeStringVal and \ref str::escape).
-       *
-       * \note Lines in \a newcomment_r which do not already start with a '#',
-       * are prefixes with "# ".
-       *
-       * \code
-       *  ## Type: string
-       *  ## Default: ""
-       *  #
-       *  # A multiline description of
-       *  # the options purpose.
-       *  #
-       *  KEY="value"
-       * \endcode
-       */
-      bool write( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
-                  const std::string & newcomment_r = std::string() );
-
-      /** Convenience to add or change a string-value in sysconfig file \a path_r.
-       *
-       * \a val_r is expected to be a plain string value, so it is propery escaped and enclosed in
-       * double quotes before it is written to the sysconfig file \a path_r.
-       *
-       * \see \ref write
-       */
-      bool writeStringVal( const Pathname & path_r, const std::string & key_r, const std::string & val_r,
-                           const std::string & newcomment_r = std::string() );
-
-    } // namespace sysconfig
-  } // namespace base
-} // namespace zypp
-
-#endif // ZYPP_BASE_SYSCONFIG_H
+#include <zypp-core/parser/Sysconfig>
index 3eddb26..613729c 100644 (file)
@@ -1,107 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/base/UserRequestException.h
- *
-*/
-#ifndef ZYPP_BASE_USERREQUESTEXCEPTION_H
-#define ZYPP_BASE_USERREQUESTEXCEPTION_H
-
-#include <iosfwd>
-
-#include <zypp/base/Exception.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : UserRequestException
-  //
-  /** Base for exceptions caused by explicit user request.
-   *
-   * Use the derived convenience classes to throw exceptions
-   * of a certain kind.
-   * \code
-   *     ProgressData ticks( makeProgressData( input_r ) );
-   *     ticks.sendTo( fnc_r );
-   *     ticks.toMin(); // start sending min (0)
-   *
-   *     iostr::EachLine line( input_r );
-   *     for( ; line; line.next() )
-   *     {
-   *       // process the line
-   *
-   *       if ( ! ticks.set( input_r.stream().tellg() ) )
-   *         ZYPP_THROW( AbortRequestException( "" ) );
-   *     }
-   * \endcode
-   * \code
-   * // either this way
-   * catch ( const AbortRequestException & excpt_r )
-   * {
-   *   ...
-   * }
-   *
-   * // or that
-   * catch ( const UserRequestException & excpt_r )
-   * {
-   *   switch ( excpt_r.kind() )
-   *   {
-   *     case UserRequestException::ABORT:
-   *       ...
-   *       break;
-   *   }
-   * }
-   * \endcode
-  */
-  class UserRequestException : public Exception
-  {
-    public:
-      enum Kind { UNSPECIFIED, IGNORE, SKIP, RETRY, ABORT };
-    public:
-      explicit
-      UserRequestException( const std::string & msg_r = std::string() );
-      UserRequestException( const std::string & msg_r, const Exception & history_r );
-      explicit
-      UserRequestException( Kind kind_r, const std::string & msg_r = std::string() );
-      UserRequestException( Kind kind_r, const std::string & msg_r, const Exception & history_r );
-    public:
-      Kind kind() const
-      { return _kind; }
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      Kind _kind;
-  };
-  ///////////////////////////////////////////////////////////////////
-
-  /** Convenience macro to declare more specific PluginScriptExceptions. */
-#define declException( EXCP, KIND )                                    \
-  struct EXCP : public UserRequestException {                          \
-    explicit                                                           \
-    EXCP( const std::string & msg_r = std::string() )                  \
-      : UserRequestException( KIND, msg_r )                            \
-    {}                                                                 \
-    EXCP( const std::string & msg_r, const Exception & history_r )     \
-      : UserRequestException( KIND, msg_r, history_r )                 \
-    {}                                                                 \
-  }
-
-  declException( IgnoreRequestException, IGNORE );
-  declException( SkipRequestException, SKIP );
-  declException( RetryRequestException, RETRY );
-  declException( AbortRequestException, ABORT );
-
-#undef declException
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_USERREQUESTEXCEPTION_H
+#include <zypp-core/base/UserRequestException>
index 815d8bd..663b71d 100644 (file)
@@ -1,102 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/base/WatchFile.h
- *
-*/
-#ifndef ZYPP_BASE_WATCHFILE_H
-#define ZYPP_BASE_WATCHFILE_H
-
-#include <iosfwd>
-
-#include <zypp/PathInfo.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-  ///////////////////////////////////////////////////////////////////
-  //
-  //   CLASS NAME : WatchFile
-  //
-  /** Remember a files attributes to detect content changes.
-   *
-   * Repeatedly call \ref hasChanged to check whether the content has
-   * changed since the last call. Creation or deletion of the file will
-   * be reported as change as well.
-   *
-   * Per default the ctor stats the file, so \ref hasChanged will detect
-   * changes done after \ref WatchFile was created.
-   *
-   * You may omit the initial stat by passing \c NO_INIT as second argument
-   * to the ctor. \ref WatchFile  will behave as if the file did not exist
-   * at the time \ref WatchFile was created.
-   *
-   * \code
-   * static WatchFile sysconfigFile( "/etc/sysconfig/SuSEfirewall2",
-   *                                 WatchFile::NO_INIT );
-   * if ( sysconfigFile.hasChanged() )
-   * {
-   *   // reload the file...
-   * }
-   * \endcode
-  */
-  class WatchFile
-  {
-    public:
-      enum Initial { NO_INIT, INIT };
-
-    public:
-      /** */
-      WatchFile( const Pathname & path_r = Pathname(),
-                 Initial mode            = INIT )
-      : _path( path_r )
-      {
-        PathInfo pi( mode == INIT ? path_r : Pathname() );
-        _size  = pi.size();
-        _mtime = pi.mtime();
-      }
-
-      const Pathname & path() const
-      { return _path; }
-
-      off_t  lastSize() const
-      { return _size;}
-
-      time_t lastMtime() const
-      { return _mtime; }
-
-      bool isDirty() const
-      {
-        PathInfo pi( _path );
-        return( _size != pi.size() || _mtime != pi.mtime() );
-      }
-
-      bool hasChanged()
-      {
-        PathInfo pi( _path );
-        if ( _size != pi.size() || _mtime != pi.mtime() )
-        {
-          _size = pi.size();
-          _mtime = pi.mtime();
-          return true;
-        }
-        return false;
-      }
-
-    private:
-      Pathname _path;
-      off_t  _size;
-      time_t _mtime;
-  };
-  ///////////////////////////////////////////////////////////////////
-
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_BASE_WATCHFILE_H
+#include <zypp-core/fs/WatchFile>
index 79890ed..8ee7800 100644 (file)
@@ -1,77 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-#ifndef ZYPP_BASE_ZCKSTREAM_H
-#define ZYPP_BASE_ZCKSTREAM_H
-
-#include <iosfwd>
-#include <streambuf>
-#include <vector>
-#include <zypp/base/SimpleStreambuf.h>
-#include <zypp/base/fXstream.h>
-
-typedef struct zckCtx zckCtx;
-
-namespace zypp {
-
-  namespace detail {
-
-    /**
-     * @short Streambuffer reading or writing zchunk files.
-     *
-     * Read and write mode are mutual exclusive. Seek is not supported.
-     *
-     * This streambuf is used in @ref ifzckstream and  @ref ofzckstream.
-     **/
-    class zckstreambufimpl {
-      public:
-
-        using error_type = std::string;
-
-        ~zckstreambufimpl();
-
-        bool isOpen   () const;
-        bool canRead  () const;
-        bool canWrite () const;
-        bool canSeek  ( std::ios_base::seekdir way_r ) const;
-
-        std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r  );
-        bool writeData( const char * buffer_r, std::streamsize count_r );
-        off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r );
-        off_t tell() const;
-
-        error_type error() const { return _lastErr; }
-
-      protected:
-        bool openImpl( const char * name_r, std::ios_base::openmode mode_r );
-        bool closeImpl ();
-
-      private:
-        void setError ();
-        int _fd = -1;
-        bool _isReading = false;
-        zckCtx *_zContext = nullptr;
-        off_t _currfp = 0;
-        error_type _lastErr;
-
-    };
-    using ZChunkStreamBuf = detail::SimpleStreamBuf<detail::zckstreambufimpl>;
-  }
-
-  /**
-   * istream reading zchunk files.
-   **/
-  using ifzckstream = detail::fXstream<std::istream,detail::ZChunkStreamBuf>;
-
-  /**
-   * ostream writing zchunk files.
-   **/
-  using ofzckstream = detail::fXstream<std::ostream,detail::ZChunkStreamBuf>;
-}
-
-#endif
+#include <zypp-core/base/ZckStream>
index ec42346..d0caaee 100644 (file)
@@ -1,96 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-#ifndef ZYPP_BASE_FXSTREAM_H
-#define ZYPP_BASE_FXSTREAM_H
-
-#include <iosfwd>
-#include <iostream>
-
-namespace zypp {
-  namespace detail {
-    /**
-     * @short Common template to define ifgzstream/ofgzstream
-     * reading/writing compressed files.
-     *
-     * Don't use fXstream directly, but @ref ifgzstream or
-     * @ref ofgzstream. fXstream is just to avoid almost
-     * duplicate code.
-     **/
-    template<class TBStream,class TStreamBuf>
-    class fXstream : public TBStream
-    {
-    public:
-
-      using ZlibError = typename TStreamBuf::error_type;
-      using stream_type = TBStream;
-      using streambuf_type = TStreamBuf;
-
-      fXstream()
-        : stream_type( nullptr )
-      { this->init( &_streambuf ); }
-
-      explicit
-        fXstream( const char * file_r )
-        : stream_type( nullptr )
-      { this->init( &_streambuf ); this->open( file_r ); }
-
-      virtual
-        ~fXstream()
-      {}
-
-      bool
-      is_open() const
-      { return _streambuf.isOpen(); }
-
-      void
-      open( const char * file_r )
-      {
-        if ( !_streambuf.open( file_r, defMode(*this) ) )
-          this->setstate(std::ios_base::failbit);
-        else
-          this->clear();
-      }
-
-      void
-      close()
-      {
-        if ( !_streambuf.close() )
-          this->setstate(std::ios_base::failbit);
-      }
-
-      /**
-             * The last error returned retuned from zlib.
-             **/
-      ZlibError
-      zError() const
-      { return _streambuf.error(); }
-
-      //! Similar to ios::rdbuf.
-      //! But it returns our specific type, not the generic streambuf *.
-      const streambuf_type&
-      getbuf() const
-      { return _streambuf; }
-
-    private:
-
-      streambuf_type _streambuf;
-
-      std::ios_base::openmode
-      defMode( const std::istream & )
-      { return std::ios_base::in; }
-
-      std::ios_base::openmode
-      defMode( const std::ostream & )
-      { return std::ios_base::out; }
-
-    };
-  }
-}
-
-#endif
+#include <zypp-core/base/fxstream.h>
index ca2aa04..da0d8fa 100644 (file)
@@ -1,50 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/CredentialFileReader.h
- *
- */
-#ifndef ZYPP_MEDIA_CREDENTIALFILEREADER_H
-#define ZYPP_MEDIA_CREDENTIALFILEREADER_H
-
-#include <zypp/base/Function.h>
-#include <zypp/Url.h>
-#include <zypp/Pathname.h>
-
-#include <zypp/media/MediaUserAuth.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{
-  ///////////////////////////////////////////////////////////////////
-  namespace media
-  {
-    //////////////////////////////////////////////////////////////////////
-    /// \class CredentialFileReader
-    /// \brief Parse credentials files and catalogs
-    class CredentialFileReader
-    {
-    public:
-      /** Callback invoked for each entry found in the file.
-       * Return \c false to abort parsing.
-       */
-      typedef function<bool(AuthData_Ptr &)> ProcessCredentials;
-
-      CredentialFileReader( const Pathname & crfile_r, const ProcessCredentials & callback_r );
-      ~CredentialFileReader();
-    private:
-      ProcessCredentials _callback;
-    };
-    //////////////////////////////////////////////////////////////////////
-
-  } // namespace media
-  ///////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
-#endif /* ZYPP_MEDIA_CREDENTIALFILEREADER_H */
+#include <zypp-media/auth/CredentialFileReader>
index 4c3878e..61dd4a2 100644 (file)
@@ -1,187 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/CredentialManager.h
- *
- */
-#ifndef ZYPP_MEDIA_CREDENTIALMANAGER_H
-#define ZYPP_MEDIA_CREDENTIALMANAGER_H
-
-#include <set>
-
-#include <zypp/Pathname.h>
-#include <zypp/media/MediaUserAuth.h>
-
-//////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ////////////////////////////////////////////////////////////////////
-
-  class Url;
-
-  //////////////////////////////////////////////////////////////////////
-  namespace media
-  { ////////////////////////////////////////////////////////////////////
-
-
-  //////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME : CredManagerOptions
-  //
-  /**
-   * \todo configurable cred file locations
-   */
-  struct CredManagerOptions
-  {
-    CredManagerOptions(const Pathname & rootdir = "");
-
-    Pathname globalCredFilePath;
-    Pathname userCredFilePath;
-    Pathname customCredFileDir;
-  };
-  //////////////////////////////////////////////////////////////////////
-
-  // comparator for CredentialSet
-  struct AuthDataComparator
-  {
-    bool operator()(const AuthData_Ptr & lhs, const AuthData_Ptr & rhs) const;
-  };
-
-  //////////////////////////////////////////////////////////////////////
-  //
-  // CLASS NAME : CredentialManager
-  //
-  /**
-   * \todo better method names
-   * \todo delete(AuthData) method
-   */
-  class CredentialManager
-  {
-  public:
-    typedef std::set<AuthData_Ptr, AuthDataComparator> CredentialSet;
-    typedef CredentialSet::size_type                   CredentialSize;
-    typedef CredentialSet::const_iterator              CredentialIterator;
-
-
-    CredentialManager(const CredManagerOptions & opts = CredManagerOptions());
-
-    ~CredentialManager()
-    {}
-
-  public:
-    /**
-     * Get credentials for the specified \a url.
-     *
-     * If the URL contains also username, it will be used to find the match
-     * for this user (in case mutliple are available).
-     *
-     * \param url URL to find credentials for.
-     * \return Pointer to retrieved authentication data on success or an empty
-     *         AuthData_Ptr otherwise.
-     * \todo return a copy instead?
-     */
-    AuthData_Ptr getCred(const Url & url);
-
-    /**
-     * Read credentials from a file.
-     */
-    AuthData_Ptr getCredFromFile(const Pathname & file);
-
-    /**
-     * Add new global credentials.
-     */
-    void addGlobalCred(const AuthData & cred);
-
-    /**
-     * Add new user credentials.
-     */
-    void addUserCred(const AuthData & cred);
-
-    /**
-     * Add new credentials with user callbacks.
-     *
-     * If the cred->url() contains 'credentials' query parameter, the
-     * credentials will be automatically saved to the specified file using the
-     * \ref saveInFile() method.
-     *
-     * Otherwise a callback will be called asking whether to save to custom
-     * file, or to global or user's credentials catalog.
-     *
-     * \todo Currently no callback is called, credentials are automatically
-     *       saved to user's credentials.cat if no 'credentials' parameter
-     *       has been specified
-     */
-    void addCred(const AuthData & cred);
-
-    /**
-     * Saves any unsaved credentials added via \ref addUserCred() or
-     * \a addGlobalCred() methods.
-     */
-    void save();
-
-    /**
-     * Saves given \a cred to global credentials file.
-     *
-     * \note Use this method to add just one piece of credentials. To add
-     *       multiple items at once, use addGlobalCred() followed
-     *       by save()
-     */
-    void saveInGlobal(const AuthData & cred);
-
-    /**
-     * Saves given \a cred to user's credentials file.
-     *
-     * \note Use this method to add just one piece of credentials. To add
-     *       multiple items at once, use addUserCred() followed
-     *       by save()
-     */
-    void saveInUser(const AuthData & cred);
-
-    /**
-     * Saves given \a cred to user specified credentials file.
-     *
-     * If the credFile path is absolute, it will be saved at that precise
-     * location. If \a credFile is just a filename, it will be saved
-     * in \ref CredManagerOptions::customCredFileDir. Otherwise the current
-     * working directory will be prepended to the file path.
-     */
-    void saveInFile(const AuthData &, const Pathname & credFile);
-
-    /**
-     * Remove all global or user credentials from memory and disk.
-     *
-     * \param global  Whether to remove global or user credentials.
-     */
-    void clearAll(bool global = false);
-
-
-    CredentialIterator credsGlobalBegin() const;
-    CredentialIterator credsGlobalEnd()   const;
-    CredentialSize     credsGlobalSize()  const;
-    bool               credsGlobalEmpty() const;
-
-    CredentialIterator credsUserBegin() const;
-    CredentialIterator credsUserEnd()   const;
-    CredentialSize     credsUserSize()  const;
-    bool               credsUserEmpty() const;
-
-    struct Impl;
-  private:
-    RW_pointer<Impl> _pimpl;
-  };
-  //////////////////////////////////////////////////////////////////////
-
-
-    ////////////////////////////////////////////////////////////////////
-  } // media
-  //////////////////////////////////////////////////////////////////////
-  ////////////////////////////////////////////////////////////////////
-} // zypp
-//////////////////////////////////////////////////////////////////////
-
-#endif /* ZYPP_MEDIA_CREDENTIALMANAGER_H */
-
+#include <zypp-media/auth/CredentialManager>
index 4fa91f1..f710b72 100644 (file)
@@ -1,47 +1 @@
-#ifndef ZYPP_MEDIA_CURLRCONFIG_H_
-#define ZYPP_MEDIA_CURLRCONFIG_H_
-
-//#include <zypp/base/NonCopyable.h>
-#include <zypp/base/String.h>
-
-namespace zypp
-{
-  namespace media
-  {
-
-
-  /**
-   * Structure holding values of curlrc options.
-   */
-  struct CurlConfig
-  {
-  public:
-    /**
-     * Parse a curlrc file and store the result in the \a config structure.
-     *
-     * \param config   a CurlConfig structure
-     * \param filename path to the curlrc file. If empty, ~/.curlrc is used.
-     * \return         0 on success, 1 if problem occurs.
-     */
-    static int parseConfig(CurlConfig & config, const std::string & filename = "");
-
-    /**
-     * Stores the \a value of the \a option in the \a config structure or
-     * logs an unknown option.
-     *
-     * \return         0 on success, 1 if problem occurs.
-     */
-    static int setParameter(CurlConfig & config,
-                            const std::string & option,
-                            const std::string & value);
-
-  public:
-    std::string proxyuserpwd;
-    // add more curl config data here as they become needed
-  };
-
-
-  } // namespace media
-} // namespace zypp
-
-#endif /*ZYPP_MEDIA_CURLRCONFIG_H_*/
+#include <zypp-curl/CurlConfig>
diff --git a/zypp/media/CurlHelper.h b/zypp/media/CurlHelper.h
deleted file mode 100644 (file)
index cb9dc2c..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-----------------------------------------------------------------------/
-*
-* This file contains private API, this might break at any time between releases.
-* You have been warned!
-*
-*/
-#ifndef ZYPP_MEDIA_CURLHELPER_H_INCLUDED
-#define ZYPP_MEDIA_CURLHELPER_H_INCLUDED
-
-#include <curl/curl.h>
-#include <zypp/Url.h>
-#include <zypp/media/TransferSettings.h>
-#include <zypp/ZYppCallbacks.h>
-
-#define  CONNECT_TIMEOUT        60
-#define  TRANSFER_TIMEOUT_MAX   60 * 60
-#define  DETECT_DIR_INDEX       0
-
-#define EXPLICITLY_NO_PROXY "_none_"
-
-#undef CURLVERSION_AT_LEAST
-#define CURLVERSION_AT_LEAST(M,N,O) LIBCURL_VERSION_NUM >= ((((M)<<8)+(N))<<8)+(O)
-
-namespace zypp
-{
-  namespace env
-  {
-    /** Long number for setting CURLOPT_DEBUGDATA */
-    inline long ZYPP_MEDIA_CURL_DEBUG()
-    {
-      long ret = 0L;
-      if ( char *ptr = ::getenv("ZYPP_MEDIA_CURL_DEBUG"); ptr && *ptr )
-        str::strtonum( ptr, ret );
-      return ret;
-    }
-
-    /** 4/6 to force IPv4/v6 */
-    int ZYPP_MEDIA_CURL_IPRESOLVE();
-  } // namespace env
-} //namespace zypp
-
-//do not export
-namespace internal {
-
-struct ProgressData
-{
-  ProgressData( CURL *_curl, time_t _timeout = 0, const zypp::Url & _url = zypp::Url(),
-    zypp::ByteCount expectedFileSize_r = 0,
-    zypp::callback::SendReport<zypp::media::DownloadProgressReport> *_report = nullptr );
-
-  CURL *curl;
-  zypp::Url    url;
-  time_t       timeout;
-  bool reached;
-  bool      fileSizeExceeded;
-  zypp::callback::SendReport<zypp::media::DownloadProgressReport> *report;
-  zypp::ByteCount _expectedFileSize;
-
-  time_t _timeStart    = 0;    ///< Start total stats
-  time_t _timeLast     = 0;    ///< Start last period(~1sec)
-  time_t _timeRcv      = 0;    ///< Start of no-data timeout
-  time_t _timeNow      = 0;    ///< Now
-
-  double _dnlTotal     = 0.0;  ///< Bytes to download or 0 if unknown
-  double _dnlLast      = 0.0;  ///< Bytes downloaded at period start
-  double _dnlNow       = 0.0;  ///< Bytes downloaded now
-
-  int    _dnlPercent= 0;       ///< Percent completed or 0 if _dnlTotal is unknown
-
-  double _drateTotal= 0.0;     ///< Download rate so far
-  double _drateLast    = 0.0;  ///< Download rate in last period
-
-  void updateStats( double dltotal = 0.0, double dlnow = 0.0 );
-
-  int reportProgress() const;
-
-
-  // download rate of the last period (cca 1 sec)
-  double                                        drate_period;
-  // bytes downloaded at the start of the last period
-  double                                        dload_period;
-  // seconds from the start of the download
-  long                                          secs;
-  // average download rate
-  double                                        drate_avg;
-  // last time the progress was reported
-  time_t                                        ltime;
-  // bytes downloaded at the moment the progress was last reported
-  double                                        dload;
-  // bytes uploaded at the moment the progress was last reported
-  double                                        uload;
-};
-
-void globalInitCurlOnce();
-int  log_curl(CURL *curl, curl_infotype info,  char *ptr, size_t len, void *max_lvl);
-size_t log_redirects_curl( char *ptr, size_t size, size_t nmemb, void *userdata);
-
-
-void fillSettingsFromUrl( const zypp::Url &url, zypp::media::TransferSettings &s );
-void fillSettingsSystemProxy( const zypp::Url& url, zypp::media::TransferSettings &s );
-
-/**
- * initialized only once, this gets the anonymous id
- * from the target, which we pass in the http header
- */
-const char * anonymousIdHeader();
-
-/**
- * initialized only once, this gets the distribution flavor
- * from the target, which we pass in the http header
- */
-const char * distributionFlavorHeader();
-
-/**
- * initialized only once, this gets the agent string
- * which also includes the curl version
- */
-const char * agentString();
-
-void curlEscape( std::string & str_r,  const char char_r, const std::string & escaped_r );
-std::string curlEscapedPath( std::string path_r );
-std::string curlUnEscape( std::string text_r );
-
-zypp::Url clearQueryString(const zypp::Url &url);
-zypp::Url propagateQueryParams( zypp::Url url_r, const zypp::Url & template_r );
-
-}
-
-
-
-
-#endif
index 37fa92e..e6424ea 100644 (file)
@@ -1,157 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaBlockList.h
- *
-*/
-#ifndef ZYPP_MEDIA_MEDIABLOCKLIST_H
-#define ZYPP_MEDIA_MEDIABLOCKLIST_H
-
-#include <sys/types.h>
-#include <vector>
-#include <optional>
-
-#include <zypp/Digest.h>
-
-namespace zypp {
-  namespace media {
-
-/**
- * a single block from the blocklist, consisting of an offset and a size
- **/
-struct MediaBlock {
-  MediaBlock( off_t off_r, size_t size_r )
-  : off( off_r )
-  , size( size_r )
-  {}
-  off_t off;
-  size_t size;
-};
-
-class MediaBlockList {
-public:
-  MediaBlockList(off_t filesize=off_t(-1));
-
-  /**
-   * do we have a blocklist describing the file?
-   * set to true when addBlock() is called
-   **/
-  inline bool haveBlocks() const {
-    return haveblocks;
-  }
-  /**
-   * add a block with offset off and size size to the block list. Note
-   * that blocks must be ordered and must not overlap. returns the
-   * block number.
-   **/
-  size_t addBlock(off_t off, size_t size);
-
-  /**
-   * return the offset/size of a block with number blkno
-   **/
-  inline MediaBlock getBlock(size_t blkno) const {
-    return blocks[blkno];
-  }
-  /**
-   * return the number of blocks in the blocklist
-   **/
-  inline size_t numBlocks() const {
-    return blocks.size();
-  }
-
-  /**
-   * set / return the size of the whole file
-   **/
-  inline void setFilesize(off_t newfilesize=off_t(-1)) {
-    filesize = newfilesize;
-  }
-  inline off_t getFilesize() const {
-    return filesize;
-  }
-  inline bool haveFilesize() const {
-    return filesize != off_t(-1);
-  }
-
-  /**
-   * set / verify the checksum over the whole file
-   **/
-  void setFileChecksum(std::string ctype, int cl, unsigned char *c);
-  std::string fileChecksumType () const;
-
-  const UByteArray &getFileChecksum( );
-  bool createFileDigest(Digest &digest) const;
-  bool verifyFileDigest(Digest &digest) const;
-  inline bool haveFileChecksum() const {
-    return !fsumtype.empty() && fsum.size();
-  }
-
-  /**
-   * set / verify the (strong) checksum over a single block
-   **/
-  void setChecksum(size_t blkno, std::string cstype, int csl, unsigned char *cs, size_t cspad=0);
-  bool checkChecksum(size_t blkno, const unsigned char *buf, size_t bufl) const;
-  UByteArray getChecksum( size_t blkno ) const;
-  std::string getChecksumType( ) const;
-  bool createDigest(Digest &digest) const;
-  bool verifyDigest(size_t blkno, Digest &digest) const;
-  inline bool haveChecksum(size_t blkno) const {
-    return chksumlen && chksums.size() >= chksumlen * (blkno + 1);
-  }
-
-  /**
-   * set / verify the (weak) rolling checksum over a single block
-   **/
-  void setRsum(size_t blkno, int rsl, unsigned int rs, size_t rspad=0);
-  bool checkRsum(size_t blkno, const unsigned char *buf, size_t bufl) const;
-  unsigned int updateRsum(unsigned int rs, const char *bytes, size_t len) const;
-  bool verifyRsum(size_t blkno, unsigned int rs) const;
-  inline bool haveRsum(size_t blkno) const {
-    return rsumlen && rsums.size() >= blkno + 1;
-  }
-
-  /**
-   * scan a file for blocks from our blocklist. if we find a suitable block,
-   * it is removed from the list
-   **/
-  void reuseBlocks(FILE *wfp, std::string filename);
-
-  /**
-   * return block list as string
-   **/
-  std::string asString() const;
-
-private:
-  void writeBlock(size_t blkno, FILE *fp, const unsigned char *buf, size_t bufl, size_t start, std::vector<bool> &found) const;
-  bool checkChecksumRotated(size_t blkno, const unsigned char *buf, size_t bufl, size_t start) const;
-
-  off_t filesize;
-  std::string fsumtype;
-  UByteArray fsum;
-
-  bool haveblocks;
-  std::vector<MediaBlock> blocks;
-
-  std::string chksumtype;
-  int chksumlen;
-  size_t chksumpad;
-  std::vector<unsigned char> chksums;
-
-  std::string rsumtype;
-  int rsumlen;
-  size_t rsumpad;
-  std::vector<unsigned int> rsums;
-};
-
-inline std::ostream & operator<<(std::ostream &str, const MediaBlockList &bl)
-{ return str << bl.asString(); }
-
-  } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_MEDIABLOCKLIST_H
-
+#include <zypp-curl/parser/MediaBlockList>
index 62ba549..4c3dba1 100644 (file)
@@ -24,7 +24,7 @@ extern "C"
 
 #include <zypp/base/Logger.h>
 #include <zypp/ExternalProgram.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
 #include <zypp/media/MediaCD.h>
 #include <zypp/media/MediaManager.h>
 #include <zypp/Url.h>
index 0246914..bf7d07c 100644 (file)
 #include <zypp/base/Logger.h>
 #include <zypp/base/Gettext.h>
 #include <zypp/TmpPath.h>
-#include <zypp/KVMap.h>
-#include <zypp/media/Mount.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/media/CredentialManager.h>
+#include <zypp-core/KVMap>
+#include <zypp-media/Mount>
+#include <zypp-media/auth/AuthData>
+#include <zypp-media/auth/CredentialManager>
 #include <zypp/ZYppCallbacks.h>
 #include <zypp/ZConfig.h>
 
index 102799e..6572a72 100644 (file)
 #include <zypp/ExternalProgram.h>
 #include <zypp/base/String.h>
 #include <zypp/base/Gettext.h>
-#include <zypp/base/Sysconfig.h>
+#include <zypp-core/parser/Sysconfig>
 #include <zypp/base/Gettext.h>
 
 #include <zypp/media/MediaCurl.h>
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/media/CredentialManager.h>
-#include <zypp/media/CurlConfig.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/ProxyInfo>
+#include <zypp-curl/auth/CurlAuthData>
+#include <zypp-media/auth/CredentialManager>
+#include <zypp-curl/CurlConfig>
+#include <zypp-curl/private/curlhelper_p.h>
 #include <zypp/Target.h>
 #include <zypp/ZYppFactory.h>
 #include <zypp/ZConfig.h>
 
 using std::endl;
 
+namespace internal {
+  using namespace zypp;
+  struct ProgressData
+  {
+    ProgressData( CURL *_curl, time_t _timeout = 0, const zypp::Url & _url = zypp::Url(),
+      zypp::ByteCount expectedFileSize_r = 0,
+      zypp::callback::SendReport<zypp::media::DownloadProgressReport> *_report = nullptr );
+
+    CURL       *curl;
+    zypp::Url  url;
+    time_t     timeout;
+    bool       reached;
+    bool      fileSizeExceeded;
+    zypp::callback::SendReport<zypp::media::DownloadProgressReport> *report;
+    zypp::ByteCount _expectedFileSize;
+
+    time_t _timeStart  = 0;    ///< Start total stats
+    time_t _timeLast   = 0;    ///< Start last period(~1sec)
+    time_t _timeRcv    = 0;    ///< Start of no-data timeout
+    time_t _timeNow    = 0;    ///< Now
+
+    double _dnlTotal   = 0.0;  ///< Bytes to download or 0 if unknown
+    double _dnlLast    = 0.0;  ///< Bytes downloaded at period start
+    double _dnlNow     = 0.0;  ///< Bytes downloaded now
+
+    int    _dnlPercent= 0;     ///< Percent completed or 0 if _dnlTotal is unknown
+
+    double _drateTotal= 0.0;   ///< Download rate so far
+    double _drateLast  = 0.0;  ///< Download rate in last period
+
+    void updateStats( double dltotal = 0.0, double dlnow = 0.0 );
+
+    int reportProgress() const;
+
+
+    // download rate of the last period (cca 1 sec)
+    double                                        drate_period;
+    // bytes downloaded at the start of the last period
+    double                                        dload_period;
+    // seconds from the start of the download
+    long                                          secs;
+    // average download rate
+    double                                        drate_avg;
+    // last time the progress was reported
+    time_t                                        ltime;
+    // bytes downloaded at the moment the progress was last reported
+    double                                        dload;
+    // bytes uploaded at the moment the progress was last reported
+    double                                        uload;
+  };
+
+
+
+  ProgressData::ProgressData(CURL *_curl, time_t _timeout, const Url &_url, ByteCount expectedFileSize_r, zypp::callback::SendReport< zypp::media::DownloadProgressReport> *_report)
+    : curl( _curl )
+    , url( _url )
+    , timeout( _timeout )
+    , reached( false )
+    , fileSizeExceeded ( false )
+    , report( _report )
+    , _expectedFileSize( expectedFileSize_r )
+  {}
+
+  void ProgressData::updateStats(double dltotal, double dlnow)
+  {
+    time_t now = _timeNow = time(0);
+
+    // If called without args (0.0), recompute based on the last values seen
+    if ( dltotal && dltotal != _dnlTotal )
+      _dnlTotal = dltotal;
+
+    if ( dlnow && dlnow != _dnlNow )
+    {
+      _timeRcv = now;
+      _dnlNow = dlnow;
+    }
+    else if ( !_dnlNow && !_dnlTotal )
+    {
+      // Start time counting as soon as first data arrives.
+      // Skip the connection / redirection time at begin.
+      return;
+    }
+
+    // init or reset if time jumps back
+    if ( !_timeStart || _timeStart > now )
+      _timeStart = _timeLast = _timeRcv = now;
+
+    // timeout condition
+    if ( timeout )
+      reached = ( (now - _timeRcv) > timeout );
+
+    // check if the downloaded data is already bigger than what we expected
+    fileSizeExceeded = _expectedFileSize > 0 && _expectedFileSize < static_cast<ByteCount::SizeType>(_dnlNow);
+
+    // percentage:
+    if ( _dnlTotal )
+      _dnlPercent = int(_dnlNow * 100 / _dnlTotal);
+
+    // download rates:
+    _drateTotal = _dnlNow / std::max( int(now - _timeStart), 1 );
+
+    if ( _timeLast < now )
+    {
+      _drateLast = (_dnlNow - _dnlLast) / int(now - _timeLast);
+      // start new period
+      _timeLast  = now;
+      _dnlLast   = _dnlNow;
+    }
+    else if ( _timeStart == _timeLast )
+      _drateLast = _drateTotal;
+  }
+
+  int ProgressData::reportProgress() const
+  {
+    if ( fileSizeExceeded )
+      return 1;
+    if ( reached )
+      return 1;        // no-data timeout
+    if ( report && !(*report)->progress( _dnlPercent, url, _drateTotal, _drateLast ) )
+      return 1;        // user requested abort
+    return 0;
+  }
+
+  const char * anonymousIdHeader()
+  {
+    // we need to add the release and identifier to the
+    // agent string.
+    // The target could be not initialized, and then this information
+    // is guessed.
+    static const std::string _value(
+      str::trim( str::form(
+        "X-ZYpp-AnonymousId: %s",
+        Target::anonymousUniqueId( Pathname()/*guess root*/ ).c_str() ) )
+      );
+    return _value.c_str();
+  }
+
+  const char * distributionFlavorHeader()
+  {
+    // we need to add the release and identifier to the
+    // agent string.
+    // The target could be not initialized, and then this information
+    // is guessed.
+    static const std::string _value(
+      str::trim( str::form(
+        "X-ZYpp-DistributionFlavor: %s",
+        Target::distributionFlavor( Pathname()/*guess root*/ ).c_str() ) )
+      );
+    return _value.c_str();
+  }
+
+  const char * agentString()
+  {
+    // we need to add the release and identifier to the
+    // agent string.
+    // The target could be not initialized, and then this information
+    // is guessed.
+    static const std::string _value(
+      str::form(
+        "ZYpp " LIBZYPP_VERSION_STRING " (curl %s) %s"
+        , curl_version_info(CURLVERSION_NOW)->version
+        , Target::targetDistribution( Pathname()/*guess root*/ ).c_str()
+        )
+      );
+    return _value.c_str();
+  }
+}
+
+
 using namespace internal;
 using namespace zypp::base;
 
@@ -972,7 +1141,7 @@ void MediaCurl::doGetFileCopy( const OnMediaLocation &srcFile , const Pathname &
     }
     else
     {
-      WAR << "Could not get the reponse code." << endl;
+      WAR << "Could not get the response code." << endl;
     }
 
     if (modified || infoRet != CURLE_OK)
index 18becf4..cde3ec9 100644 (file)
@@ -17,6 +17,7 @@
 #include <zypp/media/MediaNetworkCommonHandler.h>
 
 #include <curl/curl.h>
+
 namespace zypp {
   namespace media {
 
index 9984867..c5fbd00 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <zypp/base/Logger.h>
 #include <zypp/base/String.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
 #include <zypp/media/MediaDISK.h>
 #include <zypp/media/MediaManager.h>
 
index 60c1967..81cbbe3 100644 (file)
@@ -1,549 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaException.h
- *
-*/
-#ifndef ZYPP_MEDIA_MEDIAEXCEPTION_H
-#define ZYPP_MEDIA_MEDIAEXCEPTION_H
-
-#include <iosfwd>
-
-#include <string>
-#include <vector>
-
-#include <zypp/base/Exception.h>
-#include <zypp/Pathname.h>
-#include <zypp/Url.h>
-#include <zypp/ByteCount.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-  namespace media {
-    ///////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : MediaException
-    /** Just inherits Exception to separate media exceptions
-     *
-     **/
-    class MediaException : public Exception
-    {
-    public:
-      /** Ctor taking message.
-       * Use \ref ZYPP_THROW to throw exceptions.
-      */
-      MediaException() : Exception( "Media Exception" )
-      {}
-      /** Ctor taking message.
-       * Use \ref ZYPP_THROW to throw exceptions.
-      */
-      MediaException( const std::string & msg_r )
-      : Exception( msg_r )
-      {}
-
-      /** Dtor. */
-      virtual ~MediaException() noexcept override;
-    };
-
-    class MediaMountException : public MediaException
-    {
-    public:
-      MediaMountException()
-      : MediaException( "Media Mount Exception" )
-      {}
-
-      /** Ctor taking message.
-       * Use \ref ZYPP_THROW to throw exceptions.
-      */
-      MediaMountException( const std::string & error_r,
-                           const std::string & source_r,
-                           const std::string & target_r,
-                           const std::string & cmdout_r="")
-      : MediaException()
-      , _error(error_r)
-      , _source(source_r)
-      , _target(target_r)
-      , _cmdout(cmdout_r)
-      {}
-      /** Dtor. */
-      virtual ~MediaMountException() noexcept {}
-
-      const std::string & mountError() const
-      { return _error;  }
-      const std::string & mountSource() const
-      { return _source; }
-      const std::string & mountTarget() const
-      { return _target; }
-      const std::string & mountOutput() const
-      { return _cmdout; }
-
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _error;
-      std::string _source;
-      std::string _target;
-      std::string _cmdout;
-    };
-
-    class MediaUnmountException : public MediaException
-    {
-    public:
-      /** Ctor taking message.
-       * Use \ref ZYPP_THROW to throw exceptions.
-      */
-      MediaUnmountException( const std::string & error_r,
-                             const std::string & path_r )
-      : MediaException()
-      , _error(error_r)
-      , _path(path_r)
-      {}
-      /** Dtor. */
-      virtual ~MediaUnmountException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _error;
-      std::string _path;
-    };
-
-    class MediaBadFilenameException : public MediaException
-    {
-    public:
-      MediaBadFilenameException(const std::string & filename_r)
-      : MediaException()
-      , _filename(filename_r)
-      {}
-      virtual ~MediaBadFilenameException() noexcept {}
-      std::string filename() const { return _filename; }
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _filename;
-    };
-
-    class MediaNotOpenException : public MediaException
-    {
-    public:
-      MediaNotOpenException(const std::string & action_r)
-      : MediaException()
-      , _action(action_r)
-      {}
-      virtual ~MediaNotOpenException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _action;
-    };
-
-    class MediaFileNotFoundException : public MediaException
-    {
-    public:
-      MediaFileNotFoundException(const Url & url_r,
-                                 const Pathname & filename_r)
-      : MediaException()
-      , _url(url_r.asString())
-      , _filename(filename_r.asString())
-      {}
-      virtual ~MediaFileNotFoundException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _url;
-      std::string _filename;
-    };
-
-    class MediaWriteException : public MediaException
-    {
-    public:
-      MediaWriteException(const Pathname & filename_r)
-      : MediaException()
-      , _filename(filename_r.asString())
-      {}
-      virtual ~MediaWriteException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _filename;
-    };
-
-    class MediaNotAttachedException : public MediaException
-    {
-    public:
-      MediaNotAttachedException(const Url & url_r)
-      : MediaException()
-      , _url(url_r.asString())
-      {}
-      virtual ~MediaNotAttachedException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _url;
-    };
-
-    class MediaBadAttachPointException : public MediaException
-    {
-    public:
-      MediaBadAttachPointException(const Url & url_r)
-      : MediaException()
-      , _url(url_r.asString())
-      {}
-      virtual ~MediaBadAttachPointException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _url;
-    };
-
-    class MediaCurlInitException : public MediaException
-    {
-    public:
-      MediaCurlInitException(const Url & url_r)
-      : MediaException()
-      , _url(url_r.asString())
-      {}
-      virtual ~MediaCurlInitException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _url;
-    };
-
-    class MediaSystemException : public MediaException
-    {
-    public:
-      MediaSystemException(const Url & url_r,
-                           const std::string & message_r)
-      : MediaException()
-      , _url(url_r.asString())
-      , _message(message_r)
-      {}
-      virtual ~MediaSystemException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _url;
-      std::string _message;
-    };
-
-    class MediaNotAFileException : public MediaException
-    {
-    public:
-      MediaNotAFileException(const Url & url_r,
-                             const Pathname & path_r)
-      : MediaException()
-      , _url(url_r.asString())
-      , _path(path_r.asString())
-      {}
-      virtual ~MediaNotAFileException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _url;
-      std::string _path;
-    };
-
-    class MediaNotADirException : public MediaException
-    {
-    public:
-      MediaNotADirException(const Url & url_r,
-                            const Pathname & path_r)
-      : MediaException()
-      , _url(url_r.asString())
-      , _path(path_r.asString())
-      {}
-      virtual ~MediaNotADirException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _url;
-      std::string _path;
-    };
-
-    class MediaBadUrlException : public MediaException
-    {
-    public:
-      MediaBadUrlException(const Url & url_r,
-                           const std::string &msg_r = std::string())
-      : MediaException()
-      , _url(url_r.asString())
-      , _msg(msg_r)
-      {}
-      virtual ~MediaBadUrlException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-      std::string _url;
-      std::string _msg;
-    };
-
-    class MediaBadUrlEmptyHostException : public MediaBadUrlException
-    {
-    public:
-      MediaBadUrlEmptyHostException(const Url & url_r)
-      : MediaBadUrlException(url_r)
-      {}
-      virtual ~MediaBadUrlEmptyHostException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    };
-
-    class MediaBadUrlEmptyFilesystemException : public MediaBadUrlException
-    {
-    public:
-      MediaBadUrlEmptyFilesystemException(const Url & url_r)
-      : MediaBadUrlException(url_r)
-      {}
-      virtual ~MediaBadUrlEmptyFilesystemException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    };
-
-    class MediaBadUrlEmptyDestinationException : public MediaBadUrlException
-    {
-    public:
-      MediaBadUrlEmptyDestinationException(const Url & url_r)
-      : MediaBadUrlException(url_r)
-      {}
-      virtual ~MediaBadUrlEmptyDestinationException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    };
-
-    class MediaUnsupportedUrlSchemeException : public MediaBadUrlException
-    {
-    public:
-      MediaUnsupportedUrlSchemeException(const Url & url_r)
-      : MediaBadUrlException(url_r)
-      {}
-      virtual ~MediaUnsupportedUrlSchemeException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    };
-
-    class MediaNotSupportedException : public MediaException
-    {
-    public:
-      MediaNotSupportedException(const Url & url_r)
-      : MediaException()
-      , _url(url_r.asString())
-      {}
-      virtual ~MediaNotSupportedException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-      std::string _url;
-    };
-
-    class MediaCurlException : public MediaException
-    {
-    public:
-      MediaCurlException(const Url & url_r,
-                         const std::string & err_r,
-                         const std::string & msg_r)
-      : MediaException()
-      , _url(url_r.asString())
-      , _err(err_r)
-      , _msg(msg_r)
-      {}
-      virtual ~MediaCurlException() noexcept {}
-      std::string errstr() const { return _err; }
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-      std::string _url;
-      std::string _err;
-      std::string _msg;
-    };
-
-    class MediaCurlSetOptException : public MediaException
-    {
-    public:
-      MediaCurlSetOptException(const Url & url_r, const std::string & msg_r)
-      : MediaException()
-      , _url(url_r.asString())
-      , _msg(msg_r)
-      {}
-      virtual ~MediaCurlSetOptException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-      std::string _url;
-      std::string _msg;
-    };
-
-    class MediaNotDesiredException : public MediaException
-    {
-    public:
-      MediaNotDesiredException(const Url & url_r)
-      : MediaException()
-      , _url(url_r.asString())
-      {}
-      virtual ~MediaNotDesiredException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string  _url;
-    };
-
-    class MediaIsSharedException : public MediaException
-    {
-    public:
-      /**
-       * \param name A media source as string (see MediaSource class).
-       */
-      MediaIsSharedException(const std::string &name)
-      : MediaException()
-      , _name(name)
-      {}
-      virtual ~MediaIsSharedException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _name;
-    };
-
-    class MediaNotEjectedException: public MediaException
-    {
-    public:
-      MediaNotEjectedException()
-      : MediaException("Can't eject any media")
-      , _name("")
-      {}
-
-      MediaNotEjectedException(const std::string &name)
-      : MediaException("Can't eject media")
-      , _name(name)
-      {}
-      virtual ~MediaNotEjectedException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      std::string _name;
-    };
-
-    class MediaUnauthorizedException: public MediaException
-    {
-    public:
-      MediaUnauthorizedException()
-      : MediaException("Unauthorized media access")
-      , _url("")
-      , _err("")
-      , _hint("")
-      {}
-
-      MediaUnauthorizedException(const Url         &url_r,
-                                 const std::string &msg_r,
-                                 const std::string &err_r,
-                                 const std::string &hint_r)
-      : MediaException(msg_r)
-      , _url(url_r)
-      , _err(err_r)
-      , _hint(hint_r)
-      {}
-
-      virtual ~MediaUnauthorizedException() noexcept {}
-
-      const Url         & url()  const { return _url;  }
-      const std::string & err()  const { return _err;  }
-      /** comma separated list of available authentication types */
-      const std::string & hint() const { return _hint; }
-
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    private:
-      Url         _url;
-      std::string _err;
-      std::string _hint;
-    };
-
-    class MediaForbiddenException : public MediaException
-    {
-    public:
-      MediaForbiddenException(const Url & url_r, const std::string & msg = "")
-      : MediaException(msg)
-      , _url(url_r.asString()), _msg(msg)
-      {}
-      virtual ~MediaForbiddenException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-      std::string _url;
-      std::string _msg;
-    };
-
-    class MediaTimeoutException : public MediaException
-    {
-    public:
-      MediaTimeoutException(const Url & url_r, const std::string & msg = "")
-      : MediaException(msg)
-      , _url(url_r.asString()), _msg(msg)
-      {}
-      virtual ~MediaTimeoutException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-      std::string _url;
-      std::string _msg;
-    };
-
-    class MediaFileSizeExceededException : public MediaException
-    {
-    public:
-      MediaFileSizeExceededException(const Url & url_r, const ByteCount &cnt_r, const std::string & msg = "")
-      : MediaException(msg)
-      , _url(url_r.asString())
-      , _msg(msg)
-      , _expectedFileSize(cnt_r)
-      {}
-      virtual ~MediaFileSizeExceededException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-      std::string _url;
-      std::string _msg;
-      ByteCount _expectedFileSize;
-    };
-
-    /** For HTTP 503 and similar. */
-    class MediaTemporaryProblemException : public MediaException
-    {
-    public:
-      MediaTemporaryProblemException(const Url & url_r, const std::string & msg = "")
-      : MediaException(msg)
-      , _url(url_r.asString()), _msg(msg)
-      {}
-      virtual ~MediaTemporaryProblemException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-      std::string _url;
-      std::string _msg;
-    };
-
-    class MediaBadCAException : public MediaException
-    {
-    public:
-      MediaBadCAException(const Url & url_r, const std::string & msg = "")
-      : MediaException(msg)
-      , _url(url_r.asString()), _msg(msg)
-      {}
-      virtual ~MediaBadCAException() noexcept {}
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-      std::string _url;
-      std::string _msg;
-    };
-
-    class MediaInvalidCredentialsException : public MediaException
-    {
-    public:
-      MediaInvalidCredentialsException( const std::string & msg = "" )
-        : MediaException(msg)
-      {}
-      virtual ~MediaInvalidCredentialsException() noexcept {}
-    };
-
-  /////////////////////////////////////////////////////////////////
-  } // namespace media
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_MEDIA_MEDIAEXCEPTION_H
+#include <zypp-media/MediaException>
index 2844480..0f069e4 100644 (file)
@@ -22,7 +22,7 @@
 #include <zypp/base/String.h>
 #include <zypp/media/MediaHandler.h>
 #include <zypp/media/MediaManager.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
 #include <limits.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -314,7 +314,7 @@ MediaHandler::setAttachPrefix(const Pathname &attach_prefix)
 {
   if( attach_prefix.empty())
   {
-    MIL << "Reseting to built-in attach point prefixes."
+    MIL << "Resetting to built-in attach point prefixes."
         << std::endl;
     MediaHandler::_attachPrefix = attach_prefix;
     return true;
index e8149d2..8d0121e 100644 (file)
@@ -24,9 +24,9 @@
 #include <zypp/Url.h>
 
 #include <zypp/media/MediaSource.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 #include <zypp/APIConfig.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 
 #undef ZYPP_BASE_LOGGER_LOGGROUP
 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::media"
index 2e04948..072eac9 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <zypp/base/Logger.h>
 
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 #include <zypp/media/MediaHandler.h>
 
 #include <zypp/media/MediaNFS.h>
index 61a4951..7ba5b77 100644 (file)
@@ -12,7 +12,7 @@
 #include <iostream>
 
 #include <zypp/base/Logger.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
 
 #include <zypp/media/MediaISO.h>
 
@@ -61,32 +61,26 @@ namespace zypp
       if( _filesystem.empty())
         _filesystem = "auto";
 
-      std::string arg;
-      zypp::Url   src;
-      try
+      Url src;
       {
-        // this percent-decodes the query parameter, it must be later encoded
-        // again before used in a Url object
-        arg = _url.getQueryParam("url");
-        if( arg.empty() && _isofile.dirname().absolute())
-        {
-          src = std::string("dir:///");
-          src.setPathName(url::encode(_isofile.dirname().asString(), URL_SAFE_CHARS));
+        const std::string & arg { _url.getQueryParam("url") };
+        if ( arg.empty() ) {
+          src = "dir:/";
+          src.setPathName( _isofile.dirname() );
           _isofile = _isofile.basename();
         }
-        else
+        else try {
+          src = arg;
+        }
+        catch( const url::UrlException & e )
         {
-          src = url::encode(arg, URL_SAFE_CHARS);
+          ZYPP_CAUGHT(e);
+          ERR << "Unable to parse iso filename source media url" << std::endl;
+          MediaBadUrlException ne(_url);
+          ne.remember(e);
+          ZYPP_THROW(ne);
         }
       }
-      catch(const zypp::url::UrlException &e)
-      {
-        ZYPP_CAUGHT(e);
-        ERR << "Unable to parse iso filename source media url" << std::endl;
-        MediaBadUrlException ne(_url);
-        ne.remember(e);
-        ZYPP_THROW(ne);
-      }
       if( !src.isValid())
       {
         ERR << "Invalid iso filename source media url" << std::endl;
index 3a2b4db..1bae012 100644 (file)
 #include <iostream>
 #include <typeinfo>
 
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 #include <zypp/media/MediaManager.h>
 #include <zypp/media/MediaHandlerFactory.h>
 #include <zypp/media/MediaHandler.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
 
 #include <zypp/base/String.h>
 #include <zypp/base/Logger.h>
@@ -47,7 +47,8 @@ namespace zypp
         {
           try
           {
-            close(); // !!! make sure handler gets properly deleted.
+            if ( _handler )
+              close(); // !!! make sure handler gets properly deleted.
           }
           catch(...) {}
         }
index bb0d3ed..faef4ff 100644 (file)
@@ -18,9 +18,9 @@
 #include <zypp/Pathname.h>
 #include <zypp/PathInfo.h>
 #include <zypp/Url.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/media/MediaSource.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 
 #include <list>
 
index 5e1e87a..f598644 100644 (file)
 #include <zypp/ZConfig.h>
 #include <zypp/base/Logger.h>
 #include <zypp/media/MediaMultiCurl.h>
-#include <zypp/media/MetaLinkParser.h>
+#include <zypp-curl/parser/MetaLinkParser>
 #include <zypp/ManagedFile.h>
-#include <zypp/media/CurlHelper.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-curl/auth/CurlAuthData>
 
 using std::endl;
 using namespace zypp::base;
@@ -1381,7 +1382,7 @@ void MediaMultiCurl::doGetFileCopy( const OnMediaLocation &srcFile , const Pathn
   }
   else
   {
-    WAR << "Could not get the reponse code." << endl;
+    WAR << "Could not get the response code." << endl;
   }
 
   bool ismetalink = false;
index 1c158ad..a164c00 100644 (file)
@@ -19,8 +19,8 @@
 
 #include <zypp/media/MediaHandler.h>
 #include <zypp/media/MediaCurl.h>
-#include <zypp/media/MediaBlockList.h>
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/parser/MediaBlockList>
+#include <zypp-curl/TransferSettings>
 #include <zypp/ZYppCallbacks.h>
 
 namespace zypp {
index b60e692..082644b 100644 (file)
@@ -16,7 +16,7 @@
 #include <zypp/base/Logger.h>
 #include <zypp/base/String.h>
 #include <zypp/media/MediaNFS.h>
-#include <zypp/media/Mount.h>
+#include <zypp-media/Mount>
 
 #include <dirent.h>
 
index 8898091..73e10e8 100644 (file)
@@ -12,7 +12,7 @@
 #define ZYPP_MEDIA_MEDIANETWORKCOMMONHANDLER_H
 
 #include <zypp/media/MediaHandler.h>
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/TransferSettings>
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
diff --git a/zypp/media/MediaUserAuth.cc b/zypp/media/MediaUserAuth.cc
deleted file mode 100644 (file)
index a03a84c..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaUserAuth.cc
- *
- */
-
-#include <list>
-#include <curl/curl.h>
-
-#include <zypp/base/Gettext.h>
-#include <zypp/base/String.h>
-
-#include <zypp/media/MediaException.h>
-#include <zypp/media/MediaUserAuth.h>
-
-using std::endl;
-
-namespace zypp {
-  namespace media {
-
-
-AuthData::AuthData(const Url & url)
-      : _url(url), _lastChange(0)
-{
-  _username = url.getUsername();
-  _password = url.getPassword();
-}
-
-
-bool AuthData::valid() const
-{
-  return username().size() && password().size();
-}
-
-time_t AuthData::lastDatabaseUpdate() const
-{
-  return _lastChange;
-}
-
-void AuthData::setLastDatabaseUpdate( time_t time )
-{
-  _lastChange = time;
-}
-
-std::ostream & AuthData::dumpOn( std::ostream & str ) const
-{
-  if (_url.isValid())
-    str << "[" << _url.asString( url::ViewOptions() - url::ViewOptions::WITH_USERNAME - url::ViewOptions::WITH_PASSWORD ) << "]" << endl;
-  else
-    str << "[<no-url>]" << endl;
-  str << "username: '" << _username << "'" << std::endl
-      << "password: " << (_password.empty() ? "<empty>" : "<non-empty>");
-  return str;
-}
-
-std::ostream & AuthData::dumpAsIniOn( std::ostream & str ) const
-{
-  if (_url.isValid())
-    str
-      << "[" << _url.asString(
-        url::ViewOptions()
-        - url::ViewOptions::WITH_USERNAME
-        - url::ViewOptions::WITH_PASSWORD)
-      << "]" << endl;
-
-  str
-    << "username = " << _username << endl
-    << "password = " << _password << endl;
-
-  return str;
-}
-
-CurlAuthData::CurlAuthData()
-  : AuthData()
-  , _auth_type_str()
-  , _auth_type(CURLAUTH_NONE)
-{}
-
-CurlAuthData::CurlAuthData(const AuthData & authData)
-  : AuthData(authData)
-  , _auth_type_str()
-  , _auth_type(CURLAUTH_NONE)
-{}
-
-bool CurlAuthData::valid() const
-{
-  return username().size() && password().size();
-}
-
-std::ostream & CurlAuthData::dumpOn( std::ostream & str ) const
-{
-  AuthData::dumpOn(str) << endl
-  << " auth_type: " << _auth_type_str << " (" << _auth_type << ")";
-  return str;
-}
-
-long CurlAuthData::auth_type_str2long( std::string & auth_type_str )
-{
-  return auth_type_str2long( const_cast< const std::string &>(auth_type_str) );
-}
-
-long CurlAuthData::auth_type_str2long( const std::string & auth_type_str )
-{
-  curl_version_info_data *curl_info = curl_version_info(CURLVERSION_NOW);
-
-  std::vector<std::string>                  list;
-  std::vector<std::string>::const_iterator  it;
-  long                                      auth_type = CURLAUTH_NONE;
-
-  zypp::str::split(auth_type_str, std::back_inserter(list), ",");
-
-  for(it = list.begin(); it != list.end(); ++it)
-  {
-    if(*it == "basic")
-    {
-      auth_type |= CURLAUTH_BASIC;
-    }
-    else
-    if(*it == "digest")
-    {
-      auth_type |= CURLAUTH_DIGEST;
-    }
-    else
-    if((curl_info && (curl_info->features & CURL_VERSION_NTLM)) &&
-       (*it == "ntlm"))
-    {
-      auth_type |= CURLAUTH_NTLM;
-    }
-    else
-    if((curl_info && (curl_info->features & CURL_VERSION_SPNEGO)) &&
-       (*it == "spnego" || *it == "negotiate"))
-    {
-      // there is no separate spnego flag for this auth type
-      auth_type |= CURLAUTH_GSSNEGOTIATE;
-    }
-    else
-    if((curl_info && (curl_info->features & CURL_VERSION_GSSNEGOTIATE)) &&
-       (*it == "gssnego" || *it == "negotiate"))
-    {
-      auth_type |= CURLAUTH_GSSNEGOTIATE;
-    }
-    else
-    {
-      ZYPP_THROW(MediaException(str::Format(_("Unsupported HTTP authentication method '%s'")) % *it));
-    }
-  }
-
-  return auth_type;
-}
-
-std::string CurlAuthData::auth_type_long2str(long auth_type)
-{
-  std::list<std::string> auth_list;
-
-  if(auth_type & CURLAUTH_GSSNEGOTIATE)
-    auth_list.push_back("negotiate");
-
-  if(auth_type & CURLAUTH_NTLM)
-    auth_list.push_back("ntlm");
-
-  if(auth_type & CURLAUTH_DIGEST)
-    auth_list.push_back("digest");
-
-  if(auth_type & CURLAUTH_BASIC)
-    auth_list.push_back("basic");
-
-  return str::join(auth_list, ",");
-}
-
-
-std::ostream & operator << (std::ostream & str, const AuthData & auth_data)
-{
-  auth_data.dumpOn(str);
-  return str;
-}
-
-std::ostream & operator << (std::ostream & str, const CurlAuthData & auth_data)
-{
-  auth_data.dumpOn(str);
-  return str;
-}
-
-
-  } // namespace media
-} // namespace zypp
index c15ab92..c78fe8c 100644 (file)
@@ -1,172 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MediaUserAuth.h
- * Convenience interface for handling authentication data of media user.
- */
-#ifndef ZYPP_MEDIA_USER_AUTH_H
-#define ZYPP_MEDIA_USER_AUTH_H
-
-#include <zypp/APIConfig.h>
-
-#include <zypp/Url.h>
-#include <zypp/base/PtrTypes.h>
-
-namespace zypp {
-  namespace media {
-
-///////////////////////////////////////////////////////////////////
-
-
-/**
- * Class for handling media authentication data. This is the most generic
- * class containing only username and password members.
- */
-class AuthData
-{
-public:
-  AuthData()
-  {}
-
-  AuthData(const Url & url);
-
-  AuthData(const std::string & username, const std::string & password)
-    : _username(username), _password(password), _lastChange(0)
-  {}
-
-  virtual ~AuthData() {};
-
-  /**
-   * Checks validity of authentication data.
-   * \return true if the object contains non-empty username and
-   *  non-empty password, false otherwise.
-   */
-  virtual bool valid() const;
-
-  void setUrl(const Url & url) { _url = url; }
-  void setUsername(const std::string & username) { _username = username; }
-  void setPassword(const std::string & password) { _password = password; }
-
-  Url url() const { return _url; }
-  std::string username() const { return _username; }
-  std::string password() const { return _password; }
-
-  /*!
-   * Returns the timestamp of the last change to the database this
-   * credential is stored in, or 0 if its not known.
-   */
-  time_t lastDatabaseUpdate () const;
-  void setLastDatabaseUpdate ( time_t time );
-
-  virtual std::ostream & dumpOn( std::ostream & str ) const;
-
-  virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
-
-private:
-  Url _url;
-  std::string _username;
-  std::string _password;
-  time_t _lastChange; //< timestamp of the last change to the database this credential is stored in
-};
-
-typedef shared_ptr<AuthData> AuthData_Ptr;
-
-/**
- * Curl HTTP authentication data.
- */
-class CurlAuthData : public AuthData {
-public:
-  /**
-   * Default constructor. Initializes username and password to empty strings
-   * and authetication type to CURLAUTH_NONE.
-   */
-  CurlAuthData();
-
-  CurlAuthData(const AuthData & authData);
-
-  CurlAuthData(std::string & username, std::string & password, std::string & auth_type)
-    : AuthData(username,password), _auth_type_str(auth_type)
-  {
-    _auth_type = auth_type_str2long(auth_type);
-  }
-
-  CurlAuthData(std::string & username, std::string & password, long auth_type)
-    : AuthData(username,password), _auth_type(auth_type)
-  {
-    _auth_type_str = auth_type_long2str(auth_type);
-  }
-
-  /**
-   * Checks validity of authentication data.
-   * \return true if the object contains non-empty username,
-   *  non-empty password, and specifies authentication type; false otherwise.
-   */
-  virtual bool valid() const;
-
-  /**
-   * Set HTTP authentication type(s) to use.
-   * \param comma separated list of HTTP authentication type names
-   */
-  void setAuthType(std::string auth_type)
-  {
-    _auth_type_str = auth_type; _auth_type = auth_type_str2long(auth_type);
-  }
-
-  /*
-   * Set HTTP authentication type(s) to use.
-   * \param HTTP authentication type as in long ORed form.
-   * \see curl.h for available auth types
-   */
-  void setAuthType(long auth_type)
-  {
-    _auth_type = auth_type;
-    _auth_type_str = auth_type_long2str(auth_type);
-  }
-
-  long authType() const { return _auth_type; }
-  std::string authTypeAsString() const { return _auth_type_str; }
-
-  std::string getUserPwd() const { return username() + ":" + password(); }
-
-
-  /**
-   * Converts a string of comma separated list of authetication type names
-   * into a long of ORed CURLAUTH_* identifiers.
-   * The method also automatically leaves out any auth types declared
-   * not supported by curl_version_info().
-   *
-   * \throws MediaException if an invalid authentication type name is
-   *         encountered.
-   */
-  static long auth_type_str2long( std::string & auth_type_str );
-  static long auth_type_str2long( const std::string &auth_type_str );
-
-  /**
-   * Converts a long of ORed CURLAUTH_* identifiers into a string of comma
-   * separated list of authentication type names.
-   */
-  static std::string auth_type_long2str(long auth_type);
-
-  virtual std::ostream & dumpOn( std::ostream & str ) const;
-
-private:
-  std::string _auth_type_str;
-  long _auth_type;
-};
-
-typedef shared_ptr<CurlAuthData> CurlAuthData_Ptr;
-
-std::ostream & operator << (std::ostream & str, const AuthData & auth_data);
-std::ostream & operator << (std::ostream & str, const CurlAuthData & auth_data);
-
-///////////////////////////////////////////////////////////////////
-
-  } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_USER_AUTH_H
+#include <zypp-media/auth/AuthData>
index 1c0ab04..712a5da 100644 (file)
@@ -1,88 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/MetaLinkParser.h
- *
-*/
-#ifndef ZYPP_MEDIA_METALINKPARSER_H
-#define ZYPP_MEDIA_METALINKPARSER_H
-
-#include <string>
-
-#include <zypp/base/Exception.h>
-#include <zypp/base/NonCopyable.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/media/MediaBlockList.h>
-#include <zypp/Url.h>
-#include <zypp/ByteArray.h>
-
-namespace zypp::media {
-
-struct ml_parsedata;
-
-struct MetalinkMirror {
-  int priority = 0;
-  int maxConnections = -1; //< How many connections can be opened to that mirror, -1 means no limit was defined.
-  Url url;
-};
-
-class MetaLinkParser : private zypp::base::NonCopyable {
-public:
-  MetaLinkParser();
-  ~MetaLinkParser();
-
-  /**
-   * parse a file consisting of metalink xml data
-   * \throws Exception
-   **/
-  void parse(const Pathname &filename);
-
-  /**
-   * parse an InputStream consisting of metalink xml data
-   * \throws Exception
-   **/
-  void parse(const InputStream &is);
-
-  /**
-   * parse a chunk of a file consisting of metalink xml data.
-   * \throws Exception
-   **/
-  void parseBytes(const char* bytes, size_t len);
-  /**
-   * tells the parser that all chunks are now processed
-   * \throws Exception
-   **/
-  void parseEnd();
-
-  /**
-   * return the download urls from the parsed metalink data
-   **/
-  std::vector<Url> getUrls() const;
-
-  /**
-   * return the mirrors from the parsed metalink data
-   */
-  const std::vector<MetalinkMirror> &getMirrors() const;
-
-  /**
-   * return the block list from the parsed metalink data
-   **/
-  MediaBlockList getBlockList() const;
-
-  const std::vector<UByteArray> &getZsyncBlockHashes() const;
-  const std::vector<UByteArray> &getSHA1BlockHashes() const;
-
-private:
-  struct ml_parsedata *pd;
-};
-
-UByteArray hexstr2bytes( std::string str );
-
-} // namespace zypp::media
-
-#endif // ZYPP_MEDIA_METALINKPARSER_H
+#include <zypp-curl/parser/MetaLinkParser>
index 70970df..abb69e9 100644 (file)
@@ -1,182 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/Mount.h
- *
-*/
-
-// -*- C++ -*-
-
-#ifndef ZYPP_MEDIA_MOUNT_H
-#define ZYPP_MEDIA_MOUNT_H
-
-#include <set>
-#include <map>
-#include <string>
-#include <iosfwd>
-
-#include <zypp/ExternalProgram.h>
-#include <zypp/KVMap.h>
-
-namespace zypp {
-  namespace media {
-
-
-    /**
-     * A "struct mntent" like mount entry structure,
-     * but using std::strings.
-     */
-    struct MountEntry
-    {
-        MountEntry(const std::string &source,
-                   const std::string &target,
-                   const std::string &fstype,
-                   const std::string &options,
-                   const int         dumpfreq = 0,
-                   const int         passnum  = 0)
-            : src(source)
-            , dir(target)
-            , type(fstype)
-            , opts(options)
-            , freq(dumpfreq)
-            , pass(passnum)
-        {}
-
-        std::string src;  //!< name of mounted file system
-        std::string dir;  //!< file system path prefix
-        std::string type; //!< filesystem / mount type
-        std::string opts; //!< mount options
-        int         freq; //!< dump frequency in days
-        int         pass; //!< pass number on parallel fsck
-    };
-
-    /** \relates MountEntry
-     * A vector of mount entries.
-     */
-    typedef std::vector<MountEntry> MountEntries;
-
-    /** \relates MountEntry Stream output */
-    std::ostream & operator<<( std::ostream & str, const MountEntry & obj );
-
-    /**
-     * @short Interface to the mount program
-     */
-    class Mount
-    {
-    public:
-
-        /**
-         * For passing additional environment variables
-         * to mount
-         **/
-        typedef ExternalProgram::Environment Environment;
-
-        /**
-         * Mount options. 'key' or 'key=value' pairs, separated by ','
-         **/
-        typedef KVMap<kvmap::KVMapBase::CharSep<'=',','> > Options;
-
-    public:
-
-        /**
-        * Create an new instance.
-        */
-        Mount();
-
-        /**
-        * Clean up.
-        */
-        ~Mount();
-
-        /**
-        * mount device
-        *
-        * @param source what to mount (e.g. /dev/hda3)
-        * @param target where to mount (e.g. /mnt)
-        * @param filesystem which filesystem to use (e.g. reiserfs) (-t parameter)
-        * @param options mount options (e.g. ro) (-o parameter)
-        * @param environment optinal environment to pass (e.g. PASSWD="sennah")
-        *
-        * \throws MediaException
-        *
-        */
-
-        void mount ( const std::string& source,
-                        const std::string& target,
-                        const std::string& filesystem,
-                        const std::string& options,
-                        const Environment& environment = Environment() );
-
-        /** umount device
-         *
-         * @param path device or mountpoint to umount
-        *
-        * \throws MediaException
-        *
-         * */
-        void umount (const std::string& path);
-
-    public:
-
-        /**
-        * Return mount entries from /etc/mtab or /etc/fstab file.
-        *
-        * @param mtab The name of the (mounted) file system description
-        *             file to read from. This file should be one /etc/mtab,
-        *             /etc/fstab or /proc/mounts. Default is to read
-        *             /proc/mounts and /etc/mtab in case is not a symlink
-        *             to /proc/mounts.
-        * @returns A vector with mount entries or empty vector if reading
-        *          or parsing of the mtab file(s) failed.
-        */
-        static MountEntries
-        getEntries(const std::string &mtab = "");
-
-    private:
-
-        /** The connection to the mount process.
-         * */
-        ExternalProgram *process;
-
-        /**
-         * Run mount with the specified arguments and handle stderr.
-         * @param argv Mount arguments
-         * @param environment Addittional environment to set
-         * @param stderr_disp How to handle stderr, merged with stdout by default
-         * */
-        void run( const char *const *argv, const Environment& environment,
-                  ExternalProgram::Stderr_Disposition stderr_disp =
-                  ExternalProgram::Stderr_To_Stdout);
-
-        void run( const char *const *argv,
-                  ExternalProgram::Stderr_Disposition stderr_disp =
-                  ExternalProgram::Stderr_To_Stdout) {
-          Environment notused;
-          run( argv, notused, stderr_disp );
-        }
-
-        /** Return the exit status of the process, closing the connection if
-         * not already done.
-         * */
-        int Status();
-
-        /** Forcably kill the process
-         * */
-        void Kill();
-
-
-        /** The exit code of the process, or -1 if not yet known.
-         * */
-        int exit_code;
-    };
-
-
-  } // namespace media
-} // namespace zypp
-
-#endif
+#include <zypp-media/Mount>
index fec492a..eecbe16 100644 (file)
@@ -1,66 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/ProxyInfo.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_H
-#define ZYPP_MEDIA_PROXYINFO_H
-
-#include <string>
-#include <list>
-
-#include <zypp/base/PtrTypes.h>
-
-namespace zypp {
-
-  class Url;
-
-  namespace media {
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : ProxyInfo
-    class ProxyInfo
-    {
-    public:
-      typedef intrusive_ptr<ProxyInfo> Ptr;
-      typedef intrusive_ptr<ProxyInfo> constPtr;
-      typedef std::list<std::string> NoProxyList;
-      typedef std::list<std::string>::const_iterator NoProxyIterator;
-
-      /** Implementation */
-      struct Impl;
-      typedef shared_ptr<Impl> ImplPtr;
-
-      /** Default Ctor: guess the best available implementation. */
-      ProxyInfo();
-      /** Ctor taking a specific implementation. */
-      ProxyInfo( ProxyInfo::ImplPtr pimpl_r );
-
-      bool enabled() const;
-      std::string proxy(const Url & url) const;
-      NoProxyList noProxy() const;
-      NoProxyIterator noProxyBegin() const;
-      NoProxyIterator noProxyEnd() const;
-
-      /** Return \c true if  \ref enabled and \a url_r does not match \ref noProxy. */
-      bool useProxyFor( const Url & url_r ) const;
-
-    private:
-      /** Pointer to implementation */
-      RW_pointer<Impl> _pimpl;
-    };
-
-
-///////////////////////////////////////////////////////////////////
-
-  } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_PROXYINFO_H
+#include <zypp-curl/ProxyInfo>
index a618d8a..b4cb739 100644 (file)
@@ -1,201 +1 @@
-
-#ifndef TRANSFER_SETTINGS_H_
-#define TRANSFER_SETTINGS_H_
-
-#include <string>
-#include <vector>
-#include <zypp/base/Flags.h>
-#include <zypp/base/PtrTypes.h>
-#include <zypp/Pathname.h>
-#include <zypp/Url.h>
-
-namespace zypp::proto {
-  class TransferSettings;
-}
-
-namespace zypp
-{
-  namespace media
-  {
-
-    /**
-     * Holds transfer setting
-     */
-    class TransferSettings
-    {
-    public:
-      /** Constructs a transfer program cmd line access. */
-      TransferSettings();
-
-      TransferSettings( const zypp::proto::TransferSettings &settings );
-
-      typedef std::vector<std::string> Headers;
-
-      /** reset the settings to the defaults */
-      void reset();
-
-
-      /** add a header, on the form "Foo: Bar" */
-      void addHeader( std::string && val_r );
-
-      /** returns a list of all added headers */
-      Headers headers() const;
-
-      /** sets the user agent ie: "Mozilla v3" */
-      void setUserAgentString( std::string && val_r );
-
-      /** user agent string */
-      std::string userAgentString() const;
-
-
-      /** sets the auth username */
-      void setUsername( std::string && val_r );
-
-      /** auth username */
-      std::string username() const;
-
-      /** sets the auth password */
-      void setPassword( std::string && val_r );
-
-      /** auth password */
-      std::string password() const;
-
-      /** returns the user and password as a user:pass string */
-      std::string userPassword() const;
-
-      /** sets anonymous authentication (ie: for ftp) */
-      void setAnonymousAuth();
-
-
-      /** whether the proxy is used or not */
-      void setProxyEnabled( bool enabled );
-
-      /** proxy is enabled */
-      bool proxyEnabled() const;
-
-
-      /** proxy to use if it is enabled */
-      void setProxy( std::string && val_r );
-
-      /** proxy host */
-      std::string proxy() const;
-
-
-      /** sets the proxy user */
-      void setProxyUsername( std::string && val_r );
-
-      /** proxy auth username */
-      std::string proxyUsername() const;
-
-      /** sets the proxy password */
-      void setProxyPassword( std::string && val_r );
-
-      /** proxy auth password */
-      std::string proxyPassword() const;
-
-      /** returns the proxy user and password as a user:pass string */
-      std::string proxyUserPassword() const;
-
-
-      /** set the connect timeout */
-      void setConnectTimeout( long t );
-
-      /** connection timeout */
-      long connectTimeout() const;
-
-
-      /** set the transfer timeout */
-      void setTimeout( long t );
-
-      /** transfer timeout */
-      long timeout() const;
-
-
-      /** Set maximum number of concurrent connections for a single transfer */
-      void setMaxConcurrentConnections(long v);
-
-      /** Maximum number of concurrent connections for a single transfer */
-      long maxConcurrentConnections() const;
-
-
-      /** Set minimum download speed (bytes per second) until the connection is dropped */
-      void setMinDownloadSpeed(long v);
-
-      /** Minimum download speed (bytes per second) until the connection is dropped */
-      long minDownloadSpeed() const;
-
-
-      /** Set max download speed (bytes per second) */
-      void setMaxDownloadSpeed(long v);
-
-      /** Maximum download speed (bytes per second) */
-      long maxDownloadSpeed() const;
-
-
-      /** Set maximum silent retries */
-      void setMaxSilentTries(long v);
-
-      /** Maximum silent retries */
-      long maxSilentTries() const;
-
-
-      /** Sets whether to verify host for ssl */
-      void setVerifyHostEnabled( bool enabled );
-
-      /** Whether to verify host for ssl */
-      bool verifyHostEnabled() const;
-
-
-      /** Sets whether to verify host for ssl */
-      void setVerifyPeerEnabled( bool enabled );
-
-      /** Whether to verify peer for ssl */
-      bool verifyPeerEnabled() const;
-
-
-      /** Sets the SSL certificate authorities path */
-      void setCertificateAuthoritiesPath( Pathname && val_r );
-
-      /** SSL certificate authorities path ( default: /etc/ssl/certs ) */
-      Pathname certificateAuthoritiesPath() const;
-
-
-      /** set the allowed authentication types */
-      void setAuthType( std::string && val_r );
-
-      /** get the allowed authentication types */
-      std::string authType() const;
-
-
-      /** set whether HEAD requests are allowed */
-      void setHeadRequestsAllowed(bool allowed);
-
-      /** whether HEAD requests are allowed */
-      bool headRequestsAllowed() const;
-
-
-      /** Sets the SSL client certificate file */
-      void setClientCertificatePath( Pathname && val_r );
-
-      /** SSL client certificate file */
-      Pathname clientCertificatePath() const;
-
-
-      /** Sets the SSL client key file */
-      void setClientKeyPath( Pathname && val_r );
-
-      /** SSL client key file */
-      Pathname clientKeyPath() const;
-
-      const zypp::proto::TransferSettings &protoData() const;
-      zypp::proto::TransferSettings &protoData();
-
-    protected:
-      class Impl;
-      RWCOW_pointer<Impl> _impl;
-    };
-
-  } // namespace media
-} // namespece zypp
-
-#endif
+#include <zypp-curl/TransferSettings>
index 8847bd1..6b650c7 100644 (file)
@@ -12,7 +12,7 @@
 #include <iostream>
 #include <zypp/base/Logger.h>
 #include <zypp/media/UrlResolverPlugin.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 #include <zypp/PluginScript.h>
 #include <zypp/ZConfig.h>
 
index ec5c540..3463dc6 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <zypp/base/Exception.h>
 #include <zypp/base/NonCopyable.h>
-#include <zypp/media/MediaBlockList.h>
+#include <zypp-curl/parser/MediaBlockList>
 #include <zypp/Url.h>
 
 namespace zypp {
index afe5dc5..fbf328c 100644 (file)
@@ -1,84 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfoImpl.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
-#define ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
-
-#include <string>
-#include <list>
-
-#include <zypp/Url.h>
-#include <zypp/base/String.h>
-#include <zypp/media/ProxyInfo.h>
-
-namespace zypp {
-  namespace media {
-
-    struct ProxyInfo::Impl
-    {
-      /** Ctor */
-      Impl()
-      {}
-
-      /** Dtor */
-      virtual ~Impl()
-      {}
-
-    public:
-      /**  */
-      virtual bool enabled() const = 0;
-      /**  */
-      virtual std::string proxy(const Url & url_r) const = 0;
-      /**  */
-      virtual ProxyInfo::NoProxyList noProxy() const = 0;
-      /**  */
-      virtual ProxyInfo::NoProxyIterator noProxyBegin() const = 0;
-      /**  */
-      virtual ProxyInfo::NoProxyIterator noProxyEnd() const = 0;
-
-      /** Return \c true if  \ref enabled and \a url_r does not match \ref noProxy. */
-      bool useProxyFor( const Url & url_r ) const
-      {
-        if ( ! enabled() || proxy( url_r ).empty() )
-          return false;
-
-        ProxyInfo::NoProxyList noproxy( noProxy() );
-        if ( noproxy.size() == 1 && noproxy.front() == "*" )
-          return false; // just an asterisk disables all.
-
-        // No proxy: Either an exact match, or the previous character
-        // is a '.', so host is within the same domain.
-        // A leading '.' in the pattern is ignored. Some implementations
-        // need '.foo.ba' to prevent 'foo.ba' from matching 'xfoo.ba'.
-        std::string host( str::toLower( url_r.getHost() ) );
-        for_( it, noproxy.begin(), noproxy.end() )
-        {
-          std::string pattern( str::toLower( (*it)[0] == '.' ? it->c_str() + 1 : it->c_str() ) );
-          if ( str::hasSuffix( host, pattern )
-               && ( host.size() == pattern.size()
-                    || host[host.size()-pattern.size()-1] == '.' ) )
-            return false;
-        }
-        return true;
-      }
-
-    public:
-      /** Default Impl: empty sets. */
-      static shared_ptr<Impl> _nullimpl;
-    };
-
-
-///////////////////////////////////////////////////////////////////
-
-  } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOIMPL_H
+#include <zypp-curl/proxyinfo/proxyinfoimpl.h>
index c623d3f..ddc5604 100644 (file)
@@ -1,57 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfoLibproxy.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
-#define ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
-
-#include <string>
-#include <map>
-
-#include <proxy.h>
-
-#include <zypp/base/DefaultIntegral.h>
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/proxyinfo/ProxyInfoImpl.h>
-
-namespace zypp {
-  namespace media {
-
-
-    class ProxyInfoLibproxy : public ProxyInfo::Impl
-    {
-    public:
-      ProxyInfoLibproxy();
-      /**  */
-      ~ProxyInfoLibproxy();
-      /**  */
-      bool enabled() const
-      { return _enabled; }
-      /**  */
-      std::string proxy(const Url & url_r) const;
-      /**  */
-      ProxyInfo::NoProxyList noProxy() const
-      { return _no_proxy; }
-      /**  */
-      virtual ProxyInfo::NoProxyIterator noProxyBegin() const;
-      /**  */
-      virtual ProxyInfo::NoProxyIterator noProxyEnd() const;
-    private:
-      DefaultIntegral<bool,false> _enabled;
-      ProxyInfo::NoProxyList _no_proxy;
-      pxProxyFactory *_factory;
-    };
-
-///////////////////////////////////////////////////////////////////
-
-  } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOLIBPROXY_H
+#include <zypp-curl/proxyinfo/ProxyInfoLibproxy>
index 563e3db..4d03dc0 100644 (file)
@@ -1,54 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfoSysconfig.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOSYSCONFIG_H
-#define ZYPP_MEDIA_PROXYINFO_PROXYINFOSYSCONFIG_H
-
-#include <string>
-#include <map>
-
-#include <zypp/base/Sysconfig.h>
-#include <zypp/base/DefaultIntegral.h>
-#include <zypp/media/ProxyInfo.h>
-#include <zypp/media/proxyinfo/ProxyInfoImpl.h>
-
-namespace zypp {
-  namespace media {
-
-
-    class ProxyInfoSysconfig : public ProxyInfo::Impl
-    {
-    public:
-      ProxyInfoSysconfig(const Pathname & path);
-      /**  */
-      bool enabled() const
-      { return _enabled; }
-      /**  */
-      std::string proxy(const Url & url_r) const;
-      /**  */
-      ProxyInfo::NoProxyList noProxy() const
-      { return _no_proxy; }
-      /**  */
-      virtual ProxyInfo::NoProxyIterator noProxyBegin() const;
-      /**  */
-      virtual ProxyInfo::NoProxyIterator noProxyEnd() const;
-    private:
-      DefaultIntegral<bool,false> _enabled;
-      ProxyInfo::NoProxyList _no_proxy;
-      std::map<std::string,std::string> _proxies;
-    };
-
-///////////////////////////////////////////////////////////////////
-
-  } // namespace media
-} // namespace zypp
-
-#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOSYSCONFIG_H
+#include <zypp-curl/proxyinfo/ProxyInfoSysconfig>
index 0366917..7d82aa7 100644 (file)
@@ -1,23 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file zypp/media/proxyinfo/ProxyInfos.h
- *
-*/
-#ifndef ZYPP_MEDIA_PROXYINFO_PROXYINFOS_H
-#define ZYPP_MEDIA_PROXYINFO_PROXYINFOS_H
-
-#include <string>
-#include <list>
-
-#include <zypp/media/proxyinfo/ProxyInfoSysconfig.h>
-#ifdef WITH_LIBPROXY_SUPPORT
-#include <zypp/media/proxyinfo/ProxyInfoLibproxy.h>
-#endif
-
-#endif // ZYPP_MEDIA_PROXYINFO_PROXYINFOS_H
+#include <zypp-curl/proxyinfo/proxyinfos.h>
index 5071a45..f053cae 100644 (file)
@@ -24,7 +24,7 @@
 #include <zypp/ExternalProgram.h>
 #include <zypp/base/Regex.h>
 #include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/target/rpm/librpmDb.h>
 
 #include <zypp/misc/CheckAccessDeleted.h>
index d5a5204..3b4567e 100644 (file)
@@ -127,7 +127,7 @@ namespace zypp::misc::testcase {
 
         } else if (node->equals( "trial" )) {
           if ( !setupDone ) {
-            if ( err ) *err = "Any trials must be preceeded by the setup!";
+            if ( err ) *err = "Any trials must be preceded by the setup!";
             return false;
           }
           TestcaseTrial trial;
index 5d9ce96..eb8d9b5 100644 (file)
@@ -252,7 +252,7 @@ namespace yamltest::detail {
         auto doc = YAML::LoadFile( fName );
         if ( !parseJobs( doc, target, err ) )
           return false;
-        MIL << "Including file " << fName << "was successfull" << std::endl;
+        MIL << "Including file " << fName << "was successful" << std::endl;
       } catch ( YAML::Exception &e ) {
         if ( err ) *err = e.what();
         return false;
index 35a3b1f..4844394 100644 (file)
  */
 #include <iostream>
 
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/base/IOStream.h>
 #include <zypp/base/Logger.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
 
 #include <zypp/parser/HistoryLogReader.h>
 
index 1268439..98b7100 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <zypp/base/PtrTypes.h>
 #include <zypp/base/Flags.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 #include <zypp/Pathname.h>
 
 #include <zypp/HistoryLogData.h>
index 2d7687a..036452f 100644 (file)
@@ -1,172 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/parser/IniDict.h
- *
-*/
-#ifndef ZYPP_PARSER_INIDICT_H
-#define ZYPP_PARSER_INIDICT_H
-
-#include <iosfwd>
-#include <map>
-#include <string>
-
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/Iterator.h>
-#include <zypp/base/Iterable.h>
-#include <zypp/parser/IniParser.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////
-  namespace parser
-  { /////////////////////////////////////////////////////////////////
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : IniDict
-    //
-    /**
-     * Parses a INI file and offers its structure as a
-     * dictionary.
-     *
-     */
-    class IniDict : public IniParser
-    {
-      friend std::ostream & operator<<( std::ostream & str, const IniDict & obj );
-    public:
-      typedef std::map<std::string, std::string> EntrySet;
-      typedef std::map<std::string, EntrySet> SectionSet;
-      typedef MapKVIteratorTraits<SectionSet>::Key_const_iterator section_const_iterator;
-      typedef EntrySet::const_iterator entry_const_iterator;
-
-      /**
-       * \name Section Iterators
-       * Iterate trough ini file sections
-       * \code
-       * for ( IniDict::section_const_iterator it = dict.sectionsBegin();
-       *       it != dict.sectionsEnd();
-       *       ++it )
-       * {
-       *   MIL << (*it) << endl;
-       * }
-       * \endcode
-       */
-       //@{
-      section_const_iterator sectionsBegin() const;
-      section_const_iterator sectionsEnd() const;
-      Iterable<section_const_iterator> sections() const;
-      //@}
-
-      /**
-       * \name Entries Iterators
-       * Iterate trough ini file entries in a section
-       * \code
-       * for ( IniDict::entry_const_iterator it = dict.entriesBegin("updates");
-       *       it != dict.entriesEnd("updates");
-       *       ++it )
-       * {
-       *   MIL << (*it).first << endl;
-       * }
-       * \endcode
-       */
-
-      //@{
-      entry_const_iterator entriesBegin(const std::string &section) const;
-      entry_const_iterator entriesEnd(const std::string &section) const;
-      Iterable<entry_const_iterator> entries(const std::string &section) const;
-      //@{
-
-      /**
-       * Creates a dictionary from a InputStream
-       * containing a ini structured file
-       */
-      IniDict( const InputStream &is,
-               const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
-
-      /**
-       * Creates a mepty dictionary
-       */
-      IniDict();
-
-      /** Dtor */
-      ~IniDict();
-
-      /**
-       * Fill a dictionary from a InputStream
-       * containing a ini structured file
-       */
-      void read( const InputStream &is,
-                 const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
-
-      /**
-       * \short add an entry
-       * \param section
-       * \param key
-       * \param value
-       */
-      void insertEntry( const std::string &section,
-                        const std::string &key,
-                        const std::string &value );
-
-      /**
-       * \short add an entry
-       * \param section
-       * \param key
-       * \param value
-       */
-      void deleteSection( const std::string &section );
-
-      /**
-       * \short True if there is a section with that name
-       * \param section Section Name
-       */
-      bool hasSection( const std::string &section ) const;
-
-      /**
-       * \short True if an entry exists in the section
-       * \param section Section name
-       * \param entry entry name
-       *
-       * \note If the given section does not exist, this will
-       * of course return false.
-       */
-      bool hasEntry( const std::string &section,
-                     const std::string &entry ) const;
-    public:
-
-      /** Called when a section is found. */
-      virtual void consume( const std::string &section );
-      /** Called when a key value is found. */
-      virtual void consume( const std::string &section,
-                            const std::string &key,
-                            const std::string &value );
-
-    private:
-      SectionSet _dict;
-      /**
-       * empty map used to simulate
-       * iteration in non existant
-       * sections
-       */
-      EntrySet _empty_map;
-    };
-    ///////////////////////////////////////////////////////////////////
-
-    /** \relates IniDict Stream output */
-    std::ostream & operator<<( std::ostream & str, const IniDict & obj );
-
-    /////////////////////////////////////////////////////////////////
-  } // namespace parser
-  ///////////////////////////////////////////////////////////////////
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PARSER_INIDICT_H
+#include <zypp-core/parser/IniDict>
index de7a00f..a8459c9 100644 (file)
@@ -1,96 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/parser/IniParser.h
- *
-*/
-#ifndef ZYPP_PARSER_INIPARSER_H
-#define ZYPP_PARSER_INIPARSER_H
-
-#include <iosfwd>
-#include <string>
-#include <list>
-
-#include <zypp/base/PtrTypes.h>
-#include <zypp/base/NonCopyable.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/ProgressData.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace parser
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-/// \class IniParser
-/// \brief Simple INI-file parser
-///
-/// Lines staring with \c ; or \c # are treated as comment. Section
-/// names are enclosed by <tt>[]</tt>. Key and value are separated by \c =.
-///
-/// Lines without \c = or with a key containing any of "<tt>,|\\/</tt>"
-/// or section lines without closing \c ] are considered garbage.
-///
-class IniParser : private base::NonCopyable
-{
-public:
-  /** Default ctor */
-  IniParser();
-  /** Dtor */
-  virtual ~IniParser();
-  /** Parse the stream.
-   * \throw ParseException on errors. Invoke \ref consume
-   * for each tag. \ref consume might throw other exceptions
-   * as well.
-  */
-  void parse( const InputStream & imput_r, const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() );
-
-public:
-  /** Called when start parsing. */
-  virtual void beginParse();
-  /** Called when a section is found. */
-  virtual void consume( const std::string &section );
-  /** Called when a key value is found. */
-  virtual void consume( const std::string &section, const std::string &key, const std::string &value );
-  /** Called when the parse is done. */
-  virtual void endParse();
-
-  /** Called whenever a garbage line is found.
-   *
-   * \throw ParseException if not overloaded.
-   *
-   * Derived parsers may overload this to examine the line
-   * and call this method to actually throw the exception.
-   *
-   * Used by some parsers to accept multi-line entires.
-   */
-  virtual void garbageLine( const std::string &section, const std::string &line );
-
-public:
-  /** Name of the current InputStream. */
-  const std::string & inputname() const
-  {
-    return _inputname;
-  }
-
-private:
-  std::string _inputname;
-  std::string _current_section;
-  int _line_nr;
-  //ProgressData _ticks;
-};
-
-/////////////////////////////////////////////////////////////////
-} // namespace parser
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PARSER_INIPARSER_H
+#include <zypp-core/parser/IniParser>
index 7a60729..1f22651 100644 (file)
@@ -1,53 +1 @@
-/*---------------------------------------------------------------------\
-|                          ____ _   __ __ ___                          |
-|                         |__  / \ / / . \ . \                         |
-|                           / / \ V /|  _/  _/                         |
-|                          / /__ | | | | | |                           |
-|                         /_____||_| |_| |_|                           |
-|                                                                      |
-\---------------------------------------------------------------------*/
-/** \file      zypp/parser/tagfile/ParseException.h
- *
-*/
-#ifndef ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
-#define ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
-
-#include <iosfwd>
-#include <string>
-
-#include <zypp/base/Exception.h>
-#include <zypp/base/UserRequestException.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-  ///////////////////////////////////////////////////////////////////
-  namespace parser
-  { /////////////////////////////////////////////////////////////////
-
-    ///////////////////////////////////////////////////////////////////
-    //
-    // CLASS NAME : ParseException
-    //
-    /** */
-    class ParseException : public Exception
-    {
-    public:
-      /** Default ctor */
-      ParseException();
-      /** Ctor */
-      ParseException( const std::string & msg_r );
-        /** Dtor */
-      virtual ~ParseException() throw();
-    protected:
-      virtual std::ostream & dumpOn( std::ostream & str ) const;
-    };
-    ///////////////////////////////////////////////////////////////////
-
-    /////////////////////////////////////////////////////////////////
-  } // namespace parser
-  ///////////////////////////////////////////////////////////////////
-  /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
+#include <zypp-core/parser/ParseException>
index eded4dd..945bb5f 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <zypp/base/PtrTypes.h>
 #include <zypp/base/Function.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 
 #include <zypp/Pathname.h>
 #include <zypp/IdString.h>
index ffb6127..04d2b56 100644 (file)
 #include <zypp/base/LogTools.h>
 #include <zypp/base/String.h>
 #include <zypp/base/StringV.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/UserRequestException>
 
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/parser/IniDict>
 #include <zypp/parser/RepoFileReader.h>
 
 using std::endl;
index b38c7b6..b1cd6ac 100644 (file)
@@ -15,9 +15,9 @@
 #include <iosfwd>
 
 #include <zypp/base/PtrTypes.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/RepoInfo.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
index f41e7e8..cd7fd79 100644 (file)
 #include <zypp/base/String.h>
 #include <zypp/base/Logger.h>
 #include <zypp/base/Gettext.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/DefaultIntegral>
 
 #include <zypp/Pathname.h>
 
 #include <zypp/parser/xml/Reader.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
 
 #include <zypp/RepoInfo.h>
 
index 2da9b3e..bf1bafc 100644 (file)
@@ -15,7 +15,7 @@
 #include <zypp/base/PtrTypes.h>
 #include <zypp/base/NonCopyable.h>
 #include <zypp/base/Function.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/Pathname.h>
 #include <zypp/Date.h>
 
index 2a54cd9..689a443 100644 (file)
 #include <zypp/base/Logger.h>
 #include <zypp/base/String.h>
 #include <zypp/base/Regex.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/UserRequestException>
 
-#include <zypp/parser/IniDict.h>
+#include <zypp-core/parser/IniDict>
 #include <zypp/parser/ServiceFileReader.h>
 #include <zypp/ServiceInfo.h>
 
index aa1ee64..542f6bd 100644 (file)
@@ -15,7 +15,7 @@
 #include <iosfwd>
 
 #include <zypp/base/PtrTypes.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 #include <zypp/Pathname.h>
 
 ///////////////////////////////////////////////////////////////////
index 3204585..03409ea 100644 (file)
@@ -15,8 +15,8 @@
 #include <zypp/base/LogTools.h>
 #include <zypp/base/String.h>
 #include <zypp/base/IOStream.h>
-#include <zypp/base/UserRequestException.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/base/UserRequestException>
+#include <zypp-core/parser/ParseException>
 
 #include <zypp/parser/susetags/ContentFileReader.h>
 #include <zypp/parser/susetags/RepoIndex.h>
index 45e0d98..8090a81 100644 (file)
@@ -17,9 +17,9 @@
 #include <zypp/base/PtrTypes.h>
 #include <zypp/base/NonCopyable.h>
 #include <zypp/base/Function.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
index db8e2ac..f993d6e 100644 (file)
@@ -16,8 +16,8 @@
 
 #include <zypp/base/Logger.h>
 #include <zypp/base/String.h>
-#include <zypp/base/DtorReset.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DtorReset>
+#include <zypp-core/base/DefaultIntegral>
 
 #include <zypp/parser/xml/ParseDef.h>
 #include <zypp/parser/xml/ParseDefException.h>
index 7867f49..c74453b 100644 (file)
@@ -16,7 +16,7 @@
 #include <zypp/base/Function.h>
 #include <zypp/base/Hash.h>
 #include <zypp/base/String.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 
 #include <zypp/parser/xml/Node.h>
 
index a73b9cb..dddcaee 100644 (file)
@@ -15,7 +15,7 @@
 #include <iosfwd>
 
 #include <zypp/base/NonCopyable.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/base/Function.h>
 
 #include <zypp/parser/xml/Node.h>
index fe4bfdb..b2ae1d2 100644 (file)
@@ -212,7 +212,7 @@ namespace zypp
     for ( const std::string & tag : keywords() ) {
       // Get keyhints on the fly:
       // gpg-pubkey-39db7c82-5847eb1f.asc?fpr=22C07BA534178CD02EFE22AAB88B2FD43DBDC284
-      // Fingerprint is explicitely mentioned or id/fpr can be derived from the filename
+      // Fingerprint is explicitly mentioned or id/fpr can be derived from the filename
       if ( tag.compare( 0,10,"gpg-pubkey" ) != 0 )
         continue;
 
index ee0f1b7..4d39a9e 100644 (file)
@@ -18,7 +18,7 @@
 #include <zypp/base/NonCopyable.h>
 #include <zypp/base/Function.h>
 
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 
 namespace zypp
 {
index 8cc8e28..6b63b9b 100644 (file)
@@ -52,6 +52,8 @@ private.archenum = "noarch"
             | "sparcv8"
             | "sparc"
             | "aarch64"
+            | "armv8hl"
+            | "armv8l"
             | "armv7tnhl"
             | "armv7thl"
             | "armv7nhl"
index 701ee56..4e1bc7e 100644 (file)
       <value>sparcv8</value>
       <value>sparc</value>
       <value>aarch64</value>
+      <value>armv8hl</value>
+      <value>armv8l</value>
       <value>armv7tnhl</value>
       <value>armv7thl</value>
       <value>armv7nhl</value>
index 02e90be..29e8acd 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <zypp/Url.h>
 #include <zypp/Pathname.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 #include <zypp/RepoStatus.h>
 #include <zypp/MediaSetAccess.h>
 #include <zypp/Fetcher.h>
index 134da07..e7014fc 100644 (file)
@@ -13,7 +13,7 @@
 #include <zypp/base/Function.h>
 
 #include "MediaInfoDownloader.h"
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 
 
 namespace zypp
index c67b8b6..aa18fa4 100644 (file)
@@ -13,9 +13,9 @@
 #include <zypp/Url.h>
 #include <zypp/Pathname.h>
 #include <zypp/Fetcher.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/MediaSetAccess.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 
 namespace zypp
 {
index d62f3b3..f3610ed 100644 (file)
@@ -107,7 +107,7 @@ namespace zypp
             break;
 
           default:
-            WAR << "Igore unknown attribute: " << it << endl;
+            WAR << "Ignore unknown attribute: " << it << endl;
         }
       }
 
index 8f2ab74..600088b 100644 (file)
@@ -15,7 +15,7 @@
 #include <iosfwd>
 #include <list>
 
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/Edition.h>
 #include <zypp/Arch.h>
 #include <zypp/Date.h>
index 4aebffd..571df41 100644 (file)
@@ -15,7 +15,7 @@
 #include <zypp/repo/PackageDelta.h>
 #include <zypp/base/Logger.h>
 #include <zypp/base/Gettext.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 #include <zypp/base/NonCopyable.h>
 #include <zypp/repo/PackageProvider.h>
 #include <zypp/repo/Applydeltarpm.h>
index 10cf5ac..696c98d 100644 (file)
@@ -11,8 +11,8 @@
 #include <zypp/base/Logger.h>
 #include <zypp/base/Gettext.h>
 #include <zypp/base/String.h>
-#include <zypp/base/InputStream.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/InputStream>
+#include <zypp-core/base/UserRequestException>
 
 #include <zypp/repo/PluginServices.h>
 #include <zypp/ServiceInfo.h>
index 35fb419..2ebe5c7 100644 (file)
@@ -13,7 +13,7 @@
 #include <iosfwd>
 
 #include <zypp/base/PtrTypes.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 #include <zypp/Pathname.h>
 
 ///////////////////////////////////////////////////////////////////
index f7e1f07..2597b7a 100644 (file)
@@ -16,7 +16,7 @@
 #include <string>
 
 #include <zypp/base/Exception.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 #include <zypp/RepoInfo.h>
 #include <zypp/ServiceInfo.h>
 
index 1720d1e..76d88c1 100644 (file)
@@ -14,7 +14,7 @@
 #include <vector>
 #include <time.h>
 #include <zypp/repo/RepoMirrorList.h>
-#include <zypp/media/MetaLinkParser.h>
+#include <zypp-curl/parser/MetaLinkParser>
 #include <zypp/MediaSetAccess.h>
 #include <zypp/base/LogTools.h>
 #include <zypp/ZConfig.h>
index 01c9570..fcb0664 100644 (file)
@@ -17,7 +17,7 @@
 #include <zypp/base/Gettext.h>
 #include <zypp/base/Logger.h>
 #include <zypp/base/String.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 #include <zypp/repo/RepoProvideFile.h>
 #include <zypp/ZYppCallbacks.h>
 #include <zypp/MediaSetAccess.h>
index 2f442e9..64441fd 100644 (file)
@@ -19,7 +19,7 @@
 #include <zypp/base/Functional.h>
 #include <zypp/RepoInfo.h>
 #include <zypp/ManagedFile.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/ProvideFilePolicy.h>
 
 ///////////////////////////////////////////////////////////////////
index 1a04a78..fc906d6 100644 (file)
@@ -3,7 +3,7 @@
 #include <zypp/base/Logger.h>
 #include <zypp/repo/ServiceRepos.h>
 #include <zypp/repo/RepoException.h>
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 #include <zypp/parser/RepoFileReader.h>
 #include <zypp/media/MediaManager.h>
 #include <zypp/parser/RepoindexFileReader.h>
index 71f6efe..73cd2c3 100644 (file)
@@ -11,7 +11,7 @@
 #define ZYPP_REPO_SERVICE_REPOS
 
 #include <zypp/base/NonCopyable.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 #include <zypp/ServiceInfo.h>
 #include <zypp/RepoInfo.h>
 
index 6573b32..c798ac9 100644 (file)
@@ -6,16 +6,16 @@
 #include <zypp/base/Gettext.h>
 #include <zypp/base/String.h>
 #include <zypp/base/Regex.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/MediaSetAccess.h>
 #include <zypp/Fetcher.h>
 #include <zypp/Locale.h>
 #include <zypp/ZConfig.h>
 #include <zypp/repo/MediaInfoDownloader.h>
 #include <zypp/repo/susetags/Downloader.h>
-#include <zypp/parser/ParseException.h>
+#include <zypp-core/parser/ParseException>
 #include <zypp/parser/susetags/RepoIndex.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 
 using namespace zypp::parser;
 using namespace zypp::parser::susetags;
index ab140d8..6417f63 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <zypp/Url.h>
 #include <zypp/Pathname.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 #include <zypp/RepoInfo.h>
 #include <zypp/RepoStatus.h>
 #include <zypp/MediaSetAccess.h>
index 90bbbf2..4b495a8 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "Downloader.h"
 #include <zypp/repo/MediaInfoDownloader.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 #include <zypp/parser/xml/Reader.h>
 #include <zypp/parser/yum/RepomdFileReader.h>
 
index 79c4a79..c5c0476 100644 (file)
@@ -13,9 +13,9 @@
 #include <zypp/Url.h>
 #include <zypp/Pathname.h>
 #include <zypp/Fetcher.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/MediaSetAccess.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 #include <zypp/RepoInfo.h>
 #include <zypp/RepoStatus.h>
 #include <zypp/repo/Downloader.h>
index ae34ae0..8d53174 100644 (file)
@@ -258,9 +258,9 @@ namespace zypp
         return str << "search nothing";
 
       if ( obj.attr() )
-        str << "seach " << obj.attr() << " in ";
+        str << "search " << obj.attr() << " in ";
       else
-        str << "seach ALL in ";
+        str << "search ALL in ";
 
       if ( obj.solvable() )
         return str << obj.solvable();
index 1da5469..28f7b95 100644 (file)
@@ -15,7 +15,7 @@
 #include <iosfwd>
 
 #include <zypp/base/PtrTypes.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 
 #include <zypp/sat/detail/PoolMember.h>
 #include <zypp/sat/SolvAttr.h>
index eb75fd4..a57d215 100644 (file)
@@ -24,7 +24,7 @@
 #include <zypp/sat/LookupAttr.h>
 
 #include <zypp/Repository.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/ZConfig.h>
 
 #include <zypp/ui/Selectable.h>
index e83598d..7f7706e 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <zypp/APIConfig.h>
 #include <zypp/base/PtrTypes.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/base/String.h>
 
 #include <zypp/sat/SolvableType.h>
index 524f903..7b2b4a2 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <zypp/sat/Solvable.h>
 #include <zypp/Repository.h>
-#include <zypp/OnMediaLocation.h>
+#include <zypp-core/OnMediaLocation>
 #include <zypp/ByteCount.h>
 #include <zypp/CheckSum.h>
 #include <zypp/CpeId.h>
index 6a22255..b7b3d67 100644 (file)
@@ -16,7 +16,7 @@ extern "C"
 #include <iostream>
 #include <zypp/base/LogTools.h>
 #include <zypp/base/SerialNumber.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 #include <zypp/base/NonCopyable.h>
 #include <zypp/base/Hash.h>
 
index f29cdb0..f0de309 100644 (file)
@@ -16,7 +16,7 @@
 #include <zypp/base/PtrTypes.h>
 #include <zypp/base/Flags.h>
 #include <zypp/base/Iterator.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 
 #include <zypp/sat/SolvIterMixin.h>
 #include <zypp/sat/Solvable.h>
index 17c4118..7129e2b 100644 (file)
@@ -18,8 +18,8 @@
 #include <zypp/base/Gettext.h>
 #include <zypp/base/Exception.h>
 #include <zypp/base/Measure.h>
-#include <zypp/base/WatchFile.h>
-#include <zypp/base/Sysconfig.h>
+#include <zypp-core/fs/WatchFile>
+#include <zypp-core/parser/Sysconfig>
 #include <zypp/base/IOStream.h>
 
 #include <zypp/ZConfig.h>
index 66ef265..1017a25 100644 (file)
@@ -1449,7 +1449,7 @@ SATResolver::problems ()
                           description = str::Format(_("install %1% although it has been retracted")) % s.asString();
                         } else if ( s.isPtf() ) {
                           // translator: %1% is a package name
-                          description = str::Format(_("allow to install the PTF %1%")) % s.asString();
+                          description = str::Format(_("allow installing the PTF %1%")) % s.asString();
                         } else {
                           // translator: %1% is a package name
                           description = str::Format(_("install %1% although it is blacklisted")) % s.asString();
index 5f26c4b..d4554d8 100644 (file)
@@ -87,10 +87,10 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable, pr
     ResolverFocus _focus;              // The resolvers general attitude
 
     bool _fixsystem:1;                 // repair errors in rpm dependency graph
-    bool _allowdowngrade:1;            // allow to downgrade installed solvable
-    bool _allownamechange:1;           // allow to change name of installed solvable
-    bool _allowarchchange:1;           // allow to change architecture of installed solvables
-    bool _allowvendorchange:1;         // allow to change vendor of installed solvables
+    bool _allowdowngrade:1;            // allow one to downgrade installed solvable
+    bool _allownamechange:1;           // allow one to change name of installed solvable
+    bool _allowarchchange:1;           // allow one to change architecture of installed solvables
+    bool _allowvendorchange:1;         // allow one to change vendor of installed solvables
     bool _allowuninstall:1;            // allow removal of installed solvables
     bool _updatesystem:1;              // update
     bool _noupdateprovide:1;           // true: update packages needs not to provide old package
@@ -99,10 +99,10 @@ class SATResolver : public base::ReferenceCounted, private base::NonCopyable, pr
     bool _ignorealreadyrecommended:1;  // true: ignore recommended packages that were already recommended by the installed packages
     bool _distupgrade:1;
     bool _distupgrade_removeunsupported:1;
-    bool _dup_allowdowngrade:1;                // dup mode: allow to downgrade installed solvable
-    bool _dup_allownamechange:1;       // dup mode: allow to change name of installed solvable
-    bool _dup_allowarchchange:1;       // dup mode: allow to change architecture of installed solvables
-    bool _dup_allowvendorchange:1;     // dup mode: allow to change vendor of installed solvables
+    bool _dup_allowdowngrade:1;                // dup mode: allow one to downgrade installed solvable
+    bool _dup_allownamechange:1;       // dup mode: allow one to change name of installed solvable
+    bool _dup_allowarchchange:1;       // dup mode: allow one to change architecture of installed solvables
+    bool _dup_allowvendorchange:1;     // dup mode: allow one to change vendor of installed solvables
     bool _solveSrcPackages:1;          // false: generate no job rule for source packages selected in the pool
     bool _cleandepsOnRemove:1;         // whether removing a package should also remove no longer needed requirements
 
index 7fcf119..514db44 100644 (file)
@@ -20,7 +20,7 @@
 #include <zypp/solver/detail/Testcase.h>
 #include <zypp/base/Logger.h>
 #include <zypp/base/LogControl.h>
-#include <zypp/base/GzStream.h>
+#include <zypp-core/base/GzStream>
 #include <zypp/base/String.h>
 #include <zypp/base/PtrTypes.h>
 #include <zypp/base/NonCopyable.h>
index 84c9136..a9efd15 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <zypp/base/Logger.h>
 #include <zypp/base/Exception.h>
-#include <zypp/base/DefaultIntegral.h>
+#include <zypp-core/base/DefaultIntegral>
 #include <zypp/Repository.h>
 #include <zypp/TmpPath.h>
 #include <zypp/target/CommitPackageCacheImpl.h>
index 0f2e390..a1fdafb 100644 (file)
@@ -47,6 +47,7 @@ namespace zypp
       public:
         Impl( const Pathname & root_r )
         : _root( root_r )
+        , _myJobReport { "cmdout", "%posttrans" }
         {}
 
         ~Impl()
@@ -91,18 +92,20 @@ namespace zypp
 
           Pathname noRootScriptDir( ZConfig::instance().update_scriptsPath() / tmpDir().basename() );
 
-          ProgressData scriptProgress( static_cast<ProgressData::value_type>(_scripts.size()) );
           callback::SendReport<ProgressReport> report;
+          ProgressData scriptProgress( static_cast<ProgressData::value_type>(_scripts.size()) );
           scriptProgress.sendTo( ProgressReportAdaptor( ProgressData::ReceiverFnc(), report ) );
+          str::Format fmtScriptProgress { _("Executing %%posttrans script '%1%'") };
 
           bool firstScript = true;
+          str::Format fmtScriptFailedMsg { "warning: %%posttrans(%1%) scriptlet failed, exit status %2%\n" }; // like rpm would report it (intentionally not translated and NL-terminated)
           while ( ! _scripts.empty() )
           {
             const auto &scriptPair = _scripts.front();
             const std::string & script = scriptPair.first;
             const std::string & pkgident( script.substr( 0, script.size()-6 ) );       // strip tmp file suffix
 
-            scriptProgress.name( str::Format(_("Executing %%posttrans script '%1%'")) % pkgident );
+            scriptProgress.name( fmtScriptProgress % pkgident );
 
             bool canContinue = true;
             if (firstScript)  {
@@ -117,7 +120,7 @@ namespace zypp
               msg << "Execution of %posttrans scripts cancelled";
               WAR << msg << endl;
               historylog.comment( msg, true /*timestamp*/);
-              JobReport::warning( msg );
+              _myJobReport.warning( msg );
               return false;
             }
 
@@ -134,38 +137,34 @@ namespace zypp
             };
             ExternalProgram prog( cmd, ExternalProgram::Stderr_To_Stdout, false, -1, true, _root );
 
+            // For now we continue to collect the lines and write the history file at the end.
+            // But JobReport lines are now sent immediately as they occur.
             str::Str collect;
             for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
             {
               DBG << line;
-              collect << "    " << line;
+              collect << line;
+              _myJobReport.info( line );
             }
 
             //script was executed, remove it from the list
             _scripts.pop_front();
 
             int ret = prog.close();
-            const std::string & scriptmsg( collect );
+            if ( ret != 0 )
+            {
+              const std::string & msg { fmtScriptFailedMsg % pkgident % ret };
+              WAR << msg;
+              collect << msg;
+              _myJobReport.info( msg ); // info!, as rpm would have reported it.
+            }
 
-            if ( ret != 0 || ! scriptmsg.empty() )
+            const std::string & scriptmsg( collect );
+            if ( ! scriptmsg.empty() )
             {
-              if ( ! scriptmsg.empty() )
-              {
-                str::Str msg;
-                msg << "Output of " << pkgident << " %posttrans script:\n" << scriptmsg;
-                historylog.comment( msg, true /*timestamp*/);
-                JobReport::UserData userData( "cmdout", "%posttrans" );
-                JobReport::info( msg, userData );
-              }
-
-              if ( ret != 0 )
-              {
-                str::Str msg;
-                msg << pkgident << " %posttrans script failed (returned " << ret << ")";
-                WAR << msg << endl;
-                historylog.comment( msg, true /*timestamp*/);
-                JobReport::warning( msg );
-              }
+              str::Str msg;
+              msg << "Output of " << pkgident << " %posttrans script:\n" << scriptmsg;
+              historylog.comment( msg, true /*timestamp*/);
             }
           }
 
@@ -194,7 +193,7 @@ namespace zypp
           }
 
           historylog.comment( msg, true /*timestamp*/);
-          JobReport::warning( msg );
+          _myJobReport.warning( msg );
 
           _scripts.clear();
         }
@@ -213,6 +212,8 @@ namespace zypp
         Pathname _root;
         std::list< std::pair< std::string, std::string > > _scripts;
         boost::scoped_ptr<filesystem::TmpDir> _ptrTmpdir;
+
+        UserDataJobReport _myJobReport; ///< JobReport with ContentType "cmdout/%posttrans"
     };
 
     /** \relates RpmPostTransCollector::Impl Stream output */
index 1776e18..e71429a 100644 (file)
@@ -25,7 +25,7 @@
 #include <zypp/base/Gettext.h>
 #include <zypp/base/IOStream.h>
 #include <zypp/base/Functional.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 #include <zypp/base/Json.h>
 
 #include <zypp/ZConfig.h>
@@ -76,6 +76,7 @@
 
 // include the error codes from zypp-rpm
 #include "tools/zypp-rpm/errorcodes.h"
+#include <rpm/rpmlog.h>
 
 #include <optional>
 
@@ -400,7 +401,7 @@ namespace zypp
 
       /** Execute script and report against report_r.
        * Return \c std::pair<bool,PatchScriptReport::Action> to indicate if
-       * execution was successfull (<tt>first = true</tt>), or the desired
+       * execution was successful (<tt>first = true</tt>), or the desired
        * \c PatchScriptReport::Action in case execution failed
        * (<tt>first = false</tt>).
        *
@@ -1366,7 +1367,7 @@ namespace zypp
       }
       else
       {
-        DBG << "dryRun: Not stroring non-package data." << endl;
+        DBG << "dryRun: Not storing non-package data." << endl;
       }
 
       ///////////////////////////////////////////////////////////////////
@@ -1851,6 +1852,54 @@ namespace zypp
       }
     }
 
+
+    ///////////////////////////////////////////////////////////////////
+    /// \brief Convenience SendReport<rpm::SingleTransReport> wrapper.
+    ///
+    /// Provide convenience methods to invoke a generic \ref report
+    /// supplied with the proper \ref UserData and \ref ContentType,
+    ///////////////////////////////////////////////////////////////////
+    struct SendSingleTransReport : public callback::SendReport<rpm::SingleTransReport>
+    {
+      /** Convenience to send a \ref contentLogline. */
+      void sendLogline( const std::string & line_r, ReportType::loglevel level_r = ReportType::loglevel::msg )
+      {
+        callback::UserData data { ReportType::contentLogline };
+        data.set( "line", std::cref(line_r) );
+        data.set( "level", level_r );
+        report( data );
+      }
+      /** Convenience to send a \ref contentLogline translating a rpm loglevel. */
+      void sendLoglineRpm( const std::string & line_r, unsigned rpmlevel_r )
+      {
+        auto u2rpmlevel = []( unsigned rpmlevel_r ) -> ReportType::loglevel {
+          switch ( rpmlevel_r ) {
+            case RPMLOG_EMERG:  [[fallthrough]];  // system is unusable
+            case RPMLOG_ALERT:  [[fallthrough]];  // action must be taken immediately
+            case RPMLOG_CRIT:                     // critical conditions
+              return ReportType::loglevel::crt;
+            case RPMLOG_ERR:                      // error conditions
+              return ReportType::loglevel::err;
+            case RPMLOG_WARNING:                  // warning conditions
+              return ReportType::loglevel::war;
+            default:            [[fallthrough]];
+            case RPMLOG_NOTICE: [[fallthrough]];  // normal but significant condition
+            case RPMLOG_INFO:                     // informational
+              return ReportType::loglevel::msg;
+            case RPMLOG_DEBUG:
+              return ReportType::loglevel::dbg;
+          }
+        };
+        sendLogline( line_r, u2rpmlevel( rpmlevel_r ) );
+      }
+
+    private:
+      void report( const callback::UserData & userData_r )
+      { (*this)->report( userData_r ); }
+    };
+
+    const callback::UserData::ContentType rpm::SingleTransReport::contentLogline { "zypp-rpm", "logline" };
+
     const callback::UserData::ContentType rpm::InstallResolvableReportSA::contentRpmout( "zypp-rpm","installpkgsa" );
     const callback::UserData::ContentType rpm::RemoveResolvableReportSA::contentRpmout( "zypp-rpm","removepkgsa" );
     const callback::UserData::ContentType rpm::CommitScriptReportSA::contentRpmout( "zypp-rpm","scriptsa" );
@@ -1860,6 +1909,9 @@ namespace zypp
     void TargetImpl::commitInSingleTransaction(const ZYppCommitPolicy &policy_r, CommitPackageCache &packageCache_r, ZYppCommitResult &result_r)
     {
       namespace zpt = zypp::proto::target;
+
+      SendSingleTransReport report; // active throughout the whole rpm transaction
+
       // steps: this is our todo-list
       ZYppCommitResult::TransactionStepList & steps( result_r.rTransactionStepList() );
       MIL << "TargetImpl::commit(<list>" << policy_r << ")" << steps.size() << endl;
@@ -1896,7 +1948,8 @@ namespace zypp
 
       bool abort = false;
       zypp::AutoDispose<std::unordered_map<int, ManagedFile>> locCache([]( std::unordered_map<int, ManagedFile> &data ){
-        for ( auto &[key, value] : data ) {
+        for ( auto &[_, value] : data ) {
+          (void)_; // unsused; for older g++ versions
           value.resetDispose();
         }
         data.clear();
@@ -2062,7 +2115,7 @@ namespace zypp
           } else if ( cleanupreport ) {
             sendLogRep( (*cleanupreport), rpm::CleanupPackageReportSA::contentRpmout );
           } else {
-            WAR << "Got rpm output without active report " << line << std::endl;
+            WAR << "Got rpm output without active report " << line; // no endl! - readLine does not trim
           }
 
           // remember rpm output
@@ -2086,13 +2139,13 @@ namespace zypp
 
             std::string l = scriptSource->readLine().asString();
             if( str::endsWith( l, endOfScriptTag ) ) {
-              DBG << "Received end of script tag" << std::endl;
               gotEndOfScript = true;
-              l = l.substr( 0, l.size() - endOfScriptTag.size() );
-              if ( l.size() == 0 )
+              std::string::size_type rawsize { l.size() - endOfScriptTag.size() };
+              if ( not rawsize )
                 return;
+              l = l.substr( 0, rawsize );
             }
-
+            L_DBG("zypp-rpm") << "[rpm> " << l; // no endl! - readLine does not trim
             sendRpmLineToReport( l );
           }
         };
@@ -2123,7 +2176,6 @@ namespace zypp
             assert(false);
           }
 
-          DBG << "Starting new report, setting gotEndOfScript to false" << std::endl;
           gotEndOfScript = false;
         };
 
@@ -2226,7 +2278,6 @@ namespace zypp
             ( *cleanupreport)->progress( 100 );
             ( *cleanupreport)->finish( rpm::CleanupPackageReportSA::NO_ERROR );
           }
-          DBG << "Report finalized" << std::endl;
           currentStepId = -1;
           lineno = 0;
           rpmmsg.clear();
@@ -2284,14 +2335,14 @@ namespace zypp
           // read the stdout and forward it to our log
           prog->stdoutDevice()->connectFunc( &zyppng::IODevice::sigReadyRead, [&](){
             while( prog->stdoutDevice()->canReadLine() ) {
-              MIL << "zypp-rpm stdout: " << prog->stdoutDevice()->readLine().asStringView() << std::endl;
+              L_DBG("zypp-rpm") << "<stdout> " << prog->stdoutDevice()->readLine().asStringView(); // no endl! - readLine does not trim
             }
           });
 
           // read the stderr and forward it to our log
           prog->stderrDevice()->connectFunc( &zyppng::IODevice::sigReadyRead, [&](){
             while( prog->stderrDevice()->canReadLine() ) {
-              MIL << "zypp-rpm stderr: " << prog->stderrDevice()->readLine().asStringView() << std::endl;
+              L_ERR("zypp-rpm") << "<stderr> " << prog->stderrDevice()->readLine().asStringView(); // no endl! - readLine does not trim
             }
           });
 
@@ -2380,9 +2431,10 @@ namespace zypp
                 ERR << "Failed to parse " << m.messagetypename() << " message from zypp-rpm." << std::endl;
                 continue;
               }
-
-              sendRpmLineToReport( p.line() );
-
+              ( p.level() >= RPMLOG_ERR     ? L_ERR("zypp-rpm")
+              : p.level() >= RPMLOG_WARNING ? L_WAR("zypp-rpm")
+              : L_DBG("zypp-rpm") ) << "[rpm " << p.level() << "> " << p.line(); // no endl! - readLine does not trim
+              report.sendLoglineRpm( p.line(), p.level() );
 
             } else if (  mName == "zypp.proto.target.PackageBegin" )  {
               finalizeCurrentReport();
@@ -2463,7 +2515,6 @@ namespace zypp
             } else if (  mName == "zypp.proto.target.ScriptFinished" )  {
 
               // we just read the message, we do not act on it because a ScriptError is reported after ScriptFinished
-              MIL << "Received" << mName << " from zypp-rpm" << std::endl;
 
             } else if (  mName == "zypp.proto.target.ScriptError" )  {
 
index 1d9bc3a..80ea768 100644 (file)
@@ -25,7 +25,7 @@ extern "C"
 #include <zypp/base/LogTools.h>
 #include <zypp/base/Gettext.h>
 #include <zypp/base/Exception.h>
-#include <zypp/base/UserRequestException.h>
+#include <zypp-core/base/UserRequestException>
 
 #include <zypp/sat/Queue.h>
 #include <zypp/sat/FileConflicts.h>
index 5ff18d1..5821dba 100644 (file)
@@ -23,7 +23,7 @@ extern "C"
 
 #include <zypp/base/LogTools.h>
 #include <zypp/base/IOStream.h>
-#include <zypp/base/InputStream.h>
+#include <zypp-core/base/InputStream>
 #include <zypp/AutoDispose.h>
 #include <zypp/PathInfo.h>
 
index ad4473c..f4c82fa 100644 (file)
@@ -261,7 +261,7 @@ unsigned BinHeader::int_list( tag tag_r, intList & lst_r ) const
         return lst_r.set( headerget.val(), headerget.cnt(), headerget.type() );
 
       default:
-        INT << "RPM_TAG MISSMATCH: RPM_INTxx_TYPE " << tag_r << " got type " << headerget.type() << endl;
+        INT << "RPM_TAG MISMATCH: RPM_INTxx_TYPE " << tag_r << " got type " << headerget.type() << endl;
       }
     }
   }
@@ -292,7 +292,7 @@ unsigned BinHeader::string_list( tag tag_r, stringList & lst_r ) const
         return lst_r.set( (char**)headerget.val(), headerget.cnt() );
 
       default:
-        INT << "RPM_TAG MISSMATCH: RPM_STRING_ARRAY_TYPE " << tag_r << " got type " << headerget.type() << endl;
+        INT << "RPM_TAG MISMATCH: RPM_STRING_ARRAY_TYPE " << tag_r << " got type " << headerget.type() << endl;
       }
     }
   }
@@ -335,7 +335,7 @@ int BinHeader::int_val( tag tag_r ) const
 #endif
 
       default:
-        INT << "RPM_TAG MISSMATCH: RPM_INTxx_TYPE " << tag_r << " got type " << headerget.type() << endl;
+        INT << "RPM_TAG MISMATCH: RPM_INTxx_TYPE " << tag_r << " got type " << headerget.type() << endl;
       }
     }
   }
@@ -388,7 +388,7 @@ std::string BinHeader::string_val( tag tag_r ) const
         return (char*)headerget.val();
 
      default:
-        INT << "RPM_TAG MISSMATCH: RPM_STRING_TYPE " << tag_r << " got type " << headerget.type() << endl;
+        INT << "RPM_TAG MISMATCH: RPM_STRING_TYPE " << tag_r << " got type " << headerget.type() << endl;
       }
     }
   }
index ca4e7b9..4dba886 100644 (file)
@@ -34,13 +34,13 @@ extern "C"
 #include <zypp/base/String.h>
 #include <zypp/base/Gettext.h>
 #include <zypp/base/LocaleGuard.h>
-#include <zypp/base/DtorReset.h>
+#include <zypp-core/base/DtorReset>
 
 #include <zypp/Date.h>
 #include <zypp/Pathname.h>
 #include <zypp/PathInfo.h>
 #include <zypp/PublicKey.h>
-#include <zypp/ProgressData.h>
+#include <zypp-core/ui/ProgressData>
 
 #include <zypp/target/rpm/RpmDb.h>
 #include <zypp/target/rpm/RpmCallbacks.h>
@@ -1710,7 +1710,7 @@ void RpmDb::doInstallPackage( const Pathname & filename, RpmInstFlags flags, cal
   cmdout.set( "lineno", lineno );
 
   // LEGACY: collect and forward additional rpm output in finish
-  std::string rpmmsg;                          // TODO: immediately forward lines via Callback::report rather than collecting
+  std::string rpmmsg;
   std::vector<std::string> configwarnings;     // TODO: immediately process lines rather than collecting
 
   while ( systemReadLine( line ) )
@@ -1766,7 +1766,10 @@ void RpmDb::doInstallPackage( const Pathname & filename, RpmInstFlags flags, cal
     sstr << "rpm output:" << endl << rpmmsg << endl;
     historylog.comment(sstr.str());
     // TranslatorExplanation the colon is followed by an error message
-    ZYPP_THROW(RpmSubprocessException(_("RPM failed: ") + (rpmmsg.empty() ? error_message : rpmmsg) ));
+    auto excpt { RpmSubprocessException(_("RPM failed: ") + error_message ) };
+    if ( not rpmmsg.empty() )
+      excpt.addHistory( rpmmsg );
+    ZYPP_THROW(std::move(excpt));
   }
   else if ( ! rpmmsg.empty() )
   {
@@ -1777,7 +1780,7 @@ void RpmDb::doInstallPackage( const Pathname & filename, RpmInstFlags flags, cal
     sstr << "Additional rpm output:" << endl << rpmmsg << endl;
     historylog.comment(sstr.str());
 
-    // report additional rpm output in finish
+    // report additional rpm output in finish (LEGACY! Lines are immediately reported as InstallResolvableReport::contentRpmout)
     // TranslatorExplanation Text is followed by a ':'  and the actual output.
     report->finishInfo(str::form( "%s:\n%s\n", _("Additional rpm output"),  rpmmsg.c_str() ));
   }
@@ -1890,7 +1893,7 @@ void RpmDb::doRemovePackage( const std::string & name_r, RpmInstFlags flags, cal
 
 
   // LEGACY: collect and forward additional rpm output in finish
-  std::string rpmmsg;          // TODO: immediately forward lines via Callback::report rather than collecting
+  std::string rpmmsg;
 
   // got no progress from command, so we fake it:
   // 5  - command started
@@ -1922,7 +1925,10 @@ void RpmDb::doRemovePackage( const std::string & name_r, RpmInstFlags flags, cal
     sstr << "rpm output:" << endl << rpmmsg << endl;
     historylog.comment(sstr.str());
     // TranslatorExplanation the colon is followed by an error message
-    ZYPP_THROW(RpmSubprocessException(_("RPM failed: ") + (rpmmsg.empty() ? error_message: rpmmsg) ));
+    auto excpt { RpmSubprocessException(_("RPM failed: ") + error_message ) };
+    if ( not rpmmsg.empty() )
+      excpt.addHistory( rpmmsg );
+    ZYPP_THROW(std::move(excpt));
   }
   else if ( ! rpmmsg.empty() )
   {
@@ -1933,7 +1939,7 @@ void RpmDb::doRemovePackage( const std::string & name_r, RpmInstFlags flags, cal
     sstr << "Additional rpm output:" << endl << rpmmsg << endl;
     historylog.comment(sstr.str());
 
-    // report additional rpm output in finish
+    // report additional rpm output in finish (LEGACY! Lines are immediately reported as RemoveResolvableReport::contentRpmout)
     // TranslatorExplanation Text is followed by a ':'  and the actual output.
     report->finishInfo(str::form( "%s:\n%s\n", _("Additional rpm output"),  rpmmsg.c_str() ));
   }
index 209f2e9..7fbd87a 100644 (file)
@@ -1,62 +1,18 @@
 SET( zyppng_media_SRCS
   media/medianetwork.cc
   media/medianetworkserver.cc
-  media/network/downloader.cc
-  media/network/downloadspec.cc
-  media/network/mirrorcontrol.cc
-  media/network/networkrequestdispatcher.cc
-  media/network/networkrequesterror.cc
-  media/network/request.cc
 )
 
 SET( zyppng_media_HEADERS
   media/MediaNetwork
   media/medianetwork.h
-  media/network/AuthData
-  media/network/authdata.h
-  media/network/downloader.h
-  media/network/downloadspec.h
-  media/network/networkrequestdispatcher.h
-  media/network/networkrequesterror.h
-  media/network/request.h
-  media/network/transfersettings.h
-  media/network/TransferSettings
 )
 
 SET( zyppng_media_private_HEADERS
   media/private/medianetworkserver_p.h
-  media/network/private/downloader_p.h
-  media/network/private/mediadebug_p.h
-  media/network/private/mirrorcontrol_p.h
-  media/network/private/networkrequestdispatcher_p.h
-  media/network/private/networkrequesterror_p.h
-  media/network/private/request_p.h
-  media/network/private/downloaderstates/base_p.h
-  media/network/private/downloaderstates/basicdownloader_p.h
-  media/network/private/downloaderstates/detectmeta_p.h
-  media/network/private/downloaderstates/final_p.h
-  media/network/private/downloaderstates/initial_p.h
-  media/network/private/downloaderstates/metalinkinfo_p.h
-  media/network/private/downloaderstates/metalink_p.h
-  media/network/private/downloaderstates/mirrorhandling_p.h
-  media/network/private/downloaderstates/normal_p.h
-  media/network/private/downloaderstates/preparemulti_p.h
-  media/network/private/downloaderstates/rangedownloader_p.h
-  media/network/private/downloaderstates/zck_p.h
 )
 
 SET( zyppng_media_private_SOURCES
-  media/network/private/downloaderstates/basicdownloader_p.cc
-  media/network/private/downloaderstates/detectmeta_p.cc
-  media/network/private/downloaderstates/final_p.cc
-  media/network/private/downloaderstates/initial_p.cc
-  media/network/private/downloaderstates/metalinkinfo_p.cc
-  media/network/private/downloaderstates/metalink_p.cc
-  media/network/private/downloaderstates/mirrorhandling_p.cc
-  media/network/private/downloaderstates/normal_p.cc
-  media/network/private/downloaderstates/preparemulti_p.cc
-  media/network/private/downloaderstates/rangedownloader_p.cc
-  media/network/private/downloaderstates/zck_p.cc
 )
 
 SET( zyppng_appcode_HEADERS
index 123d8e7..0e7bf2d 100644 (file)
@@ -1,6 +1,6 @@
 #include "context.h"
 #include <zypp-core/zyppng/base/EventLoop>
-#include <zypp/zyppng/media/network/private/mirrorcontrol_p.h>
+#include <zypp-curl/ng/network/private/mirrorcontrol_p.h>
 
 namespace zyppng {
 
index 011ca5e..7816835 100644 (file)
@@ -9,25 +9,23 @@
 #include "medianetwork.h"
 #include "private/medianetworkserver_p.h"
 
-#include <zypp/media/MediaException.h>
+#include <zypp-media/MediaException>
 #include <zypp-core/zyppng/base/private/linuxhelpers_p.h>
 #include <zypp-core/zyppng/base/EventLoop>
 #include <zypp-core/zyppng/base/AutoDisconnect>
 #include <zypp-core/zyppng/io/SockAddr>
-#include <zypp/zyppng/media/network/downloadspec.h>
+#include <zypp-curl/ng/network/DownloadSpec>
 
-#include <zypp/zyppng/media/network/networkrequestdispatcher.h>
-#include <zypp/zyppng/media/network/networkrequesterror.h>
-#include <zypp/zyppng/media/network/AuthData>
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/NetworkRequestDispatcher>
+#include <zypp-curl/ng/network/NetworkRequestError>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
 #include <zypp-core/zyppng/base/EventDispatcher>
 #include <zypp-core/zyppng/base/AbstractEventSource>
 #include <zypp-core/zyppng/rpc/rpc.h>
 
-#include <zypp/media/CurlHelper.h>
-#include <zypp/media/MediaUserAuth.h>
-#include <zypp/media/MediaException.h>
-#include <zypp/media/CredentialManager.h>
+#include <zypp-curl/private/curlhelper_p.h>
+#include <zypp-media/MediaException>
+#include <zypp-media/auth/CredentialManager>
 #include <zypp/ZConfig.h>
 #include <zypp/ZYppCallbacks.h>
 #include <zypp/base/String.h>
index 1c7ca61..d86796a 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <zypp/media/MediaNetworkCommonHandler.h>
 #include <zypp-core/zyppng/core/Url>
-#include <zypp/zyppng/media/network/AuthData>
+#include <zypp-curl/ng/network/AuthData>
 #include <zypp-proto/envelope.pb.h>
 #include <zypp-proto/messages.pb.h>
 #include <zypp-core/zyppng/io/private/iobuffer_p.h>
index ebe657c..1612f4d 100644 (file)
@@ -7,9 +7,9 @@
 |                                                                      |
 ----------------------------------------------------------------------*/
 #include "private/medianetworkserver_p.h"
-#include <zypp/zyppng/media/network/downloader.h>
-#include <zypp/zyppng/media/network/downloadspec.h>
-#include <zypp/zyppng/media/network/private/mirrorcontrol_p.h>
+#include <zypp-curl/ng/network/Downloader>
+#include <zypp-curl/ng/network/DownloadSpec>
+#include <zypp-curl/ng/network/private/mirrorcontrol_p.h>
 #include <zypp-core/zyppng/base/private/threaddata_p.h>
 #include <zypp-core/zyppng/base/private/linuxhelpers_p.h>
 #include <zypp-core/zyppng/base/EventLoop>
 #include <zypp-core/zyppng/base/SocketNotifier>
 #include <zypp-core/zyppng/rpc/rpc.h>
 
-#include <zypp/media/TransferSettings.h>
+#include <zypp-curl/TransferSettings>
 #include <zypp/PathInfo.h>
 
 #include <zypp-proto/envelope.pb.h>
 #include <zypp-proto/messages.pb.h>
 
-#include <zypp/zyppng/media/network/private/mediadebug_p.h>
+#include <zypp-curl/ng/network/private/mediadebug_p.h>
+#include <zypp/Target.h>
+#include <zypp/ZConfig.h>
 
 #include <algorithm>
 #include <csignal>
 #undef ZYPP_BASE_LOGGER_LOGGROUP
 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::MediaNetworkServer"
 
+namespace internal {
+  /**
+   * initialized only once, this gets the agent string
+   * which also includes the curl version
+   *
+   * Defined in MediaCurl.cc
+   */
+  const char * agentString();
+}
+
 namespace zyppng {
 
   using HeaderSizeType = zyppng::rpc::HeaderSizeType;
@@ -38,6 +50,16 @@ namespace zyppng {
   MediaNetworkServer::MediaNetworkServer( )
     : _downloadManager( std::make_shared<Downloader>( MirrorControl::create() ) )
   {
+    _downloadManager->setCredManagerOptions( zypp::media::CredManagerOptions( zypp::ZConfig::instance().repoManagerRoot()) );
+    auto dispatcher = _downloadManager->requestDispatcher();
+    if ( dispatcher ) {
+      dispatcher->setAgentString( ::internal::agentString() );
+      dispatcher->setHostSpecificHeader("download.opensuse.org", "X-ZYpp-AnonymousId", zypp::Target::anonymousUniqueId( zypp::Pathname()/*guess root*/ ) );
+      dispatcher->setHostSpecificHeader("download.opensuse.org", "X-ZYpp-DistributionFlavor", zypp::Target::distributionFlavor( zypp::Pathname()/*guess root*/ ) );
+    } else {
+      // this branch should never be executed
+      ERR << "Unable to initialize user agent string and zypp http headers." << std::endl;
+    }
   }
 
   void MediaNetworkServer::listen( const std::string &sockPath )