]> git.saurik.com Git - apt.git/blob - apt-private/private-download.cc
cleanup headers and especially #includes everywhere
[apt.git] / apt-private / private-download.cc
1 // Include Files /*{{{*/
2 #include <config.h>
3
4 #include <apt-pkg/acquire.h>
5 #include <apt-pkg/acquire-item.h>
6 #include <apt-pkg/configuration.h>
7 #include <apt-pkg/error.h>
8 #include <apt-pkg/strutl.h>
9
10 #include <apt-private/private-output.h>
11 #include <apt-private/private-download.h>
12
13 #include <fstream>
14 #include <string>
15 #include <vector>
16
17 #include <apti18n.h>
18 /*}}}*/
19
20 // CheckAuth - check if each download comes form a trusted source /*{{{*/
21 bool CheckAuth(pkgAcquire& Fetcher, bool const PromptUser)
22 {
23 std::string UntrustedList;
24 for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin(); I < Fetcher.ItemsEnd(); ++I)
25 if (!(*I)->IsTrusted())
26 UntrustedList += std::string((*I)->ShortDesc()) + " ";
27
28 if (UntrustedList == "")
29 return true;
30
31 ShowList(c2out,_("WARNING: The following packages cannot be authenticated!"),UntrustedList,"");
32
33 if (_config->FindB("APT::Get::AllowUnauthenticated",false) == true)
34 {
35 c2out << _("Authentication warning overridden.\n");
36 return true;
37 }
38
39 if (PromptUser == false)
40 return _error->Error(_("Some packages could not be authenticated"));
41
42 if (_config->FindI("quiet",0) < 2
43 && _config->FindB("APT::Get::Assume-Yes",false) == false)
44 {
45 c2out << _("Install these packages without verification?") << std::flush;
46 if (!YnPrompt(false))
47 return _error->Error(_("Some packages could not be authenticated"));
48
49 return true;
50 }
51 else if (_config->FindB("APT::Get::Force-Yes",false) == true)
52 return true;
53
54 return _error->Error(_("There are problems and -y was used without --force-yes"));
55 }
56 /*}}}*/
57 bool AcquireRun(pkgAcquire &Fetcher, int const PulseInterval, bool * const Failure, bool * const TransientNetworkFailure)/*{{{*/
58 {
59 pkgAcquire::RunResult res;
60 if(PulseInterval > 0)
61 res = Fetcher.Run(PulseInterval);
62 else
63 res = Fetcher.Run();
64
65 if (res == pkgAcquire::Failed)
66 return false;
67
68 for (pkgAcquire::ItemIterator I = Fetcher.ItemsBegin();
69 I != Fetcher.ItemsEnd(); ++I)
70 {
71
72 if ((*I)->Status == pkgAcquire::Item::StatDone &&
73 (*I)->Complete == true)
74 continue;
75
76 if (TransientNetworkFailure != NULL && (*I)->Status == pkgAcquire::Item::StatIdle)
77 {
78 *TransientNetworkFailure = true;
79 continue;
80 }
81
82 ::URI uri((*I)->DescURI());
83 uri.User.clear();
84 uri.Password.clear();
85 std::string descUri = std::string(uri);
86 _error->Error(_("Failed to fetch %s %s\n"), descUri.c_str(),
87 (*I)->ErrorText.c_str());
88
89 if (Failure != NULL)
90 *Failure = true;
91 }
92
93 return true;
94 }
95 /*}}}*/