apt  0.9.7.7ubuntu4
acquire-item.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: acquire-item.h,v 1.26.2.3 2004/01/02 18:51:00 mdz Exp $
4 /* ######################################################################
5 
6  Acquire Item - Item to acquire
7 
8  When an item is instantiated it will add it self to the local list in
9  the Owner Acquire class. Derived classes will then call QueueURI to
10  register all the URI's they wish to fetch at the initial moment.
11 
12  Three item classes are provided to provide functionality for
13  downloading of Index, Translation and Packages files.
14 
15  A Archive class is provided for downloading .deb files. It does Hash
16  checking and source location as well as a retry algorithm.
17 
18  ##################################################################### */
19  /*}}}*/
20 #ifndef PKGLIB_ACQUIRE_ITEM_H
21 #define PKGLIB_ACQUIRE_ITEM_H
22 
23 #include <apt-pkg/acquire.h>
24 #include <apt-pkg/hashes.h>
25 #include <apt-pkg/weakptr.h>
26 #include <apt-pkg/pkgcache.h>
27 
28 #ifndef APT_8_CLEANER_HEADERS
29 #include <apt-pkg/indexfile.h>
30 #include <apt-pkg/vendor.h>
31 #include <apt-pkg/sourcelist.h>
32 #include <apt-pkg/pkgrecords.h>
33 #include <apt-pkg/indexrecords.h>
34 #endif
35 
42 class indexRecords;
43 class pkgRecords;
44 class pkgSourceList;
45 
59 {
60  protected:
61 
64 
70  inline void QueueURI(ItemDesc &Item)
71  {Owner->Enqueue(Item);};
72 
74  inline void Dequeue() {Owner->Dequeue(this);};
75 
85  void Rename(std::string From,std::string To);
86 
87  public:
88 
90  enum ItemState
91  {
94 
97 
100 
105 
110 
115  } Status;
116 
120  std::string ErrorText;
121 
123  unsigned long long FileSize;
124 
126  unsigned long long PartialSize;
127 
131  const char *Mode;
132 
140  unsigned long ID;
141 
146  bool Complete;
147 
153  bool Local;
154  std::string UsedMirror;
155 
164  unsigned int QueueCounter;
165 
169  std::string DestFile;
170 
184  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
185 
205  virtual void Done(std::string Message,unsigned long long Size,std::string Hash,
207 
217  virtual void Start(std::string Message,unsigned long long Size);
218 
227  virtual std::string Custom600Headers() {return std::string();};
228 
233  virtual std::string DescURI() = 0;
238  virtual std::string ShortDesc() {return DescURI();}
239 
241  virtual void Finished() {};
242 
248  virtual std::string HashSum() {return std::string();};
249 
251  pkgAcquire *GetOwner() {return Owner;};
252 
254  virtual bool IsTrusted() {return false;};
255 
256  // report mirror problems
264  void ReportMirrorFailure(std::string FailCode);
265 
266 
279 
283  virtual ~Item();
284 };
285  /*}}}*/ /*{{{*/
287 struct DiffInfo {
289  std::string file;
290 
292  std::string sha1;
293 
295  unsigned long size;
296 };
297  /*}}}*/
305 {
306  protected:
308  bool Debug;
309 
312 
316 
317  public:
318  // Specialized action members
319  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
320  virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
322  virtual std::string DescURI() {return Desc.URI;};
323  virtual std::string Custom600Headers();
324  virtual bool ParseIndex(std::string const &IndexFile);
325 
338  pkgAcqSubIndex(pkgAcquire *Owner, std::string const &URI,std::string const &URIDesc,
339  std::string const &ShortDesc, HashString const &ExpectedHash);
340 };
341  /*}}}*/
352 {
353  protected:
355  bool Debug;
356 
359 
363  std::string RealURI;
364 
369 
373  std::string CurrentPackagesFile;
374 
378  std::string Description;
379 
380  public:
381  // Specialized action members
382  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
383  virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
385  virtual std::string DescURI() {return RealURI + "Index";};
386  virtual std::string Custom600Headers();
387 
398  bool ParseDiffIndex(std::string IndexDiffFile);
399 
400 
413  pkgAcqDiffIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc,
414  std::string ShortDesc, HashString ExpectedHash);
415 };
416  /*}}}*/
429 {
430  private:
431 
441  bool QueueNextDiff();
442 
454  void Finish(bool allDone=false);
455 
456  protected:
457 
461  bool Debug;
462 
467 
471  std::string RealURI;
472 
477 
479  std::string Description;
480 
489  std::vector<DiffInfo> available_patches;
490 
492  std::string ServerSha1;
493 
496  {
499 
502 
504  StateUnzipDiff, // FIXME: No longer used
505 
508  } State;
509 
510  public:
511 
517  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
518 
519  virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
521  virtual std::string DescURI() {return RealURI + "Index";};
522 
545  pkgAcqIndexDiffs(pkgAcquire *Owner,std::string URI,std::string URIDesc,
546  std::string ShortDesc, HashString ExpectedHash,
547  std::string ServerSha1,
548  std::vector<DiffInfo> diffs=std::vector<DiffInfo>());
549 };
550  /*}}}*/
559 {
560  protected:
561 
564 
568  bool Erase;
569 
575  // FIXME: instead of a bool it should use a verify string that will
576  // then be used in the pkgAcqIndex::Done method to ensure that
577  // the downloaded file contains the expected tag
578  bool Verify;
579 
584 
588  std::string RealURI;
589 
592 
596  std::string CompressionExtension;
597 
598  public:
599 
600  // Specialized action members
601  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
602  virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
604  virtual std::string Custom600Headers();
605  virtual std::string DescURI() {return Desc.URI;};
606  virtual std::string HashSum() {return ExpectedHash.toStr(); };
607 
627  pkgAcqIndex(pkgAcquire *Owner,std::string URI,std::string URIDesc,
628  std::string ShortDesc, HashString ExpectedHash,
629  std::string compressExt="");
630  pkgAcqIndex(pkgAcquire *Owner, struct IndexTarget const * const Target,
631  HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
632  void Init(std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc);
633 };
634  /*}}}*/
643 {
644  public:
645 
646  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
647  virtual std::string Custom600Headers();
648 
660  pkgAcqIndexTrans(pkgAcquire *Owner,std::string URI,std::string URIDesc,
661  std::string ShortDesc);
662  pkgAcqIndexTrans(pkgAcquire *Owner, struct IndexTarget const * const Target,
663  HashString const &ExpectedHash, indexRecords const *MetaIndexParser);
664 };
665  /*}}}*/ /*{{{*/
668 {
669  public:
671  std::string URI;
672 
674  std::string Description;
675 
677  std::string ShortDesc;
678 
682  std::string MetaKey;
683 
684  virtual bool IsOptional() const {
685  return false;
686  }
687  virtual bool IsSubIndex() const {
688  return false;
689  }
690 };
691  /*}}}*/ /*{{{*/
694 {
695  virtual bool IsOptional() const {
696  return true;
697  }
698 };
699  /*}}}*/ /*{{{*/
702 {
703  virtual bool IsSubIndex() const {
704  return true;
705  }
706 };
707  /*}}}*/ /*{{{*/
710 {
711  virtual bool IsSubIndex() const {
712  return true;
713  }
714 };
715  /*}}}*/
716 
726 {
727  protected:
729  std::string LastGoodSig;
730 
733 
738  std::string RealURI;
739 
741  std::string MetaIndexURI;
742 
746  std::string MetaIndexURIDesc;
747 
751  std::string MetaIndexShortDesc;
752 
755 
761  const std::vector<struct IndexTarget*>* IndexTargets;
762 
763  public:
764 
765  // Specialized action members
766  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
767  virtual void Done(std::string Message,unsigned long long Size,std::string Md5Hash,
769  virtual std::string Custom600Headers();
770  virtual std::string DescURI() {return RealURI; };
771 
773  pkgAcqMetaSig(pkgAcquire *Owner,std::string URI,std::string URIDesc, std::string ShortDesc,
774  std::string MetaIndexURI, std::string MetaIndexURIDesc, std::string MetaIndexShortDesc,
775  const std::vector<struct IndexTarget*>* IndexTargets,
777 };
778  /*}}}*/
790 {
791  protected:
794 
798  std::string RealURI;
799 
805  std::string SigFile;
806 
808  const std::vector<struct IndexTarget*>* IndexTargets;
809 
812 
815  bool AuthPass;
816  // required to deal gracefully with problems caused by incorrect ims hits
817  bool IMSHit;
818 
824  bool VerifyVendor(std::string Message);
825 
835  void RetrievalDone(std::string Message);
836 
846  void AuthDone(std::string Message);
847 
856  void QueueIndexes(bool verify);
857 
858  public:
859 
860  // Specialized action members
861  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
862  virtual void Done(std::string Message,unsigned long long Size, std::string Hash,
864  virtual std::string Custom600Headers();
865  virtual std::string DescURI() {return RealURI; };
866 
869  std::string URI,std::string URIDesc, std::string ShortDesc,
870  std::string SigFile,
871  const std::vector<struct IndexTarget*>* IndexTargets,
873 };
874  /*}}}*/
877 {
879  std::string MetaIndexURI;
880 
882  std::string MetaIndexURIDesc;
883 
885  std::string MetaIndexShortDesc;
886 
888  std::string MetaSigURI;
889 
891  std::string MetaSigURIDesc;
892 
894  std::string MetaSigShortDesc;
895 
896 public:
897  void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
898  virtual std::string Custom600Headers();
899 
902  std::string const &URI, std::string const &URIDesc, std::string const &ShortDesc,
903  std::string const &MetaIndexURI, std::string const &MetaIndexURIDesc, std::string const &MetaIndexShortDesc,
904  std::string const &MetaSigURI, std::string const &MetaSigURIDesc, std::string const &MetaSigShortDesc,
905  const std::vector<struct IndexTarget*>* IndexTargets,
907 };
908  /*}}}*/
915 {
916  protected:
919 
922 
927 
932 
935 
939  std::string &StoreFilename;
940 
943 
949  unsigned int Retries;
950 
954  bool Trusted;
955 
957  bool QueueNext();
958 
959  public:
960 
961  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
962  virtual void Done(std::string Message,unsigned long long Size,std::string Hash,
964  virtual std::string DescURI() {return Desc.URI;};
965  virtual std::string ShortDesc() {return Desc.ShortDesc;};
966  virtual void Finished();
967  virtual std::string HashSum() {return ExpectedHash.toStr(); };
968  virtual bool IsTrusted();
969 
990  std::string &StoreFilename);
991 };
992  /*}}}*/
1000 {
1002  pkgAcquire::ItemDesc Desc;
1003 
1005  HashString ExpectedHash;
1006 
1010  unsigned int Retries;
1011 
1013  bool IsIndexFile;
1014 
1015  public:
1016 
1017  // Specialized action members
1018  virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
1019  virtual void Done(std::string Message,unsigned long long Size,std::string CalcHash,
1021  virtual std::string DescURI() {return Desc.URI;};
1022  virtual std::string HashSum() {return ExpectedHash.toStr(); };
1023  virtual std::string Custom600Headers();
1024 
1056  pkgAcqFile(pkgAcquire *Owner, std::string URI, std::string Hash, unsigned long long Size,
1057  std::string Desc, std::string ShortDesc,
1058  const std::string &DestDir="", const std::string &DestFilename="",
1059  bool IsIndexFile=false);
1060 };
1061  /*}}}*/
1064 #endif