libzypp 17.32.2
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#ifndef ZYPP_MEDIA_PRIVATE_PROVIDE_MESSAGE_P_H_INCLUDED
14#define ZYPP_MEDIA_PRIVATE_PROVIDE_MESSAGE_P_H_INCLUDED
15
297#include <zypp-core/base/PtrTypes.h>
298#include <zypp-core/zyppng/pipelines/Expected>
299#include <zypp-core/zyppng/rpc/MessageStream>
300#include <zypp-media/ng/ProvideSpec> // for FieldType
301#include <zypp-media/ng/HeaderValueMap>
302
303#include <boost/iterator/iterator_adaptor.hpp>
304
305#include <functional>
306
307namespace zypp::proto {
308 class Envelope;
309 class Configuration;
310 class Capabilities;
311 class ProvideMessage;
312}
313
314namespace zyppng {
315
372
373 class ProviderConfiguration : public std::map<std::string, std::string>, public RpcBaseType
374 {
375 ZYPP_RPCBASE
376 public:
377
378 using map::map;
379 };
380
381 class WorkerCaps : public RpcBaseType
382 {
383 ZYPP_RPCBASE
384 public:
393
394 enum Flags {
395 None = 0, // Just for completeness
396 SingleInstance = 1, // If this flag is set a worker can only be started once, this is implicit in some worker types.
397 Pipeline = 2, // The worker can handle multiple requests at the same time
398 ZyppLogFormat = 4, // The worker writes messages to stderr in zypp log format
399 FileArtifacts = 8, // The results of this worker are artifacts, which means they need to be cleaned up. This is implicit for all downloading workers. For all mounting workers this is ignored.
400 // CPU bound workers can use it to signal they leave artifact files behind that need to be cleaned up
401 };
402
403 explicit WorkerCaps();
404 ~WorkerCaps();
405
406 WorkerCaps(const WorkerCaps &) = default;
407 WorkerCaps(WorkerCaps &&) = default;
408 WorkerCaps &operator=(const WorkerCaps &) = default;
410
411 uint32_t protocol_version() const; // The workers should set this field to the protocol version they implement.
412 WorkerType worker_type() const;
413 Flags cfg_flags() const;
414 const std::string &worker_name() const;
415
416 void set_protocol_version( uint32_t v );
417 void set_worker_type( WorkerType t );
418 void set_cfg_flags( Flags f );
419 void set_worker_name( std::string name );
420
421 private:
423 };
424
425 namespace ProvideStartedMsgFields
426 {
427 constexpr std::string_view Url ("url");
428 constexpr std::string_view LocalFilename ("local_filename");
429 constexpr std::string_view StagingFilename ("staging_filename");
430 }
431
432 namespace ProvideFinishedMsgFields
433 {
434 constexpr std::string_view LocalFilename ("local_filename");
435 constexpr std::string_view CacheHit ("cacheHit");
436 }
437
438 namespace AuthInfoMsgFields
439 {
440 constexpr std::string_view Username ("username");
441 constexpr std::string_view Password ("password");
442 constexpr std::string_view AuthTimestamp ("auth_timestamp");
443 constexpr std::string_view AuthType ("authType");
444 }
445
446 namespace RedirectMsgFields
447 {
448 constexpr std::string_view NewUrl ("new_url");
449 }
450
451 namespace MetalinkRedirectMsgFields
452 {
453 constexpr std::string_view NewUrl ("new_url");
454 }
455
456 namespace ErrMsgFields
457 {
458 constexpr std::string_view Reason ("reason");
459 constexpr std::string_view Transient ("transient");
460 constexpr std::string_view History ("history");
461 }
462
463 namespace ProvideMsgFields
464 {
465 constexpr std::string_view Url ("url");
466 constexpr std::string_view Filename ("filename");
467 constexpr std::string_view DeltaFile ("delta_file");
468 constexpr std::string_view ExpectedFilesize ("expected_filesize");
469 constexpr std::string_view CheckExistOnly ("check_existance_only");
470 constexpr std::string_view MetalinkEnabled ("metalink_enabled");
471 }
472
473 namespace AttachMsgFields
474 {
475 constexpr std::string_view Url ("url");
476 constexpr std::string_view AttachId ("attach_id");
477 constexpr std::string_view VerifyType ("verify_type");
478 constexpr std::string_view VerifyData ("verify_data");
479 constexpr std::string_view MediaNr ("media_nr");
480 constexpr std::string_view Device ("device");
481 constexpr std::string_view Label ("label");
482 }
483
484 namespace AttachFinishedMsgFields
485 {
486 constexpr std::string_view LocalMountPoint ("local_mountpoint");
487 }
488
489 namespace DetachMsgFields
490 {
491 constexpr std::string_view Url ("url");
492 }
493
494 namespace AuthDataRequestMsgFields
495 {
496 constexpr std::string_view EffectiveUrl ("effective_url");
497 constexpr std::string_view LastAuthTimestamp ("last_auth_timestamp");
498 constexpr std::string_view LastUser ("username");
499 constexpr std::string_view AuthHint ("authHint");
500 }
501
502 namespace MediaChangeRequestMsgFields
503 {
504 constexpr std::string_view Label ("label");
505 constexpr std::string_view MediaNr ("media_nr");
506 constexpr std::string_view Device ("device");
507 constexpr std::string_view Desc ("desc");
508 }
509
510 namespace EjectMsgFields
511 {
512 constexpr std::string_view device ("device");
513 }
514
516 {
517 ZYPP_RPCBASE
518 public:
520
521 ProvideMessage(const ProvideMessage &) = default;
526
527 static expected<ProvideMessage> create ( const zyppng::RpcMessage &message );
528 static expected<ProvideMessage> create ( const zypp::proto::ProvideMessage &message );
529 static ProvideMessage createProvideStarted ( const uint32_t reqId, const zypp::Url &url , const std::optional<std::string> &localFilename = {}, const std::optional<std::string> &stagingFilename = {} );
530 static ProvideMessage createProvideFinished ( const uint32_t reqId, const std::string &localFilename , bool cacheHit );
531 static ProvideMessage createAttachFinished ( const uint32_t reqId, const std::optional<std::string> &localMountPoint = {} );
532 static ProvideMessage createDetachFinished ( const uint32_t reqId );
533 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 = {} );
534 static ProvideMessage createMediaChanged ( const uint32_t reqId );
535 static ProvideMessage createRedirect ( const uint32_t reqId, const zypp::Url &newUrl );
536 static ProvideMessage createMetalinkRedir ( const uint32_t reqId, const std::vector<zypp::Url> &newUrls );
537 static ProvideMessage createErrorResponse ( const uint32_t reqId, const uint code, const std::string &reason, bool transient = false );
538
539 static ProvideMessage createProvide ( const uint32_t reqId
540 , const zypp::Url &url
541 , const std::optional<std::string> &filename = {}
542 , const std::optional<std::string> &deltaFile = {}
543 , const std::optional<int64_t> &expFilesize = {}
544 , bool checkExistOnly = false );
545
546 static ProvideMessage createCancel ( const uint32_t reqId );
547
548 static ProvideMessage createAttach( const uint32_t reqId
549 , const zypp::Url &url
550 , const std::string attachId
551 , const std::string &label
552 , const std::optional<std::string> &verifyType = {}
553 , const std::optional<std::string> &verifyData = {}
554 , const std::optional<int32_t> &mediaNr = {} );
555
556 static ProvideMessage createDetach ( const uint32_t reqId, const zypp::Url &attachUrl );
557 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 = {} );
558 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 );
559
560 uint requestId () const;
561 void setRequestId ( const uint id );
562
563 uint32_t code() const;
564 void setCode ( const uint32_t newCode );
565
566 std::vector<FieldVal> values ( const std::string_view &str ) const;
567 std::vector<FieldVal> values ( const std::string &str ) const;
568 HeaderValueMap headers() const;
573 FieldVal value ( const std::string_view &str, const FieldVal &defaultVal = FieldVal() ) const;
574 FieldVal value ( const std::string &str, const FieldVal &defaultVal = FieldVal() ) const;
575 void setValue ( const std::string &name, const FieldVal &value );
576 void setValue ( const std::string_view &name, const FieldVal &value );
577 void addValue ( const std::string &name, const FieldVal &value );
578 void addValue ( const std::string_view &name, const FieldVal &value );
579 void forEachVal( const std::function<bool( const std::string &name, const FieldVal &val)> &cb ) const;
580
581 private:
584 };
585}
586
587namespace zypp {
588 template<> zypp::proto::Configuration* rwcowClone<zypp::proto::Configuration>( const zypp::proto::Configuration * rhs );
589 template<> zypp::proto::Capabilities* rwcowClone<zypp::proto::Capabilities>( const zypp::proto::Capabilities * rhs );
590 template<> zypp::proto::ProvideMessage* rwcowClone<zypp::proto::ProvideMessage>( const zypp::proto::ProvideMessage * rhs );
591}
592
593
594
595#endif
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
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
ProvideMessage & operator=(ProvideMessage &&)=default
static ProvideMessage createRedirect(const uint32_t reqId, const zypp::Url &newUrl)
static ProvideMessage createMetalinkRedir(const uint32_t reqId, const std::vector< zypp::Url > &newUrls)
ProvideMessage(const ProvideMessage &)=default
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)
ProvideMessage & operator=(const ProvideMessage &)=default
static expected< ProvideMessage > create(const zyppng::RpcMessage &message)
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
ProvideMessage(ProvideMessage &&)=default
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 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={})
zypp::RWCOW_pointer< zypp::proto::Capabilities > _data
const std::string & worker_name() const
WorkerCaps(WorkerCaps &&)=default
Flags cfg_flags() const
WorkerCaps(const WorkerCaps &)=default
void set_worker_type(WorkerType t)
WorkerCaps & operator=(const WorkerCaps &)=default
void set_protocol_version(uint32_t v)
WorkerType worker_type() const
uint32_t protocol_version() const
WorkerCaps & operator=(WorkerCaps &&)=default
void set_worker_name(std::string name)
void set_cfg_flags(Flags f)
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
zypp::proto::ProvideMessage * rwcowClone< zypp::proto::ProvideMessage >(const zypp::proto::ProvideMessage *rhs)
zypp::proto::Capabilities * rwcowClone< zypp::proto::Capabilities >(const zypp::proto::Capabilities *rhs)
zypp::proto::Configuration * rwcowClone< zypp::proto::Configuration >(const zypp::proto::Configuration *rhs)
constexpr std::string_view LocalMountPoint("local_mountpoint")
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 LocalFilename("local_filename")
constexpr std::string_view NewUrl("new_url")
@ PeerCertificateInvalid