acquire-item.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-item.h,v 1.9 1998/11/13 07:08:50 jgg Exp $
  4. /* ######################################################################
  5. Acquire Item - Item to acquire
  6. When an item is instantiated it will add it self to the local list in
  7. the Owner Acquire class. Derived classes will then call QueueURI to
  8. register all the URI's they wish to fetch for at the initial moment.
  9. Two item classes are provided to provide functionality for downloading
  10. of Index files and downloading of Packages.
  11. ##################################################################### */
  12. /*}}}*/
  13. #ifndef PKGLIB_ACQUIRE_ITEM_H
  14. #define PKGLIB_ACQUIRE_ITEM_H
  15. #include <apt-pkg/acquire.h>
  16. #include <apt-pkg/sourcelist.h>
  17. #include <apt-pkg/pkgrecords.h>
  18. #ifdef __GNUG__
  19. #pragma interface "apt-pkg/acquire-item.h"
  20. #endif
  21. // Item to acquire
  22. class pkgAcquire::Item
  23. {
  24. protected:
  25. pkgAcquire *Owner;
  26. inline void QueueURI(ItemDesc &Item)
  27. {Owner->Enqueue(Item);};
  28. void Rename(string From,string To);
  29. public:
  30. // State of the item
  31. enum {StatIdle, StatFetching, StatDone, StatError} Status;
  32. string ErrorText;
  33. unsigned long FileSize;
  34. char *Mode;
  35. unsigned long ID;
  36. bool Complete;
  37. bool Local;
  38. // Number of queues we are inserted into
  39. unsigned int QueueCounter;
  40. // File to write the fetch into
  41. string DestFile;
  42. virtual void Failed(string Message);
  43. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  44. virtual void Start(string Message,unsigned long Size);
  45. virtual string Custom600Headers() {return string();};
  46. Item(pkgAcquire *Owner);
  47. virtual ~Item();
  48. };
  49. // Item class for index files
  50. class pkgAcqIndex : public pkgAcquire::Item
  51. {
  52. protected:
  53. const pkgSourceList::Item *Location;
  54. bool Decompression;
  55. bool Erase;
  56. pkgAcquire::ItemDesc Desc;
  57. public:
  58. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  59. virtual string Custom600Headers();
  60. pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location);
  61. };
  62. // Item class for index files
  63. class pkgAcqIndexRel : public pkgAcquire::Item
  64. {
  65. protected:
  66. const pkgSourceList::Item *Location;
  67. pkgAcquire::ItemDesc Desc;
  68. public:
  69. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  70. virtual string Custom600Headers();
  71. pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location);
  72. };
  73. // Item class for archive files
  74. class pkgAcqArchive : public pkgAcquire::Item
  75. {
  76. protected:
  77. pkgCache::VerIterator Version;
  78. pkgAcquire::ItemDesc Desc;
  79. pkgSourceList *Sources;
  80. pkgRecords *Recs;
  81. string MD5;
  82. public:
  83. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  84. pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
  85. pkgRecords *Recs,pkgCache::VerIterator const &Version);
  86. };
  87. #endif