]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.h
policy: Assign per-version pins
[apt.git] / apt-pkg / acquire-item.h
index 790d1f3d89b547c9ed40d86da4eb45579a5ff358..df1380b5eda7211ad42959f81c9e6a53f0741d7a 100644 (file)
@@ -1,6 +1,5 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: acquire-item.h,v 1.26.2.3 2004/01/02 18:51:00 mdz Exp $
 /* ######################################################################
 
    Acquire Item - Item to acquire
@@ -21,6 +20,7 @@
 #define PKGLIB_ACQUIRE_ITEM_H
 
 #include <apt-pkg/acquire.h>
+#include <apt-pkg/indexfile.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/weakptr.h>
 #include <apt-pkg/pkgcache.h>
@@ -31,7 +31,6 @@
 #include <map>
 
 #ifndef APT_8_CLEANER_HEADERS
-#include <apt-pkg/indexfile.h>
 #include <apt-pkg/vendor.h>
 #include <apt-pkg/sourcelist.h>
 #include <apt-pkg/pkgrecords.h>
 class indexRecords;
 class pkgRecords;
 class pkgSourceList;
-class IndexTarget;
 class pkgAcqMetaBase;
 
-class IndexTarget                                                      /*{{{*/
-/** \brief Information about an index file. */
-{
-   public:
-   /** \brief A URI from which the index file can be downloaded. */
-   std::string URI;
-
-   /** \brief A description of the index file. */
-   std::string Description;
-
-   /** \brief A shorter description of the index file. */
-   std::string ShortDesc;
-
-   /** \brief The key by which this index file should be
-       looked up within the meta index file. */
-   std::string MetaKey;
-
-   /** \brief Is it okay if the file isn't found in the meta index */
-   bool IsOptional;
-
-   /** \brief Target specific options defined by the implementation */
-   std::map<std::string, std::string> Options;
-
-   IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
-        std::string const &LongDesc, std::string const &URI, bool const IsOptional,
-        std::map<std::string, std::string> const &Options);
-};
-                                                                       /*}}}*/
 class pkgAcquire::Item : public WeakPointable                          /*{{{*/
 /** \brief Represents the process by which a pkgAcquire object should
  *  retrieve a file or a collection of files.
@@ -278,6 +248,7 @@ class pkgAcquire::Item : public WeakPointable                               /*{{{*/
 
    /** \return the acquire process with which this item is associated. */
    pkgAcquire *GetOwner() const;
+   pkgAcquire::ItemDesc &GetItemDesc();
 
    /** \return \b true if this object is being fetched from a trusted source. */
    virtual bool IsTrusted() const;
@@ -373,6 +344,7 @@ class pkgAcquire::Item : public WeakPointable                               /*{{{*/
 class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item                /*{{{*/
 /** \brief baseclass for the indexes files to manage them all together */
 {
+   void *d;
    protected:
    IndexTarget const Target;
    HashStringList GetExpectedHashesFor(std::string const MetaKey) const;
@@ -408,7 +380,6 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem              /*{{{*/
 /** \brief the manager of a transaction */
 {
    void *d;
-
  protected:
    std::vector<pkgAcqTransactionItem*> Transaction;
 
@@ -506,6 +477,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem              /*{{{*/
                  std::vector<IndexTarget> const IndexTargets,
                  IndexTarget const &DataTarget,
                  indexRecords* const MetaIndexParser);
+   virtual ~pkgAcqMetaBase();
 };
                                                                        /*}}}*/
 /** \brief An item that is responsible for downloading the meta-index  {{{
@@ -521,7 +493,6 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem              /*{{{*/
 class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
 {
    void *d;
-
    protected:
    IndexTarget const DetachedSigTarget;
 
@@ -541,6 +512,7 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
    pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
                   IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget,
                   std::vector<IndexTarget> const IndexTargets, indexRecords * const MetaIndexParser);
+   virtual ~pkgAcqMetaIndex();
 
    friend class pkgAcqMetaSig;
 };
@@ -617,6 +589,7 @@ class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
 
    pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
                    IndexTarget const Target);
+   virtual ~pkgAcqBaseIndex();
 };
                                                                        /*}}}*/
 /** \brief An item that is responsible for fetching an index file of   {{{
@@ -680,6 +653,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
     */
    pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
                    IndexTarget const Target);
+   virtual ~pkgAcqDiffIndex();
  private:
    APT_HIDDEN void QueueOnIMSHit() const;
 };
@@ -779,6 +753,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
    pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
                          IndexTarget const Target, DiffInfo const &patch,
                          std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
+   virtual ~pkgAcqIndexMergeDiffs();
 };
                                                                        /*}}}*/
 /** \brief An item that is responsible for fetching server-merge patches {{{
@@ -892,6 +867,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
    pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
                     IndexTarget const Target,
                    std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>());
+   virtual ~pkgAcqIndexDiffs();
 };
                                                                        /*}}}*/
 /** \brief An acquire item that is responsible for fetching an index   {{{
@@ -968,8 +944,10 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
 
    pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
                IndexTarget const Target);
+   virtual ~pkgAcqIndex();
 
-   void Init(std::string const &URI, std::string const &URIDesc,
+   private:
+   APT_HIDDEN void Init(std::string const &URI, std::string const &URIDesc,
              std::string const &ShortDesc);
 };
                                                                        /*}}}*/
@@ -1058,6 +1036,121 @@ class pkgAcqArchive : public pkgAcquire::Item
    pkgAcqArchive(pkgAcquire * const Owner,pkgSourceList * const Sources,
                 pkgRecords * const Recs,pkgCache::VerIterator const &Version,
                 std::string &StoreFilename);
+   virtual ~pkgAcqArchive();
+};
+                                                                       /*}}}*/
+/** \brief Retrieve the changelog for the given version                        {{{
+ *
+ *  Downloads the changelog to a temporary file it will also remove again
+ *  while it is deconstructed or downloads it to a named location.
+ */
+class pkgAcqChangelog : public pkgAcquire::Item
+{
+   void *d;
+   std::string TemporaryDirectory;
+   std::string const SrcName;
+   std::string const SrcVersion;
+
+   public:
+   // we will never have hashes for changelogs.
+   // If you need verified ones, download the deb and extract the changelog.
+   virtual HashStringList GetExpectedHashes() const { return HashStringList(); }
+   virtual bool HashesRequired() const { return false; }
+
+   // Specialized action members
+   virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
+   virtual void Done(std::string const &Message, HashStringList const &CalcHashes,
+                    pkgAcquire::MethodConfig const * const Cnf);
+   virtual std::string DescURI() const {return Desc.URI;};
+
+   /** returns the URI to the changelog of this version
+    *
+    * @param Ver is the version to get the changelog for
+    * @return the URI which will be used to acquire the changelog
+    */
+   static std::string URI(pkgCache::VerIterator const &Ver);
+
+   /** returns the URI to the changelog of this version
+    *
+    *  \param Rls is the Release file the package comes from
+    *  \param Component in which the package resides, can be empty
+    *  \param SrcName is the source package name
+    *  \param SrcVersion is the source package version
+    * @return the URI which will be used to acquire the changelog
+    */
+   static std::string URI(pkgCache::RlsFileIterator const &Rls,
+        char const * const Component, char const * const SrcName,
+        char const * const SrcVersion);
+
+   /** returns the URI to the changelog of this version
+    *
+    *  \param Template URI where CHANGEPATH has to be filled in
+    *  \param Component in which the package resides, can be empty
+    *  \param SrcName is the source package name
+    *  \param SrcVersion is the source package version
+    * @return the URI which will be used to acquire the changelog
+    */
+   static std::string URI(std::string const &Template,
+        char const * const Component, char const * const SrcName,
+        char const * const SrcVersion);
+
+   /** returns the URI template for this release file
+    *
+    *  \param Rls is a Release file
+    * @return the URI template to use for this release file
+    */
+   static std::string URITemplate(pkgCache::RlsFileIterator const &Rls);
+
+   /** \brief Create a new pkgAcqChangelog object.
+    *
+    *  \param Owner The pkgAcquire object with which this object is
+    *  associated.
+    *  \param Ver is the version to get the changelog for
+    *  \param DestDir The directory the file should be downloaded into.
+    *  Will be an autocreated (and cleaned up) temporary directory if not set.
+    *  \param DestFilename The filename the file should have in #DestDir
+    *  Defaults to sourcepackagename.changelog if not set.
+    */
+   pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::VerIterator const &Ver,
+        std::string const &DestDir="", std::string const &DestFilename="");
+
+   /** \brief Create a new pkgAcqChangelog object.
+    *
+    *  \param Owner The pkgAcquire object with which this object is
+    *  associated.
+    *  \param Rls is the Release file the package comes from
+    *  \param Component in which the package resides, can be empty
+    *  \param SrcName is the source package name
+    *  \param SrcVersion is the source package version
+    *  \param DestDir The directory the file should be downloaded into.
+    *  Will be an autocreated (and cleaned up) temporary directory if not set.
+    *  \param DestFilename The filename the file should have in #DestDir
+    *  Defaults to sourcepackagename.changelog if not set.
+    */
+   pkgAcqChangelog(pkgAcquire * const Owner, pkgCache::RlsFileIterator const &Rls,
+        char const * const Component, char const * const SrcName, char const * const SrcVersion,
+        std::string const &DestDir="", std::string const &DestFilename="");
+
+   /** \brief Create a new pkgAcqChangelog object.
+    *
+    *  \param Owner The pkgAcquire object with which this object is
+    *  associated.
+    *  \param URI is to be used to get the changelog
+    *  \param SrcName is the source package name
+    *  \param SrcVersion is the source package version
+    *  \param DestDir The directory the file should be downloaded into.
+    *  Will be an autocreated (and cleaned up) temporary directory if not set.
+    *  \param DestFilename The filename the file should have in #DestDir
+    *  Defaults to sourcepackagename.changelog if not set.
+    */
+   pkgAcqChangelog(pkgAcquire * const Owner, std::string const &URI,
+        char const * const SrcName, char const * const SrcVersion,
+        std::string const &DestDir="", std::string const &DestFilename="");
+
+   virtual ~pkgAcqChangelog();
+
+private:
+   APT_HIDDEN void Init(std::string const &DestDir, std::string const &DestFilename);
 };
                                                                        /*}}}*/
 /** \brief Retrieve an arbitrary file to the current directory.                {{{
@@ -1125,6 +1218,7 @@ class pkgAcqFile : public pkgAcquire::Item
              std::string const &Desc, std::string const &ShortDesc,
              std::string const &DestDir="", std::string const &DestFilename="",
              bool const IsIndexFile=false);
+   virtual ~pkgAcqFile();
 };
                                                                        /*}}}*/
 /** @} */