-
- // File to write the fetch into
- string DestFile;
-
- // Action members invoked by the worker
- virtual void Failed(string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(string Message,unsigned long Size,string Md5Hash,
- pkgAcquire::MethodConfig *Cnf);
- virtual void Start(string Message,unsigned long Size);
- virtual string Custom600Headers() {return string();};
- virtual string DescURI() = 0;
- virtual string ShortDesc() {return DescURI();}
- virtual void Finished() {};
-
- // Inquire functions
- virtual string MD5Sum() {return string();};
- pkgAcquire *GetOwner() {return Owner;};
- virtual bool IsTrusted() {return false;};
-
- // report mirror problems
- void ReportMirrorFailure(string FailCode);
-
- Item(pkgAcquire *Owner);
+
+ /** \brief The number of additional fetch items that are expected
+ * once this item is done.
+ *
+ * Some items like pkgAcqMeta{Index,Sig} will queue additional
+ * items. This variable can be set by the methods if it knows
+ * in advance how many items to expect to get a more accurate
+ * progress.
+ */
+ unsigned int ExpectedAdditionalItems;
+
+ /** \brief The name of the file into which the retrieved object
+ * will be written.
+ */
+ std::string DestFile;
+
+ /** \brief Invoked by the acquire worker when the object couldn't
+ * be fetched.
+ *
+ * This is a branch of the continuation of the fetch process.
+ *
+ * \param Message An RFC822-formatted message from the acquire
+ * method describing what went wrong. Use LookupTag() to parse
+ * it.
+ *
+ * \param Cnf The method via which the worker tried to fetch this object.
+ *
+ * \sa pkgAcqMethod
+ */
+ virtual void Failed(std::string const &Message,pkgAcquire::MethodConfig const * const Cnf);
+
+ /** \brief Invoked by the acquire worker to check if the successfully
+ * fetched object is also the objected we wanted to have.
+ *
+ * Note that the object might \e not have been written to
+ * DestFile; check for the presence of an Alt-Filename entry in
+ * Message to find the file to which it was really written.
+ *
+ * This is called before Done is called and can prevent it by returning
+ * \b false which will result in Failed being called instead.
+ *
+ * You should prefer to use this method over calling Failed() from Done()
+ * as this has e.g. the wrong progress reporting.
+ *
+ * \param Message Data from the acquire method. Use LookupTag()
+ * to parse it.
+ * \param Cnf The method via which the object was fetched.
+ *
+ * \sa pkgAcqMethod
+ */
+ virtual bool VerifyDone(std::string const &Message,
+ pkgAcquire::MethodConfig const * const Cnf);
+
+ /** \brief Invoked by the acquire worker when the object was
+ * fetched successfully.
+ *
+ * Note that the object might \e not have been written to
+ * DestFile; check for the presence of an Alt-Filename entry in
+ * Message to find the file to which it was really written.
+ *
+ * Done is often used to switch from one stage of the processing
+ * to the next (e.g. fetching, unpacking, copying). It is one
+ * branch of the continuation of the fetch process.
+ *
+ * \param Message Data from the acquire method. Use LookupTag()
+ * to parse it.
+ * \param Hashes The HashSums of the object that was fetched.
+ * \param Cnf The method via which the object was fetched.
+ *
+ * \sa pkgAcqMethod
+ */
+ virtual void Done(std::string const &Message, HashStringList const &Hashes,
+ pkgAcquire::MethodConfig const * const Cnf);
+
+ /** \brief Invoked when the worker starts to fetch this object.
+ *
+ * \param Message RFC822-formatted data from the worker process.
+ * Use LookupTag() to parse it.
+ *
+ * \param Hashes The expected hashes of the object being fetched.
+ *
+ * \sa pkgAcqMethod
+ */
+ virtual void Start(std::string const &Message, unsigned long long const Size);
+
+ /** \brief Custom headers to be sent to the fetch process.
+ *
+ * \return a string containing RFC822-style headers that are to be
+ * inserted into the 600 URI Acquire message sent to the fetch
+ * subprocess. The headers are inserted after a newline-less
+ * line, so they should (if nonempty) have a leading newline and
+ * no trailing newline.
+ */
+ virtual std::string Custom600Headers() const;
+
+ /** \brief A "descriptive" URI-like string.
+ *
+ * \return a URI that should be used to describe what is being fetched.
+ */
+ virtual std::string DescURI() const = 0;
+ /** \brief Short item description.
+ *
+ * \return a brief description of the object being fetched.
+ */
+ virtual std::string ShortDesc() const;
+
+ /** \brief Invoked by the worker when the download is completely done. */
+ virtual void Finished();
+
+ /** \return HashSums the DestFile is supposed to have in this stage */
+ virtual HashStringList GetExpectedHashes() const = 0;
+ /** \return the 'best' hash for display proposes like --print-uris */
+ std::string HashSum() const;
+
+ /** \return if having no hashes is a hard failure or not
+ *
+ * Idealy this is always \b true for every subclass, but thanks to
+ * historical grow we don't have hashes for all files in all cases
+ * in all steps, so it is slightly more complicated than it should be.
+ */
+ virtual bool HashesRequired() const { return true; }
+
+ /** \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;
+
+ /** \brief Report mirror problem
+ *
+ * This allows reporting mirror failures back to a centralized
+ * server. The apt-report-mirror-failure script is called for this
+ *
+ * \param FailCode A short failure string that is send
+ */
+ APT_DEPRECATED_MSG("Item::Failed does this for you") void ReportMirrorFailure(std::string const &FailCode);
+
+ /** \brief Set the name of the current active subprocess
+ *
+ * See also #ActiveSubprocess
+ */
+ void SetActiveSubprocess(std::string const &subprocess);
+
+ /** \brief Initialize an item.
+ *
+ * Adds the item to the list of items known to the acquire
+ * process, but does not place it into any fetch queues (you must
+ * manually invoke QueueURI() to do so).
+ *
+ * \param Owner The new owner of this item.
+ */
+ explicit Item(pkgAcquire * const Owner);
+
+ /** \brief Remove this item from its owner's queue by invoking
+ * pkgAcquire::Remove.
+ */