libzypp 17.31.23
providemessage_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*/
15#ifndef ZYPP_MEDIA_PRIVATE_PROVIDE_MESSAGE_P_H_INCLUDED
16#define ZYPP_MEDIA_PRIVATE_PROVIDE_MESSAGE_P_H_INCLUDED
17
18#include <zypp-core/base/PtrTypes.h>
19#include <zypp-core/zyppng/pipelines/Expected>
20#include <zypp-core/zyppng/rpc/MessageStream>
21#include <zypp-media/ng/ProvideSpec> // for FieldType
22#include <zypp-media/ng/HeaderValueMap>
23#include <variant>
24#include <functional>
25#include <zypp-proto/media/provider.pb.h>
26
27namespace zypp::proto {
28 class ProvideMessage;
29 class Envelope;
30}
31
32namespace zyppng {
33
34 namespace ProvideStartedMsgFields
35 {
36 constexpr std::string_view Url ("url");
37 constexpr std::string_view LocalFilename ("local_filename");
38 constexpr std::string_view StagingFilename ("staging_filename");
39 }
40
41 namespace ProvideFinishedMsgFields
42 {
43 constexpr std::string_view LocalFilename ("local_filename");
44 constexpr std::string_view CacheHit ("cacheHit");
45 }
46
47 namespace AuthInfoMsgFields
48 {
49 constexpr std::string_view Username ("username");
50 constexpr std::string_view Password ("password");
51 constexpr std::string_view AuthTimestamp ("auth_timestamp");
52 constexpr std::string_view AuthType ("authType");
53 }
54
55 namespace RedirectMsgFields
56 {
57 constexpr std::string_view NewUrl ("new_url");
58 }
59
60 namespace MetalinkRedirectMsgFields
61 {
62 constexpr std::string_view NewUrl ("new_url");
63 }
64
65 namespace ErrMsgFields
66 {
67 constexpr std::string_view Reason ("reason");
68 constexpr std::string_view Transient ("transient");
69 constexpr std::string_view History ("history");
70 }
71
72 namespace ProvideMsgFields
73 {
74 constexpr std::string_view Url ("url");
75 constexpr std::string_view Filename ("filename");
76 constexpr std::string_view DeltaFile ("delta_file");
77 constexpr std::string_view ExpectedFilesize ("expected_filesize");
78 constexpr std::string_view CheckExistOnly ("check_existance_only");
79 constexpr std::string_view MetalinkEnabled ("metalink_enabled");
80 }
81
82 namespace AttachMsgFields
83 {
84 constexpr std::string_view Url ("url");
85 constexpr std::string_view AttachId ("attach_id");
86 constexpr std::string_view VerifyType ("verify_type");
87 constexpr std::string_view VerifyData ("verify_data");
88 constexpr std::string_view MediaNr ("media_nr");
89 constexpr std::string_view Device ("device");
90 constexpr std::string_view Label ("label");
91 }
92
93 namespace DetachMsgFields
94 {
95 constexpr std::string_view Url ("url");
96 }
97
98 namespace AuthDataRequestMsgFields
99 {
100 constexpr std::string_view EffectiveUrl ("effective_url");
101 constexpr std::string_view LastAuthTimestamp ("last_auth_timestamp");
102 constexpr std::string_view LastUser ("username");
103 constexpr std::string_view AuthHint ("authHint");
104 }
105
106 namespace MediaChangeRequestMsgFields
107 {
108 constexpr std::string_view Label ("label");
109 constexpr std::string_view MediaNr ("media_nr");
110 constexpr std::string_view Device ("device");
111 constexpr std::string_view Desc ("desc");
112 }
113
114 namespace EjectMsgFields
115 {
116 constexpr std::string_view device ("device");
117 }
118
120 {
121 public:
122 using Code = zypp::proto::MessageCodes;
124
125 static expected<ProvideMessage> create ( const zyppng::RpcMessage &message );
126 static expected<ProvideMessage> create ( const zypp::proto::ProvideMessage &message );
127 static ProvideMessage createProvideStarted ( const uint32_t reqId, const zypp::Url &url , const std::optional<std::string> &localFilename = {}, const std::optional<std::string> &stagingFilename = {} );
128 static ProvideMessage createProvideFinished ( const uint32_t reqId, const std::string &localFilename , bool cacheHit );
129 static ProvideMessage createAttachFinished ( const uint32_t reqId );
130 static ProvideMessage createDetachFinished ( const uint32_t reqId );
131 static ProvideMessage createAuthInfo ( const uint32_t reqId, const std::string &user, const std::string &pw, int64_t timestamp, const std::map<std::string, std::string> &extraValues = {} );
132 static ProvideMessage createMediaChanged ( const uint32_t reqId );
133 static ProvideMessage createRedirect ( const uint32_t reqId, const zypp::Url &newUrl );
134 static ProvideMessage createMetalinkRedir ( const uint32_t reqId, const std::vector<zypp::Url> &newUrls );
135 static ProvideMessage createErrorResponse ( const uint32_t reqId, const uint code, const std::string &reason, bool transient = false );
136
137 static ProvideMessage createProvide ( const uint32_t reqId
138 , const zypp::Url &url
139 , const std::optional<std::string> &filename = {}
140 , const std::optional<std::string> &deltaFile = {}
141 , const std::optional<int64_t> &expFilesize = {}
142 , bool checkExistOnly = false );
143
144 static ProvideMessage createCancel ( const uint32_t reqId );
145
146 static ProvideMessage createAttach( const uint32_t reqId
147 , const zypp::Url &url
148 , const std::string attachId
149 , const std::string &label
150 , const std::optional<std::string> &verifyType = {}
151 , const std::optional<std::string> &verifyData = {}
152 , const std::optional<int32_t> &mediaNr = {} );
153
154 static ProvideMessage createDetach ( const uint32_t reqId, const zypp::Url &attachUrl );
155 static ProvideMessage createAuthDataRequest ( const uint32_t reqId, const zypp::Url &effectiveUrl, const std::string &lastTriedUser ="", const std::optional<int64_t> &lastAuthTimestamp = {}, const std::map<std::string, std::string> &extraValues = {} );
156 static ProvideMessage createMediaChangeRequest ( const uint32_t reqId, const std::string &label, int32_t mediaNr, const std::vector<std::string> &devices, const std::optional<std::string> &desc );
157
158 uint requestId () const;
159 void setRequestId ( const uint id );
160
161 uint code () const;
162 void setCode ( const uint newCode );
163
164 std::vector<FieldVal> values ( const std::string_view &str ) const;
165 std::vector<FieldVal> values ( const std::string &str ) const;
166 HeaderValueMap headers() const;
171 FieldVal value ( const std::string_view &str, const FieldVal &defaultVal = FieldVal() ) const;
172 FieldVal value ( const std::string &str, const FieldVal &defaultVal = FieldVal() ) const;
173 void setValue ( const std::string &name, const FieldVal &value );
174 void setValue ( const std::string_view &name, const FieldVal &value );
175 void addValue ( const std::string &name, const FieldVal &value );
176 void addValue ( const std::string_view &name, const FieldVal &value );
177 void forEachVal( const std::function<bool( const std::string &name, const FieldVal &val)> &cb ) const;
178
179 zypp::proto::ProvideMessage &impl();
180 const zypp::proto::ProvideMessage &impl() const;
181
182 private:
185 };
186}
187
188namespace zypp {
189 template<>
190 inline zypp::proto::ProvideMessage* rwcowClone<zypp::proto::ProvideMessage>( const zypp::proto::ProvideMessage * rhs )
191 { return new zypp::proto::ProvideMessage(*rhs); }
192}
193
194
195
196#endif
Url manipulation class.
Definition: Url.h:92
static ProvideMessage createProvideStarted(const uint32_t reqId, const zypp::Url &url, const std::optional< std::string > &localFilename={}, const std::optional< std::string > &stagingFilename={})
static ProvideMessage createAuthInfo(const uint32_t reqId, const std::string &user, const std::string &pw, int64_t timestamp, const std::map< std::string, std::string > &extraValues={})
zypp::RWCOW_pointer< zypp::proto::ProvideMessage > _impl
static ProvideMessage createRedirect(const uint32_t reqId, const zypp::Url &newUrl)
static ProvideMessage createMetalinkRedir(const uint32_t reqId, const std::vector< zypp::Url > &newUrls)
static ProvideMessage createCancel(const uint32_t reqId)
void forEachVal(const std::function< bool(const std::string &name, const FieldVal &val)> &cb) const
HeaderValueMap headers() const
static ProvideMessage createMediaChanged(const uint32_t reqId)
static ProvideMessage createProvideFinished(const uint32_t reqId, const std::string &localFilename, bool cacheHit)
static expected< ProvideMessage > create(const zyppng::RpcMessage &message)
zypp::proto::MessageCodes Code
std::vector< FieldVal > values(const std::string_view &str) const
static ProvideMessage createMediaChangeRequest(const uint32_t reqId, const std::string &label, int32_t mediaNr, const std::vector< std::string > &devices, const std::optional< std::string > &desc)
static ProvideMessage createAttachFinished(const uint32_t reqId)
zypp::proto::ProvideMessage & impl()
FieldVal value(const std::string_view &str, const FieldVal &defaultVal=FieldVal()) const
void setCode(const uint newCode)
void setValue(const std::string &name, const FieldVal &value)
static ProvideMessage createAuthDataRequest(const uint32_t reqId, const zypp::Url &effectiveUrl, const std::string &lastTriedUser="", const std::optional< int64_t > &lastAuthTimestamp={}, const std::map< std::string, std::string > &extraValues={})
static ProvideMessage createProvide(const uint32_t reqId, const zypp::Url &url, const std::optional< std::string > &filename={}, const std::optional< std::string > &deltaFile={}, const std::optional< int64_t > &expFilesize={}, bool checkExistOnly=false)
void setRequestId(const uint id)
static ProvideMessage createDetachFinished(const uint32_t reqId)
void addValue(const std::string &name, const FieldVal &value)
static ProvideMessage createDetach(const uint32_t reqId, const zypp::Url &attachUrl)
static ProvideMessage createErrorResponse(const uint32_t reqId, const uint code, const std::string &reason, bool transient=false)
static ProvideMessage createAttach(const uint32_t reqId, const zypp::Url &url, const std::string attachId, const std::string &label, const std::optional< std::string > &verifyType={}, const std::optional< std::string > &verifyData={}, const std::optional< int32_t > &mediaNr={})
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::proto::ProvideMessage * rwcowClone< zypp::proto::ProvideMessage >(const zypp::proto::ProvideMessage *rhs)
constexpr std::string_view AttachId("attach_id")
constexpr std::string_view Device("device")
constexpr std::string_view VerifyData("verify_data")
constexpr std::string_view VerifyType("verify_type")
constexpr std::string_view Label("label")
constexpr std::string_view MediaNr("media_nr")
constexpr std::string_view LastUser("username")
constexpr std::string_view AuthHint("authHint")
constexpr std::string_view EffectiveUrl("effective_url")
constexpr std::string_view LastAuthTimestamp("last_auth_timestamp")
constexpr std::string_view Password("password")
constexpr std::string_view AuthType("authType")
constexpr std::string_view Username("username")
constexpr std::string_view AuthTimestamp("auth_timestamp")
constexpr std::string_view device("device")
constexpr std::string_view Reason("reason")
constexpr std::string_view History("history")
constexpr std::string_view Transient("transient")
constexpr std::string_view Label("label")
constexpr std::string_view Desc("desc")
constexpr std::string_view MediaNr("media_nr")
constexpr std::string_view Device("device")
constexpr std::string_view NewUrl("new_url")
constexpr std::string_view LocalFilename("local_filename")
constexpr std::string_view CacheHit("cacheHit")
constexpr std::string_view MetalinkEnabled("metalink_enabled")
constexpr std::string_view ExpectedFilesize("expected_filesize")
constexpr std::string_view DeltaFile("delta_file")
constexpr std::string_view CheckExistOnly("check_existance_only")
constexpr std::string_view Filename("filename")
constexpr std::string_view StagingFilename("staging_filename")
constexpr std::string_view Url("url")
constexpr std::string_view LocalFilename("local_filename")
constexpr std::string_view NewUrl("new_url")
RW_pointer supporting 'copy on write' functionality.
Definition: PtrTypes.h:459