]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.h
implement 'apt-get files' to access index targets
[apt.git] / apt-pkg / acquire-item.h
index 910e4131bd21ee069625460c8db3f4556baec9c8..b6d569737d96532e872836fe6aedf5423f372cbd 100644 (file)
@@ -21,6 +21,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>
@@ -28,9 +29,9 @@
 
 #include <string>
 #include <vector>
+#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 APT_HIDDEN IndexTarget                                           /*{{{*/
-/** \brief Information about an index file. */
-{
-   public:
-   /** \brief A URI from which the index file can be downloaded. */
-   std::string const URI;
-
-   /** \brief A description of the index file. */
-   std::string const Description;
-
-   /** \brief A shorter description of the index file. */
-   std::string const ShortDesc;
-
-   /** \brief The key by which this index file should be
-    *  looked up within the meta signature file.
-    */
-   std::string const MetaKey;
-
-   virtual bool IsOptional() const {
-      return false;
-   }
-
-   IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
-        std::string const &LongDesc, std::string const &URI) :
-      URI(URI), Description(LongDesc), ShortDesc(ShortDesc), MetaKey(MetaKey) {}
-};
-                                                                       /*}}}*/
-class APT_HIDDEN OptionalIndexTarget : public IndexTarget              /*{{{*/
-/** \brief Information about an optional index file. */
-{
-   public:
-   virtual bool IsOptional() const {
-      return true;
-   }
-
-   OptionalIndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
-        std::string const &LongDesc, std::string const &URI) :
-      IndexTarget(MetaKey, ShortDesc, LongDesc, URI) {}
-};
-                                                                       /*}}}*/
 class pkgAcquire::Item : public WeakPointable                          /*{{{*/
 /** \brief Represents the process by which a pkgAcquire object should
  *  retrieve a file or a collection of files.
@@ -385,7 +345,7 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item             /*{{{*/
 /** \brief baseclass for the indexes files to manage them all together */
 {
    protected:
-   IndexTarget const * const Target;
+   IndexTarget const Target;
    HashStringList GetExpectedHashesFor(std::string const MetaKey) const;
 
    bool QueueURI(pkgAcquire::ItemDesc &Item);
@@ -403,13 +363,13 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item           /*{{{*/
    };
    virtual bool TransactionState(TransactionStates const state);
 
-   virtual std::string DescURI() const { return Target->URI; }
+   virtual std::string DescURI() const { return Target.URI; }
    virtual HashStringList GetExpectedHashes() const;
    virtual std::string GetMetaKey() const;
    virtual bool HashesRequired() const;
 
 
-   pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const * const Target);
+   pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target);
    virtual ~pkgAcqTransactionItem();
 
    friend class pkgAcqMetaBase;
@@ -423,7 +383,6 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem              /*{{{*/
  protected:
    std::vector<pkgAcqTransactionItem*> Transaction;
 
-   IndexTarget const DataTarget;
  public:
    /** \brief A package-system-specific parser for the meta-index file. */
    indexRecords *MetaIndexParser;
@@ -433,7 +392,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem              /*{{{*/
    /** \brief The index files which should be looked up in the meta-index
     *  and then downloaded.
     */
-   const std::vector<IndexTarget*>* const IndexTargets;
+   std::vector<IndexTarget> const IndexTargets;
 
    /** \brief If \b true, the index's signature is currently being verified.
     */
@@ -515,7 +474,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem              /*{{{*/
    virtual std::string GetFinalFilename() const;
 
    pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                 std::vector<IndexTarget*> const * const IndexTargets,
+                 std::vector<IndexTarget> const IndexTargets,
                  IndexTarget const &DataTarget,
                  indexRecords* const MetaIndexParser);
 };
@@ -552,7 +511,7 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
    /** \brief Create a new pkgAcqMetaIndex. */
    pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
                   IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget,
-                  const std::vector<IndexTarget*>* const IndexTargets, indexRecords * const MetaIndexParser);
+                  std::vector<IndexTarget> const IndexTargets, indexRecords * const MetaIndexParser);
 
    friend class pkgAcqMetaSig;
 };
@@ -588,7 +547,7 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem
                     pkgAcquire::MethodConfig const * const Cnf);
 
    /** \brief Create a new pkgAcqMetaSig. */
-   pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const * const Target,
+   pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target,
         pkgAcqMetaIndex * const MetaIndex);
    virtual ~pkgAcqMetaSig();
 };
@@ -613,7 +572,7 @@ public:
                IndexTarget const &ClearsignedTarget,
                IndexTarget const &DetachedDataTarget,
                IndexTarget const &DetachedSigTarget,
-               std::vector<IndexTarget*> const * const IndexTargets,
+               std::vector<IndexTarget> const IndexTargets,
                indexRecords * const MetaIndexParser);
    virtual ~pkgAcqMetaClearSig();
 };
@@ -628,7 +587,7 @@ class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
    virtual std::string GetFinalFilename() const;
 
    pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                   IndexTarget const * const Target);
+                   IndexTarget const Target);
 };
                                                                        /*}}}*/
 /** \brief An item that is responsible for fetching an index file of   {{{
@@ -648,11 +607,6 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
    /** \brief If \b true, debugging information will be written to std::clog. */
    bool Debug;
 
-   /** \brief The index file which will be patched to generate the new
-    *  file.
-    */
-   std::string CurrentPackagesFile;
-
    /** \brief A description of the Packages file (stored in
     *  pkgAcquire::ItemDesc::Description).
     */
@@ -669,7 +623,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
    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 DescURI() const {return Target->URI + "Index";};
+   virtual std::string DescURI() const {return Target.URI + "Index";};
    virtual std::string Custom600Headers() const;
    virtual std::string GetMetaKey() const;
 
@@ -696,7 +650,7 @@ 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 * const Target);
+                   IndexTarget const Target);
  private:
    APT_HIDDEN void QueueOnIMSHit() const;
 };
@@ -772,7 +726,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
         pkgAcquire::MethodConfig const * const Cnf);
    virtual std::string Custom600Headers() const;
-   virtual std::string DescURI() const {return Target->URI + "Index";};
+   virtual std::string DescURI() const {return Target.URI + "Index";};
    virtual HashStringList GetExpectedHashes() const;
    virtual bool HashesRequired() const;
 
@@ -794,8 +748,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
     *  check if it was the last one to complete the download step
     */
    pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                         IndexTarget const * const Target,
-                         DiffInfo const &patch,
+                         IndexTarget const Target, DiffInfo const &patch,
                          std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
 };
                                                                        /*}}}*/
@@ -885,7 +838,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
                     pkgAcquire::MethodConfig const * const Cnf);
    virtual std::string Custom600Headers() const;
-   virtual std::string DescURI() const {return Target->URI + "IndexDiffs";};
+   virtual std::string DescURI() const {return Target.URI + "IndexDiffs";};
    virtual HashStringList GetExpectedHashes() const;
    virtual bool HashesRequired() const;
 
@@ -908,7 +861,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
     *  that depends on it.
     */
    pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                    IndexTarget const * const Target,
+                    IndexTarget const Target,
                    std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>());
 };
                                                                        /*}}}*/
@@ -970,9 +923,6 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
    /** \brief Schedule file for verification after a IMS hit */
    void ReverifyAfterIMS();
 
-   /** \brief Validate the downloaded index file */
-   bool ValidateFile(std::string const &FileName);
-
    /** \brief Get the full pathname of the final file for the current URI */
    virtual std::string GetFinalFilename() const;
 
@@ -988,7 +938,7 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
    virtual std::string GetMetaKey() const;
 
    pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-               IndexTarget const * const Target);
+               IndexTarget const Target);
 
    void Init(std::string const &URI, std::string const &URIDesc,
              std::string const &ShortDesc);