backup of YUM*Impl skeletons
authorJiri Srain <jsrain@suse.cz>
Thu, 24 Nov 2005 16:39:31 +0000 (16:39 +0000)
committerJiri Srain <jsrain@suse.cz>
Thu, 24 Nov 2005 16:39:31 +0000 (16:39 +0000)
13 files changed:
devel/devel.jsrain/yum/YUMParser.test/006-patch-correct.test.xml.ref
zypp/detail/PackageImplIf.h
zypp/source/yum/Makefile.am
zypp/source/yum/YUMMessageImpl.cc
zypp/source/yum/YUMMessageImpl.h
zypp/source/yum/YUMPackageImpl.cc
zypp/source/yum/YUMPackageImpl.h
zypp/source/yum/YUMPatchImpl.cc
zypp/source/yum/YUMPatchImpl.h
zypp/source/yum/YUMScriptImpl.cc
zypp/source/yum/YUMScriptImpl.h
zypp/source/yum/YUMSource.cc
zypp/source/yum/YUMSource.h

index 03daaf3..7ff1d66 100644 (file)
@@ -34,6 +34,52 @@ namespace zypp
     {
     public:
       typedef Package ResType;
+#if 0
+      class CheckSum
+      {
+      public:
+        CheckSum(std::string type, bool pkgid, std::string checksum) {
+          _type = type; _pkgid = pkgid; _checksum = checksum;
+        }
+        std::string type() { return _type; }
+        bool pkgid() { return _pkgid; }
+        std::string checksum() { return _checksum; }
+      private:
+        std::string _type;
+        bool _pkgid;
+        std::string _checksum;
+      };
+      /**
+      * @short Holds data about how much space will be needed per directory
+      **/
+      class DirSize {
+      public:
+        DirSize();
+        DirSize(const std::string& path,
+                const std::string& size,
+                const std::string& fileCount)
+       : path(path), sizeKByte(size), fileCount(fileCount)
+       {}
+        const std::string path;
+        const std::string sizeKByte;
+        const std::string fileCount;
+      };
+    
+      /**
+       * @short Holds Data about file and file type
+       *  (directory, plain)
+       **/
+      class FileData {
+      public:
+        std::string name;
+        std::string type;
+        FileData();
+        FileData(const std::string &name,
+                 const std::string &type)
+       : name(name), type(type)
+       {}
+      };
+#endif
 
     public:
       /** \name Rpm Package Attributes. */
@@ -62,21 +108,21 @@ namespace zypp
       /** */
       virtual std::string os() const PURE_VIRTUAL;
       /** */
-      virtual std::list<std::string> prein() const PURE_VIRTUAL;
+      virtual Text prein() const PURE_VIRTUAL;
       /** */
-      virtual std::list<std::string> postin() const PURE_VIRTUAL;
+      virtual Text postin() const PURE_VIRTUAL;
       /** */
-      virtual std::list<std::string> preun() const PURE_VIRTUAL;
+      virtual Text preun() const PURE_VIRTUAL;
       /** */
-      virtual std::list<std::string> postun() const PURE_VIRTUAL;
+      virtual Text postun() const PURE_VIRTUAL;
       /** */
       virtual FSize sourcesize() const PURE_VIRTUAL;
       /** */
       virtual FSize archivesize() const PURE_VIRTUAL;
       /** */
-      virtual std::list<std::string> authors() const PURE_VIRTUAL;
+      virtual Text authors() const PURE_VIRTUAL;
       /** */
-      virtual std::list<std::string> filenames() const PURE_VIRTUAL;
+      virtual Text filenames() const PURE_VIRTUAL;
       //@}
 
       /** \name Additional Package Attributes.
index deea0cf..d5e2396 100644 (file)
@@ -22,6 +22,6 @@ lib@PACKAGE@_source_yum_la_SOURCES =  \
        YUMScriptImpl.cc                \
        YUMMessageImpl.cc               \
        YUMPackageImpl.cc               \
-       YUMPatchImpl.cc
+       YUMPatchImpl.cc 
 
 ## ##################################################
index 3a5c7e1..263596e 100644 (file)
@@ -30,14 +30,48 @@ namespace zypp
       ///////////////////////////////////////////////////////////////////
 
       /** Default ctor
-       * \bug CANT BE CONSTUCTED THAT WAY ANYMORE
       */
       YUMMessageImpl::YUMMessageImpl(
        const zypp::parser::yum::YUMPatchMessage & parsed
       )
       {
        _text = parsed.text;
+       _type = parsed.type;
       }
+      /** Get the text of the message */
+      std::string YUMMessageImpl::text() const {
+       return _text;
+      }
+      /** Get the type of the message (YesNo / OK) */
+      std::string YUMMessageImpl::type() const {
+       return _type;
+      }
+      Label YUMMessageImpl::summary() const
+      { return ResObjectImplIf::summary(); }
+
+      Text YUMMessageImpl::description() const
+      { return ResObjectImplIf::description(); }
+
+      Text YUMMessageImpl::insnotify() const
+      { return ResObjectImplIf::insnotify(); }
+
+      Text YUMMessageImpl::delnotify() const
+      { return ResObjectImplIf::delnotify(); }
+
+      FSize YUMMessageImpl::size() const
+      { return ResObjectImplIf::size(); }
+
+      bool YUMMessageImpl::providesSources() const
+      { return ResObjectImplIf::providesSources(); }
+
+      Label YUMMessageImpl::instSrcLabel() const
+      { return ResObjectImplIf::instSrcLabel(); }
+
+      Vendor YUMMessageImpl::instSrcVendor() const
+      { return ResObjectImplIf::instSrcVendor(); }
+
+
+
     } // namespace yum
     /////////////////////////////////////////////////////////////////
   } // namespace source
index 598d660..865ea8e 100644 (file)
@@ -30,11 +30,38 @@ namespace zypp
       //
       /** Class representing a message
       */
-      class YUMMessageImpl : public detail::MessageImpl
+      class YUMMessageImpl : public detail::MessageImplIf
       {
       public:
         /** Default ctor */
         YUMMessageImpl( const zypp::parser::yum::YUMPatchMessage & parsed );
+       /** Get the text of the message */
+       virtual std::string text() const;
+       /** Get the type of the message (YesNo / OK) */
+       virtual std::string type() const;
+       /** */
+       virtual Label summary() const;
+       /** */
+       virtual Text description() const;
+       /** */
+       virtual Text insnotify() const;
+       /** */
+       virtual Text delnotify() const;
+       /** */
+       virtual FSize size() const;
+       /** */
+       virtual bool providesSources() const;
+       /** */
+       virtual Label instSrcLabel() const;
+       /** */
+       virtual Vendor instSrcVendor() const;
+
+
+      protected:
+       /** The text of the message */
+       std::string _text;
+       /** The type of the message (YesNo / OK) */
+       std::string _type;
       };
       ///////////////////////////////////////////////////////////////////
     } // namespace yum
index fff2b1e..b19ba5f 100644 (file)
@@ -11,6 +11,7 @@
 */
 
 #include "zypp/source/yum/YUMPackageImpl.h"
+#include "zypp/base/String.h"
 
 using namespace std;
 using namespace zypp::detail;
@@ -30,41 +31,71 @@ namespace zypp
       ///////////////////////////////////////////////////////////////////
 
       /** Default ctor
-       * \bug CANT BE CONSTUCTED THAT WAY ANYMORE
       */
       YUMPackageImpl::YUMPackageImpl(
+       const zypp::parser::yum::YUMPrimaryData & parsed
+      )
+#if 0
+      : _size_package(strtol(parsed.sizePackage.c_str(), 0, 10)),
+       _size_archive(strtol(parsed.sizeArchive.c_str(), 0, 10)),
+       _size_installed(strtol(parsed.sizeInstalled.c_str(), 0, 10)),
+       _authors(parsed.authors),
+       _keywords(parsed.keywords),
+       _packager(parsed.packager),
+       _url(parsed.url),
+       _buildhost(parsed.buildhost),
+       _vendor(parsed.vendor),
+       _group(parsed.group),
+       _license(parsed.license),
+       _type(parsed.type),
+       _sourcepkg(parsed.sourcerpm),
+       _checksum(parsed.checksumType,
+                 string::toLower(parsed.checksumPkgid) == "yes",
+                 parsed.checksum),
+       _media(parsed.media),
+       _time_file(strtol(parsed.timeFile.c_str(), 0, 10)),
+       _time_build(strtol(parsed.timeBuild.c_str(), 0, 10)),
+       _location(parsed.location),
+       _files(parsed.files),
+       _dir_sizes(parsed.dirSizes),
+       _install_only(parsed.installOnly)
+#endif
+      {
+      }
+      YUMPackageImpl::YUMPackageImpl(
        const zypp::parser::yum::YUMPatchPackage & parsed
       )
+#if 0
+      : _size_package( strtol(parsed.sizePackage.c_str(), 0, 10)),
+       _size_archive( strtol(parsed.sizeArchive.c_str(), 0, 10)),
+       _size_installed( strtol(parsed.sizeInstalled.c_str(), 0, 10)),
+       _authors( parsed.authors),
+       _keywords( parsed.keywords),
+       _packager( parsed.packager),
+       _url( parsed.url),
+       _buildhost( parsed.buildhost),
+       _vendor( parsed.vendor),
+       _group( parsed.group),
+       _license( parsed.license),
+       _type( parsed.type),
+       _sourcepkg( parsed.sourcerpm),
+       _checksum(parsed.checksumType,
+                 string::toLower(parsed.checksumPkgid) == "yes",
+                 parsed.checksum),
+       _media(parsed.media),
+       _time_file(strtol(parsed.timeFile.c_str(), 0, 10)),
+       _time_build(strtol(parsed.timeBuild.c_str(), 0, 10)),
+       _location(parsed.location),
+       _files(parsed.files),
+       _dir_sizes(parsed.dirSizes),
+       _install_only(parsed.installOnly)
+#endif
       {
+       
 /*
-    std::string type;
-    std::string checksumType;
-    std::string checksumPkgid;
-    std::string checksum;
     std::string summary;
     std::string description;
-    std::string packager;
-    std::string url;
-    std::string timeFile;
-    std::string timeBuild;
-    std::string sizePackage;
-    std::string sizeInstalled;
-    std::string sizeArchive;
-    std::string location;
-    std::string license;
-    std::string vendor;
-    std::string group;
-    std::string buildhost;
-    std::string sourcerpm;
-    std::string headerStart;
-    std::string headerEnd;
-    std::list<FileData> files;
     // SuSE specific data
-    std::list<std::string> authors;
-    std::list<std::string> keywords;
-    std::string  media;
-    std::list<YUMDirSize> dirSizes;
-    bool installOnly;
     // Change Log
     std::list<ChangelogEntry> changelog;
     // Package Files
@@ -91,14 +122,241 @@ namespace zypp
       std::string buildtime;
       YUMBaseVersion baseVersion;
     } deltaRpm;
+*/
+      }
 
 
+      /** Package summary */
+      Label YUMPackageImpl::summary() const
+      { }
+      /** Package description */
+      Text YUMPackageImpl::description() const
+      { }
+      Text YUMPackageImpl::insnotify() const
+      { }
+      Text YUMPackageImpl::delnotify() const
+      { }
+      FSize YUMPackageImpl::size() const
+      { }
+      bool YUMPackageImpl::providesSources() const
+      { }
+      Label YUMPackageImpl::instSrcLabel() const
+      { }
+      Vendor YUMPackageImpl::instSrcVendor() const
+      { }
+      /** */
+      Date YUMPackageImpl::buildtime() const
+      { }
+      /** */
+      std::string YUMPackageImpl::buildhost() const
+      { }
+      /** */
+      Date YUMPackageImpl::installtime() const
+      { }
+      /** */
+      std::string YUMPackageImpl::distribution() const
+      { }
+      /** */
+      Vendor YUMPackageImpl::vendor() const
+      { }
+      /** */
+      Label YUMPackageImpl::license() const
+      { }
+      /** */
+      std::string YUMPackageImpl::packager() const
+      { }
+      /** */
+      PackageGroup YUMPackageImpl::group() const
+      { }
+      /** */
+      Text YUMPackageImpl::changelog() const
+      { }
+      /** Don't ship it as class Url, because it might be
+       * in fact anything but a legal Url. */
+      std::string YUMPackageImpl::url() const
+      { }
+      /** */
+      std::string YUMPackageImpl::os() const
+      { }
+      /** */
+      Text YUMPackageImpl::prein() const
+      { }
+      /** */
+      Text YUMPackageImpl::postin() const
+      { }
+      /** */
+      Text YUMPackageImpl::preun() const
+      { }
+      /** */
+      Text YUMPackageImpl::postun() const
+      { }
+      /** */
+      FSize YUMPackageImpl::sourcesize() const
+      { }
+      /** */
+      FSize YUMPackageImpl::archivesize() const
+      { }
+      /** */
+      Text YUMPackageImpl::authors() const
+      { }
+      /** */
+      Text YUMPackageImpl::filenames() const
+      { }
+      License YUMPackageImpl::licenseToConfirm() const
+      { }
 
 
 
 
-*/
+#if 0
+      /** */
+      std::list<std::string> YUMPackageImpl::insnotify() const
+      { return std::list<std::string>(); }
+      /** */
+      std::list<std::string> YUMPackageImpl::delnotify() const
+      { return std::list<std::string>(); }
+      /** */
+      unsigned YUMPackageImpl::packageSize() const
+      { return _size_package; }
+      /** */
+      unsigned YUMPackageImpl::archiveSize() const
+      { return _size_archive; }
+      /** */
+      unsigned YUMPackageImpl::installedSize() const
+      { return _size_installed; }
+// FIXME do not understand items below
+      /** */
+      bool YUMPackageImpl::providesSources() const
+      {
+       return false;
+      }
+      /** */
+      std::string YUMPackageImpl::instSrcLabel() const
+      {
+       return "";
+      }
+      /** */
+      std::string YUMPackageImpl::instSrcVendor() const
+      {
+       return "";
+      }
+      /** */
+      unsigned YUMPackageImpl::instSrcRank() const
+      {
+       return 0;
+      }
+      /** */
+      std::string YUMPackageImpl::buildhost() const
+      {
+       return _buildhost;
       }
+      /** */
+      std::string YUMPackageImpl::distribution() const
+      {
+       return "";
+      }
+      /** */
+      std::string YUMPackageImpl::vendor() const
+      {
+       return _vendor;
+      }
+      /** */
+      std::string YUMPackageImpl::license() const
+      {
+       return _license;
+      }
+      /** */
+      std::list<std::string> YUMPackageImpl::licenseToConfirm() const
+      {
+       return std::list<std::string>();
+      }
+      /** */
+      std::string YUMPackageImpl::packager() const
+      {
+       return _packager;
+      }
+      /** */
+      std::string YUMPackageImpl::group() const
+      {
+       return _group;
+      }
+      /** */
+      std::list<std::string> YUMPackageImpl::changelog() const
+      {}
+      /** */
+      std::string YUMPackageImpl::url() const
+      {
+       return _url;
+      }
+      /** */
+      std::string YUMPackageImpl::os() const
+      {}
+      /** */
+      std::list<std::string> YUMPackageImpl::prein() const
+      {}
+      /** */
+      std::list<std::string> YUMPackageImpl::postin() const
+      {}
+      /** */
+      std::list<std::string> YUMPackageImpl::preun() const
+      {}
+      /** */
+      std::list<std::string> YUMPackageImpl::postun() const
+      {}
+      /** */
+      std::string YUMPackageImpl::sourcepkg() const
+      { return _sourcepkg; }
+      /** */
+      std::string YUMPackageImpl::type() const
+      { return _type; }
+      /** */
+      std::list<std::string> YUMPackageImpl::authors() const
+      { return _authors; }
+      /** */
+      std::list<std::string> YUMPackageImpl::filenames() const
+      {}
+      /** */
+      std::list<std::string> YUMPackageImpl::recommends() const
+      {}
+      /** */
+      std::list<std::string> YUMPackageImpl::suggests() const
+      {}
+      /** */
+      std::string YUMPackageImpl::location() const
+      {}
+      /** */
+      unsigned int YUMPackageImpl::medianr() const
+      {}
+      /** */
+      std::list<std::string> YUMPackageImpl::keywords() const
+      { return _keywords; }
+      /** */
+      std::string YUMPackageImpl::md5sum() const
+      {}
+      /** */
+      std::string YUMPackageImpl::externalUrl() const
+      {}
+      /** */
+      std::list<Edition> YUMPackageImpl::patchRpmBaseVersions() const
+      {}
+      /** */
+      unsigned YUMPackageImpl::patchRpmSize() const
+      {}
+      /** */
+      bool YUMPackageImpl::forceInstall() const
+      {}
+      /** */
+      std::string YUMPackageImpl::patchRpmMD5() const
+      {}
+      /** */
+      bool YUMPackageImpl::isRemote() const
+      {}
+      /** */
+      bool YUMPackageImpl::prefererCandidate() const
+      {}
+
+#endif
+
     } // namespace yum
     /////////////////////////////////////////////////////////////////
   } // namespace source
index f22dd41..dbe5328 100644 (file)
@@ -29,20 +29,204 @@ namespace zypp
       //        CLASS NAME : YUMPackageImpl
       //
       /** Class representing a package
-       *
-       * \todo Deriving from detail::PackageImpl is useless here. PackageImpl
-       * is dumb, i.e. it provides nothing, but the dtor needed to instanciate
-       * detail::PackageImplIf. All values returned are the PackageImplIf
-       * defaults. We should rename the detail::*Impl classes, and classify
-       * them into Dumb (holding no real data, provided the ImplIf dtor is
-       * the only prure virtual) and FullStore (providing a protected variable
-       * and interface methods returning them for each datum),
       */
-      class YUMPackageImpl : public detail::PackageImpl
+      class YUMPackageImpl : public detail::PackageImplIf
       {
       public:
-        /** Default ctor */
-        YUMPackageImpl( const zypp::parser::yum::YUMPatchPackage & parsed );
+       /** Default ctor
+       */
+       YUMPackageImpl(
+         const zypp::parser::yum::YUMPrimaryData & parsed
+       );
+       YUMPackageImpl(
+         const zypp::parser::yum::YUMPatchPackage & parsed
+       );
+
+       /** Package summary */
+       virtual Label summary() const;
+       /** Package description */
+       virtual Text description() const;
+       virtual Text insnotify() const;
+       virtual Text delnotify() const;
+       virtual FSize size() const;
+       virtual bool providesSources() const;
+       virtual Label instSrcLabel() const;
+       virtual Vendor instSrcVendor() const;
+       /** */
+       virtual Date buildtime() const;
+       /** */
+       virtual std::string buildhost() const;
+       /** */
+       virtual Date installtime() const;
+       /** */
+       virtual std::string distribution() const;
+       /** */
+       virtual Vendor vendor() const;
+       /** */
+       virtual Label license() const;
+       /** */
+       virtual std::string packager() const;
+       /** */
+       virtual PackageGroup group() const;
+       /** */
+       virtual Text changelog() const;
+       /** Don't ship it as class Url, because it might be
+        * in fact anything but a legal Url. */
+       virtual std::string url() const;
+       /** */
+       virtual std::string os() const;
+       /** */
+       virtual Text prein() const;
+       /** */
+       virtual Text postin() const;
+       /** */
+       virtual Text preun() const;
+       /** */
+       virtual Text postun() const;
+       /** */
+       virtual FSize sourcesize() const;
+       /** */
+       virtual FSize archivesize() const;
+       /** */
+       virtual Text authors() const;
+       /** */
+       virtual Text filenames() const;
+        virtual License licenseToConfirm() const;
+
+#if 0
+        /** */
+        virtual std::list<std::string> insnotify() const;
+        /** */
+        virtual std::list<std::string> delnotify() const;
+        /** */
+        virtual unsigned packageSize() const;
+        /** */
+        virtual unsigned installedSize() const;
+        /** */
+        virtual unsigned archiveSize() const;
+        /** */
+        virtual bool providesSources() const;
+        /** */
+        virtual std::string instSrcLabel() const;
+        /** */
+        virtual std::string instSrcVendor() const;
+        /** */
+        virtual unsigned instSrcRank() const;
+        /** */
+        virtual std::string buildhost() const;
+        /** */
+        virtual std::string distribution() const;
+        /** */
+        virtual std::string vendor() const;
+        /** */
+        virtual std::string license() const;
+        /** */
+        virtual std::list<std::string> licenseToConfirm() const;
+        /** */
+        virtual std::string packager() const;
+        /** */
+        virtual std::string group() const;
+        /** */
+        virtual std::list<std::string> changelog() const;
+        /** */
+        virtual std::string url() const;
+        /** */
+        virtual std::string os() const;
+        /** */
+        virtual std::list<std::string> prein() const;
+        /** */
+        virtual std::list<std::string> postin() const;
+        /** */
+        virtual std::list<std::string> preun() const;
+        /** */
+        virtual std::list<std::string> postun() const;
+        /** */
+        virtual std::string sourcepkg() const;
+        /** */
+        virtual std::string type() const;
+        /** */
+        virtual std::list<std::string> authors() const;
+        /** */
+        virtual std::list<std::string> filenames() const;
+        /** */
+        virtual std::list<std::string> recommends() const;
+        /** */
+        virtual std::list<std::string> suggests() const;
+        /** */
+        virtual std::string location() const;
+        /** */
+        virtual unsigned int medianr() const;
+        /** */
+        virtual std::list<std::string> keywords() const;
+        /** */
+        virtual std::string md5sum() const;
+        /** */
+        virtual std::string externalUrl() const;
+        /** */
+        virtual std::list<Edition> patchRpmBaseVersions() const;
+        /** */
+        virtual unsigned patchRpmSize() const;
+        /** */
+        virtual bool forceInstall() const;
+        /** */
+        virtual std::string patchRpmMD5() const;
+        /** */
+        virtual bool isRemote() const;
+        /** */
+        virtual bool prefererCandidate() const;
+      protected:
+       unsigned _size_package;
+       unsigned _size_installed;
+       unsigned _size_archive;
+       std::list<std::string> _authors;
+       std::list<std::string>_keywords;
+       std::string _packager;
+       std::string _url;
+       std::string _buildhost;
+       std::string _vendor;
+       std::string _group;
+       std::string _license;
+       std::string _sourcepkg;
+       std::string _type;
+       CheckSum _checksum;
+       std::string _media;
+       unsigned _time_file;
+       unsigned _time_build;
+       std::string _location;
+       std::list<FileData> _files;
+       std::list<DirSize> _dir_sizes;
+       bool _install_only;
+/*
+       std::string summary;
+       std::list<std::string> description;
+       // SuSE specific data
+       // Change Log
+       std::list<ChangelogEntry> changelog;
+       // Package Files
+       struct {
+         std::string arch;
+         std::string filename;
+         std::string downloadsize;
+         std::string md5sum;
+         std::string buildtime;
+       } plainRpm;
+       struct {
+         std::string arch;
+         std::string filename;
+         std::string downloadsize;
+         std::string md5sum;
+         std::string buildtime;
+         std::list<YUMBaseVersion> baseVersions;
+       } patchRpm;
+       struct {
+         std::string arch;
+         std::string filename;
+         std::string downloadsize;
+
+
+*/
+#endif
+
        };
       ///////////////////////////////////////////////////////////////////
     } // namespace yum
index e9aba77..86421fd 100644 (file)
@@ -14,8 +14,7 @@
 #include "zypp/source/yum/YUMSource.h"
 #include <zypp/CapFactory.h>
 #include "zypp/parser/yum/YUMParserData.h"
-#warning DISBALED INCLUDE BELOW AS IT DOES NOT COMPILE
-//#include <zypp/parser/yum/YUMParser.h>
+#include <zypp/parser/yum/YUMParser.h>
 #include "zypp/Package.h"
 #include "zypp/Script.h"
 #include "zypp/Message.h"
@@ -48,18 +47,36 @@ namespace zypp
        YUMSource * src
       )
       {
+       _patch_id = parsed.patchId;
+        _timestamp = atol(parsed.timestamp.c_str());
+        _category = parsed.category;
+        _reboot_needed = parsed.rebootNeeded;
+        _affects_pkg_manager = parsed.packageManager;
+        std::string updateScript;
+/*
+        std::string engine;
+        MultiLang description;
+        _summary = parsed.MultiLang summary;
+*/
+
+
+
+
+      /** Patch description */
+//      std::list<std::string> _description;
+
+
+
+
+
+       // now process the atoms
        CapFactory _f;
-#warning ORIGINAL CODE DISABLED AS IT DOES NOT COMPILE
-       Capability cap( _f.parse(
-         parsed.name, Resolvable::Kind("Patch")
-         ) );
-#if 0
        Capability cap( _f.parse(
          Resolvable::Kind("Patch"),
          parsed.name,
-         Edition(),
-         Arch("noarch")));
-#endif
+         Rel(Rel::EQ),
+         Edition(parsed.ver, parsed.rel, strtol(parsed.epoch.c_str(), 0, 10))
+         ));
        for (std::list<shared_ptr<YUMPatchAtom> >::const_iterator it
                                        = parsed.atoms.begin();
             it != parsed.atoms.end();
@@ -105,7 +122,139 @@ namespace zypp
        }
       }
 
+      std::string YUMPatchImpl::id() const
+      {
+        return _patch_id;
+      }
+      unsigned int YUMPatchImpl::timestamp() const
+      {
+        return _timestamp;
+      }
+
+      Label YUMPatchImpl::summary() const
+      { return _summary; }
+
+      Text YUMPatchImpl::description() const
+      { return _description; }
+
+      Text YUMPatchImpl::insnotify() const
+      { return ResObjectImplIf::insnotify(); }
+
+      Text YUMPatchImpl::delnotify() const
+      { return ResObjectImplIf::delnotify(); }
+
+      FSize YUMPatchImpl::size() const
+      { return ResObjectImplIf::size(); }
+
+      bool YUMPatchImpl::providesSources() const
+      { return ResObjectImplIf::providesSources(); }
+
+      Label YUMPatchImpl::instSrcLabel() const
+      { return ResObjectImplIf::instSrcLabel(); }
 
+      Vendor YUMPatchImpl::instSrcVendor() const
+      { return ResObjectImplIf::instSrcVendor(); }
+
+      std::string YUMPatchImpl::category() const
+      {
+        return _category;
+      }
+  
+      bool YUMPatchImpl::reboot_needed() const
+      {
+        return _reboot_needed;
+      }
+  
+      bool YUMPatchImpl::affects_pkg_manager() const
+      {
+        return _affects_pkg_manager;
+      }
+  
+      bool YUMPatchImpl::interactive() {
+        if (_reboot_needed)
+        {
+          DBG << "Patch needs reboot" << endl;
+          return true;
+        }
+        AtomList not_installed = not_installed_atoms();
+        for (AtomList::iterator it = not_installed.begin();
+          it != not_installed.end();
+          it++)
+        {
+          if ((*it)->kind() == "Message")
+          {
+  //          DBG << "Patch contains a message" << endl;
+            return true;
+          }
+          if ((*it)->kind() == "Package")
+          {
+                                   // Resolvable*
+                                    // Resolvable
+                                     // ResolvablePtr
+  
+  
+            // <ma> never do somthing like this!!!
+  //          Package* p = (Package*)&**it;
+            //
+            // (*it) is a ResolvablePtr
+  
+  
+  
+  
+            // FIXME use the condition
+  //          if (p->licenseToConfirm() != "")
+            if (false)
+            {
+  //            DBG << "Package has a license to be shown to user" << endl;
+              return true;
+            }
+          }
+        }
+        return false;
+      }
+  
+      YUMPatchImpl::AtomList YUMPatchImpl::all_atoms() {
+        return _atoms;
+      }
+  
+      YUMPatchImpl::AtomList YUMPatchImpl::not_installed_atoms() {
+        AtomList ret;
+        for (AtomList::iterator it = _atoms.begin();
+          it != _atoms.end();
+          it++)
+        {
+          if (true) // FIXME check if atom/resolvable is not installed
+          {
+            ret.push_back(*it);
+          }
+        }
+        return ret;
+      }
+  
+  // TODO check necessarity of functions below
+  
+      bool YUMPatchImpl::any_atom_selected() {
+        for (AtomList::iterator it = _atoms.begin();
+          it != _atoms.end();
+          it++)
+        {
+          if (false) // FIXME check if atom/resolvable is selected
+          {
+            return true;
+          }
+        }
+        return false;
+      }
+  
+      void YUMPatchImpl::mark_atoms_to_freshen( bool freshen ) {
+        for (AtomList::iterator it = _atoms.begin();
+          it != _atoms.end();
+          it++)
+        {
+          // TODO mark the resolvable to be or not to be freshed
+        }
+      }
+  
     } // namespace yum
     /////////////////////////////////////////////////////////////////
   } // namespace source
index 5147c20..cd7a48e 100644 (file)
@@ -31,7 +31,7 @@ namespace zypp
       //
       /** Class representing a patch
       */
-      class YUMPatchImpl : public detail::PatchImpl
+      class YUMPatchImpl : public detail::PatchImplIf
       {
       public:
         /** Default ctor */
@@ -39,6 +39,54 @@ namespace zypp
          const zypp::parser::yum::YUMPatchData & parsed,
          YUMSource * src
        );
+       /** Patch ID */
+       std::string id() const;
+       /** Patch time stamp */
+       unsigned int timestamp() const;
+       /** Patch category (recommended, security,...) */
+       std::string category() const;
+       /** Does the system need to reboot to finish the update process? */
+       bool reboot_needed() const;
+       /** Does the patch affect the package manager itself? */
+       bool affects_pkg_manager() const;
+       /** Is the patch installation interactive? (does it need user input?) */
+       bool interactive();
+       /** The list of all atoms building the patch */
+       AtomList all_atoms();
+       /** The list of those atoms which have not been installed */
+       AtomList not_installed_atoms();
+
+       /** Patch summary */
+       virtual Label summary() const;
+       /** Patch description */
+       virtual Text description() const;
+       virtual Text insnotify() const;
+       virtual Text delnotify() const;
+       virtual FSize size() const;
+       virtual bool providesSources() const;
+       virtual Label instSrcLabel() const;
+       virtual Vendor instSrcVendor() const;
+
+// TODO check necessarity of functions below
+       bool any_atom_selected();
+       void mark_atoms_to_freshen(bool freshen);
+      protected:
+       /** Patch ID */
+       std::string _patch_id;
+       /** Patch time stamp */
+       int _timestamp;
+       /** Patch summary */
+       Label _summary;
+       /** Patch description */
+       Text _description;
+       /** Patch category (recommended, security,...) */
+       std::string _category;
+       /** Does the system need to reboot to finish the update process? */
+       bool _reboot_needed;
+       /** Does the patch affect the package manager itself? */
+       bool _affects_pkg_manager;
+       /** The list of all atoms building the patch */
+       AtomList _atoms;
        };
       ///////////////////////////////////////////////////////////////////
     } // namespace yum
index 549ab70..135e288 100644 (file)
@@ -34,7 +34,6 @@ namespace zypp
       ///////////////////////////////////////////////////////////////////
 
       /** Default ctor
-       * \bug CANT BE CONSTUCTED THAT WAY ANYMORE
       */
       YUMScriptImpl::YUMScriptImpl(
        const zypp::parser::yum::YUMPatchScript & parsed
@@ -43,6 +42,41 @@ namespace zypp
        _do_script = parsed.do_script;
        _undo_script = parsed.undo_script;
       }
+      std::string YUMScriptImpl::do_script() const {
+       return _do_script;
+      }
+      /** Get the script to undo the change */
+      std::string YUMScriptImpl::undo_script() const {
+       return _undo_script;
+      }
+      /** Check whether script to undo the change is available */
+      bool YUMScriptImpl::undo_available() const {
+       return _undo_script != "";
+      }
+      Label YUMScriptImpl::summary() const
+      { return ResObjectImplIf::summary(); }
+
+      Text YUMScriptImpl::description() const
+      { return ResObjectImplIf::description(); }
+
+      Text YUMScriptImpl::insnotify() const
+      { return ResObjectImplIf::insnotify(); }
+
+      Text YUMScriptImpl::delnotify() const
+      { return ResObjectImplIf::delnotify(); }
+
+      FSize YUMScriptImpl::size() const
+      { return ResObjectImplIf::size(); }
+
+      bool YUMScriptImpl::providesSources() const
+      { return ResObjectImplIf::providesSources(); }
+
+      Label YUMScriptImpl::instSrcLabel() const
+      { return ResObjectImplIf::instSrcLabel(); }
+
+      Vendor YUMScriptImpl::instSrcVendor() const
+      { return ResObjectImplIf::instSrcVendor(); }
+
     } // namespace yum
     /////////////////////////////////////////////////////////////////
   } // namespace source
index adfabdc..35da351 100644 (file)
@@ -29,11 +29,33 @@ namespace zypp
       //        CLASS NAME : YUMScriptImpl
       //
       /** Class representing an update script */
-      class YUMScriptImpl : public detail::ScriptImpl
+      class YUMScriptImpl : public detail::ScriptImplIf
       {
       public:
         /** Default ctor */
         YUMScriptImpl( const zypp::parser::yum::YUMPatchScript & parsed );
+       /** Get the script to perform the change */
+       virtual std::string do_script() const;
+       /** Get the script to undo the change */
+       virtual std::string undo_script() const;
+       /** Check whether script to undo the change is available */
+       virtual bool undo_available() const;
+
+       virtual Label summary() const;
+       virtual Text description() const;
+       virtual Text insnotify() const;
+       virtual Text delnotify() const;
+       virtual FSize size() const;
+       virtual bool providesSources() const;
+       virtual Label instSrcLabel() const;
+       virtual Vendor instSrcVendor() const;
+
+
+      protected:
+       /** The script to perform the change */
+       std::string _do_script;
+       /** The script to undo the change */
+       std::string _undo_script;
       };
       ///////////////////////////////////////////////////////////////////
     } // namespace yum
index 98fe641..e970f18 100644 (file)
@@ -16,6 +16,8 @@
 #include "zypp/source/yum/YUMMessageImpl.h"
 #include "zypp/source/yum/YUMPatchImpl.h"
 
+#include <zypp/base/Logger.h>
+
 #include <zypp/CapFactory.h>
 
 using namespace std;
@@ -38,8 +40,8 @@ namespace zypp
 
       /** Default ctor
       */
-        YUMSource::YUMSource()
-       {}
+      YUMSource::YUMSource()
+      {}
 
 
        Package::Ptr YUMSource::createPackage(
@@ -47,7 +49,8 @@ namespace zypp
        )
        {
          shared_ptr<YUMPackageImpl> impl(new YUMPackageImpl(parsed));
-         Dependencies _deps = createDependencies(parsed);
+         Dependencies _deps = createDependencies(parsed,
+                                                 Resolvable::Kind("Package"));
          Package::Ptr package = detail::makeResolvableFromImpl(
            parsed.name,
            Edition( parsed.ver, parsed.rel ),
@@ -62,7 +65,8 @@ namespace zypp
        )
        {
          shared_ptr<YUMMessageImpl> impl(new YUMMessageImpl(parsed));
-         Dependencies _deps = createDependencies(parsed);
+         Dependencies _deps = createDependencies(parsed,
+                                                 Resolvable::Kind("Message"));
          Message::Ptr message = detail::makeResolvableFromImpl(
            parsed.name,
            Edition( parsed.ver, parsed.rel ),
@@ -78,7 +82,8 @@ namespace zypp
        )
        {
          shared_ptr<YUMScriptImpl> impl(new YUMScriptImpl(parsed));
-         Dependencies _deps = createDependencies(parsed);
+         Dependencies _deps = createDependencies(parsed,
+                                                 Resolvable::Kind("Script"));
          Script::Ptr script = detail::makeResolvableFromImpl(
            parsed.name,
            Edition( parsed.ver, parsed.rel ),
@@ -94,7 +99,8 @@ namespace zypp
        )
        {
          shared_ptr<YUMPatchImpl> impl(new YUMPatchImpl(parsed, this));
-         Dependencies _deps = createDependencies(parsed);
+         Dependencies _deps = createDependencies(parsed,
+                                                 Resolvable::Kind("Patch"));
          Patch::Ptr patch = detail::makeResolvableFromImpl(
            parsed.name,
            Edition( parsed.ver, parsed.rel ),
@@ -106,10 +112,10 @@ namespace zypp
        }
 
        Dependencies YUMSource::createDependencies(
-         const zypp::parser::yum::YUMObjectData & parsed
+         const zypp::parser::yum::YUMObjectData & parsed,
+         const Resolvable::Kind my_kind
        )
        {
-         CapFactory _f;
          CapSet _provides;
          CapSet _conflicts;
          CapSet _obsoletes;
@@ -121,40 +127,28 @@ namespace zypp
               it != parsed.provides.end();
               it++)
          {
-           // FIXME do not create the string this way
-           // FIXME other types than only packages
-           // FIXME use also the flags
-           _provides.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+           _provides.insert(createCapability(*it, my_kind));
          }
   
          for (std::list<YUMDependency>::const_iterator it = parsed.conflicts.begin();
               it != parsed.conflicts.end();
               it++)
          {
-           // FIXME do not create the string this way
-           // FIXME other types than only packages
-           // FIXME use also the flags
-           _conflicts.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+           _conflicts.insert(createCapability(*it, my_kind));
          }
   
          for (std::list<YUMDependency>::const_iterator it = parsed.obsoletes.begin();
               it != parsed.obsoletes.end();
               it++)
          {
-           // FIXME do not create the string this way
-           // FIXME other types than only packages
-           // FIXME use also the flags
-           _obsoletes.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+           _obsoletes.insert(createCapability(*it, my_kind));
          }
   
          for (std::list<YUMDependency>::const_iterator it = parsed.freshen.begin();
               it != parsed.freshen.end();
               it++)
          {
-           // FIXME do not create the string this way
-           // FIXME other types than only packages
-           // FIXME use also the flags
-           _freshens.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+           _freshens.insert(createCapability(*it, my_kind));
          }
   
          for (std::list<YUMDependency>::const_iterator it = parsed.requires.begin();
@@ -165,9 +159,9 @@ namespace zypp
            // FIXME other types than only packages
            // FIXME use also the flags
            if (it->pre == "1")
-             _prerequires.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+             _prerequires.insert(createCapability(*it, my_kind));
            else
-             _requires.insert (_f.parse(it->name + " = " + it->ver + "-" + it->rel));
+             _requires.insert(createCapability(*it, my_kind));
          }
   
          _deps.setProvides(_provides);
@@ -178,10 +172,25 @@ namespace zypp
          _deps.setPrerequires(_prerequires);
          return _deps;
        }
-  
-
-
 
+       Capability YUMSource::createCapability(const YUMDependency & dep,
+                                              const Resolvable::Kind & my_kind)
+       {
+         CapFactory _f;
+         Resolvable::Kind _kind = dep.kind == ""
+           ? my_kind
+           : Resolvable::Kind(dep.kind);
+         Capability cap = _f.parse(
+           _kind,
+           dep.name,
+           Rel(dep.flags),
+           Edition(dep.ver,
+                   dep.rel,
+                   strtol(dep.epoch.c_str(), 0, 10))
+         );
+         return cap;
+       }
+  
     } // namespace yum
     /////////////////////////////////////////////////////////////////
   } // namespace source
index 7ceafcb..a08d42c 100644 (file)
@@ -19,6 +19,8 @@
 #include "zypp/Script.h"
 #include "zypp/Patch.h"
 
+using namespace zypp::parser::yum;
+
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
@@ -55,9 +57,12 @@ namespace zypp
 
 
        Dependencies createDependencies(
-         const zypp::parser::yum::YUMObjectData & parsed
+         const zypp::parser::yum::YUMObjectData & parsed,
+         const Resolvable::Kind my_kind
        );
 
+       Capability createCapability(const YUMDependency & dep,
+                                   const Resolvable::Kind & my_kind);
 
 
        };