acquire-item.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-item.h,v 1.13 1999/01/30 06:07:24 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 MD5Sum() {return string();};
  48. virtual string Describe() = 0;
  49. virtual string Custom600Headers() {return string();};
  50. Item(pkgAcquire *Owner);
  51. virtual ~Item();
  52. };
  53. // Item class for index files
  54. class pkgAcqIndex : public pkgAcquire::Item
  55. {
  56. protected:
  57. const pkgSourceList::Item *Location;
  58. bool Decompression;
  59. bool Erase;
  60. pkgAcquire::ItemDesc Desc;
  61. public:
  62. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  63. virtual string Custom600Headers();
  64. virtual string Describe();
  65. pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location);
  66. };
  67. // Item class for index files
  68. class pkgAcqIndexRel : public pkgAcquire::Item
  69. {
  70. protected:
  71. const pkgSourceList::Item *Location;
  72. pkgAcquire::ItemDesc Desc;
  73. public:
  74. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  75. virtual string Custom600Headers();
  76. virtual string Describe();
  77. pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location);
  78. };
  79. // Item class for archive files
  80. class pkgAcqArchive : public pkgAcquire::Item
  81. {
  82. protected:
  83. pkgCache::VerIterator Version;
  84. pkgAcquire::ItemDesc Desc;
  85. pkgSourceList *Sources;
  86. pkgRecords *Recs;
  87. string MD5;
  88. string &StoreFilename;
  89. pkgCache::VerFileIterator Vf;
  90. bool QueueNext();
  91. public:
  92. virtual void Failed(string Message);
  93. virtual string MD5Sum() {return MD5;};
  94. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  95. virtual string Describe();
  96. pkgAcqArchive(pkgAcquire *Owner,pkgSourceList *Sources,
  97. pkgRecords *Recs,pkgCache::VerIterator const &Version,
  98. string &StoreFilename);
  99. };
  100. #endif