X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/83b880c6505a20247239d897b7387bba37942993..91e42c2b4e9a6e8c7c1db29e9d1606741d251ca0:/apt-pkg/acquire.h diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index ef16d8556..0d2b21233 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -1,6 +1,5 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire.h,v 1.29.2.1 2003/12/24 23:09:17 mdz Exp $ /* ###################################################################### Acquire - File Acquiration @@ -68,9 +67,10 @@ #include #include +#include -#include #include +#include #include #include @@ -101,7 +101,7 @@ class pkgAcquire /** \brief FD of the Lock file we acquire in Setup (if any) */ int LockFD; /** \brief dpointer placeholder (for later in case we need it) */ - void *d; + void * const d; public: @@ -111,6 +111,7 @@ class pkgAcquire struct MethodConfig; struct ItemDesc; friend class Item; + friend class pkgAcqMetaBase; friend class Queue; typedef std::vector::iterator ItemIterator; @@ -351,14 +352,24 @@ class pkgAcquire * long as the pkgAcquire object does. * \param Lock defines a lock file that should be acquired to ensure * only one Acquire class is in action at the time or an empty string - * if no lock file should be used. + * if no lock file should be used. If set also all needed directories + * will be created. */ - bool Setup(pkgAcquireStatus *Progress = NULL, std::string const &Lock = ""); + APT_DEPRECATED bool Setup(pkgAcquireStatus *Progress = NULL, std::string const &Lock = ""); void SetLog(pkgAcquireStatus *Progress) { Log = Progress; } + /** \brief acquire lock and perform directory setup + * + * \param Lock defines a lock file that should be acquired to ensure + * only one Acquire class is in action at the time or an empty string + * if no lock file should be used. If set also all needed directories + * will be created and setup. + */ + bool GetLock(std::string const &Lock); + /** \brief Construct a new pkgAcquire. */ - pkgAcquire(pkgAcquireStatus *Log) APT_DEPRECATED; + explicit pkgAcquire(pkgAcquireStatus *Log); pkgAcquire(); /** \brief Destroy this pkgAcquire object. @@ -368,6 +379,8 @@ class pkgAcquire */ virtual ~pkgAcquire(); + private: + APT_HIDDEN void Initialize(); }; /** \brief Represents a single download source from which an item @@ -377,13 +390,13 @@ class pkgAcquire */ struct pkgAcquire::ItemDesc : public WeakPointable { - /** \brief The URI from which to download this item. */ + /** \brief URI from which to download this item. */ std::string URI; - /** brief A description of this item. */ + /** \brief description of this item. */ std::string Description; - /** brief A shorter description of this item. */ + /** \brief shorter description of this item. */ std::string ShortDesc; - /** brief The underlying item which is to be downloaded. */ + /** \brief underlying item which is to be downloaded. */ Item *Owner; }; /*}}}*/ @@ -398,7 +411,7 @@ class pkgAcquire::Queue friend class pkgAcquire::Worker; /** \brief dpointer placeholder (for later in case we need it) */ - void *d; + void * const d; /** \brief The next queue in the pkgAcquire object's list of queues. */ Queue *Next; @@ -406,13 +419,18 @@ class pkgAcquire::Queue protected: /** \brief A single item placed in this queue. */ - struct QItem : pkgAcquire::ItemDesc + struct QItem : public ItemDesc { /** \brief The next item in the queue. */ QItem *Next; /** \brief The worker associated with this item, if any. */ pkgAcquire::Worker *Worker; + /** \brief The underlying items interested in the download */ + std::vector Owners; + + typedef std::vector::const_iterator owner_iterator; + /** \brief Assign the ItemDesc portion of this QItem from * another ItemDesc */ @@ -421,10 +439,24 @@ class pkgAcquire::Queue URI = I.URI; Description = I.Description; ShortDesc = I.ShortDesc; + Owners.clear(); + Owners.push_back(I.Owner); Owner = I.Owner; }; + + /** @return the sum of all expected hashes by all owners */ + HashStringList GetExpectedHashes() const; + + /** @return smallest maximum size of all owners */ + unsigned long long GetMaximumSize() const; + + /** \brief get partial files in order */ + void SyncDestinationFiles() const; + + /** @return the custom headers to use for this item */ + std::string Custom600Headers() const; }; - + /** \brief The name of this queue. */ std::string Name; @@ -544,7 +576,7 @@ class pkgAcquire::Queue * \param Name The name of the new queue. * \param Owner The download process that owns the new queue. */ - Queue(std::string Name,pkgAcquire *Owner); + Queue(std::string const &Name,pkgAcquire * const Owner); /** Shut down all the worker processes associated with this queue * and empty the queue. @@ -556,7 +588,7 @@ class pkgAcquire::Queue class pkgAcquire::UriIterator { /** \brief dpointer placeholder (for later in case we need it) */ - void *d; + void * const d; /** The next queue to iterate over. */ pkgAcquire::Queue *CurQ; @@ -577,7 +609,7 @@ class pkgAcquire::UriIterator } }; - inline pkgAcquire::ItemDesc const *operator ->() const {return CurItem;}; + inline pkgAcquire::Queue::QItem const *operator ->() const {return CurItem;}; inline bool operator !=(UriIterator const &rhs) const {return rhs.CurQ != CurQ || rhs.CurItem != CurItem;}; inline bool operator ==(UriIterator const &rhs) const {return rhs.CurQ == CurQ && rhs.CurItem == CurItem;}; @@ -585,22 +617,15 @@ class pkgAcquire::UriIterator * * \param Q The queue over which this UriIterator should iterate. */ - UriIterator(pkgAcquire::Queue *Q) : CurQ(Q), CurItem(0) - { - while (CurItem == 0 && CurQ != 0) - { - CurItem = CurQ->Items; - CurQ = CurQ->Next; - } - } - virtual ~UriIterator() {}; + explicit UriIterator(pkgAcquire::Queue *Q); + virtual ~UriIterator(); }; /*}}}*/ /** \brief Information about the properties of a single acquire method. {{{*/ struct pkgAcquire::MethodConfig { /** \brief dpointer placeholder (for later in case we need it) */ - void *d; + void * const d; /** \brief The next link on the acquire method list. * @@ -651,8 +676,7 @@ struct pkgAcquire::MethodConfig */ MethodConfig(); - /* \brief Destructor, empty currently */ - virtual ~MethodConfig() {}; + virtual ~MethodConfig(); }; /*}}}*/ /** \brief A monitor object for downloads controlled by the pkgAcquire class. {{{ @@ -662,7 +686,7 @@ struct pkgAcquire::MethodConfig class pkgAcquireStatus { /** \brief dpointer placeholder (for later in case we need it) */ - void *d; + void * const d; protected: @@ -714,6 +738,10 @@ class pkgAcquireStatus /** \brief The number of items that have been successfully downloaded. */ unsigned long CurrentItems; + /** \brief The estimated percentage of the download (0-100) + */ + double Percent; + public: /** \brief If \b true, the download scheduler should call Pulse() @@ -794,7 +822,7 @@ class pkgAcquireStatus /** \brief Initialize all counters to 0 and the time to the current time. */ pkgAcquireStatus(); - virtual ~pkgAcquireStatus() {}; + virtual ~pkgAcquireStatus(); }; /*}}}*/ /** @} */