libzypp 17.34.0
providemessage.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9
11
12#include <zypp-core/Url.h>
13#include <string_view>
14#include <string>
15
16#include <zypp-proto/media/provider.pb.h>
17
18namespace zyppng {
19
20 const std::string &ProviderConfiguration::staticTypeName()
21 {
22 return rpc::messageTypeName<zypp::proto::Configuration>();
23 }
24
25 const std::string &ProviderConfiguration::typeName() const
26 {
27 return staticTypeName();
28 }
29
30 bool ProviderConfiguration::deserialize(const std::string &data)
31 {
32 clear();
33 zypp::proto::Configuration implVar;
34 if ( !implVar.ParseFromString( data ) )
35 return false;
36
37 insert( implVar.values ().begin (), implVar.values ().end() );
38 return true;
39 }
40
41 void ProviderConfiguration::serializeInto(std::string &str) const
42 {
43 zypp::proto::Configuration implVar;
44 implVar.mutable_values()->insert( begin(), end() );
45 implVar.SerializeToString( &str );
46 }
47
48 std::string ProviderConfiguration::serialize( ) const
49 {
50 std::string res;
51 serializeInto(res);
52 return res;
53 }
54
55
60 : _data( new zypp::proto::Capabilities() )
61 { }
62
63 ZYPP_IMPL_RPCBASE(WorkerCaps, zypp::proto::Capabilities, _data)
64
67
69 {
70 return _data->protocol_version ();
71 }
72
74 {
75 return static_cast<WorkerCaps::WorkerType>(_data->worker_type ());
76 }
77
79 {
80 return static_cast<WorkerCaps::Flags>(_data->cfg_flags());
81 }
82
83 const std::string &WorkerCaps::worker_name() const
84 {
85 return _data->worker_name();
86 }
87
89 {
90 _data->set_protocol_version(v);
91 }
92
94 {
95 _data->set_worker_type( static_cast<uint32_t>(t) );
96 }
97
99 {
100 _data->set_cfg_flags( static_cast<uint32_t>(f) );
101 }
102
103 void WorkerCaps::set_worker_name(std::string name)
104 {
105 _data->set_worker_name ( std::move(name) );
106 }
107
108 static ProvideMessage::FieldVal fieldValFromProto ( const zypp::proto::DataField &field )
109 {
111 switch ( field.field_val_case () ) {
112 case zypp::proto::DataField::FieldValCase::kBoolVal:
113 v = field.bool_val();
114 break;
115 case zypp::proto::DataField::FieldValCase::kDoubleVal:
116 v = field.double_val();
117 break;
118 case zypp::proto::DataField::FieldValCase::kIntVal:
119 v = field.int_val();
120 break;
121 case zypp::proto::DataField::FieldValCase::kLongVal:
122 v = field.long_val();
123 break;
124 case zypp::proto::DataField::FieldValCase::kStrVal:
125 v = field.str_val();
126 break;
127 case zypp::proto::DataField::FieldValCase::FIELD_VAL_NOT_SET:
128 ZYPP_THROW( std::logic_error("Unexpected DataField type"));
129 break;
130 }
131 return v;
132 }
133
134 static void fieldValToProto ( const ProvideMessage::FieldVal &val, zypp::proto::DataField &field )
135 {
136 if ( val.isString() )
137 field.set_str_val( val.asString () );
138 else if ( val.isInt() )
139 field.set_int_val( val.asInt() );
140 else if ( val.isInt64() )
141 field.set_long_val( val.asInt64() );
142 else if ( val.isDouble() )
143 field.set_double_val( val.asDouble() );
144 else if ( val.isBool() )
145 field.set_bool_val( val.asBool() );
146 else
147 ZYPP_THROW( std::logic_error("Unexpected FieldVal type"));
148 }
149
151 {
152 const auto c = msg.code();
153 const auto validCode = ( c >= ProvideMessage::Code::FirstInformalCode && c <= ProvideMessage::Code::LastInformalCode )
154 || ( c >= ProvideMessage::Code::FirstSuccessCode && c <= ProvideMessage::Code::LastSuccessCode )
155 || ( c >= ProvideMessage::Code::FirstRedirCode && c <= ProvideMessage::Code::LastRedirCode )
156 || ( c >= ProvideMessage::Code::FirstClientErrCode && c <= ProvideMessage::Code::LastClientErrCode )
157 || ( c >= ProvideMessage::Code::FirstSrvErrCode && c <= ProvideMessage::Code::LastSrvErrCode )
158 || ( c >= ProvideMessage::Code::FirstControllerCode && c <= ProvideMessage::Code::LastControllerCode)
159 || ( c >= ProvideMessage::Code::FirstWorkerCode && c <= ProvideMessage::Code::LastWorkerCode );
160 if ( !validCode ) {
161 return zyppng::expected<void>::error( ZYPP_EXCPT_PTR ( InvalidMessageReceivedException("Invalid code in ProvideMessage")) );
162 }
163
164 #define DEF_REQ_FIELD( fname ) bool has_##fname = false
165
166 #define REQ_FIELD_CHECK( msgtype, fname, ftype ) \
167 if ( name == #fname ) { \
168 if ( !std::holds_alternative<ftype>(val.asVariant()) ) { \
169 error = ZYPP_EXCPT_PTR( InvalidMessageReceivedException( zypp::str::Str() << "Parse error " << #msgtype << ", Field " << #fname << " has invalid type" ) ); \
170 return false; \
171 } \
172 has_##fname = true; \
173 }
174
175 #define OR_REQ_FIELD_CHECK( msgtype, fname, ftype ) else REQ_FIELD_CHECK( msgtype, fname, ftype )
176
177 #define OPT_FIELD_CHECK( msgtype, fname, ftype ) \
178 if ( name == #fname ) { \
179 if ( !std::holds_alternative<ftype>(val.asVariant() ) ) { \
180 error = ZYPP_EXCPT_PTR( InvalidMessageReceivedException( zypp::str::Str() << "Parse error " << #msgtype << ", Field " << #fname << " has invalid type" ) ); \
181 return false; \
182 } \
183 }
184
185 #define OR_OPT_FIELD_CHECK( msgtype, fname, ftype ) else OPT_FIELD_CHECK( msgtype, fname, ftype )
186
187 #define FAIL_IF_NOT_SEEN_REQ_FIELD( msgtype, fname ) \
188 if ( !has_##fname ) \
189 return expected<void>::error( ZYPP_EXCPT_PTR( InvalidMessageReceivedException( zypp::str::Str() << #msgtype <<" message does not contain required " << #fname << " field" ) ) )
190
191 #define FAIL_IF_ERROR( ) \
192 if ( error ) return expected<void>::error( error )
193
194 const auto &validateErrorMsg = []( const auto &msg ){
195 std::exception_ptr error;
197 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
198 REQ_FIELD_CHECK ( Error, reason, std::string )
199 OR_OPT_FIELD_CHECK ( Error, history, std::string )
200 OR_OPT_FIELD_CHECK ( Error, transient, bool )
201 return true;
202 });
206 };
207
208 switch ( c )
209 {
210 case ProvideMessage::Code::ProvideStarted: {
211 std::exception_ptr error;
212 DEF_REQ_FIELD(url);
213 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
214 REQ_FIELD_CHECK ( ProvideStarted, url, std::string )
217 return true;
218 });
221 break;
222 }
223 case ProvideMessage::Code::ProvideFinished: {
224 std::exception_ptr error;
227 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
230 return true;
231 });
235 break;
236 }
237 case ProvideMessage::Code::AttachFinished: {
238 std::exception_ptr error;
239 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
241 return true;
242 });
244 break;
245 }
246 case ProvideMessage::Code::DetachFinished: {
247 // no fields
248 break;
249 }
250 case ProvideMessage::Code::AuthInfo: {
251 std::exception_ptr error;
252 DEF_REQ_FIELD(username);
253 DEF_REQ_FIELD(password);
255 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
256 REQ_FIELD_CHECK ( AuthInfo, username, std::string )
257 OR_REQ_FIELD_CHECK ( AuthInfo, password, std::string )
259 OR_OPT_FIELD_CHECK ( AuthInfo, authType, std::string )
260 return true;
261 });
266 break;
267 }
268 case ProvideMessage::Code::MediaChanged:
269 /* No Fields */
270 break;
271 case ProvideMessage::Code::Redirect: {
272 std::exception_ptr error;
274 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
275 REQ_FIELD_CHECK ( Redirect, new_url, std::string )
276 return true;
277 });
280 break;
281 }
282 case ProvideMessage::Code::Metalink: {
283 std::exception_ptr error;
285 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
286 REQ_FIELD_CHECK ( Metalink, new_url, std::string )
287 return true;
288 });
291 break;
292 }
293 case ProvideMessage::Code::BadRequest:
294 case ProvideMessage::Code::Unauthorized:
295 case ProvideMessage::Code::Forbidden:
296 case ProvideMessage::Code::PeerCertificateInvalid:
297 case ProvideMessage::Code::NotFound:
298 case ProvideMessage::Code::ExpectedSizeExceeded:
299 case ProvideMessage::Code::ConnectionFailed:
300 case ProvideMessage::Code::Timeout:
301 case ProvideMessage::Code::Cancelled:
302 case ProvideMessage::Code::InvalidChecksum:
303 case ProvideMessage::Code::MountFailed:
304 case ProvideMessage::Code::Jammed:
305 case ProvideMessage::Code::NoAuthData:
306 case ProvideMessage::Code::MediaChangeAbort:
307 case ProvideMessage::Code::MediaChangeSkip:
308 case ProvideMessage::Code::InternalError: {
309 const auto &e = validateErrorMsg(msg);
310 if ( !e )
311 return e;
312 break;
313 }
314 case ProvideMessage::Code::Prov: {
315 std::exception_ptr error;
316 DEF_REQ_FIELD(url);
317 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
318 REQ_FIELD_CHECK ( Provide, url, std::string )
319 OR_OPT_FIELD_CHECK ( Provide, filename, std::string )
320 OR_OPT_FIELD_CHECK ( Provide, delta_file, std::string )
324 return true;
325 });
328 break;
329 }
330 case ProvideMessage::Code::Cancel:
331 /* No Fields */
332 break;
333
334 case ProvideMessage::Code::Attach: {
335 std::exception_ptr error;
336
337 DEF_REQ_FIELD(url);
339 DEF_REQ_FIELD(label);
340
341 // not really required, but this way we can check if all false or all true
345
346 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
347 REQ_FIELD_CHECK ( Attach, url , std::string )
348 OR_REQ_FIELD_CHECK ( Attach, attach_id , std::string )
349 OR_REQ_FIELD_CHECK ( Attach, label , std::string )
350 OR_REQ_FIELD_CHECK ( Attach, verify_type, std::string )
351 OR_REQ_FIELD_CHECK ( Attach, verify_data, std::string )
353 OR_OPT_FIELD_CHECK ( Attach, device , std::string )
354 return true;
355 });
359 if ( ! ( ( has_verify_data == has_verify_type ) && ( has_verify_type == has_media_nr ) ) )
360 return expected<void>::error( ZYPP_EXCPT_PTR ( InvalidMessageReceivedException("Error in Attach message, one of the following fields is not set or invalid: ( verify_type, verify_data, media_nr ). Either none or all need to be set. ")) );
362 break;
363 }
364 case ProvideMessage::Code::Detach: {
365 std::exception_ptr error;
366 DEF_REQ_FIELD(url);
367 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
368 REQ_FIELD_CHECK ( Detach, url, std::string )
369 return true;
370 });
373 break;
374 }
375 case ProvideMessage::Code::AuthDataRequest: {
376 std::exception_ptr error;
378 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
380 OR_OPT_FIELD_CHECK ( AuthDataRequest, last_auth_timestamp, int64_t )
381 OR_OPT_FIELD_CHECK ( AuthDataRequest, username, std::string )
383 return true;
384 });
387 break;
388 }
389 case ProvideMessage::Code::MediaChangeRequest: {
390 std::exception_ptr error;
391 DEF_REQ_FIELD(label);
393 DEF_REQ_FIELD(device);
394 msg.forEachVal( [&]( const auto &name, const ProvideMessage::FieldVal &val ){
395 REQ_FIELD_CHECK ( MediaChangeRequest, label, std::string )
397 OR_REQ_FIELD_CHECK ( MediaChangeRequest, device, std::string )
399 return true;
400 });
405 break;
406 }
407 default: {
408 // all error messages have the same format
409 if ( c >= ProvideMessage::Code::FirstClientErrCode && c <= ProvideMessage::Code::LastSrvErrCode ) {
410 const auto &e = validateErrorMsg(msg);
411 if ( !e )
412 return e;
413 }
414 break;
415 }
416 }
418 }
419
421 : _impl ( new zypp::proto::ProvideMessage )
422 { }
423
424 ZYPP_IMPL_RPCBASE( ProvideMessage, zypp::proto::ProvideMessage, _impl )
425
427 {
428 ProvideMessage msg;
429 const auto &res = RpcMessageStream::parseMessageInto<zypp::proto::ProvideMessage>( message, *msg._impl );
430 if ( res ) {
431 const auto &valid = validateMessage(msg);
432 if ( !valid ) {
433 ERR << "Invalid message for ID: " << msg._impl->request_id() << std::endl;;
435 }
436
438 }
439 ERR << "Failed to parse message" << std::endl;;
441 }
442
443 expected<ProvideMessage> ProvideMessage::create( const zypp::proto::ProvideMessage &message )
444 {
445 ProvideMessage msg;
446 *msg._impl = std::move(message);
447 const auto &valid = validateMessage(msg);
448 if ( !valid ) {
449 ERR << "Invalid message for ID: " << msg._impl->request_id() << std::endl;;
451 }
452
454 }
455
456 ProvideMessage ProvideMessage::createProvideStarted( const uint32_t reqId, const zypp::Url &url, const std::optional<std::string> &localFilename, const std::optional<std::string> &stagingFilename )
457 {
458 ProvideMessage msg;
459 msg.setCode ( ProvideMessage::Code::ProvideStarted );
460 msg.setRequestId ( reqId );
462 if ( localFilename )
464 if ( stagingFilename )
466
467 return msg;
468 }
469
471 {
472 ProvideMessage msg;
473 msg.setCode ( ProvideMessage::Code::ProvideFinished );
474 msg.setRequestId ( reqId );
477
478 return msg;
479 }
480
481 ProvideMessage ProvideMessage::createAttachFinished(const uint32_t reqId , const std::optional<std::string> &localMountPoint )
482 {
483 ProvideMessage msg;
484 msg.setCode ( ProvideMessage::Code::AttachFinished );
485 msg.setRequestId ( reqId );
486
487 if ( localMountPoint )
489
490 return msg;
491 }
492
494 {
495 ProvideMessage msg;
496 msg.setCode ( ProvideMessage::Code::DetachFinished );
497 msg.setRequestId ( reqId );
498
499 return msg;
500 }
501
502 ProvideMessage 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 )
503 {
504 ProvideMessage msg;
505 msg.setCode ( ProvideMessage::Code::AuthInfo );
506 msg.setRequestId ( reqId );
510 for ( auto i : extraValues ) {
511 msg.setValue( i.first, i.second );
512 }
513 return msg;
514 }
515
517 {
518 ProvideMessage msg;
519 msg.setCode ( ProvideMessage::Code::MediaChanged );
520 msg.setRequestId ( reqId );
521
522 return msg;
523 }
524
526 {
527 ProvideMessage msg;
528 msg.setCode ( ProvideMessage::Code::Redirect );
529 msg.setRequestId ( reqId );
531
532 return msg;
533 }
534
535 ProvideMessage ProvideMessage::createMetalinkRedir( const uint32_t reqId, const std::vector<zypp::Url> &newUrls )
536 {
537 ProvideMessage msg;
538 msg.setCode ( ProvideMessage::Code::Metalink );
539 msg.setRequestId ( reqId );
540 for( const auto &val : newUrls )
541 msg.addValue( MetalinkRedirectMsgFields::NewUrl, val.asCompleteString() );
542
543 return msg;
544 }
545
546 ProvideMessage ProvideMessage::createErrorResponse( const uint32_t reqId, const uint code, const std::string &reason, bool transient )
547 {
548 ProvideMessage msg;
549 if ( code < Code::FirstClientErrCode || code > Code::LastSrvErrCode )
550 ZYPP_THROW(std::out_of_range("code must be between 400 and 599"));
551 msg.setCode ( code );
552 msg.setRequestId ( reqId );
555 return msg;
556 }
557
558 ProvideMessage 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 )
559 {
560 ProvideMessage msg;
561 msg.setCode ( ProvideMessage::Code::Prov );
562 msg.setRequestId ( reqId );
564
565 if ( filename )
566 msg.setValue ( ProvideMsgFields::Filename, *filename );
567 if ( deltaFile )
568 msg.setValue ( ProvideMsgFields::DeltaFile, *deltaFile );
569 if ( expFilesize )
572
573 return msg;
574 }
575
577 {
578 ProvideMessage msg;
579 msg.setCode ( ProvideMessage::Code::Cancel );
580 msg.setRequestId ( reqId );
581
582 return msg;
583 }
584
585 ProvideMessage 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 )
586 {
587 ProvideMessage msg;
588 msg.setCode ( ProvideMessage::Code::Attach );
589 msg.setRequestId ( reqId );
592 msg.setValue ( AttachMsgFields::Label, label );
593
594 if ( verifyType.has_value() && verifyData.has_value() && mediaNr.has_value() ) {
596 msg.setValue ( AttachMsgFields::VerifyData, *verifyData );
597 msg.setValue ( AttachMsgFields::MediaNr, *mediaNr );
598 } else {
599 if ( !( ( verifyType.has_value() == verifyData.has_value() ) && ( verifyData.has_value() == mediaNr.has_value() ) ) )
600 WAR << "Attach message requires verifyType, verifyData and mediaNr either set together or not set at all." << std::endl;
601 }
602
603 return msg;
604 }
605
607 {
608 ProvideMessage msg;
609 msg.setCode ( ProvideMessage::Code::Detach );
610 msg.setRequestId ( reqId );
611 msg.setValue ( DetachMsgFields::Url, attachUrl.asCompleteString() );
612
613 return msg;
614 }
615
616 ProvideMessage 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 )
617 {
618 ProvideMessage msg;
619 msg.setCode ( ProvideMessage::Code::AuthDataRequest );
620 msg.setRequestId ( reqId );
622 if ( lastTriedUser.size() )
624 if ( lastAuthTimestamp )
625 msg.setValue ( AuthDataRequestMsgFields::LastAuthTimestamp, *lastAuthTimestamp );
626
627 return msg;
628 }
629
630 ProvideMessage 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 )
631 {
632 ProvideMessage msg;
633 msg.setCode ( ProvideMessage::Code::MediaChangeRequest );
634 msg.setRequestId ( reqId );
637 for ( const auto &device : devices )
639 if ( desc )
641
642 return msg;
643 }
644
646 {
647 return _impl->request_id();
648 }
649
651 {
652 _impl->set_request_id( id );
653 }
654
655 uint32_t ProvideMessage::code() const
656 {
657 return _impl->message_code();
658 }
659
660 void ProvideMessage::setCode(const uint32_t newCode )
661 {
662 _impl->set_message_code ( newCode );
663 }
664
665 std::vector<ProvideMessage::FieldVal> ProvideMessage::values( const std::string_view &str ) const
666 {
667 std::vector<ProvideMessage::FieldVal> values;
668 const auto &fields = _impl->fields();
669 for ( const auto &field : fields ) {
670 if ( field.key() != str )
671 continue;
672 values.push_back( fieldValFromProto(field) );
673 }
674 return values;
675 }
676
677 std::vector<ProvideMessage::FieldVal> ProvideMessage::values( const std::string &str ) const
678 {
679 return values( std::string_view(str));
680 }
681
683 {
684 const auto &fields = _impl->fields();
685 auto i = std::find_if( fields.rbegin(), fields.rend(), [&str]( const auto &val ){ return val.key() == str; } );
686 if ( i == fields.rend() )
687 return defaultVal;
688 return fieldValFromProto(*i);
689 }
690
691
693 {
695 auto &fields = _impl->fields();
696 for ( const auto &val : fields ) {
697 res.add( val.key() ,fieldValFromProto(val) );
698 }
699 return res;
700 }
701
703 {
704 return value( std::string_view(str), defaultVal );
705 }
706
707 void ProvideMessage::setValue( const std::string &name, const FieldVal &value )
708 {
709 setValue( std::string_view(name), value );
710 }
711
712 void ProvideMessage::setValue( const std::string_view &name, const FieldVal &value )
713 {
714 auto &fields = *_impl->mutable_fields();
715 auto i = std::find_if( fields.rbegin(), fields.rend(), [&name]( const auto &val ){ return val.key() == name; } );
716 if ( i == fields.rend() ) {
717 auto &newVal = *_impl->add_fields();
718 newVal.set_key( name.data() );
720 } else
722 }
723
724 void ProvideMessage::addValue( const std::string &name, const FieldVal &value )
725 {
726 return addValue( std::string_view(name), value );
727 }
728
729 void ProvideMessage::addValue( const std::string_view &name, const FieldVal &value )
730 {
731 auto &newVal = *_impl->add_fields();
732 newVal.set_key( name.data() );
734 }
735
736 void ProvideMessage::forEachVal( const std::function<bool (const std::string &, const FieldVal &)> &cb ) const
737 {
738 auto &fields = _impl->fields();
739 for ( const auto &val : fields ) {
740 if ( !cb( val.key(), fieldValFromProto(val) ) ) {
741 return;
742 }
743 }
744 }
745}
746
747namespace zypp {
748 template<>
749 proto::Configuration *rwcowClone<proto::Configuration>(const proto::Configuration *rhs)
750 { return new proto::Configuration( *rhs ); }
751
752 template<>
753 proto::Capabilities *rwcowClone<proto::Capabilities>(const proto::Capabilities *rhs)
754 { return new proto::Capabilities( *rhs ); }
755
756 template<>
757 zypp::proto::ProvideMessage* rwcowClone<zypp::proto::ProvideMessage>( const zypp::proto::ProvideMessage * rhs )
758 { return new zypp::proto::ProvideMessage(*rhs); }
759}
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
Container of Capability (currently read only).
Url manipulation class.
Definition Url.h:92
std::string asCompleteString() const
Returns a complete string representation of the Url object.
Definition Url.cc:509
double asDouble() const
int32_t asInt() const
const std::string & asString() const
int64_t asInt64() const
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={})
void setCode(const uint32_t newCode)
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)
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)
FieldVal value(const std::string_view &str, const FieldVal &defaultVal=FieldVal()) const
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 expected< ProvideMessage > create(const zyppng::RpcMessage &message)
static ProvideMessage createDetach(const uint32_t reqId, const zypp::Url &attachUrl)
static ProvideMessage createAttachFinished(const uint32_t reqId, const std::optional< std::string > &localMountPoint={})
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={})
virtual std::string serialize() const
virtual bool deserialize(const std::string &data)=0
virtual const std::string & typeName() const =0
virtual void serializeInto(std::string &str) const =0
zypp::RWCOW_pointer< zypp::proto::Capabilities > _data
const std::string & worker_name() const
Flags cfg_flags() const
void set_worker_type(WorkerType t)
void set_protocol_version(uint32_t v)
WorkerType worker_type() const
uint32_t protocol_version() const
void set_worker_name(std::string name)
void set_cfg_flags(Flags f)
static expected success(ConsParams &&...params)
Definition expected.h:115
#define ZYPP_IMPL_RPCBASE(Class, ImplClass, implVar)
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
proto::Configuration * rwcowClone< proto::Configuration >(const proto::Configuration *rhs)
zypp::proto::ProvideMessage * rwcowClone< zypp::proto::ProvideMessage >(const zypp::proto::ProvideMessage *rhs)
proto::Capabilities * rwcowClone< proto::Capabilities >(const proto::Capabilities *rhs)
constexpr std::string_view LocalMountPoint("local_mountpoint")
constexpr std::string_view AttachId("attach_id")
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 Url("url")
constexpr std::string_view LastUser("username")
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 Username("username")
constexpr std::string_view AuthTimestamp("auth_timestamp")
constexpr std::string_view Url("url")
constexpr std::string_view Reason("reason")
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 Url("url")
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")
static void fieldValToProto(const ProvideMessage::FieldVal &val, zypp::proto::DataField &field)
static expected< void > validateMessage(const ProvideMessage &msg)
static ProvideMessage::FieldVal fieldValFromProto(const zypp::proto::DataField &field)
#define FAIL_IF_NOT_SEEN_REQ_FIELD(msgtype, fname)
#define DEF_REQ_FIELD(fname)
#define OR_OPT_FIELD_CHECK(msgtype, fname, ftype)
#define FAIL_IF_ERROR()
#define OPT_FIELD_CHECK(msgtype, fname, ftype)
#define REQ_FIELD_CHECK(msgtype, fname, ftype)
#define OR_REQ_FIELD_CHECK(msgtype, fname, ftype)
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
Definition Exception.h:433
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:429
#define ERR
Definition Logger.h:100
#define WAR
Definition Logger.h:99