]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-item.h
rename StopAuthentication -> CheckStopAuthentication and make it protected
[apt.git] / apt-pkg / acquire-item.h
index 3c81f77a9aff940c2940b29a0d93f5789f7b2fd7..02b8c13e8ec465fd683ab790d4fbfad91e77001e 100644 (file)
@@ -283,7 +283,6 @@ class pkgAcquire::Item : public WeakPointable
    /** \return \b true if this object is being fetched from a trusted source. */
    virtual bool IsTrusted() const {return false;};
    
-   // report mirror problems
    /** \brief Report mirror problem
     * 
     *  This allows reporting mirror failures back to a centralized
@@ -293,6 +292,11 @@ class pkgAcquire::Item : public WeakPointable
     */
    void ReportMirrorFailure(std::string FailCode);
 
+   /** \brief Set the name of the current active subprocess
+    *
+    *  See also #ActiveSubprocess
+    */
+   void SetActiveSubprocess(const std::string &subprocess);
 
    /** \brief Initialize an item.
     *
@@ -364,6 +368,13 @@ class pkgAcqMetaBase  : public pkgAcquire::Item
     */
    const std::vector<IndexTarget*>* IndexTargets;
 
+   /** \brief If \b true, the index's signature is currently being verified.
+    */
+   bool AuthPass;
+
+   // required to deal gracefully with problems caused by incorrect ims hits
+   bool IMSHit; 
+
    /** \brief Starts downloading the individual index files.
     *
     *  \param verify If \b true, only indices whose expected hashsum
@@ -374,6 +385,45 @@ class pkgAcqMetaBase  : public pkgAcquire::Item
     */
    void QueueIndexes(bool verify);
 
+
+   /** \brief Called when a file is finished being retrieved.
+    *
+    *  If the file was not downloaded to DestFile, a copy process is
+    *  set up to copy it to DestFile; otherwise, Complete is set to \b
+    *  true and the file is moved to its final location.
+    *
+    *  \param Message The message block received from the fetch
+    *  subprocess.
+    */
+   bool CheckDownloadDone(const std::string &Message,
+                          const std::string &RealURI);
+
+   /** \brief Queue the downloaded Signature for verification */
+   void QueueForSignatureVerify(const std::string &MetaIndexFile,
+                                const std::string &MetaIndexFileSignature);
+
+   /** \brief Called when authentication succeeded.
+    *
+    *  Sanity-checks the authenticated file, queues up the individual
+    *  index files for download, and saves the signature in the lists
+    *  directory next to the authenticated list file.
+    *
+    *  \param Message The message block received from the fetch
+    *  subprocess.
+    */
+   bool CheckAuthDone(std::string Message, const std::string &RealURI);
+
+   /** Check if the current item should fail at this point */
+   bool CheckStopAuthentication(const std::string &RealURI,
+                                const std::string &Message);
+
+   /** \brief Check that the release file is a release file for the
+    *  correct distribution.
+    *
+    *  \return \b true if no fatal errors were encountered.
+    */
+   bool VerifyVendor(std::string Message, const std::string &RealURI);
+   
  public:
    // transaction code
    void Add(Item *I);
@@ -381,10 +431,14 @@ class pkgAcqMetaBase  : public pkgAcquire::Item
    bool TransactionHasError() APT_PURE;
    void CommitTransaction();
 
-   // helper for the signature warning
-   bool GenerateAuthWarning(const std::string &RealURI,
-                            const std::string &Message);
-
+   /** \brief Stage (queue) a copy action when the transaction is commited
+    */
+   void TransactionStageCopy(Item *I,
+                             const std::string &From, 
+                             const std::string &To);
+   /** \brief Stage (queue) a removal action when the transaction is commited
+    */
+   void TransactionStageRemoval(Item *I, const std::string &FinalFile);
 
    pkgAcqMetaBase(pkgAcquire *Owner,
                   const std::vector<IndexTarget*>* IndexTargets,
@@ -392,7 +446,8 @@ class pkgAcqMetaBase  : public pkgAcquire::Item
                   HashStringList const &ExpectedHashes=HashStringList(),
                   pkgAcqMetaBase *TransactionManager=NULL)
       : Item(Owner, ExpectedHashes, TransactionManager),
-        MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets) {};
+        MetaIndexParser(MetaIndexParser), IndexTargets(IndexTargets),
+        AuthPass(false), IMSHit(false) {};
 };
 
 /** \brief An acquire item that downloads the detached signature       {{{
@@ -415,23 +470,24 @@ class pkgAcqMetaSig : public pkgAcqMetaBase
     */
    std::string RealURI;
 
-   std::string URIDesc;
-   std::string ShortDesc;
-
    /** \brief The file we need to verify */
    std::string MetaIndexFile;
 
-   /** \brief If we are in fetching or download state */
-   bool AuthPass;
+   /** \brief The file we use to verify the MetaIndexFile with */
+   std::string MetaIndexFileSignature;
+
+   /** \brief Long URI description used in the acquire system */
+   std::string URIDesc;
 
-   /** \brief Was this file already on disk */
-   bool IMSHit;
+   /** \brief Short URI description used in the acquire system */
+   std::string ShortDesc;
 
    public:
    
    // Specialized action members
    virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
+   virtual void Done(std::string Message,unsigned long long Size,
+                     HashStringList const &Hashes,
                     pkgAcquire::MethodConfig *Cnf);
    virtual std::string Custom600Headers() const;
    virtual std::string DescURI() {return RealURI; };
@@ -467,48 +523,6 @@ class pkgAcqMetaIndex : public pkgAcqMetaBase
     */
    std::string RealURI;
 
-   /** \brief The file in which the signature for this index was stored.
-    *
-    *  If empty, the signature and the md5sums of the individual
-    *  indices will not be checked.
-    */
-   std::string SigFile;
-
-   /** \brief If \b true, the index's signature is currently being verified.
-    */
-   bool AuthPass;
-   // required to deal gracefully with problems caused by incorrect ims hits
-   bool IMSHit; 
-
-   /** \brief Check that the release file is a release file for the
-    *  correct distribution.
-    *
-    *  \return \b true if no fatal errors were encountered.
-    */
-   bool VerifyVendor(std::string Message);
-
-   /** \brief Called when a file is finished being retrieved.
-    *
-    *  If the file was not downloaded to DestFile, a copy process is
-    *  set up to copy it to DestFile; otherwise, Complete is set to \b
-    *  true and the file is moved to its final location.
-    *
-    *  \param Message The message block received from the fetch
-    *  subprocess.
-    */
-   void RetrievalDone(std::string Message);
-
-   /** \brief Called when authentication succeeded.
-    *
-    *  Sanity-checks the authenticated file, queues up the individual
-    *  index files for download, and saves the signature in the lists
-    *  directory next to the authenticated list file.
-    *
-    *  \param Message The message block received from the fetch
-    *  subprocess.
-    */
-   void AuthDone(std::string Message);
-
    std::string URIDesc;
    std::string ShortDesc;
 
@@ -569,7 +583,8 @@ class pkgAcqMetaClearSig : public pkgAcqMetaIndex
 public:
    virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
    virtual std::string Custom600Headers() const;
-   virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
+   virtual void Done(std::string Message,unsigned long long Size,
+                     HashStringList const &Hashes,
                     pkgAcquire::MethodConfig *Cnf);
 
    /** \brief Create a new pkgAcqMetaClearSig. */
@@ -595,10 +610,20 @@ class pkgAcqBaseIndex : public pkgAcquire::Item
    /** \brief Pointer to the IndexTarget data
     */
    const struct IndexTarget * Target;
+
+   /** \brief Pointer to the indexRecords parser */
    indexRecords *MetaIndexParser;
+
    /** \brief The MetaIndex Key */
    std::string MetaKey;
 
+   /** \brief The URI of the index file to recreate at our end (either
+    *  by downloading it or by applying partial patches).
+    */
+   std::string RealURI;
+
+   bool VerifyHashByMetaKey(HashStringList const &Hashes);
+
    pkgAcqBaseIndex(pkgAcquire *Owner,
                    pkgAcqMetaBase *TransactionManager,
                    struct IndexTarget const * const Target,
@@ -625,11 +650,6 @@ class pkgAcqDiffIndex : public pkgAcqBaseIndex
    /** \brief If \b true, debugging information will be written to std::clog. */
    bool Debug;
 
-   /** \brief The URI of the index file to recreate at our end (either
-    *  by downloading it or by applying partial patches).
-    */
-   std::string RealURI;
-
    /** \brief The index file which will be patched to generate the new
     *  file.
     */
@@ -706,11 +726,6 @@ class pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
     */
    bool Debug;
 
-   /** \brief URI of the package index file that is being
-    *  reconstructed.
-    */
-   std::string RealURI;
-
    /** \brief description of the file being downloaded. */
    std::string Description;
 
@@ -825,11 +840,6 @@ class pkgAcqIndexDiffs : public pkgAcqBaseIndex
     */
    bool Debug;
 
-   /** \brief The URI of the package index file that is being
-    *  reconstructed.
-    */
-   std::string RealURI;
-
    /** A description of the file being downloaded. */
    std::string Description;
 
@@ -921,24 +931,41 @@ class pkgAcqIndex : public pkgAcqBaseIndex
 
    protected:
 
-   /** \brief If \b true, the index file has been decompressed. */
-   bool Decompression;
+   /** \brief The stages the method goes through
+    *
+    *  The method first downloads the indexfile, then its decompressed (or
+    *  copied) and verified
+    */
+   enum AllStages {
+      STAGE_DOWNLOAD,
+      STAGE_DECOMPRESS_AND_VERIFY,
+   };
+   AllStages Stage;
+
+   /** \brief Handle what needs to be done when the download is done */
+   void StageDownloadDone(std::string Message,
+                          HashStringList const &Hashes,
+                          pkgAcquire::MethodConfig *Cfg);
 
-   /** \brief If \b true, the partially downloaded file will be
-    *  removed when the download completes.
+   /** \brief Handle what needs to be done when the decompression/copy is
+    *         done 
     */
-   bool Erase;
+   void StageDecompressDone(std::string Message,
+                            HashStringList const &Hashes,
+                            pkgAcquire::MethodConfig *Cfg);
 
-   /** \brief The object that is actually being fetched (minus any
-    *  compression-related extensions).
+   /** \brief If \b set, this partially downloaded file will be
+    *  removed when the download completes.
     */
-   std::string RealURI;
+   std::string EraseFileName;
 
    /** \brief The compression-related file extensions that are being
     *  added to the downloaded file one by one if first fails (e.g., "gz bz2").
     */
-   std::string CompressionExtension;
+   std::string CompressionExtensions;
 
+   /** \brief The actual compression extension currently used */
+   std::string CurrentCompressionExtension;
 
    /** \brief Do the changes needed to fetch via AptByHash (if needed) */
    void InitByHashIfNeeded(const std::string MetaKey);
@@ -953,11 +980,15 @@ class pkgAcqIndex : public pkgAcqBaseIndex
    /** \brief Schedule file for verification after a IMS hit */
    void ReverifyAfterIMS();
 
+   /** \brief Validate the downloaded index file */
+   bool ValidateFile(const std::string &FileName);
+
    public:
    
    // Specialized action members
    virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
-   virtual void Done(std::string Message,unsigned long long Size, HashStringList const &Hashes,
+   virtual void Done(std::string Message,unsigned long long Size, 
+                     HashStringList const &Hashes,
                     pkgAcquire::MethodConfig *Cnf);
    virtual std::string Custom600Headers() const;
    virtual std::string DescURI() {return Desc.URI;};