acquire-item.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-item.h,v 1.7 1998/11/11 06:54:14 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. #ifdef __GNUG__
  18. #pragma interface "apt-pkg/acquire-item.h"
  19. #endif
  20. // Item to acquire
  21. class pkgAcquire::Item
  22. {
  23. protected:
  24. pkgAcquire *Owner;
  25. inline void QueueURI(ItemDesc &Item)
  26. {Owner->Enqueue(Item);};
  27. void Rename(string From,string To);
  28. public:
  29. // State of the item
  30. enum {StatIdle, StatFetching, StatDone, StatError} Status;
  31. string ErrorText;
  32. unsigned long FileSize;
  33. char *Mode;
  34. unsigned long ID;
  35. bool Complete;
  36. // Number of queues we are inserted into
  37. unsigned int QueueCounter;
  38. // File to write the fetch into
  39. string DestFile;
  40. virtual void Failed(string Message);
  41. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  42. virtual void Start(string Message,unsigned long Size);
  43. virtual string Custom600Headers() {return string();};
  44. Item(pkgAcquire *Owner);
  45. virtual ~Item();
  46. };
  47. // Item class for index files
  48. class pkgAcqIndex : public pkgAcquire::Item
  49. {
  50. protected:
  51. const pkgSourceList::Item *Location;
  52. bool Decompression;
  53. bool Erase;
  54. pkgAcquire::ItemDesc Desc;
  55. public:
  56. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  57. virtual string Custom600Headers();
  58. pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location);
  59. };
  60. // Item class for index files
  61. class pkgAcqIndexRel : public pkgAcquire::Item
  62. {
  63. protected:
  64. const pkgSourceList::Item *Location;
  65. pkgAcquire::ItemDesc Desc;
  66. public:
  67. virtual void Done(string Message,unsigned long Size,string Md5Hash);
  68. virtual string Custom600Headers();
  69. pkgAcqIndexRel(pkgAcquire *Owner,const pkgSourceList::Item *Location);
  70. };
  71. #endif