libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_MEDIA_MEDIAMANAGER_H 00013 #define ZYPP_MEDIA_MEDIAMANAGER_H 00014 00015 #include <zypp/media/MediaAccess.h> 00016 00017 #include <zypp/base/Deprecated.h> 00018 #include <zypp/base/NonCopyable.h> 00019 #include <zypp/base/PtrTypes.h> 00020 #include <zypp/Pathname.h> 00021 #include <zypp/Url.h> 00022 00023 #include <list> 00024 00025 00027 namespace zypp 00028 { 00029 00031 namespace media 00032 { 00033 00034 00036 typedef zypp::RW_pointer<MediaAccess> MediaAccessRef; 00037 00038 // OBSOLETE HERE: 00039 typedef MediaAccessId MediaId; 00040 typedef unsigned int MediaNr; 00041 00042 00044 // forward declaration 00045 class MountEntry; 00046 class MediaManager_Impl; 00047 00049 // 00050 // CLASS NAME : MediaVerifierBase 00051 // 00055 class MediaVerifierBase //: private zypp::NonCopyable 00056 { 00057 public: 00058 MediaVerifierBase() 00059 {} 00060 00061 virtual 00062 ~MediaVerifierBase() 00063 {} 00064 00069 virtual std::string 00070 info() const; 00071 00072 /* 00073 ** Check if the specified attached media contains 00074 ** the desired media (e.g. SLES10 CD1). 00075 */ 00076 virtual bool 00077 isDesiredMedia(const MediaAccessRef &ref) = 0; 00078 }; 00079 00080 00082 // 00083 // CLASS NAME : NoVerifier 00084 // 00088 class NoVerifier : public MediaVerifierBase 00089 { 00090 public: 00091 NoVerifier(): MediaVerifierBase() 00092 {} 00093 00094 virtual 00095 ~NoVerifier() 00096 {} 00097 00101 virtual std::string 00102 info() const; 00103 00104 /* 00105 ** Don't check if the specified attached media contains 00106 ** the desired media number. Always return true. 00107 */ 00108 virtual bool 00109 isDesiredMedia(const MediaAccessRef &ref) 00110 { 00111 (void)ref; 00112 return true; 00113 } 00114 }; 00115 00116 00118 // 00119 // CLASS NAME : MediaVerifierRef 00120 // 00124 typedef zypp::RW_pointer<MediaVerifierBase> MediaVerifierRef; 00125 00126 00128 // 00129 // CLASS NAME : MediaManager 00130 // 00468 class MediaManager: private zypp::base::NonCopyable 00469 { 00470 public: 00482 MediaManager(); 00483 00488 ~MediaManager(); 00489 00510 MediaAccessId 00511 open(const Url &url, const Pathname & preferred_attach_point = ""); 00512 00517 void 00518 close(MediaAccessId accessId); 00519 00526 bool 00527 isOpen(MediaAccessId accessId) const; 00528 00538 std::string 00539 protocol(MediaAccessId accessId) const; 00540 00546 bool 00547 downloads(MediaAccessId accessId) const; 00548 00550 static 00551 ZYPP_DEPRECATED bool downloads(const Url &url) 00552 { return url.schemeIsDownloading(); } 00553 00561 Url 00562 url(MediaAccessId accessId) const; 00563 00564 public: 00573 void 00574 addVerifier(MediaAccessId accessId, 00575 const MediaVerifierRef &verifier); 00576 00584 void 00585 delVerifier(MediaAccessId accessId); 00586 00587 public: 00600 bool 00601 setAttachPrefix(const Pathname &attach_prefix); 00602 00612 void 00613 attach(MediaAccessId accessId); 00614 00616 ZYPP_DEPRECATED void attachDesiredMedia(MediaAccessId accessId) 00617 { attach( accessId ); } 00618 00630 void 00631 release(MediaAccessId accessId, const std::string & ejectDev = ""); 00632 00636 void 00637 releaseAll(); 00638 00653 void 00654 disconnect(MediaAccessId accessId); 00655 00663 bool 00664 isAttached(MediaAccessId accessId) const; 00665 00674 bool 00675 isSharedMedia(MediaAccessId accessId) const; 00676 00686 bool 00687 isDesiredMedia(MediaAccessId accessId) const; 00688 00699 bool 00700 isDesiredMedia(MediaAccessId accessId, 00701 const MediaVerifierRef &verifier) const; 00702 00714 bool 00715 isChangeable(MediaAccessId accessId); 00716 00729 Pathname 00730 localRoot(MediaAccessId accessId) const; 00731 00744 Pathname 00745 localPath(MediaAccessId accessId, const Pathname & pathname) const; 00746 00747 public: 00766 void 00767 provideFile(MediaAccessId accessId, 00768 const Pathname &filename ) const; 00769 00773 void 00774 provideDir(MediaAccessId accessId, 00775 const Pathname &dirname) const; 00776 00780 void 00781 provideDirTree(MediaAccessId accessId, 00782 const Pathname &dirname) const; 00783 00787 void 00788 releaseFile(MediaAccessId accessId, 00789 const Pathname &filename) const; 00790 00794 void 00795 releaseDir(MediaAccessId accessId, 00796 const Pathname &dirname) const; 00797 00801 void 00802 releasePath(MediaAccessId accessId, 00803 const Pathname &pathname) const; 00804 00808 void 00809 dirInfo(MediaAccessId accessId, 00810 std::list<std::string> &retlist, 00811 const Pathname &dirname, 00812 bool dots = true) const; 00813 00817 void 00818 dirInfo(MediaAccessId accessId, 00819 filesystem::DirContent &retlist, 00820 const Pathname &dirname, 00821 bool dots = true) const; 00822 00826 bool doesFileExist(MediaAccessId accessId, 00827 const Pathname & filename ) const; 00828 00838 void 00839 getDetectedDevices(MediaAccessId accessId, 00840 std::vector<std::string> & devices, 00841 unsigned int & index) const; 00842 00843 void 00844 setDeltafile(MediaAccessId accessId, 00845 const Pathname &filename ) const; 00846 00847 public: 00852 static time_t 00853 getMountTableMTime(); 00854 00859 static std::vector<MountEntry> 00860 getMountEntries(); 00861 00871 bool 00872 isUseableAttachPoint(const Pathname &path, 00873 bool mtab=true) const; 00874 00875 private: 00876 friend class MediaHandler; 00877 00887 AttachedMedia 00888 getAttachedMedia(MediaAccessId &accessId) const; 00889 00899 AttachedMedia 00900 findAttachedMedia(const MediaSourceRef &media) const; 00901 00910 void 00911 forceReleaseShared(const MediaSourceRef &media); 00912 00913 private: 00917 static zypp::RW_pointer<MediaManager_Impl> m_impl; 00918 }; 00919 00920 00922 } // namespace media 00924 00926 } // namespace zypp 00928 00929 #endif // ZYPP_MEDIA_MEDIAMANAGER_H 00930 00931 /* 00932 ** vim: set ts=2 sts=2 sw=2 ai et: 00933 */