acquire-item.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-item.h,v 1.12 1998/12/11 06:32:34 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. A Archive class is provided for downloading .deb files. It does Md5
  12. checking and source location.
  13. ##################################################################### */
  14. /*}}}*/
  15. #ifndef PKGLIB_ACQUIRE_ITEM_H
  16. #define PKGLIB_ACQUIRE_ITEM_H
  17. #include <apt-pkg/acquire.h>
  18. #include <apt-pkg/sourcelist.h>
  19. #include <apt-pkg/pkgrecords.h>
  20. #ifdef __GNUG__
  21. #pragma interface "apt-pkg/acquire-item.h"
  22. #endif
  23. // Item to acquire
  24. class pkgAcquire::Item
  25. {
  26. protected:
  27. pkgAcquire *Owner;
  28. inline void QueueURI(ItemDesc &Item)
  29. {Owner->Enqueue(Item);};
  30. void Rename(string From,string To);
  31. public:
  32. // State of the item
  33. enum {StatIdle, StatFetching, StatDone, StatError} Status;
  34. string ErrorText;
  35. unsigned long FileSize;
  36. char *Mode;
  37. unsigned long ID;
  38. bool Complete;
  39. bool Local;
  40. // Number of queues we are inserted into
  41. unsigned int QueueCounter;
  42. // File to write the fetch into
  43. string DestFile;
  44. virtual void Failed(string Message);
  45. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  46. virtual void Start(string Message,unsigned long Size);
  47. virtual string Describe() = 0;
  48. virtual string Custom600Headers() {return string();};
  49. Item(pkgAcquire *Owner);
  50. virtual ~Item();
  51. };
  52. // Item class for index files
  53. class pkgAcqIndex : public pkgAcquire::Item
  54. {
  55. protected:
  56. const pkgSourceList::Item *Location;
  57. bool Decompression;
  58. bool Erase;
  59. pkgAcquire::ItemDesc Desc;
  60. public:
  61. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  62. virtual string Custom600Headers();
  63. virtual string Describe();
  64. pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location);
  65. };
  66. // Item class for index files
  67. class pkgAcqIndexRel : public pkgAcquire::Item
  68. {
  69. protected:
  70. const pkgSourceList::Item *Location;
  71. pkgAcquire::ItemDesc Desc;
  72. public:
  73. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  74. virtual string Custom600Headers();
  75. virtual string Describe();
  76. pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location);
  77. };
  78. // Item class for archive files
  79. class pkgAcqArchive : public pkgAcquire::Item
  80. {
  81. protected:
  82. pkgCache::VerIterator Version;
  83. pkgAcquire::ItemDesc Desc;
  84. pkgSourceList *Sources;
  85. pkgRecords *Recs;
  86. string MD5;
  87. string &StoreFilename;
  88. pkgCache::VerFileIterator Vf;
  89. bool QueueNext();
  90. public:
  91. virtual void Failed(string Message);
  92. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  93. virtual string Describe();
  94. pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
  95. pkgRecords *Recs,pkgCache::VerIterator const &Version,
  96. string &StoreFilename);
  97. };
  98. #endif