60 ManagedMedia(
const ManagedMedia &m)
77 DBG <<
"checkAttached(" <<
id <<
") not attached" << std::endl;
102 DBG <<
"checkDesired(" <<
id <<
"): not desired (report by "
103 <<
verifier->info() <<
")" << std::endl;
109 DBG <<
"checkDesired(" <<
id <<
"): desired (report by "
110 <<
verifier->info() <<
")" << std::endl;
112 DBG <<
"checkDesired(" <<
id <<
"): desired (cached)" << std::endl;
123 typedef std::map<MediaAccessId, ManagedMedia> ManagedMediaMap;
134 return std::string(
typeid((*
this)).name());
142 return std::string(
"zypp::media::NoVerifier");
167 ManagedMediaMap::iterator it;
174 if( it->second.handler->dependsOnParent())
179 it->second.handler->resetParentId();
206 inline ManagedMedia &
209 ManagedMediaMap::iterator it(
mediaMap.find(accessId));
222 time_t mtime = zypp::PathInfo(
"/etc/mtab").mtime();
225 WAR <<
"Failed to retrieve modification time of '/etc/mtab'"
231 static inline MountEntries
269 ManagedMedia tmp( handler, verifier);
271 tmp.handler->open(url, preferred_attach_point);
275 m_impl->mediaMap[nextId] = tmp;
277 DBG <<
"Opened new media access using id " << nextId
278 <<
" to " << url.
asString() << std::endl;
298 ManagedMediaMap::iterator m(
m_impl->mediaMap.begin());
299 for( ; m !=
m_impl->mediaMap.end(); ++m)
301 if( m->second.handler->dependsOnParent(accessId,
true))
304 m->second.handler->url().asString()
309 DBG <<
"Close to access handler using id "
310 << accessId <<
" requested" << std::endl;
312 ManagedMedia &ref(
m_impl->findMM(accessId));
313 ref.handler->close();
315 m_impl->mediaMap.erase(accessId);
324 ManagedMediaMap::iterator it(
m_impl->mediaMap.find(accessId));
325 return it !=
m_impl->mediaMap.end() &&
326 it->second.handler->isOpen();
335 ManagedMedia &ref(
m_impl->findMM(accessId));
337 return ref.handler->protocol();
346 ManagedMedia &ref(
m_impl->findMM(accessId));
348 return ref.handler->downloads();
357 ManagedMedia &ref(
m_impl->findMM(accessId));
359 return ref.handler->url();
372 ManagedMedia &ref(
m_impl->findMM(accessId));
377 DBG <<
"MediaVerifier change: id=" << accessId <<
", verifier="
378 << verifier->info() << std::endl;
387 ManagedMedia &ref(
m_impl->findMM(accessId));
391 ref.verifier.swap(verifier);
393 DBG <<
"MediaVerifier change: id=" << accessId <<
", verifier="
394 << verifier->info() << std::endl;
411 ManagedMedia &ref(
m_impl->findMM(accessId));
413 DBG <<
"attach(id=" << accessId <<
")" << std::endl;
416 ref.handler->attach(
false);
419 ref.checkDesired(accessId);
426 if (!ref.handler->hasMoreDevices())
429 if (ref.handler->isAttached())
430 ref.handler->release();
433 MIL <<
"checkDesired(" << accessId <<
") of first device failed,"
434 " going to try others with attach(true)" << std::endl;
436 while (ref.handler->hasMoreDevices())
441 ref.handler->attach(
true);
442 ref.checkDesired(accessId);
449 if (!ref.handler->hasMoreDevices())
451 MIL <<
"No desired media found after trying all detected devices." << std::endl;
456 DBG <<
"Skipping " << media.mediaSource->asString() <<
": not desired media." << std::endl;
458 ref.handler->release();
464 if (!ref.handler->hasMoreDevices())
468 DBG <<
"Skipping " << media.mediaSource->asString() <<
" because of exception thrown by attach(true)" << std::endl;
470 if (ref.handler->isAttached()) ref.handler->release();
481 ManagedMedia &ref(
m_impl->findMM(accessId));
483 DBG <<
"release(id=" << accessId;
484 if (!ejectDev.empty())
485 DBG <<
", " << ejectDev;
486 DBG <<
")" << std::endl;
488 if(!ejectDev.empty())
496 ManagedMediaMap::iterator m(
m_impl->mediaMap.begin());
497 for( ; m !=
m_impl->mediaMap.end(); ++m)
499 if( m->second.handler->dependsOnParent(accessId,
false))
503 DBG <<
"Forcing release of handler depending on access id "
504 << accessId << std::endl;
505 m->second.desired =
false;
506 m->second.handler->release();
516 ref.handler->release(ejectDev);
525 MIL <<
"Releasing all attached media" << std::endl;
527 ManagedMediaMap::iterator m(
m_impl->mediaMap.begin());
528 for( ; m !=
m_impl->mediaMap.end(); ++m)
530 if( m->second.handler->dependsOnParent())
535 if(m->second.handler->isAttached())
537 DBG <<
"Releasing media id " << m->first << std::endl;
538 m->second.desired =
false;
539 m->second.handler->release();
543 DBG <<
"Media id " << m->first <<
" not attached " << std::endl;
549 ERR <<
"Failed to release media id " << m->first << std::endl;
553 MIL <<
"Exit" << std::endl;
562 ManagedMedia &ref(
m_impl->findMM(accessId));
564 ref.handler->disconnect();
573 ManagedMedia &ref(
m_impl->findMM(accessId));
575 return ref.handler->isAttached();
583 ManagedMedia &ref(
m_impl->findMM(accessId));
585 return ref.handler->isSharedMedia();
594 ManagedMedia &ref(
m_impl->findMM(accessId));
596 if( !ref.handler->isAttached())
603 ref.desired = ref.verifier->isDesiredMedia(ref.handler);
610 DBG <<
"isDesiredMedia(" << accessId <<
"): "
611 << (ref.desired ?
"" :
"not ")
612 <<
"desired (report by "
613 << ref.verifier->info() <<
")" << std::endl;
628 ManagedMedia &ref(
m_impl->findMM(accessId));
631 if( ref.handler->isAttached())
634 desired = v->isDesiredMedia(ref.handler);
641 DBG <<
"isDesiredMedia(" << accessId <<
"): "
642 << (desired ?
"" :
"not ")
643 <<
"desired (report by "
644 << v->info() <<
")" << std::endl;
661 ManagedMedia &ref(
m_impl->findMM(accessId));
664 path = ref.handler->localRoot();
671 const Pathname & pathname)
const
675 ManagedMedia &ref(
m_impl->findMM(accessId));
678 path = ref.handler->localPath(pathname);
685 const Pathname &filename )
const
689 ManagedMedia &ref(
m_impl->findMM(accessId));
691 ref.checkDesired(accessId);
693 ref.handler->provideFile(filename);
699 const Pathname &filename )
const
703 ManagedMedia &ref(
m_impl->findMM(accessId));
705 ref.checkDesired(accessId);
707 ref.handler->setDeltafile(filename);
713 const Pathname &dirname)
const
717 ManagedMedia &ref(
m_impl->findMM(accessId));
719 ref.checkDesired(accessId);
721 ref.handler->provideDir(dirname);
727 const Pathname &dirname)
const
731 ManagedMedia &ref(
m_impl->findMM(accessId));
733 ref.checkDesired(accessId);
735 ref.handler->provideDirTree(dirname);
741 const Pathname &filename)
const
745 ManagedMedia &ref(
m_impl->findMM(accessId));
747 ref.checkAttached(accessId);
749 ref.handler->releaseFile(filename);
755 const Pathname &dirname)
const
759 ManagedMedia &ref(
m_impl->findMM(accessId));
761 ref.checkAttached(accessId);
763 ref.handler->releaseDir(dirname);
770 const Pathname &pathname)
const
774 ManagedMedia &ref(
m_impl->findMM(accessId));
776 ref.checkAttached(accessId);
778 ref.handler->releasePath(pathname);
784 std::list<std::string> &retlist,
785 const Pathname &dirname,
790 ManagedMedia &ref(
m_impl->findMM(accessId));
793 ref.checkAttached(accessId);
795 ref.handler->dirInfo(retlist, dirname, dots);
802 const Pathname &dirname,
807 ManagedMedia &ref(
m_impl->findMM(accessId));
810 ref.checkAttached(accessId);
812 ref.handler->dirInfo(retlist, dirname, dots);
820 ManagedMedia &ref(
m_impl->findMM(accessId));
823 ref.checkAttached(accessId);
825 return ref.handler->doesFileExist(filename);
831 std::vector<std::string> & devices,
832 unsigned int & index)
const
835 ManagedMedia &ref(
m_impl->findMM(accessId));
836 return ref.handler->getDetectedDevices(devices, index);
863 if( path.empty() || path ==
"/" || !PathInfo(path).isDir())
871 ManagedMediaMap::const_iterator m(
m_impl->mediaMap.begin());
872 for( ; m !=
m_impl->mediaMap.end(); ++m)
878 std::string our(path.asString());
886 if( mnt.size() > our.size() &&
887 mnt.at(our.size()) ==
'/' &&
888 !mnt.compare(0, our.size(), our))
903 MountEntries entries(
m_impl->getMountEntries());
904 MountEntries::const_iterator e;
905 for( e = entries.begin(); e != entries.end(); ++e)
907 std::string mnt(Pathname(e->dir).asString());
908 std::string our(path.asString());
916 if( mnt.size() > our.size() &&
917 mnt.at(our.size()) ==
'/' &&
918 !mnt.compare(0, our.size(), our))
935 ManagedMedia &ref(
m_impl->findMM(accessId));
937 return ref.handler->attachedMedia();
946 if( !media || media->type.empty())
949 ManagedMediaMap::const_iterator m(
m_impl->mediaMap.begin());
950 for( ; m !=
m_impl->mediaMap.end(); ++m)
952 if( !m->second.handler->isAttached())
968 if( !media || media->type.empty())
971 ManagedMediaMap::iterator m(
m_impl->mediaMap.begin());
972 for( ; m !=
m_impl->mediaMap.end(); ++m)
974 if( !m->second.handler->isAttached())
980 m->second.handler->release();
981 m->second.desired =
false;
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
std::string asString() const
Returns a default string representation of the Url object.
#define ZYPP_RETHROW(EXCPT)
Drops a logline and rethrows, updating the CodeLocation.
std::list< DirEntry > DirContent
Returned by readdir.
std::string numstring(char n, int w=0)
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Base class for Exception.
Wrapper for const correct access via Smart pointer types.
std::string getScheme() const
Returns the scheme name of the URL.