nathan@0: /* nathan@0: * MP3/MPlayer plugin to VDR (C++) nathan@0: * nathan@0: * (C) 2001-2006 Stefan Huelswitt nathan@0: * nathan@0: * This code is free software; you can redistribute it and/or nathan@0: * modify it under the terms of the GNU General Public License nathan@0: * as published by the Free Software Foundation; either version 2 nathan@0: * of the License, or (at your option) any later version. nathan@0: * nathan@0: * This code is distributed in the hope that it will be useful, nathan@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of nathan@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nathan@0: * GNU General Public License for more details. nathan@0: * nathan@0: * You should have received a copy of the GNU General Public License nathan@0: * along with this program; if not, write to the Free Software nathan@0: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. nathan@0: * Or, point your browser to http://www.gnu.org/copyleft/gpl.html nathan@0: */ nathan@0: nathan@0: #ifndef ___DATA_H nathan@0: #define ___DATA_H nathan@0: nathan@0: #include nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: class cFileSource; nathan@0: nathan@0: extern char *Quote(const char *str); nathan@0: extern char *AddPath(const char *dir, const char *filename); nathan@0: extern bool CheckVDRVersion(int Version, int Major, int Minor, const char *text=0); nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: class cScanDir { nathan@0: protected: nathan@0: enum eScanType { stFile, stDir }; nathan@0: virtual void DoItem(cFileSource *src, const char *subdir, const char *name)=0; nathan@0: public: nathan@0: virtual ~cScanDir() {} nathan@0: bool ScanDir(cFileSource *src, const char *subdir, eScanType type, const char * const *spec, const char * const *excl, bool recursiv); nathan@0: }; nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: enum eObjType { otDir, otParent, otFile, otBase }; nathan@0: nathan@0: class cFileObj : public cListObject { nathan@0: private: nathan@0: cFileSource *source; nathan@0: char *subdir, *name, *path, *fpath; nathan@0: eObjType type; nathan@0: // nathan@0: void Set(void); nathan@0: void MakeFullName(char **fp, const char *Name); nathan@0: public: nathan@0: cFileObj(cFileSource *Source, const char *Subdir, const char *Name, const eObjType Type); nathan@0: cFileObj(const cFileObj *obj); nathan@0: virtual ~cFileObj(); nathan@0: #if APIVERSNUM >= 10315 nathan@0: virtual int Compare(const cListObject &ListObject) const; nathan@0: #else nathan@0: virtual bool operator<(const cListObject &ListObject); nathan@0: #endif nathan@0: void SetName(const char *Name); nathan@0: void SplitAndSet(const char *Path); nathan@0: bool GuessType(void); nathan@0: // nathan@0: bool Exists(void); nathan@0: bool TestName(const char *newName); nathan@0: bool Rename(const char *newName); nathan@0: bool Create(const char *newName); nathan@0: bool Delete(void); nathan@0: // nathan@0: inline const char *Name(void) const { return name; } nathan@0: inline const char *Subdir(void) const { return subdir; } nathan@0: inline cFileSource *Source(void) const { return source; } nathan@0: inline eObjType Type(void) const { return type; } nathan@0: inline const char *Path(void) const { return path; } nathan@0: inline const char *FullPath(void) const { return fpath; } nathan@0: }; nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: class cDirList : public cScanDir, public cList { nathan@0: private: nathan@0: eObjType otype; nathan@0: protected: nathan@0: virtual void DoItem(cFileSource *src, const char *subdir, const char *name); nathan@0: public: nathan@0: bool Load(cFileSource *src, const char *subdir, const char * const *excl=0); nathan@0: }; nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: class cFileSource : public cListObject { nathan@0: private: nathan@0: enum eAction { acMount, acUnmount, acEject, acStatus }; nathan@0: char *basedir, *realbasedir; nathan@0: char *description; nathan@0: char **include; nathan@0: bool needsmount; nathan@0: int useCount, incCount; nathan@0: // remember last browse position nathan@0: char *browsedir, *browseparent; nathan@0: // nathan@0: void Set(const char *Basedir, const char *Description, const bool NeedsMount, const char *Include); nathan@0: bool Action(eAction act); nathan@0: void ClearRemember(void); nathan@0: void Clear(void); nathan@0: public: nathan@0: cFileSource(void); nathan@0: cFileSource(const char *Basedir, const char *Description, const bool NeedsMount, const char *Include=0); nathan@0: ~cFileSource(); nathan@0: bool Parse(char *s); nathan@0: bool Mount(void); nathan@0: bool Unmount(void); nathan@0: bool Eject(void); nathan@0: bool Status(void); nathan@0: void Block(void) { useCount++; } nathan@0: void Unblock(void) { useCount--; } nathan@0: void SetRemember(const char *dir, const char *parent); nathan@0: bool GetRemember(char * &dir, char * &parent); nathan@0: inline const char *BaseDir(void) const { return basedir; } nathan@0: inline const char *RealBaseDir(void) const { return realbasedir; } nathan@0: inline const char *Description(void) const { return description; } nathan@0: inline const char * const * Include(void) const { return include; } nathan@0: inline bool NeedsMount(void) const { return needsmount; } nathan@0: }; nathan@0: nathan@0: #endif //___DATA_H