libzypp 17.25.7
MediaManager.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_MEDIA_MEDIAMANAGER_H
13#define ZYPP_MEDIA_MEDIAMANAGER_H
14
16
17#include <zypp/APIConfig.h>
19#include <zypp/base/PtrTypes.h>
20#include <zypp/Pathname.h>
21#include <zypp/Url.h>
22
23#include <list>
24
25
27namespace zypp
28{
29
31 namespace media
32 {
33
34
37
38 // OBSOLETE HERE:
40 typedef unsigned int MediaNr;
41
42
44 // forward declaration
45 struct MountEntry;
47
49 //
50 // CLASS NAME : MediaVerifierBase
51 //
55 class MediaVerifierBase //: private zypp::NonCopyable
56 {
57 public:
59 {}
60
61 virtual
63 {}
64
69 virtual std::string
70 info() const;
71
72 /*
73 ** Check if the specified attached media contains
74 ** the desired media (e.g. SLES10 CD1).
75 */
76 virtual bool
78 };
79
80
82 //
83 // CLASS NAME : NoVerifier
84 //
89 {
90 public:
92 {}
93
94 virtual
96 {}
97
101 virtual std::string
102 info() const;
103
104 /*
105 ** Don't check if the specified attached media contains
106 ** the desired media number. Always return true.
107 */
108 virtual bool
110 {
111 (void)ref;
112 return true;
113 }
114 };
115
116
118 //
119 // CLASS NAME : MediaVerifierRef
120 //
125
126
128 //
129 // CLASS NAME : MediaManager
130 //
471 {
472 public:
484 MediaManager();
485
491
513 open(const Url &url, const Pathname & preferred_attach_point = "");
514
519 void
520 close(MediaAccessId accessId);
521
528 bool
529 isOpen(MediaAccessId accessId) const;
530
540 std::string
541 protocol(MediaAccessId accessId) const;
542
548 bool
549 downloads(MediaAccessId accessId) const;
550
558 Url
559 url(MediaAccessId accessId) const;
560
561 public:
570 void
571 addVerifier(MediaAccessId accessId,
573
581 void
582 delVerifier(MediaAccessId accessId);
583
584 public:
597 bool
598 setAttachPrefix(const Pathname &attach_prefix);
599
609 void
610 attach(MediaAccessId accessId);
611
623 void
624 release(MediaAccessId accessId, const std::string & ejectDev = "");
625
629 void
630 releaseAll();
631
646 void
647 disconnect(MediaAccessId accessId);
648
656 bool
657 isAttached(MediaAccessId accessId) const;
658
667 bool
668 isSharedMedia(MediaAccessId accessId) const;
669
679 bool
680 isDesiredMedia(MediaAccessId accessId) const;
681
692 bool
694 const MediaVerifierRef &verifier) const;
695
707 bool
708 isChangeable(MediaAccessId accessId);
709
723 localRoot(MediaAccessId accessId) const;
724
738 localPath(MediaAccessId accessId, const Pathname & pathname) const;
739
740 public:
760 void
761 provideFile(MediaAccessId accessId,
762 const Pathname &filename,
763 const ByteCount &expectedFileSize) const;
764
765 void
766 provideFile(MediaAccessId accessId,
767 const Pathname &filename ) const;
768
772 void
773 provideDir(MediaAccessId accessId,
774 const Pathname &dirname) const;
775
779 void
781 const Pathname &dirname) const;
782
786 void
787 releaseFile(MediaAccessId accessId,
788 const Pathname &filename) const;
789
793 void
794 releaseDir(MediaAccessId accessId,
795 const Pathname &dirname) const;
796
800 void
801 releasePath(MediaAccessId accessId,
802 const Pathname &pathname) const;
803
807 void
808 dirInfo(MediaAccessId accessId,
809 std::list<std::string> &retlist,
810 const Pathname &dirname,
811 bool dots = true) const;
812
816 void
817 dirInfo(MediaAccessId accessId,
818 filesystem::DirContent &retlist,
819 const Pathname &dirname,
820 bool dots = true) const;
821
825 bool doesFileExist(MediaAccessId accessId,
826 const Pathname & filename ) const;
827
837 void
839 std::vector<std::string> & devices,
840 unsigned int & index) const;
841
842 void
844 const Pathname &filename ) const;
845
846 public:
851 static time_t
853
858 static std::vector<MountEntry>
860
870 bool
871 isUseableAttachPoint(const Pathname &path,
872 bool mtab=true) const;
873
874 private:
875 friend class MediaHandler;
876
887 getAttachedMedia(MediaAccessId &accessId) const;
888
899 findAttachedMedia(const MediaSourceRef &media) const;
900
909 void
911
912 private:
917 };
918
919
921 } // namespace media
923
925} // namespace zypp
927
928#endif // ZYPP_MEDIA_MEDIAMANAGER_H
929
930/*
931** vim: set ts=2 sts=2 sw=2 ai et:
932*/
MediaVerifierRef verifier
Store and operate with byte count.
Definition: ByteCount.h:31
Url manipulation class.
Definition: Url.h:92
Abstract base class for 'physical' MediaHandler like MediaCD, etc.
Definition: MediaHandler.h:45
Manages access to the 'physical' media, e.g CDROM drives, Disk volumes, directory trees,...
Definition: MediaManager.h:471
void setDeltafile(MediaAccessId accessId, const Pathname &filename) const
MediaAccessId open(const Url &url, const Pathname &preferred_attach_point="")
Opens the media access for specified with the url.
void delVerifier(MediaAccessId accessId)
Remove verifier for specified media id.
void releaseFile(MediaAccessId accessId, const Pathname &filename) const
FIXME: see MediaAccess class.
bool isChangeable(MediaAccessId accessId)
Simple check, based on media's URL scheme, telling whether the it is possible to physically change th...
void forceReleaseShared(const MediaSourceRef &media)
void releaseAll()
Release all attached media.
static zypp::RW_pointer< MediaManager_Impl > m_impl
Static reference to the implementation (singleton).
Definition: MediaManager.h:916
void disconnect(MediaAccessId accessId)
Disconnect a remote media.
void attach(MediaAccessId accessId)
Attach the media using the concrete handler (checks all devices).
void releaseDir(MediaAccessId accessId, const Pathname &dirname) const
FIXME: see MediaAccess class.
bool isOpen(MediaAccessId accessId) const
Query if the media access is open / exists.
void releasePath(MediaAccessId accessId, const Pathname &pathname) const
FIXME: see MediaAccess class.
void dirInfo(MediaAccessId accessId, std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
FIXME: see MediaAccess class.
void close(MediaAccessId accessId)
Close the media access with specified id.
Url url(MediaAccessId accessId) const
Returns the Media Access Url of the media access id.
bool isDesiredMedia(MediaAccessId accessId) const
Ask the registered verifier if the attached media is the desired one or not.
void provideFile(MediaAccessId accessId, const Pathname &filename, const ByteCount &expectedFileSize) const
Provide provide file denoted by relative path below of the 'attach point' of the specified media and ...
void release(MediaAccessId accessId, const std::string &ejectDev="")
Release the attached media and optionally eject.
bool isAttached(MediaAccessId accessId) const
Check if media is attached or not.
AttachedMedia getAttachedMedia(MediaAccessId &accessId) const
static time_t getMountTableMTime()
Get the modification time of the /etc/mtab file.
~MediaManager()
Destroys MediaManager envelope instance.
bool isSharedMedia(MediaAccessId accessId) const
Returns information if media is on a shared physical device or not.
std::string protocol(MediaAccessId accessId) const
Query the protocol name used by the media access handler.
bool doesFileExist(MediaAccessId accessId, const Pathname &filename) const
FIXME: see MediaAccess class.
void provideDir(MediaAccessId accessId, const Pathname &dirname) const
FIXME: see MediaAccess class.
AttachedMedia findAttachedMedia(const MediaSourceRef &media) const
bool isUseableAttachPoint(const Pathname &path, bool mtab=true) const
Check if the specified path is useable as attach point.
MediaManager()
Creates a MediaManager envelope instance.
Pathname localPath(MediaAccessId accessId, const Pathname &pathname) const
Shortcut for 'localRoot() + pathname', but returns an empty pathname if media is not attached.
void provideDirTree(MediaAccessId accessId, const Pathname &dirname) const
FIXME: see MediaAccess class.
void addVerifier(MediaAccessId accessId, const MediaVerifierRef &verifier)
Add verifier implementation for the specified media id.
bool setAttachPrefix(const Pathname &attach_prefix)
Set or resets the directory name, where the media manager handlers create their temporary attach poin...
void getDetectedDevices(MediaAccessId accessId, std::vector< std::string > &devices, unsigned int &index) const
Fill in a vector of detected ejectable devices and the index of the currently attached device within ...
Pathname localRoot(MediaAccessId accessId) const
Return the local directory that corresponds to medias url, no matter if media isAttached or not.
bool downloads(MediaAccessId accessId) const
Hint if files are downloaded or not.
static std::vector< MountEntry > getMountEntries()
Get current mount entries from /etc/mtab file.
Interface to implement a media verifier.
Definition: MediaManager.h:56
virtual std::string info() const
Returns a string with some info about the verifier.
virtual bool isDesiredMedia(const MediaAccessRef &ref)=0
Dummy default media verifier, which is always happy.
Definition: MediaManager.h:89
virtual bool isDesiredMedia(const MediaAccessRef &ref)
Definition: MediaManager.h:109
virtual std::string info() const
Returns the "zypp::media::NoVerifier" string.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
std::list< DirEntry > DirContent
Returned by readdir.
Definition: PathInfo.h:547
unsigned int MediaNr
Definition: MediaManager.h:40
zypp::RW_pointer< MediaVerifierBase > MediaVerifierRef
A shared reference to the MediaVerifier implementation.
Definition: MediaManager.h:124
zypp::RW_pointer< MediaAccess > MediaAccessRef
Definition: MediaManager.h:36
unsigned int MediaAccessId
Media manager access Id type.
Definition: MediaSource.h:29
MediaAccessId MediaId
Definition: MediaManager.h:39
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:286
A simple structure containing references to a media source and its attach point.
Definition: MediaSource.h:134
A "struct mntent" like mount entry structure, but using std::strings.
Definition: Mount.h:35