libzypp 17.35.14
base_p.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* You have been warned!
12*
13*/
14#ifndef ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
15#define ZYPP_CURL_NG_NETWORK_PRIVATE_DOWNLOADERSTATES_BASE_P_H_INCLUDED
16
19#include <zypp-core/TriBool.h>
20#include <zypp-curl/ng/network/Downloader>
21#include <zypp-curl/ng/network/DownloadSpec>
22#include <zypp-core/zyppng/core/ByteArray>
24#include <zypp-curl/ng/network/TransferSettings>
27#include <zypp-media/auth/CredentialManager>
28
29namespace zyppng {
30
31 class NetworkRequestDispatcher;
32 class DownloadPrivate;
33
41 {
43 public:
44 DownloadPrivateBase ( Downloader &parent, std::shared_ptr<NetworkRequestDispatcher> requestDispatcher, std::shared_ptr<MirrorControl> mirrors, DownloadSpec &&spec, Download &p );
45 ~DownloadPrivateBase () override;
46
47 struct Block {
48 off_t start = 0;
49 size_t len = 0;
50
51 std::string chksumtype;
52 std::optional<UByteArray> chksumVec;
53 std::optional<size_t> chksumCompareLen; //< initialized if only the first few bytes of the checksum should be considered
54 std::optional<size_t> chksumPad; //< initialized if the hashed blocks for a digest need to be padded if a block is smaller ( e.g. last block in a zsync file )
55
56 int _retryCount = 0; //< how many times was this request restarted
57 NetworkRequestError _failedWithErr; //< what was the error this request failed with
58 };
59
60 struct Request : public NetworkRequest {
61
63 using Ptr = std::shared_ptr<Request>;
64 using WeakPtr = std::shared_ptr<Request>;
65
66 template <typename Receiver>
67 void connectSignals ( Receiver &dl ) {
68 _sigStartedConn = connect ( &NetworkRequest::sigStarted, dl, &Receiver::onRequestStarted );
69 _sigProgressConn = connect ( &NetworkRequest::sigProgress, dl, &Receiver::onRequestProgress );
70 _sigFinishedConn = connect ( &NetworkRequest::sigFinished, dl, &Receiver::onRequestFinished );
71 }
72 void disconnectSignals ();
73
74 time_t _authTimestamp = 0; //< timestamp of the AuthData we tried already
75 Url _originalUrl; //< The unstripped URL as it was passed to Download , before transfer settings are removed
77
81 };
82
83
84 bool _emittedSigStart = false;
85 bool handleRequestAuthError(const std::shared_ptr<Request>& req, const zyppng::NetworkRequestError &err);
86
88
89#if ENABLE_ZCHUNK_COMPRESSION
90 bool hasZckInfo () const;
91#endif
92
93 std::shared_ptr<NetworkRequestDispatcher> _requestDispatcher;
94 std::shared_ptr<MirrorControl> _mirrorControl;
95
96 zypp::media::CredentialManager::CredentialSet _credCache; //< the credential cache for this download
97
98 DownloadSpec _spec; // the download settings
99 mutable zypp::TriBool _specHasZckInfo = zypp::indeterminate;
100
101 Downloader *_parent = nullptr;
102
103 time_t _lastTriedAuthTime = 0; //< if initialized this shows the last timestamp that got from user code for a auth request
104 bool _stopOnMetalink = false; //< Stop the download if a metalink was received for external parsing
105 bool _stoppedOnMetalink = false; //< Statemachine was stopped after receiving a metalink file
107
108 Signal< void ( Download &req )> _sigStarted;
110 Signal< void ( Download &req, off_t dlnow )> _sigAlive;
111 Signal< void ( Download &req, off_t dltotal, off_t dlnow )> _sigProgress;
112 Signal< void ( Download &req )> _sigFinished;
113 Signal< void ( zyppng::Download &req, zyppng::NetworkAuthData &auth, const std::string &availAuth )> _sigAuthRequired;
114
115 };
116
117}
118
119#endif
Url manipulation class.
Definition Url.h:92
std::set< AuthData_Ptr, AuthDataComparator > CredentialSet
Curl HTTP authentication data.
Holds transfer setting.
Base::WeakPtr parent
Definition base_p.h:22
static auto connect(typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
Definition base.h:142
std::shared_ptr< MirrorControl > _mirrorControl
Definition base_p.h:94
NetworkRequestError safeFillSettingsFromURL(const Url &url, TransferSettings &set)
Signal< void(Download &req, Download::State state)> _sigStateChanged
Definition base_p.h:109
zypp::media::CredentialManager::CredentialSet _credCache
Definition base_p.h:96
bool handleRequestAuthError(const std::shared_ptr< Request > &req, const zyppng::NetworkRequestError &err)
Definition downloader.cc:32
Signal< void(zyppng::Download &req, zyppng::NetworkAuthData &auth, const std::string &availAuth)> _sigAuthRequired
Definition base_p.h:113
zypp::TriBool _specHasZckInfo
Definition base_p.h:99
Signal< void(Download &req, off_t dlnow)> _sigAlive
Definition base_p.h:110
std::shared_ptr< NetworkRequestDispatcher > _requestDispatcher
Definition base_p.h:93
DownloadPrivateBase(Downloader &parent, std::shared_ptr< NetworkRequestDispatcher > requestDispatcher, std::shared_ptr< MirrorControl > mirrors, DownloadSpec &&spec, Download &p)
Definition downloader.cc:21
Signal< void(Download &req)> _sigFinished
Definition base_p.h:112
Signal< void(Download &req, off_t dltotal, off_t dlnow)> _sigProgress
Definition base_p.h:111
NetworkRequest::Priority _defaultSubRequestPriority
Definition base_p.h:106
Signal< void(Download &req)> _sigStarted
Definition base_p.h:108
The Downloader class.
Definition downloader.h:39
std::shared_ptr< Mirror > MirrorHandle
The NetworkRequestError class Represents a error that occured in.
SignalProxy< void(NetworkRequest &req, const NetworkRequestError &err)> sigFinished()
Signals that the download finished.
Definition request.cc:1051
NetworkRequest(Url url, zypp::Pathname targetFile, FileMode fMode=WriteExclusive)
Definition request.cc:740
SignalProxy< void(NetworkRequest &req)> sigStarted()
Signals that the dispatcher dequeued the request and actually starts downloading data.
Definition request.cc:1036
SignalProxy< void(NetworkRequest &req, off_t dltotal, off_t dlnow, off_t ultotal, off_t ulnow)> sigProgress()
Signals if there was data read from the download.
Definition request.cc:1046
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:30
sigc::connection connection
Definition signals.h:180
std::optional< size_t > chksumCompareLen
Definition base_p.h:53
std::optional< size_t > chksumPad
Definition base_p.h:54
std::optional< UByteArray > chksumVec
Definition base_p.h:52
NetworkRequestError _failedWithErr
Definition base_p.h:57
std::shared_ptr< Request > WeakPtr
Definition base_p.h:64
MirrorControl::MirrorHandle _myMirror
Definition base_p.h:76
std::shared_ptr< Request > Ptr
Definition base_p.h:63
void connectSignals(Receiver &dl)
Definition base_p.h:67
#define ZYPP_DECLARE_PUBLIC(Class)
Definition zyppglobal.h:98