50 const Pathname MediaAccess::_noPath;
54 MediaAccess::MediaAccess ()
97 bool exactIdMatch)
const
108 MIL <<
"Url is not valid" << endl;
118 MIL <<
"Trying scheme '" << scheme <<
"'" << endl;
124 if (scheme ==
"cd" || scheme ==
"dvd")
126 else if (scheme ==
"nfs" || scheme ==
"nfs4")
128 else if (scheme ==
"iso")
130 else if (scheme ==
"file" || scheme ==
"dir")
132 else if (scheme ==
"hd")
134 else if (scheme ==
"cifs" || scheme ==
"smb")
136 else if (scheme ==
"ftp" || scheme ==
"tftp" || scheme ==
"http" || scheme ==
"https")
139 bool use_aria =
false;
140 bool use_multicurl =
true;
141 string urlmediahandler ( url.
getQueryParam(
"mediahandler") );
142 if ( urlmediahandler ==
"multicurl" )
145 use_multicurl =
true;
147 else if ( urlmediahandler ==
"aria2c" )
150 use_multicurl =
false;
152 else if ( urlmediahandler ==
"curl" )
155 use_multicurl =
false;
159 if ( ! urlmediahandler.empty() )
161 WAR <<
"unknown mediahandler set: " << urlmediahandler << endl;
163 const char *ariaenv = getenv(
"ZYPP_ARIA2C" );
164 const char *multicurlenv = getenv(
"ZYPP_MULTICURL" );
166 if ( use_multicurl && multicurlenv && ( strcmp(multicurlenv,
"0" ) == 0 ) )
168 WAR <<
"multicurl manually disabled." << endl;
169 use_multicurl =
false;
171 else if ( !use_multicurl && multicurlenv && ( strcmp(multicurlenv,
"1" ) == 0 ) )
173 WAR <<
"multicurl manually enabled." << endl;
174 use_multicurl =
true;
177 if ( use_aria && ariaenv && ( strcmp(ariaenv,
"0" ) == 0 ) )
179 WAR <<
"aria2c manually disabled. Falling back to curl" << endl;
182 else if ( !use_aria && ariaenv && ( strcmp(ariaenv,
"1" ) == 0 ) )
186 WAR <<
"no aria2c for FTP, despite ZYPP_ARIA2C=1" << endl;
189 WAR <<
"aria2c manually enabled." << endl;
198 WAR <<
"aria2c not found. Falling back to curl" << endl;
205 curl =
new MediaAria2c (url,preferred_attach_point);
206 else if ( use_multicurl )
209 curl =
new MediaCurl (url,preferred_attach_point);
211 UrlResolverPlugin::HeaderList::const_iterator it;
212 for (it = custom_headers.begin();
213 it != custom_headers.end();
215 std::string header = it->first +
": " + it->second;
216 MIL <<
"Added custom header -> " << header << endl;
221 else if (scheme ==
"plugin" )
230 ERR <<
"Failed to create media handler" << endl;
234 MIL <<
"Opened: " << *
this << endl;
282 WAR <<
"Close: " << *
this <<
" (" << excpt_r <<
")" << endl;
285 MIL <<
"Close: " << *
this <<
" (OK)" << endl;
317 unsigned int & index)
const
325 if (!devices.empty())
488 return str <<
"MediaAccess( closed )";
496 DBG <<
"From: " << from << endl <<
"To: " << to << endl;
499 Pathname dir = path.dirname();
500 string base = path.basename();
520 {
return obj.
dumpOn( str ); }