libzypp 17.31.23
mirrorhandling_p.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------*/
9
12
13#include "mirrorhandling_p.h"
14
15namespace zyppng {
16
18 : BasicState(parent)
19 { }
20
22 {
23 _sigMirrorsReadyConn.disconnect();
24 }
25
27 {
28 auto &sm = stateMachine();
29 auto res = sm._mirrorControl->pickBestMirror( _fileMirrors );
30 if ( res.code == MirrorControl::PickResult::Again ) {
32 _sigMirrorsReadyConn = sm._mirrorControl->connectFunc( &MirrorControl::sigNewMirrorsReady, [this](){
33 _sigMirrorsReadyConn.disconnect();
35 }, *this );
36 return Delayed;
37 } else if ( res.code == MirrorControl::PickResult::Unknown ) {
39 return Failed;
40 }
41 mirrorReceived( res.result );
42 return Ok;
43 }
44
46 {
47 auto &sm = stateMachine();
48 Url myUrl;
49 TransferSettings settings;
50
51 myUrl = *pick.first;
52
53 settings = sm._spec.settings();
54 //if this is a different host than the initial request, we reset username/password
55 if ( myUrl.getHost() != sm._spec.url().getHost() ) {
56 settings.setUsername( std::string() );
57 settings.setPassword( std::string() );
58 settings.setAuthType( std::string() );
59 }
60
61 NetworkRequestError err = sm.safeFillSettingsFromURL( myUrl, settings );
63 return err;
64
65 url = myUrl;
66 set = settings;
67 return err;
68 }
69
70}
Holds transfer setting.
void setUsername(const std::string &val_r)
sets the auth username
void setPassword(const std::string &val_r)
sets the auth password
void setAuthType(const std::string &val_r)
set the allowed authentication types
std::pair< std::vector< Url >::const_iterator, MirrorHandle > MirrorPick
SignalProxy< void()> sigNewMirrorsReady()
The NetworkRequestError class Represents a error that occured in.
Type type() const
type Returns the type of the error
NetworkRequestError setupMirror(const MirrorControl::MirrorPick &pick, Url &url, TransferSettings &set)
virtual void mirrorReceived(MirrorControl::MirrorPick mirror)=0
MirrorHandlingStateBase(DownloadPrivate &parent)