libzypp  17.31.31
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 
15 namespace 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 ) {
31  if ( !_sigMirrorsReadyConn )
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 );
62  if ( err.type() != NetworkRequestError::NoError )
63  return err;
64 
65  url = myUrl;
66  set = settings;
67  return err;
68  }
69 
70 }
SignalProxy< void()> sigNewMirrorsReady()
void setPassword(const std::string &val_r)
sets the auth password
MirrorHandlingStateBase(DownloadPrivate &parent)
Holds transfer setting.
virtual void mirrorReceived(MirrorControl::MirrorPick mirror)=0
void setUsername(const std::string &val_r)
sets the auth username
void setAuthType(const std::string &val_r)
set the allowed authentication types
The NetworkRequestError class Represents a error that occured in.
std::pair< std::vector< Url >::const_iterator, MirrorHandle > MirrorPick
NetworkRequestError setupMirror(const MirrorControl::MirrorPick &pick, Url &url, TransferSettings &set)
Type type() const
type Returns the type of the error