]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.h
remove the longtime deprecated vendor{,list} stuff
[apt.git] / apt-pkg / acquire-item.h
index b6d569737d96532e872836fe6aedf5423f372cbd..93d812248083c4c7299459a372fb46b9320aa924 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
 #include <map>
 
 #ifndef APT_8_CLEANER_HEADERS
-#include <apt-pkg/vendor.h>
 #include <apt-pkg/sourcelist.h>
 #include <apt-pkg/pkgrecords.h>
-#include <apt-pkg/indexrecords.h>
 #endif
 
 /** \addtogroup acquire
  *  \file acquire-item.h
  */
 
-class indexRecords;
 class pkgRecords;
 class pkgSourceList;
-class pkgAcqMetaBase;
+class pkgAcqMetaClearSig;
+class pkgAcqIndexMergeDiffs;
+class metaIndex;
 
 class pkgAcquire::Item : public WeakPointable                          /*{{{*/
 /** \brief Represents the process by which a pkgAcquire object should
@@ -249,6 +247,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;
@@ -276,7 +275,7 @@ class pkgAcquire::Item : public WeakPointable                               /*{{{*/
     *
     *  \param Owner The new owner of this item.
     */
-   Item(pkgAcquire * const Owner);
+   explicit Item(pkgAcquire * const Owner);
 
    /** \brief Remove this item from its owner's queue by invoking
     *  pkgAcquire::Remove.
@@ -336,17 +335,19 @@ class pkgAcquire::Item : public WeakPointable                             /*{{{*/
    virtual std::string GetFinalFilename() const;
 
    private:
-   void *d;
+   void * const d;
 
    friend class pkgAcqMetaBase;
+   friend class pkgAcqMetaClearSig;
 };
                                                                        /*}}}*/
 class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item                /*{{{*/
 /** \brief baseclass for the indexes files to manage them all together */
 {
+   void * const d;
    protected:
    IndexTarget const Target;
-   HashStringList GetExpectedHashesFor(std::string const MetaKey) const;
+   HashStringList GetExpectedHashesFor(std::string const &MetaKey) const;
 
    bool QueueURI(pkgAcquire::ItemDesc &Item);
 
@@ -355,7 +356,7 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item             /*{{{*/
    std::string PartialFile;
 
    /** \brief TransactionManager */
-   pkgAcqMetaBase * const TransactionManager;
+   pkgAcqMetaClearSig * const TransactionManager;
 
    enum TransactionStates {
       TransactionCommit,
@@ -369,26 +370,20 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item           /*{{{*/
    virtual bool HashesRequired() const;
 
 
-   pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target);
+   pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager, IndexTarget const &Target);
    virtual ~pkgAcqTransactionItem();
 
    friend class pkgAcqMetaBase;
+   friend class pkgAcqMetaClearSig;
 };
                                                                        /*}}}*/
 class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem         /*{{{*/
 /** \brief the manager of a transaction */
 {
-   void *d;
-
+   void * const d;
  protected:
    std::vector<pkgAcqTransactionItem*> Transaction;
 
- public:
-   /** \brief A package-system-specific parser for the meta-index file. */
-   indexRecords *MetaIndexParser;
-   indexRecords *LastMetaIndexParser;
- protected:
-
    /** \brief The index files which should be looked up in the meta-index
     *  and then downloaded.
     */
@@ -473,10 +468,10 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem            /*{{{*/
    /** \brief Get the full pathname of the final file for the current URI */
    virtual std::string GetFinalFilename() const;
 
-   pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                 std::vector<IndexTarget> const IndexTargets,
-                 IndexTarget const &DataTarget,
-                 indexRecords* const MetaIndexParser);
+   pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
+                 std::vector<IndexTarget> const &IndexTargets,
+                 IndexTarget const &DataTarget);
+   virtual ~pkgAcqMetaBase();
 };
                                                                        /*}}}*/
 /** \brief An item that is responsible for downloading the meta-index  {{{
@@ -491,8 +486,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem              /*{{{*/
  */
 class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
 {
-   void *d;
-
+   void * const d;
    protected:
    IndexTarget const DetachedSigTarget;
 
@@ -509,9 +503,10 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
    virtual void Finished();
 
    /** \brief Create a new pkgAcqMetaIndex. */
-   pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
+   pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
                   IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget,
-                  std::vector<IndexTarget> const IndexTargets, indexRecords * const MetaIndexParser);
+                  std::vector<IndexTarget> const &IndexTargets);
+   virtual ~pkgAcqMetaIndex();
 
    friend class pkgAcqMetaSig;
 };
@@ -526,7 +521,7 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
  */
 class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem
 {
-   void *d;
+   void * const d;
 
    pkgAcqMetaIndex * const MetaIndex;
 
@@ -545,23 +540,27 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem
    virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
                     pkgAcquire::MethodConfig const * const Cnf);
+   virtual std::string Custom600Headers() const;
 
    /** \brief Create a new pkgAcqMetaSig. */
-   pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target,
-        pkgAcqMetaIndex * const MetaIndex);
+   pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
+        IndexTarget const &Target, pkgAcqMetaIndex * const MetaIndex);
    virtual ~pkgAcqMetaSig();
 };
                                                                        /*}}}*/
 /** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/
 class APT_HIDDEN pkgAcqMetaClearSig : public pkgAcqMetaIndex
 {
-   void *d;
+   void * const d;
 
    IndexTarget const ClearsignedTarget;
    IndexTarget const DetachedDataTarget;
-   IndexTarget const DetachedSigTarget;
 
-public:
+ public:
+   /** \brief A package-system-specific parser for the meta-index file. */
+   metaIndex *MetaIndexParser;
+   metaIndex *LastMetaIndexParser;
+
    virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
    virtual std::string Custom600Headers() const;
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
@@ -572,22 +571,23 @@ public:
                IndexTarget const &ClearsignedTarget,
                IndexTarget const &DetachedDataTarget,
                IndexTarget const &DetachedSigTarget,
-               std::vector<IndexTarget> const IndexTargets,
-               indexRecords * const MetaIndexParser);
+               std::vector<IndexTarget> const &IndexTargets,
+               metaIndex * const MetaIndexParser);
    virtual ~pkgAcqMetaClearSig();
 };
                                                                        /*}}}*/
 /** \brief Common base class for all classes that deal with fetching indexes   {{{*/
 class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
 {
-   void *d;
+   void * const d;
 
  public:
    /** \brief Get the full pathname of the final file for the current URI */
    virtual std::string GetFinalFilename() const;
 
-   pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                   IndexTarget const Target);
+   pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
+                   IndexTarget const &Target);
+   virtual ~pkgAcqBaseIndex();
 };
                                                                        /*}}}*/
 /** \brief An item that is responsible for fetching an index file of   {{{
@@ -601,7 +601,8 @@ class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
  */
 class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
 {
-   void *d;
+   void * const d;
+   std::vector<pkgAcqIndexMergeDiffs*> * diffs;
 
  protected:
    /** \brief If \b true, debugging information will be written to std::clog. */
@@ -649,8 +650,9 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
     *
     *  \param ShortDesc A short description of the list file to download.
     */
-   pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                   IndexTarget const Target);
+   pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * const TransactionManager,
+                   IndexTarget const &Target);
+   virtual ~pkgAcqDiffIndex();
  private:
    APT_HIDDEN void QueueOnIMSHit() const;
 };
@@ -682,7 +684,7 @@ struct APT_HIDDEN DiffInfo {                                                /*{{{*/
  */
 class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
 {
-   void *d;
+   void * const d;
 
    protected:
 
@@ -747,9 +749,10 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
     *  \param allPatches contains all related items so that each item can
     *  check if it was the last one to complete the download step
     */
-   pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                         IndexTarget const Target, DiffInfo const &patch,
+   pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * 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 {{{
@@ -765,7 +768,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
  */
 class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
 {
-   void *d;
+   void * const d;
 
    private:
 
@@ -860,9 +863,10 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
     *  should be ordered so that each diff appears before any diff
     *  that depends on it.
     */
-   pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                    IndexTarget const Target,
+   pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaClearSig * 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   {{{
@@ -874,7 +878,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
  */
 class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
 {
-   void *d;
+   void * const d;
 
    protected:
 
@@ -937,10 +941,12 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
    virtual std::string DescURI() const {return Desc.URI;};
    virtual std::string GetMetaKey() const;
 
-   pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-               IndexTarget const Target);
+   pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaClearSig * 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);
 };
                                                                        /*}}}*/
@@ -951,7 +957,7 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
  */
 class pkgAcqArchive : public pkgAcquire::Item
 {
-   void *d;
+   void * const d;
 
    bool LocalSource;
    HashStringList ExpectedHashes;
@@ -1029,6 +1035,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 * const 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.                {{{
@@ -1039,7 +1160,7 @@ class pkgAcqArchive : public pkgAcquire::Item
  */
 class pkgAcqFile : public pkgAcquire::Item
 {
-   void *d;
+   void * const d;
 
    /** \brief How many times to retry the download, set from
     *  Acquire::Retries.
@@ -1096,6 +1217,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();
 };
                                                                        /*}}}*/
 /** @} */