libzypp 17.37.17
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
18
290
292#include <zypp-core/zyppng/pipelines/Expected>
294#include <zypp-media/ng/ProvideSpec> // for FieldType
295#include <zypp-media/ng/HeaderValueMap>
296
297#include <boost/iterator/iterator_adaptor.hpp>
298
299namespace zypp::proto {
300 class Envelope;
301 class Configuration;
302 class Capabilities;
303 class ProvideMessage;
304}
305
306namespace zyppng {
307
364
365 class ProviderConfiguration : public std::map<std::string, std::string>
366 {
367 public:
368 using map::map;
369
370 static constexpr std::string_view typeName = "ProviderConfiguration";
373 };
374
376 {
377 public:
379 enum WorkerType : uint32_t {
385 };
386
387 enum Flags : uint32_t {
388 None = 0, // Just for completeness
389 SingleInstance = 1, // If this flag is set a worker can only be started once, this is implicit in some worker types.
390 Pipeline = 2, // The worker can handle multiple requests at the same time
391 ZyppLogFormat = 4, // The worker writes messages to stderr in zypp log format
392 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.
393 // CPU bound workers can use it to signal they leave artifact files behind that need to be cleaned up
394 };
395
396 explicit WorkerCaps();
397 ~WorkerCaps();
398
399 WorkerCaps(const WorkerCaps &) = default;
400 WorkerCaps(WorkerCaps &&) = default;
401 WorkerCaps &operator=(const WorkerCaps &) = default;
403
404 uint32_t protocol_version() const; // The workers should set this field to the protocol version they implement.
405 WorkerType worker_type() const;
406 Flags cfg_flags() const;
407 const std::string &worker_name() const;
408
409 void set_protocol_version( uint32_t v );
410 void set_worker_type( WorkerType t );
411 void set_cfg_flags( Flags f );
412 void set_worker_name( std::string name );
413
414 static constexpr std::string_view typeName = "WorkerCaps";
417
418 private:
419 uint32_t _protocolVersion = 1;
421 uint32_t _cfgFlags = None;
422 std::string _workerName;
423 };
424
426 constexpr std::string_view RequestCode("requestCode");
427 constexpr std::string_view RequestId("requestId");
428 }
429
431 {
432 constexpr std::string_view Url ("url");
433 constexpr std::string_view LocalFilename ("local_filename");
434 constexpr std::string_view StagingFilename ("staging_filename");
435 }
436
438 {
439 constexpr std::string_view LocalFilename ("local_filename");
440 constexpr std::string_view CacheHit ("cacheHit");
441 }
442
444 {
445 constexpr std::string_view Username ("username");
446 constexpr std::string_view Password ("password");
447 constexpr std::string_view AuthTimestamp ("auth_timestamp");
448 constexpr std::string_view AuthType ("authType");
449 }
450
452 {
453 constexpr std::string_view NewUrl ("new_url");
454 }
455
457 {
458 constexpr std::string_view NewUrl ("new_url");
459 }
460
461 namespace ErrMsgFields
462 {
463 constexpr std::string_view Reason ("reason");
464 constexpr std::string_view Transient ("transient");
465 constexpr std::string_view History ("history");
466 }
467
469 {
470 constexpr std::string_view Url ("url");
471 constexpr std::string_view Filename ("filename");
472 constexpr std::string_view DeltaFile ("delta_file");
473 constexpr std::string_view ExpectedFilesize ("expected_filesize");
474 constexpr std::string_view CheckExistOnly ("check_existance_only");
475 constexpr std::string_view MetalinkEnabled ("metalink_enabled");
476 }
477
479 {
480 constexpr std::string_view Url ("url");
481 constexpr std::string_view AttachId ("attach_id");
482 constexpr std::string_view VerifyType ("verify_type");
483 constexpr std::string_view VerifyData ("verify_data");
484 constexpr std::string_view MediaNr ("media_nr");
485 constexpr std::string_view Device ("device");
486 constexpr std::string_view Label ("label");
487 }
488
490 {
491 constexpr std::string_view LocalMountPoint ("local_mountpoint");
492 }
493
495 {
496 constexpr std::string_view Url ("url");
497 }
498
500 {
501 constexpr std::string_view EffectiveUrl ("effective_url");
502 constexpr std::string_view LastAuthTimestamp ("last_auth_timestamp");
503 constexpr std::string_view LastUser ("username");
504 constexpr std::string_view AuthHint ("authHint");
505 }
506
508 {
509 constexpr std::string_view Label ("label");
510 constexpr std::string_view MediaNr ("media_nr");
511 constexpr std::string_view Device ("device");
512 constexpr std::string_view Desc ("desc");
513 }
514
516 {
517 constexpr std::string_view device ("device");
518 }
519
521 {
522 public:
524
525 ProvideMessage(const ProvideMessage &) = default;
530
531 static constexpr std::string_view typeName = "ProvideMessage";
532
533 static expected<ProvideMessage> create ( const zypp::PluginFrame &message );
536
537 static ProvideMessage createProvideStarted ( const uint32_t reqId, const zypp::Url &url , const std::optional<std::string> &localFilename = {}, const std::optional<std::string> &stagingFilename = {} );
538 static ProvideMessage createProvideFinished ( const uint32_t reqId, const std::string &localFilename , bool cacheHit );
539 static ProvideMessage createAttachFinished ( const uint32_t reqId, const std::optional<std::string> &localMountPoint = {} );
540 static ProvideMessage createDetachFinished ( const uint32_t reqId );
541 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 = {} );
542 static ProvideMessage createMediaChanged ( const uint32_t reqId );
543 static ProvideMessage createRedirect ( const uint32_t reqId, const zypp::Url &newUrl );
544 static ProvideMessage createMetalinkRedir ( const uint32_t reqId, const std::vector<zypp::Url> &newUrls );
545 static ProvideMessage createErrorResponse (const uint32_t reqId, const Code code, const std::string &reason, bool transient = false );
546
547 static ProvideMessage createProvide ( const uint32_t reqId
548 , const zypp::Url &url
549 , const std::optional<std::string> &filename = {}
550 , const std::optional<std::string> &deltaFile = {}
551 , const std::optional<int64_t> &expFilesize = {}
552 , bool checkExistOnly = false );
553
554 static ProvideMessage createCancel ( const uint32_t reqId );
555
556 static ProvideMessage createAttach( const uint32_t reqId
557 , const zypp::Url &url
558 , const std::string attachId
559 , const std::string &label
560 , const std::optional<std::string> &verifyType = {}
561 , const std::optional<std::string> &verifyData = {}
562 , const std::optional<int32_t> &mediaNr = {} );
563
564 static ProvideMessage createDetach ( const uint32_t reqId, const zypp::Url &attachUrl );
565 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 = {} );
566 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 );
567
568 uint requestId () const;
569 void setRequestId ( const uint id );
570
571 Code code() const;
572 void setCode (const Code newCode );
573
574 const std::vector<ProvideMessage::FieldVal> &values ( const std::string_view &str ) const;
575 const std::vector<ProvideMessage::FieldVal> &values ( const std::string &str ) const;
576 const HeaderValueMap &headers() const;
581 FieldVal value ( const std::string_view &str, const FieldVal &defaultVal = FieldVal() ) const;
582 FieldVal value ( const std::string &str, const FieldVal &defaultVal = FieldVal() ) const;
583 void setValue ( const std::string &name, const FieldVal &value );
584 void setValue ( const std::string_view &name, const FieldVal &value );
585 void addValue ( const std::string &name, const FieldVal &value );
586 void addValue ( const std::string_view &name, const FieldVal &value );
587
588 private:
590 uint _reqId = -1;
593 };
594}
595
596#endif
Container of Capability (currently read only).
Command frame for communication with PluginScript.
Definition PluginFrame.h:42
Url manipulation class.
Definition Url.h:93
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={})
expected< zypp::PluginFrame > toStompMessage() const
static expected< ProvideMessage > fromStompMessage(const zypp::PluginFrame &msg)
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)
const HeaderValueMap & headers() const
static constexpr std::string_view typeName
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 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
const std::vector< ProvideMessage::FieldVal > & values(const std::string_view &str) 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 createErrorResponse(const uint32_t reqId, const Code code, const std::string &reason, bool transient=false)
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)
void setCode(const Code newCode)
static expected< ProvideMessage > create(const zypp::PluginFrame &message)
static ProvideMessage createAttachFinished(const uint32_t reqId, const std::optional< std::string > &localMountPoint={})
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={})
static zyppng::expected< ProviderConfiguration > fromStompMessage(const zypp::PluginFrame &msg)
zyppng::expected< zypp::PluginFrame > toStompMessage() const
static constexpr std::string_view typeName
zyppng::expected< zypp::PluginFrame > toStompMessage() const
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
static constexpr std::string_view typeName
static zyppng::expected< WorkerCaps > fromStompMessage(const zypp::PluginFrame &msg)
void set_worker_name(std::string name)
void set_cfg_flags(Flags f)
Url details namespace.
Definition UrlBase.cc:58
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 RequestId("requestId")
constexpr std::string_view RequestCode("requestCode")
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
zypp::Url Url
Definition url.h:15