From 85cb3f04252b0228830903b21c08bb64e9919c18 Mon Sep 17 00:00:00 2001 From: geronimo Date: Sun, 29 Jul 2012 15:11:47 +0200 Subject: changed server setup to config file, little rearrangement of sources --- libs/IO/File.cc | 181 ++++++++++++++++ libs/IO/File.h | 67 ++++++ libs/IO/FileRepresentation.cc | 132 ++++++++++++ libs/IO/FileRepresentation.h | 56 +++++ libs/IO/FileSystem.cc | 132 ++++++++++++ libs/IO/FileSystem.h | 50 +++++ libs/IO/IO.cbp | 70 +++++++ libs/IO/IO.cbp.save | 68 ++++++ libs/IO/IO.depend | 1 + libs/IO/IO.layout | 34 +++ libs/IO/IO.layout.save | 34 +++ libs/IO/Makefile | 128 ++++++++++++ libs/IO/nbproject/Makefile-Debug.mk | 120 +++++++++++ libs/IO/nbproject/Makefile-Release.mk | 116 +++++++++++ libs/IO/nbproject/Makefile-impl.mk | 133 ++++++++++++ libs/IO/nbproject/Makefile-variables.mk | 35 ++++ libs/IO/nbproject/Package-Debug.bash | 75 +++++++ libs/IO/nbproject/Package-Release.bash | 75 +++++++ libs/IO/nbproject/configurations.xml | 116 +++++++++++ libs/IO/nbproject/private/Makefile-variables.mk | 7 + libs/IO/nbproject/private/configurations.xml | 72 +++++++ libs/IO/nbproject/private/private.xml | 8 + libs/IO/nbproject/project.xml | 28 +++ libs/IO/summary.txt | 1 + libs/fsScan/fsScan.cbp | 13 +- libs/fsScan/fsScan.layout | 46 +---- libs/fsScan/fsScan.layout.save | 46 +---- libs/fsScan/include/AbstractMedia.h | 13 +- libs/fsScan/include/AbstractMultiFileMovie.h | 12 +- libs/fsScan/include/Audio.h | 14 +- libs/fsScan/include/DVDImage.h | 12 +- libs/fsScan/include/FSMediaScanner.h | 52 +++++ libs/fsScan/include/File.h | 67 ------ libs/fsScan/include/FileRepresentation.h | 56 ----- libs/fsScan/include/FileSystem.h | 50 ----- libs/fsScan/include/FilesystemScanner.h | 52 ----- libs/fsScan/include/LegacyVdrRecording.h | 12 +- libs/fsScan/include/MediaFactory.h | 19 +- libs/fsScan/include/Movie.h | 14 +- libs/fsScan/include/Picture.h | 12 +- libs/fsScan/include/VdrRecording.h | 12 +- libs/fsScan/nbproject/Makefile-Debug.mk | 54 ++--- libs/fsScan/nbproject/Makefile-Release.mk | 24 +-- libs/fsScan/nbproject/configurations.xml | 55 ++++- libs/fsScan/nbproject/project.xml | 7 +- libs/fsScan/src/AbstractMedia.cc | 17 +- libs/fsScan/src/AbstractMultiFileMovie.cc | 12 +- libs/fsScan/src/Audio.cc | 19 +- libs/fsScan/src/DVDImage.cc | 12 +- libs/fsScan/src/FSMediaScanner.cc | 111 ++++++++++ libs/fsScan/src/File.cc | 181 ---------------- libs/fsScan/src/FileRepresentation.cc | 132 ------------ libs/fsScan/src/FileSystem.cc | 132 ------------ libs/fsScan/src/FilesystemScanner.cc | 111 ---------- libs/fsScan/src/LegacyVdrRecording.cc | 12 +- libs/fsScan/src/MediaFactory.cc | 40 ++-- libs/fsScan/src/Movie.cc | 18 +- libs/fsScan/src/Picture.cc | 12 +- libs/fsScan/src/VdrRecording.cc | 12 +- libs/networking/include/Credentials.h | 7 +- libs/networking/include/HTTPResponse.h | 12 +- libs/networking/include/ServerConfig.h | 38 +++- libs/networking/include/Url.h | 67 ------ libs/networking/nbproject/Makefile-Debug.mk | 50 +++-- libs/networking/nbproject/Makefile-Release.mk | 6 - libs/networking/nbproject/configurations.xml | 39 +++- .../nbproject/private/configurations.xml | 2 +- libs/networking/nbproject/project.xml | 6 +- libs/networking/networking.cbp | 9 +- libs/networking/networking.layout | 30 ++- libs/networking/networking.layout.save | 24 ++- libs/networking/src/ConnectionHandler.cc | 12 +- libs/networking/src/HTTPResponse.cc | 12 +- libs/networking/src/ServerConfig.cc | 127 ++++++++++-- libs/networking/src/Url.cc | 229 --------------------- libs/util/Url.cc | 229 +++++++++++++++++++++ libs/util/Url.h | 67 ++++++ libs/util/include/AbstractListAssembler.h | 12 +- libs/util/include/JSonWriter.h | 12 +- libs/util/include/ManagedMap.h | 12 +- libs/util/include/Persistable.h | 35 ++++ libs/util/include/Url.h | 67 ++++++ libs/util/nbproject/Makefile-Debug.mk | 12 +- libs/util/nbproject/Makefile-Release.mk | 6 + libs/util/nbproject/configurations.xml | 19 +- libs/util/nbproject/private/configurations.xml | 2 +- libs/util/nbproject/project.xml | 4 +- libs/util/src/Url.cc | 229 +++++++++++++++++++++ libs/util/util.cbp | 8 +- libs/util/util.layout | 28 ++- libs/util/util.layout.save | 30 ++- libs/vdr/nbproject/Makefile-Debug.mk | 4 +- libs/vdr/nbproject/configurations.xml | 4 +- libs/vdr/nbproject/private/configurations.xml | 2 +- libs/vdr/src/i18n.cc | 16 +- libs/vdr/vdr.cbp | 6 +- libs/vdr/vdr.layout | 30 ++- libs/vdr/vdr.layout.save | 26 ++- 98 files changed, 3207 insertions(+), 1525 deletions(-) create mode 100644 libs/IO/File.cc create mode 100644 libs/IO/File.h create mode 100644 libs/IO/FileRepresentation.cc create mode 100644 libs/IO/FileRepresentation.h create mode 100644 libs/IO/FileSystem.cc create mode 100644 libs/IO/FileSystem.h create mode 100644 libs/IO/IO.cbp create mode 100644 libs/IO/IO.cbp.save create mode 100644 libs/IO/IO.depend create mode 100644 libs/IO/IO.layout create mode 100644 libs/IO/IO.layout.save create mode 100644 libs/IO/Makefile create mode 100644 libs/IO/nbproject/Makefile-Debug.mk create mode 100644 libs/IO/nbproject/Makefile-Release.mk create mode 100644 libs/IO/nbproject/Makefile-impl.mk create mode 100644 libs/IO/nbproject/Makefile-variables.mk create mode 100644 libs/IO/nbproject/Package-Debug.bash create mode 100644 libs/IO/nbproject/Package-Release.bash create mode 100644 libs/IO/nbproject/configurations.xml create mode 100644 libs/IO/nbproject/private/Makefile-variables.mk create mode 100644 libs/IO/nbproject/private/configurations.xml create mode 100644 libs/IO/nbproject/private/private.xml create mode 100644 libs/IO/nbproject/project.xml create mode 100644 libs/IO/summary.txt create mode 100644 libs/fsScan/include/FSMediaScanner.h delete mode 100644 libs/fsScan/include/File.h delete mode 100644 libs/fsScan/include/FileRepresentation.h delete mode 100644 libs/fsScan/include/FileSystem.h delete mode 100644 libs/fsScan/include/FilesystemScanner.h create mode 100644 libs/fsScan/src/FSMediaScanner.cc delete mode 100644 libs/fsScan/src/File.cc delete mode 100644 libs/fsScan/src/FileRepresentation.cc delete mode 100644 libs/fsScan/src/FileSystem.cc delete mode 100644 libs/fsScan/src/FilesystemScanner.cc delete mode 100644 libs/networking/include/Url.h delete mode 100644 libs/networking/src/Url.cc create mode 100644 libs/util/Url.cc create mode 100644 libs/util/Url.h create mode 100644 libs/util/include/Persistable.h create mode 100644 libs/util/include/Url.h create mode 100644 libs/util/src/Url.cc (limited to 'libs') diff --git a/libs/IO/File.cc b/libs/IO/File.cc new file mode 100644 index 0000000..477c5c8 --- /dev/null +++ b/libs/IO/File.cc @@ -0,0 +1,181 @@ +/** + * ======================== legal notice ====================== + * + * File: File.cc + * Created: 21. Juli 2012, 12 + * Author: Geronimo + * Project: libfsScan: mediatypes and filesystem scanning + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +#include +#include +#include +#include +#include +#include + +cFileSystem *cFile::fs = NULL; +static mode_t ReadMask = S_IRUSR | S_IRGRP | S_IROTH; +static mode_t WriteMask = S_IWUSR | S_IWGRP | S_IWOTH; +static mode_t ExecMask = S_IXUSR | S_IXGRP | S_IXOTH; + + +cFile::cFile(const char *Path) + : rep(NULL) +{ + if (!fs) fs = new cFileSystem(); + if (!Path) { + Path = getcwd(NULL, 0); + rep = fs->representationOfFile(Path); + free((char *) Path); + } + else rep = fs->representationOfFile(Path); +} + +cFile::cFile(const cFile &other) + : rep(other.rep) +{ + if (!fs) fs = new cFileSystem(); +} + +cFile::cFile(const cFile& Parent, const char* RelativePath) + : rep(NULL) +{ + if (!fs) fs = new cFileSystem(); + rep = fs->representationOfFile(Parent, RelativePath); +} + +cFile::cFile(const cFileRepresentation *fr) + : rep(fr) +{ + if (!fs) fs = new cFileSystem(); +} + +cFile::~cFile() +{ +} + +cFile &cFile::operator =(const cFile &other) +{ + rep = other.rep; + return *this; +} + +const char *cFile::AbsolutePath(void) const +{ + if (rep) return rep->Path(); + return NULL; +} + +bool cFile::Exists(void) const +{ + if (rep) return rep->exists; + return false; +} + +bool cFile::IsDirectory(void) const +{ + if (rep) return (rep->mode & S_IFMT) == S_IFDIR; + return false; +} + +bool cFile::IsFile(void) const +{ + if (rep) return (rep->mode & S_IFMT) == S_IFREG; + return false; +} + +bool cFile::IsSymbolic(void) const +{ + if (rep) return (rep->mode & S_IFMT) == S_IFLNK; + return false; +} + +bool cFile::CanRead(void) const +{ + if (rep) return rep->mode & ReadMask; + return false; +} + +bool cFile::CanWrite(void) const +{ + if (rep) return rep->mode & WriteMask; + return false; +} + +bool cFile::CanExecute(void) const +{ + if (rep) return rep->mode & ExecMask; + return false; +} + +off64_t cFile::Size(void) const +{ + if (rep) return rep->size; + return 0; +} + +ulong cFile::LastModified(void) const +{ + if (rep) return rep->lastModified; + return 0; +} + +cFile *cFile::Parent(void) const +{ + if (rep) return new cFile(rep->getParent()); + return NULL; +} + +const char *cFile::Name(void) const +{ + if (rep) return rep->name; + return NULL; +} + +void cFile::Cleanup(void) +{ + if (fs) { + delete fs; + fs = NULL; + } +} + +void cFile::VisitFiles(int (*cb)(void *, cFile *, const char *), void *opaque) +{ + if (!Exists() || !IsDirectory()) return; + struct dirent entryBuffer, *pE; + DIR *dir = opendir(AbsolutePath()); + + while (!readdir_r(dir, &entryBuffer, &pE) && pE) { + if (*(pE->d_name) == '.') continue; // don't bother with hidden stuff + cb(opaque, this, pE->d_name); + } + closedir(dir); +} + +char *cFile::toURI() const +{ + if (rep) return rep->toURI(); + return NULL; +} + +void cFile::SetVirtualRoot(bool isRoot) +{ + if (rep) ((cFileRepresentation *)rep)->SetVirtualRoot(isRoot); +} diff --git a/libs/IO/File.h b/libs/IO/File.h new file mode 100644 index 0000000..587d99c --- /dev/null +++ b/libs/IO/File.h @@ -0,0 +1,67 @@ +/** + * ======================== legal notice ====================== + * + * File: File.h + * Created: 21. Juli 2012, 12 + * Author: Geronimo + * Project: libfsScan: mediatypes and filesystem scanning + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +#ifndef FILE_H +#define FILE_H + +#include +#include + +class cFileSystem; +class cFileRepresentation; +class cStringBuilder; +class cFile { +public: + cFile(const char *Path = NULL); + cFile(const cFile &other); + cFile(const cFile &Parent, const char *RelativePath); + virtual ~cFile(); + + cFile &operator =(const cFile &other); + bool CanRead(void) const; + bool CanWrite(void) const; + bool CanExecute(void) const; + bool Exists(void) const; + bool IsDirectory(void) const; + bool IsFile(void) const; + bool IsSymbolic(void) const; + off64_t Size(void) const; + ulong LastModified(void) const; + const char *Name(void) const; + void SetVirtualRoot(bool isRoot = true); + const char *AbsolutePath(void) const; ///< returns an allocated string + char *toURI(void) const; ///< returns an allocated string + cFile *Parent(void) const; ///< allocates a new file instance! + void VisitFiles(int (*cb)(void *, cFile *, const char *), void *opaque); + static void Cleanup(void); + +private: + cFile(const cFileRepresentation *); + const cFileRepresentation *rep; + static cFileSystem *fs; + friend class cFileSystem; +}; + +#endif /* FILE_H */ + diff --git a/libs/IO/FileRepresentation.cc b/libs/IO/FileRepresentation.cc new file mode 100644 index 0000000..81599a3 --- /dev/null +++ b/libs/IO/FileRepresentation.cc @@ -0,0 +1,132 @@ +/** + * ======================== legal notice ====================== + * + * File: FileRepresentation.cc + * Created: 21. Juli 2012, 12 + * Author: Geronimo + * Project: libfsScan: mediatypes and filesystem scanning + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +cFileRepresentation::cFileRepresentation(const char *Name) + : exists(false) + , isRoot(true) + , isVirtualRoot(true) + , mode(0) + , size(0) + , lastModified(0) + , name(NULL) + , path(NULL) + , parent(NULL) +{ + struct stat st; + + if (!stat(Name, &st)) { + name = strdup(Name); + exists = true; + mode = st.st_mode; + size = st.st_size; + lastModified = st.st_mtime; + } +} + +cFileRepresentation::cFileRepresentation(const cFileRepresentation *Parent, const char *Name) + : exists(false) + , isRoot(false) + , isVirtualRoot(false) + , mode(0) + , size(0) + , lastModified(0) + , name(strdup(Name)) + , path(NULL) + , parent(Parent) +{ + struct stat st; + + if (!stat(Path(), &st)) { + exists = true; + mode = st.st_mode; + size = st.st_size; + lastModified = st.st_mtime; + } +} + +cFileRepresentation::~cFileRepresentation() +{ + free(name); + free(path); +} + +const char *cFileRepresentation::Path() const +{ + if (!path) { + cStringBuilder sb; + + if (parent) sb.Append(parent->Path()); + sb.Append(cFileSystem::PathSeparator).Append(name); + path = sb.toString(); + } + return path; +} + +void cFileRepresentation::SetVirtualRoot(bool isRoot) +{ + isVirtualRoot = isRoot; +} + +char *cFileRepresentation::toURI() const +{ + cStringBuilder *sb = new cStringBuilder(); + const cFileRepresentation *f = this; + std::stack rev; + cURLEncoder *enc = cUrl::Encoder(); + char *tmp, *chk, *rv; + size_t stackSize; + + while (!f->isVirtualRoot) { + rev.push(f); + stackSize = rev.size(); + f = f->parent; + } + + for (;;) { + f = rev.top(); + rev.pop(); + chk = f->name + strlen(f->name) - 1; + if (*chk != cFileSystem::PathSeparator) sb->Append(cFileSystem::PathSeparator); + tmp = enc->Encode(f->name); + sb->Append(tmp); + free(tmp); + if (rev.empty()) break; + } + rv = sb->toString(); + delete sb; + + return rv; +} diff --git a/libs/IO/FileRepresentation.h b/libs/IO/FileRepresentation.h new file mode 100644 index 0000000..39a3c1e --- /dev/null +++ b/libs/IO/FileRepresentation.h @@ -0,0 +1,56 @@ +/** + * ======================== legal notice ====================== + * + * File: FileRepresentation.h + * Created: 21. Juli 2012, 12 + * Author: Geronimo + * Project: libfsScan: mediatypes and filesystem scanning + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +#ifndef FILEREPRESENTATION_H +#define FILEREPRESENTATION_H + +#include + +class cStringBuilder; +class cFileRepresentation { +public: + virtual ~cFileRepresentation(); + + const char *Path(void) const; + const cFileRepresentation *getParent(void) const { return parent; }; + void SetVirtualRoot(bool isRoot); + +private: + cFileRepresentation(const char *Name); + cFileRepresentation(const cFileRepresentation *Parent, const char *Name); + char *toURI(void) const; + bool exists; + bool isRoot; + bool isVirtualRoot; + mode_t mode; + off64_t size; + ulong lastModified; + char *name; + mutable char *path; + const cFileRepresentation *parent; + friend class cFileSystem; + friend class cFile; + }; + +#endif // FILEREPRESENTATION_H diff --git a/libs/IO/FileSystem.cc b/libs/IO/FileSystem.cc new file mode 100644 index 0000000..3891c97 --- /dev/null +++ b/libs/IO/FileSystem.cc @@ -0,0 +1,132 @@ +/** + * ======================== legal notice ====================== + * + * File: FileSystem.cc + * Created: 21. Juli 2012, 12 + * Author: Geronimo + * Project: libfsScan: mediatypes and filesystem scanning + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +#include +#include +#include +#include +#include +#include +#include + +char cFileSystem::PathSeparator = '/'; +char cFileSystem::RootPath[4] = { PathSeparator, 0, 0, 0 }; + +cFileSystem::cFileSystem() +{ +} + +cFileSystem::~cFileSystem() +{ + std::tr1::unordered_map::iterator it = fileCache.begin(); + + while (it != fileCache.end()) { + if (it->second) delete it->second; + ++it; + } +} + +cFileRepresentation *cFileSystem::cacheEntry(const char* Path) +{ + if (fileCache.empty()) return NULL; + std::tr1::unordered_map::iterator it = fileCache.find(Path); + + if (it != fileCache.end()) return it->second; + return NULL; +} + +cFileRepresentation *cFileSystem::representationOfFile(const cFile &Parent, const char* Path) +{ + cFileRepresentation *parentRep = (cFileRepresentation *) Parent.rep; + cFileRepresentation *tmp = NULL; + cStringBuilder *sb = new cStringBuilder(Parent.AbsolutePath()); + char *scratch = strdup(Path); + char *last = scratch + strlen(Path); + char *start = *scratch == PathSeparator ? scratch + 1 : scratch; + char *end = strchr(scratch, PathSeparator); + char *path; + + while (start < last) { + end = strchr(start, PathSeparator); + if (!end) end = start + strlen(start); + *end = 0; + sb->Append(PathSeparator).Append(start); + path = sb->toString(); + tmp = cacheEntry(path); + if (!tmp) { + tmp = new cFileRepresentation(parentRep, start); + fileCache[path] = tmp; + } + parentRep = tmp; + free(path); + start = end + 1; + } + free(scratch); + delete sb; + + if (tmp) return tmp; + return NULL; +} + +cFileRepresentation *cFileSystem::representationOfFile(const char* Path) +{ + cFileRepresentation *rv = cacheEntry(Path); + + if (!rv) { + cFileRepresentation *tmp = NULL; + char *scratch = strdup(Path); + char *p; + + for (p = strrchr(scratch, PathSeparator); !rv && p; p = strrchr(scratch, PathSeparator)) { + if (p > scratch) *p = 0; + else { + if (!(rv = cacheEntry(RootPath))) { + *p = 0; + tmp = new cFileRepresentation(RootPath); + fileCache[RootPath] = tmp; + break; + } + } + if ((tmp = cacheEntry(scratch))) break; + } + + if (tmp) { + cFileRepresentation *parent = tmp; + size_t poolSize = fileCache.size(); + const char *last = scratch + strlen(Path); + + for (p = scratch + strlen(scratch) + 1; p < last; p += strlen(p) + 1) { + if (!*(p - 1)) *(p - 1) = PathSeparator; + tmp = new cFileRepresentation(parent, p); + fileCache[scratch] = tmp; + poolSize = fileCache.size(); + parent = tmp; + } + rv = parent; + } + free(scratch); + } + return rv; +} + diff --git a/libs/IO/FileSystem.h b/libs/IO/FileSystem.h new file mode 100644 index 0000000..0cf4a2f --- /dev/null +++ b/libs/IO/FileSystem.h @@ -0,0 +1,50 @@ +/** + * ======================== legal notice ====================== + * + * File: FileSystem.h + * Created: 21. Juli 2012, 12 + * Author: Geronimo + * Project: libfsScan: mediatypes and filesystem scanning + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +#ifndef FILESYSTEM_H +#define FILESYSTEM_H + +#include +#include + +class cFile; +class cFileRepresentation; +class cFileSystem { +public: + cFileSystem(); + virtual ~cFileSystem(); + + cFileRepresentation *representationOfFile(const char *Path); + cFileRepresentation *representationOfFile(const cFile &Parent, const char *Path); + +private: + cFileRepresentation *cacheEntry(const char *Path); + std::tr1::unordered_map fileCache; + static char PathSeparator; + static char RootPath[4]; + friend class cFileRepresentation; + }; + +#endif /* FILESYSTEM_H */ + diff --git a/libs/IO/IO.cbp b/libs/IO/IO.cbp new file mode 100644 index 0000000..36f087a --- /dev/null +++ b/libs/IO/IO.cbp @@ -0,0 +1,70 @@ + + + + + + diff --git a/libs/IO/IO.cbp.save b/libs/IO/IO.cbp.save new file mode 100644 index 0000000..52f0fe6 --- /dev/null +++ b/libs/IO/IO.cbp.save @@ -0,0 +1,68 @@ + + + + + + diff --git a/libs/IO/IO.depend b/libs/IO/IO.depend new file mode 100644 index 0000000..c4ac310 --- /dev/null +++ b/libs/IO/IO.depend @@ -0,0 +1 @@ +# depslib dependency file v1.0 diff --git a/libs/IO/IO.layout b/libs/IO/IO.layout new file mode 100644 index 0000000..f0b6b2a --- /dev/null +++ b/libs/IO/IO.layout @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/IO/IO.layout.save b/libs/IO/IO.layout.save new file mode 100644 index 0000000..e837daf --- /dev/null +++ b/libs/IO/IO.layout.save @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/IO/Makefile b/libs/IO/Makefile new file mode 100644 index 0000000..ec9de69 --- /dev/null +++ b/libs/IO/Makefile @@ -0,0 +1,128 @@ +# +# There exist several targets which are by default empty and which can be +# used for execution of your targets. These targets are usually executed +# before and after some main targets. They are: +# +# .build-pre: called before 'build' target +# .build-post: called after 'build' target +# .clean-pre: called before 'clean' target +# .clean-post: called after 'clean' target +# .clobber-pre: called before 'clobber' target +# .clobber-post: called after 'clobber' target +# .all-pre: called before 'all' target +# .all-post: called after 'all' target +# .help-pre: called before 'help' target +# .help-post: called after 'help' target +# +# Targets beginning with '.' are not intended to be called on their own. +# +# Main targets can be executed directly, and they are: +# +# build build a specific configuration +# clean remove built files from a configuration +# clobber remove all built files +# all build all configurations +# help print help mesage +# +# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and +# .help-impl are implemented in nbproject/makefile-impl.mk. +# +# Available make variables: +# +# CND_BASEDIR base directory for relative paths +# CND_DISTDIR default top distribution directory (build artifacts) +# CND_BUILDDIR default top build directory (object files, ...) +# CONF name of current configuration +# CND_PLATFORM_${CONF} platform name (current configuration) +# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) +# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) +# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) +# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) +# CND_PACKAGE_NAME_${CONF} name of package (current configuration) +# CND_PACKAGE_PATH_${CONF} path to package (current configuration) +# +# NOCDDL + + +# Environment +MKDIR=mkdir +CP=cp +CCADMIN=CCadmin + + +# build +build: .build-post + +.build-pre: +# Add your pre 'build' code here... + +.build-post: .build-impl +# Add your post 'build' code here... + + +# clean +clean: .clean-post + +.clean-pre: +# Add your pre 'clean' code here... + +.clean-post: .clean-impl +# Add your post 'clean' code here... + + +# clobber +clobber: .clobber-post + +.clobber-pre: +# Add your pre 'clobber' code here... + +.clobber-post: .clobber-impl +# Add your post 'clobber' code here... + + +# all +all: .all-post + +.all-pre: +# Add your pre 'all' code here... + +.all-post: .all-impl +# Add your post 'all' code here... + + +# build tests +build-tests: .build-tests-post + +.build-tests-pre: +# Add your pre 'build-tests' code here... + +.build-tests-post: .build-tests-impl +# Add your post 'build-tests' code here... + + +# run tests +test: .test-post + +.test-pre: +# Add your pre 'test' code here... + +.test-post: .test-impl +# Add your post 'test' code here... + + +# help +help: .help-post + +.help-pre: +# Add your pre 'help' code here... + +.help-post: .help-impl +# Add your post 'help' code here... + + + +# include project implementation makefile +include nbproject/Makefile-impl.mk + +# include project make variables +include nbproject/Makefile-variables.mk diff --git a/libs/IO/nbproject/Makefile-Debug.mk b/libs/IO/nbproject/Makefile-Debug.mk new file mode 100644 index 0000000..0fa73d7 --- /dev/null +++ b/libs/IO/nbproject/Makefile-Debug.mk @@ -0,0 +1,120 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a -pre and a -post target defined where you can add customized code. +# +# This makefile implements configuration specific macros and targets. + + +# Environment +MKDIR=mkdir +CP=cp +GREP=grep +NM=nm +CCADMIN=CCadmin +RANLIB=ranlib +CC=gcc +CCC=g++ +CXX=g++ +FC=gfortran +AS=as + +# Macros +CND_PLATFORM=GNU-Linux-x86 +CND_DLIB_EXT=so +CND_CONF=Debug +CND_DISTDIR=dist +CND_BUILDDIR=build + +# Include project Makefile +include Makefile + +# Object Directory +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} + +# Object Files +OBJECTFILES= \ + ${OBJECTDIR}/src/FileRepresentation.o \ + ${OBJECTDIR}/src/LineReader.o \ + ${OBJECTDIR}/src/File.o \ + ${OBJECTDIR}/src/ConfigReader.o \ + ${OBJECTDIR}/src/FileReader.o \ + ${OBJECTDIR}/src/FileSystem.o + + +# C Compiler Flags +CFLAGS= + +# CC Compiler Flags +CCFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration +CXXFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration + +# Fortran Compiler Flags +FFLAGS= + +# Assembler Flags +ASFLAGS= + +# Link Libraries and Options +LDLIBSOPTIONS= + +# Build Targets +.build-conf: ${BUILD_SUBPROJECTS} + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a + +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a: ${OBJECTFILES} + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} + ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a + ${AR} -rv ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a ${OBJECTFILES} + $(RANLIB) ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a + +${OBJECTDIR}/src/FileRepresentation.o: src/FileRepresentation.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileRepresentation.o src/FileRepresentation.cc + +${OBJECTDIR}/src/LineReader.o: src/LineReader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/LineReader.o src/LineReader.cc + +${OBJECTDIR}/src/File.o: src/File.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/File.o src/File.cc + +${OBJECTDIR}/src/ConfigReader.o: src/ConfigReader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ConfigReader.o src/ConfigReader.cc + +${OBJECTDIR}/src/FileReader.o: src/FileReader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileReader.o src/FileReader.cc + +${OBJECTDIR}/src/FileSystem.o: src/FileSystem.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileSystem.o src/FileSystem.cc + +# Subprojects +.build-subprojects: + cd ../vdr && ${MAKE} -f Makefile CONF=Debug + cd ../util && ${MAKE} -f Makefile CONF=Debug + +# Clean Targets +.clean-conf: ${CLEAN_SUBPROJECTS} + ${RM} -r ${CND_BUILDDIR}/${CND_CONF} + ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a + +# Subprojects +.clean-subprojects: + cd ../vdr && ${MAKE} -f Makefile CONF=Debug clean + cd ../util && ${MAKE} -f Makefile CONF=Debug clean + +# Enable dependency checking +.dep.inc: .depcheck-impl + +include .dep.inc diff --git a/libs/IO/nbproject/Makefile-Release.mk b/libs/IO/nbproject/Makefile-Release.mk new file mode 100644 index 0000000..853a053 --- /dev/null +++ b/libs/IO/nbproject/Makefile-Release.mk @@ -0,0 +1,116 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a -pre and a -post target defined where you can add customized code. +# +# This makefile implements configuration specific macros and targets. + + +# Environment +MKDIR=mkdir +CP=cp +GREP=grep +NM=nm +CCADMIN=CCadmin +RANLIB=ranlib +CC=gcc +CCC=g++ +CXX=g++ +FC=gfortran +AS=as + +# Macros +CND_PLATFORM=GNU-Linux-x86 +CND_DLIB_EXT=so +CND_CONF=Release +CND_DISTDIR=dist +CND_BUILDDIR=build + +# Include project Makefile +include Makefile + +# Object Directory +OBJECTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM} + +# Object Files +OBJECTFILES= \ + ${OBJECTDIR}/src/FileRepresentation.o \ + ${OBJECTDIR}/src/LineReader.o \ + ${OBJECTDIR}/src/File.o \ + ${OBJECTDIR}/src/ConfigReader.o \ + ${OBJECTDIR}/src/FileReader.o \ + ${OBJECTDIR}/src/FileSystem.o + + +# C Compiler Flags +CFLAGS= + +# CC Compiler Flags +CCFLAGS= +CXXFLAGS= + +# Fortran Compiler Flags +FFLAGS= + +# Assembler Flags +ASFLAGS= + +# Link Libraries and Options +LDLIBSOPTIONS= + +# Build Targets +.build-conf: ${BUILD_SUBPROJECTS} + "${MAKE}" -f nbproject/Makefile-${CND_CONF}.mk ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a + +${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a: ${OBJECTFILES} + ${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM} + ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a + ${AR} -rv ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a ${OBJECTFILES} + $(RANLIB) ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a + +${OBJECTDIR}/src/FileRepresentation.o: src/FileRepresentation.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileRepresentation.o src/FileRepresentation.cc + +${OBJECTDIR}/src/LineReader.o: src/LineReader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/LineReader.o src/LineReader.cc + +${OBJECTDIR}/src/File.o: src/File.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/File.o src/File.cc + +${OBJECTDIR}/src/ConfigReader.o: src/ConfigReader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ConfigReader.o src/ConfigReader.cc + +${OBJECTDIR}/src/FileReader.o: src/FileReader.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileReader.o src/FileReader.cc + +${OBJECTDIR}/src/FileSystem.o: src/FileSystem.cc + ${MKDIR} -p ${OBJECTDIR}/src + ${RM} $@.d + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileSystem.o src/FileSystem.cc + +# Subprojects +.build-subprojects: + +# Clean Targets +.clean-conf: ${CLEAN_SUBPROJECTS} + ${RM} -r ${CND_BUILDDIR}/${CND_CONF} + ${RM} ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a + +# Subprojects +.clean-subprojects: + +# Enable dependency checking +.dep.inc: .depcheck-impl + +include .dep.inc diff --git a/libs/IO/nbproject/Makefile-impl.mk b/libs/IO/nbproject/Makefile-impl.mk new file mode 100644 index 0000000..41a3b3c --- /dev/null +++ b/libs/IO/nbproject/Makefile-impl.mk @@ -0,0 +1,133 @@ +# +# Generated Makefile - do not edit! +# +# Edit the Makefile in the project folder instead (../Makefile). Each target +# has a pre- and a post- target defined where you can add customization code. +# +# This makefile implements macros and targets common to all configurations. +# +# NOCDDL + + +# Building and Cleaning subprojects are done by default, but can be controlled with the SUB +# macro. If SUB=no, subprojects will not be built or cleaned. The following macro +# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf +# and .clean-reqprojects-conf unless SUB has the value 'no' +SUB_no=NO +SUBPROJECTS=${SUB_${SUB}} +BUILD_SUBPROJECTS_=.build-subprojects +BUILD_SUBPROJECTS_NO= +BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}} +CLEAN_SUBPROJECTS_=.clean-subprojects +CLEAN_SUBPROJECTS_NO= +CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}} + + +# Project Name +PROJECTNAME=IO + +# Active Configuration +DEFAULTCONF=Debug +CONF=${DEFAULTCONF} + +# All Configurations +ALLCONFS=Debug Release + + +# build +.build-impl: .build-pre .validate-impl .depcheck-impl + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf + + +# clean +.clean-impl: .clean-pre .validate-impl .depcheck-impl + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf + + +# clobber +.clobber-impl: .clobber-pre .depcheck-impl + @#echo "=> Running $@..." + for CONF in ${ALLCONFS}; \ + do \ + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \ + done + +# all +.all-impl: .all-pre .depcheck-impl + @#echo "=> Running $@..." + for CONF in ${ALLCONFS}; \ + do \ + "${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \ + done + +# build tests +.build-tests-impl: .build-impl .build-tests-pre + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf + +# run tests +.test-impl: .build-tests-impl .test-pre + @#echo "=> Running $@... Configuration=$(CONF)" + "${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf + +# dependency checking support +.depcheck-impl: + @echo "# This code depends on make tool being used" >.dep.inc + @if [ -n "${MAKE_VERSION}" ]; then \ + echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \ + echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \ + echo "include \$${DEPFILES}" >>.dep.inc; \ + echo "endif" >>.dep.inc; \ + else \ + echo ".KEEP_STATE:" >>.dep.inc; \ + echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \ + fi + +# configuration validation +.validate-impl: + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ + then \ + echo ""; \ + echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \ + echo "See 'make help' for details."; \ + echo "Current directory: " `pwd`; \ + echo ""; \ + fi + @if [ ! -f nbproject/Makefile-${CONF}.mk ]; \ + then \ + exit 1; \ + fi + + +# help +.help-impl: .help-pre + @echo "This makefile supports the following configurations:" + @echo " ${ALLCONFS}" + @echo "" + @echo "and the following targets:" + @echo " build (default target)" + @echo " clean" + @echo " clobber" + @echo " all" + @echo " help" + @echo "" + @echo "Makefile Usage:" + @echo " make [CONF=] [SUB=no] build" + @echo " make [CONF=] [SUB=no] clean" + @echo " make [SUB=no] clobber" + @echo " make [SUB=no] all" + @echo " make help" + @echo "" + @echo "Target 'build' will build a specific configuration and, unless 'SUB=no'," + @echo " also build subprojects." + @echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no'," + @echo " also clean subprojects." + @echo "Target 'clobber' will remove all built files from all configurations and," + @echo " unless 'SUB=no', also from subprojects." + @echo "Target 'all' will will build all configurations and, unless 'SUB=no'," + @echo " also build subprojects." + @echo "Target 'help' prints this message." + @echo "" + diff --git a/libs/IO/nbproject/Makefile-variables.mk b/libs/IO/nbproject/Makefile-variables.mk new file mode 100644 index 0000000..56d45ff --- /dev/null +++ b/libs/IO/nbproject/Makefile-variables.mk @@ -0,0 +1,35 @@ +# +# Generated - do not edit! +# +# NOCDDL +# +CND_BASEDIR=`pwd` +CND_BUILDDIR=build +CND_DISTDIR=dist +# Debug configuration +CND_PLATFORM_Debug=GNU-Linux-x86 +CND_ARTIFACT_DIR_Debug=dist/Debug/GNU-Linux-x86 +CND_ARTIFACT_NAME_Debug=libio.a +CND_ARTIFACT_PATH_Debug=dist/Debug/GNU-Linux-x86/libio.a +CND_PACKAGE_DIR_Debug=dist/Debug/GNU-Linux-x86/package +CND_PACKAGE_NAME_Debug=IO.tar +CND_PACKAGE_PATH_Debug=dist/Debug/GNU-Linux-x86/package/IO.tar +# Release configuration +CND_PLATFORM_Release=GNU-Linux-x86 +CND_ARTIFACT_DIR_Release=dist/Release/GNU-Linux-x86 +CND_ARTIFACT_NAME_Release=libio.a +CND_ARTIFACT_PATH_Release=dist/Release/GNU-Linux-x86/libio.a +CND_PACKAGE_DIR_Release=dist/Release/GNU-Linux-x86/package +CND_PACKAGE_NAME_Release=IO.tar +CND_PACKAGE_PATH_Release=dist/Release/GNU-Linux-x86/package/IO.tar +# +# include compiler specific variables +# +# dmake command +ROOT:sh = test -f nbproject/private/Makefile-variables.mk || \ + (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk) +# +# gmake command +.PHONY: $(shell test -f nbproject/private/Makefile-variables.mk || (mkdir -p nbproject/private && touch nbproject/private/Makefile-variables.mk)) +# +include nbproject/private/Makefile-variables.mk diff --git a/libs/IO/nbproject/Package-Debug.bash b/libs/IO/nbproject/Package-Debug.bash new file mode 100644 index 0000000..d2cdb5c --- /dev/null +++ b/libs/IO/nbproject/Package-Debug.bash @@ -0,0 +1,75 @@ +#!/bin/bash -x + +# +# Generated - do not edit! +# + +# Macros +TOP=`pwd` +CND_PLATFORM=GNU-Linux-x86 +CND_CONF=Debug +CND_DISTDIR=dist +CND_BUILDDIR=build +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging +TMPDIRNAME=tmp-packaging +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a +OUTPUT_BASENAME=libio.a +PACKAGE_TOP_DIR=IO/ + +# Functions +function checkReturnCode +{ + rc=$? + if [ $rc != 0 ] + then + exit $rc + fi +} +function makeDirectory +# $1 directory path +# $2 permission (optional) +{ + mkdir -p "$1" + checkReturnCode + if [ "$2" != "" ] + then + chmod $2 "$1" + checkReturnCode + fi +} +function copyFileToTmpDir +# $1 from-file path +# $2 to-file path +# $3 permission +{ + cp "$1" "$2" + checkReturnCode + if [ "$3" != "" ] + then + chmod $3 "$2" + checkReturnCode + fi +} + +# Setup +cd "${TOP}" +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package +rm -rf ${NBTMPDIR} +mkdir -p ${NBTMPDIR} + +# Copy files and create directories and links +cd "${TOP}" +makeDirectory "${NBTMPDIR}/IO/lib" +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 + + +# Generate tar file +cd "${TOP}" +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/IO.tar +cd ${NBTMPDIR} +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/IO.tar * +checkReturnCode + +# Cleanup +cd "${TOP}" +rm -rf ${NBTMPDIR} diff --git a/libs/IO/nbproject/Package-Release.bash b/libs/IO/nbproject/Package-Release.bash new file mode 100644 index 0000000..13f19f5 --- /dev/null +++ b/libs/IO/nbproject/Package-Release.bash @@ -0,0 +1,75 @@ +#!/bin/bash -x + +# +# Generated - do not edit! +# + +# Macros +TOP=`pwd` +CND_PLATFORM=GNU-Linux-x86 +CND_CONF=Release +CND_DISTDIR=dist +CND_BUILDDIR=build +NBTMPDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tmp-packaging +TMPDIRNAME=tmp-packaging +OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a +OUTPUT_BASENAME=libio.a +PACKAGE_TOP_DIR=IO/ + +# Functions +function checkReturnCode +{ + rc=$? + if [ $rc != 0 ] + then + exit $rc + fi +} +function makeDirectory +# $1 directory path +# $2 permission (optional) +{ + mkdir -p "$1" + checkReturnCode + if [ "$2" != "" ] + then + chmod $2 "$1" + checkReturnCode + fi +} +function copyFileToTmpDir +# $1 from-file path +# $2 to-file path +# $3 permission +{ + cp "$1" "$2" + checkReturnCode + if [ "$3" != "" ] + then + chmod $3 "$2" + checkReturnCode + fi +} + +# Setup +cd "${TOP}" +mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package +rm -rf ${NBTMPDIR} +mkdir -p ${NBTMPDIR} + +# Copy files and create directories and links +cd "${TOP}" +makeDirectory "${NBTMPDIR}/IO/lib" +copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}lib/${OUTPUT_BASENAME}" 0644 + + +# Generate tar file +cd "${TOP}" +rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/IO.tar +cd ${NBTMPDIR} +tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/IO.tar * +checkReturnCode + +# Cleanup +cd "${TOP}" +rm -rf ${NBTMPDIR} diff --git a/libs/IO/nbproject/configurations.xml b/libs/IO/nbproject/configurations.xml new file mode 100644 index 0000000..7cc1823 --- /dev/null +++ b/libs/IO/nbproject/configurations.xml @@ -0,0 +1,116 @@ + + + + + include/ConfigReader.h + include/File.h + include/FileReader.h + include/FileRepresentation.h + include/FileSystem.h + include/LineReader.h + + + + + src/ConfigReader.cc + src/File.cc + src/FileReader.cc + src/FileRepresentation.cc + src/FileSystem.cc + src/LineReader.cc + + + + + Makefile + + + Makefile + + + + LOCAL_SOURCES + default + + + + + include + ../util/include + ../vdr/include + + -std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration + + _FILE_OFFSET_BITS=64 + _GNU_SOURCE=1 + _LARGEFILE64_SOURCE + _LARGEFILE_SOURCE + _REENTRANT + __STDC_CONSTANT_MACROS + __STDC_FORMAT_MACROS + __STDC_LIMIT_MACROS + + 2 + + + + + + + + + + + + + + LOCAL_SOURCES + default + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + + diff --git a/libs/IO/nbproject/private/Makefile-variables.mk b/libs/IO/nbproject/private/Makefile-variables.mk new file mode 100644 index 0000000..a64183e --- /dev/null +++ b/libs/IO/nbproject/private/Makefile-variables.mk @@ -0,0 +1,7 @@ +# +# Generated - do not edit! +# +# NOCDDL +# +# Debug configuration +# Release configuration diff --git a/libs/IO/nbproject/private/configurations.xml b/libs/IO/nbproject/private/configurations.xml new file mode 100644 index 0000000..616cc91 --- /dev/null +++ b/libs/IO/nbproject/private/configurations.xml @@ -0,0 +1,72 @@ + + + Makefile + + + + localhost + 2 + + + + + + + + + + + + + + + gdb + + + + "${OUTPUT_PATH}" + + "${OUTPUT_PATH}" + + true + 0 + 0 + + + + + + + localhost + 2 + + + + + + + + + + + + + + + gdb + + + + "${OUTPUT_PATH}" + + "${OUTPUT_PATH}" + + true + 0 + 0 + + + + + + diff --git a/libs/IO/nbproject/private/private.xml b/libs/IO/nbproject/private/private.xml new file mode 100644 index 0000000..3ef29a3 --- /dev/null +++ b/libs/IO/nbproject/private/private.xml @@ -0,0 +1,8 @@ + + + + 3 + 0 + + + diff --git a/libs/IO/nbproject/project.xml b/libs/IO/nbproject/project.xml new file mode 100644 index 0000000..e083e62 --- /dev/null +++ b/libs/IO/nbproject/project.xml @@ -0,0 +1,28 @@ + + + org.netbeans.modules.cnd.makeproject + + + IO + + cc + h + UTF-8 + + ../vdr + ../util + + + + + Debug + 3 + + + Release + 3 + + + + + diff --git a/libs/IO/summary.txt b/libs/IO/summary.txt new file mode 100644 index 0000000..543fe28 --- /dev/null +++ b/libs/IO/summary.txt @@ -0,0 +1 @@ +libIO: classes for files, filesystem and input/output diff --git a/libs/fsScan/fsScan.cbp b/libs/fsScan/fsScan.cbp index 8f51f56..21a5de4 100644 --- a/libs/fsScan/fsScan.cbp +++ b/libs/fsScan/fsScan.cbp @@ -35,11 +35,12 @@ - + + @@ -47,10 +48,7 @@ - - - - + @@ -60,10 +58,7 @@ - - - - + diff --git a/libs/fsScan/fsScan.layout b/libs/fsScan/fsScan.layout index 2fdf779..2db2bda 100644 --- a/libs/fsScan/fsScan.layout +++ b/libs/fsScan/fsScan.layout @@ -1,39 +1,24 @@ - - - - - - - - - - - - - - - - + - + - + - + - + - + @@ -41,24 +26,9 @@ - - - - - - - - - - - - - - - - + - + diff --git a/libs/fsScan/fsScan.layout.save b/libs/fsScan/fsScan.layout.save index 6134cfb..2db2bda 100644 --- a/libs/fsScan/fsScan.layout.save +++ b/libs/fsScan/fsScan.layout.save @@ -6,29 +6,19 @@ - - - - - - + - + - - - - - - + - + - + - + @@ -36,29 +26,9 @@ - - - - - - - - - - - - - - - - - - - - - + - + diff --git a/libs/fsScan/include/AbstractMedia.h b/libs/fsScan/include/AbstractMedia.h index 750ffde..8c87dd5 100644 --- a/libs/fsScan/include/AbstractMedia.h +++ b/libs/fsScan/include/AbstractMedia.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: AbstractMedia.h * Created: 2. Juli 2012, 14 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef ABSTRACTMEDIA_H @@ -56,6 +56,7 @@ public: ulong LastModified(void) const; const char *LogicalPath(void) const { return logicalPath; } virtual const char *Name(void) const; + virtual bool NeedsFurtherScan(void) const; virtual size_t Size(void) const; virtual const char *URI(void) const { return uri; } virtual void Refresh(void); diff --git a/libs/fsScan/include/AbstractMultiFileMovie.h b/libs/fsScan/include/AbstractMultiFileMovie.h index aed75b9..6913a74 100644 --- a/libs/fsScan/include/AbstractMultiFileMovie.h +++ b/libs/fsScan/include/AbstractMultiFileMovie.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: AbstractMultiFileMovie.h * Created: 3. Juli 2012, 07 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef ABSTRACTMULTIFILEMOVIE_H diff --git a/libs/fsScan/include/Audio.h b/libs/fsScan/include/Audio.h index 44472ef..42611c2 100644 --- a/libs/fsScan/include/Audio.h +++ b/libs/fsScan/include/Audio.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: Audio.h * Created: 2. Juli 2012, 15 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef AUDIO_H @@ -32,6 +32,8 @@ public: cAudio(const cFile &File, const char *Mime); virtual ~cAudio(); + virtual bool NeedsFurtherScan(void) const; + private: static const char *ContentType(const char *Extension); static SupportedExtension knownExtensions[]; diff --git a/libs/fsScan/include/DVDImage.h b/libs/fsScan/include/DVDImage.h index 1a657ff..5845d77 100644 --- a/libs/fsScan/include/DVDImage.h +++ b/libs/fsScan/include/DVDImage.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: DVDImage.h * Created: 3. Juli 2012, 08 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef DVDIMAGE_H diff --git a/libs/fsScan/include/FSMediaScanner.h b/libs/fsScan/include/FSMediaScanner.h new file mode 100644 index 0000000..1c85b46 --- /dev/null +++ b/libs/fsScan/include/FSMediaScanner.h @@ -0,0 +1,52 @@ +/** + * ======================== legal notice ====================== + * + * File: FSMediaScanner.h + * Created: 2. Juli 2012, 13 + * Author: Geronimo + * Project: libfsScan: mediatypes and filesystem scanning + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +#ifndef FSMEDIASCANNER_H +#define FSMEDIASCANNER_H + +#include +#include +#include + +class cAbstractMedia; +class cFSMediaScanner { +public: + cFSMediaScanner(); + virtual ~cFSMediaScanner(); + + cManagedVector &MediaPool(void) { return pool; } + std::map &Categories(void) { return categories; } + cAbstractMedia *FindMedia(const char *LogicalPath); + void Refresh(void); + void SetMediaFactory(cMediaFactory *factory); + +private: + size_t fileBufSize; + cManagedVector pool; + std::map categories; + cMediaFactory *mediaFactory; + }; + +#endif /* FSMEDIASCANNER_H */ + diff --git a/libs/fsScan/include/File.h b/libs/fsScan/include/File.h deleted file mode 100644 index 587d99c..0000000 --- a/libs/fsScan/include/File.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: File.h - * Created: 21. Juli 2012, 12 - * Author: Geronimo - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#ifndef FILE_H -#define FILE_H - -#include -#include - -class cFileSystem; -class cFileRepresentation; -class cStringBuilder; -class cFile { -public: - cFile(const char *Path = NULL); - cFile(const cFile &other); - cFile(const cFile &Parent, const char *RelativePath); - virtual ~cFile(); - - cFile &operator =(const cFile &other); - bool CanRead(void) const; - bool CanWrite(void) const; - bool CanExecute(void) const; - bool Exists(void) const; - bool IsDirectory(void) const; - bool IsFile(void) const; - bool IsSymbolic(void) const; - off64_t Size(void) const; - ulong LastModified(void) const; - const char *Name(void) const; - void SetVirtualRoot(bool isRoot = true); - const char *AbsolutePath(void) const; ///< returns an allocated string - char *toURI(void) const; ///< returns an allocated string - cFile *Parent(void) const; ///< allocates a new file instance! - void VisitFiles(int (*cb)(void *, cFile *, const char *), void *opaque); - static void Cleanup(void); - -private: - cFile(const cFileRepresentation *); - const cFileRepresentation *rep; - static cFileSystem *fs; - friend class cFileSystem; -}; - -#endif /* FILE_H */ - diff --git a/libs/fsScan/include/FileRepresentation.h b/libs/fsScan/include/FileRepresentation.h deleted file mode 100644 index 39a3c1e..0000000 --- a/libs/fsScan/include/FileRepresentation.h +++ /dev/null @@ -1,56 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: FileRepresentation.h - * Created: 21. Juli 2012, 12 - * Author: Geronimo - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#ifndef FILEREPRESENTATION_H -#define FILEREPRESENTATION_H - -#include - -class cStringBuilder; -class cFileRepresentation { -public: - virtual ~cFileRepresentation(); - - const char *Path(void) const; - const cFileRepresentation *getParent(void) const { return parent; }; - void SetVirtualRoot(bool isRoot); - -private: - cFileRepresentation(const char *Name); - cFileRepresentation(const cFileRepresentation *Parent, const char *Name); - char *toURI(void) const; - bool exists; - bool isRoot; - bool isVirtualRoot; - mode_t mode; - off64_t size; - ulong lastModified; - char *name; - mutable char *path; - const cFileRepresentation *parent; - friend class cFileSystem; - friend class cFile; - }; - -#endif // FILEREPRESENTATION_H diff --git a/libs/fsScan/include/FileSystem.h b/libs/fsScan/include/FileSystem.h deleted file mode 100644 index 0cf4a2f..0000000 --- a/libs/fsScan/include/FileSystem.h +++ /dev/null @@ -1,50 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: FileSystem.h - * Created: 21. Juli 2012, 12 - * Author: Geronimo - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#ifndef FILESYSTEM_H -#define FILESYSTEM_H - -#include -#include - -class cFile; -class cFileRepresentation; -class cFileSystem { -public: - cFileSystem(); - virtual ~cFileSystem(); - - cFileRepresentation *representationOfFile(const char *Path); - cFileRepresentation *representationOfFile(const cFile &Parent, const char *Path); - -private: - cFileRepresentation *cacheEntry(const char *Path); - std::tr1::unordered_map fileCache; - static char PathSeparator; - static char RootPath[4]; - friend class cFileRepresentation; - }; - -#endif /* FILESYSTEM_H */ - diff --git a/libs/fsScan/include/FilesystemScanner.h b/libs/fsScan/include/FilesystemScanner.h deleted file mode 100644 index 51cd44e..0000000 --- a/libs/fsScan/include/FilesystemScanner.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: FilesystemScanner.h - * Created: 2. Juli 2012, 13 - * Author: Geronimo - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#ifndef FILESYSTEMSCANNER_H -#define FILESYSTEMSCANNER_H - -#include -#include -#include - -class cAbstractMedia; -class cFilesystemScanner { -public: - cFilesystemScanner(); - virtual ~cFilesystemScanner(); - - cManagedVector &MediaPool(void) { return pool; } - std::map &Categories(void) { return categories; } - cAbstractMedia *FindMedia(const char *LogicalPath); - void Refresh(void); - void SetMediaFactory(cMediaFactory *factory); - -private: - size_t fileBufSize; - cManagedVector pool; - std::map categories; - cMediaFactory *mediaFactory; - }; - -#endif /* FILESYSTEMSCANNER_H */ - diff --git a/libs/fsScan/include/LegacyVdrRecording.h b/libs/fsScan/include/LegacyVdrRecording.h index d60902a..cc46348 100644 --- a/libs/fsScan/include/LegacyVdrRecording.h +++ b/libs/fsScan/include/LegacyVdrRecording.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: LegacyVdrRecording.h * Created: 3. Juli 2012, 08 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef LEGACYVDRRECORDING_H diff --git a/libs/fsScan/include/MediaFactory.h b/libs/fsScan/include/MediaFactory.h index 200335b..2ddcaa5 100644 --- a/libs/fsScan/include/MediaFactory.h +++ b/libs/fsScan/include/MediaFactory.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: MediaFactory.h * Created: 2. Juli 2012, 15 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef MEDIAFACTORY_H @@ -32,9 +32,10 @@ class cAbstractMedia; class cFile; class cManagedVector; +class cServerConfig; class cMediaFactory { public: - cMediaFactory(const cFile &BaseDirectory); + cMediaFactory(const cServerConfig &config); virtual ~cMediaFactory(); cAbstractMedia *CreateMedia(const cFile &FileOrDirectory); @@ -43,8 +44,12 @@ public: void SetBaseDirectory(const cFile &dir); private: + void Scan4MetaData(cAbstractMedia *media); + int CreateMedia(const cFile *Parent, const char *Name); static int createMedia(void *opaque, cFile *Parent, const char *Name); + const cServerConfig &config; cFile baseDirectory; + cManagedVector *mediaPool; char *scratch; size_t scratchSize; }; diff --git a/libs/fsScan/include/Movie.h b/libs/fsScan/include/Movie.h index ecb62ec..5a4f60d 100644 --- a/libs/fsScan/include/Movie.h +++ b/libs/fsScan/include/Movie.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: Movie.h * Created: 2. Juli 2012, 15 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef MOVIE_H @@ -32,6 +32,8 @@ public: cMovie(const cFile &File, const char *Mime, SupportedMediaType Type = cAbstractMedia::Movie); virtual ~cMovie(); + virtual bool NeedsFurtherScan(void) const; + private: static const char *ContentType(const char *Extension); static SupportedExtension knownExtensions[]; diff --git a/libs/fsScan/include/Picture.h b/libs/fsScan/include/Picture.h index 3e9a079..669509b 100644 --- a/libs/fsScan/include/Picture.h +++ b/libs/fsScan/include/Picture.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: Picture.h * Created: 2. Juli 2012, 15 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef PICTURE_H diff --git a/libs/fsScan/include/VdrRecording.h b/libs/fsScan/include/VdrRecording.h index 9b92c61..a8ec292 100644 --- a/libs/fsScan/include/VdrRecording.h +++ b/libs/fsScan/include/VdrRecording.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: VdrRecording.h * Created: 3. Juli 2012, 08 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef VDRRECORDING_H diff --git a/libs/fsScan/nbproject/Makefile-Debug.mk b/libs/fsScan/nbproject/Makefile-Debug.mk index 316d5a4..1e0062b 100644 --- a/libs/fsScan/nbproject/Makefile-Debug.mk +++ b/libs/fsScan/nbproject/Makefile-Debug.mk @@ -41,10 +41,7 @@ OBJECTFILES= \ ${OBJECTDIR}/src/VdrRecording.o \ ${OBJECTDIR}/src/MediaFactory.o \ ${OBJECTDIR}/src/LegacyVdrRecording.o \ - ${OBJECTDIR}/src/FileRepresentation.o \ - ${OBJECTDIR}/src/File.o \ - ${OBJECTDIR}/src/FilesystemScanner.o \ - ${OBJECTDIR}/src/FileSystem.o \ + ${OBJECTDIR}/src/FSMediaScanner.o \ ${OBJECTDIR}/src/AbstractMultiFileMovie.o \ ${OBJECTDIR}/src/AbstractMedia.o \ ${OBJECTDIR}/src/Movie.o @@ -54,8 +51,8 @@ OBJECTFILES= \ CFLAGS= # CC Compiler Flags -CCFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -ansi -CXXFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -ansi +CCFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration +CXXFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration # Fortran Compiler Flags FFLAGS= @@ -79,70 +76,59 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libfsscan.a: ${OBJECTFILES} ${OBJECTDIR}/src/Picture.o: src/Picture.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Picture.o src/Picture.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Picture.o src/Picture.cc ${OBJECTDIR}/src/Audio.o: src/Audio.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Audio.o src/Audio.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Audio.o src/Audio.cc ${OBJECTDIR}/src/DVDImage.o: src/DVDImage.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/DVDImage.o src/DVDImage.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/DVDImage.o src/DVDImage.cc ${OBJECTDIR}/src/VdrRecording.o: src/VdrRecording.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/VdrRecording.o src/VdrRecording.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/VdrRecording.o src/VdrRecording.cc ${OBJECTDIR}/src/MediaFactory.o: src/MediaFactory.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/MediaFactory.o src/MediaFactory.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/MediaFactory.o src/MediaFactory.cc ${OBJECTDIR}/src/LegacyVdrRecording.o: src/LegacyVdrRecording.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/LegacyVdrRecording.o src/LegacyVdrRecording.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/LegacyVdrRecording.o src/LegacyVdrRecording.cc -${OBJECTDIR}/src/FileRepresentation.o: src/FileRepresentation.cc +${OBJECTDIR}/src/FSMediaScanner.o: src/FSMediaScanner.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileRepresentation.o src/FileRepresentation.cc - -${OBJECTDIR}/src/File.o: src/File.cc - ${MKDIR} -p ${OBJECTDIR}/src - ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/File.o src/File.cc - -${OBJECTDIR}/src/FilesystemScanner.o: src/FilesystemScanner.cc - ${MKDIR} -p ${OBJECTDIR}/src - ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FilesystemScanner.o src/FilesystemScanner.cc - -${OBJECTDIR}/src/FileSystem.o: src/FileSystem.cc - ${MKDIR} -p ${OBJECTDIR}/src - ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileSystem.o src/FileSystem.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FSMediaScanner.o src/FSMediaScanner.cc ${OBJECTDIR}/src/AbstractMultiFileMovie.o: src/AbstractMultiFileMovie.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractMultiFileMovie.o src/AbstractMultiFileMovie.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractMultiFileMovie.o src/AbstractMultiFileMovie.cc ${OBJECTDIR}/src/AbstractMedia.o: src/AbstractMedia.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractMedia.o src/AbstractMedia.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractMedia.o src/AbstractMedia.cc ${OBJECTDIR}/src/Movie.o: src/Movie.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Movie.o src/Movie.cc + $(COMPILE.cc) -g -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_REENTRANT -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iinclude -I../networking/include -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Movie.o src/Movie.cc # Subprojects .build-subprojects: + cd ../vdr && ${MAKE} -f Makefile CONF=Debug + cd ../util && ${MAKE} -f Makefile CONF=Debug + cd ../networking && ${MAKE} -f Makefile CONF=Debug + cd ../IO && ${MAKE} -f Makefile CONF=Debug # Clean Targets .clean-conf: ${CLEAN_SUBPROJECTS} @@ -151,6 +137,10 @@ ${OBJECTDIR}/src/Movie.o: src/Movie.cc # Subprojects .clean-subprojects: + cd ../vdr && ${MAKE} -f Makefile CONF=Debug clean + cd ../util && ${MAKE} -f Makefile CONF=Debug clean + cd ../networking && ${MAKE} -f Makefile CONF=Debug clean + cd ../IO && ${MAKE} -f Makefile CONF=Debug clean # Enable dependency checking .dep.inc: .depcheck-impl diff --git a/libs/fsScan/nbproject/Makefile-Release.mk b/libs/fsScan/nbproject/Makefile-Release.mk index 072cdf0..bc8c6a9 100644 --- a/libs/fsScan/nbproject/Makefile-Release.mk +++ b/libs/fsScan/nbproject/Makefile-Release.mk @@ -41,10 +41,7 @@ OBJECTFILES= \ ${OBJECTDIR}/src/VdrRecording.o \ ${OBJECTDIR}/src/MediaFactory.o \ ${OBJECTDIR}/src/LegacyVdrRecording.o \ - ${OBJECTDIR}/src/FileRepresentation.o \ - ${OBJECTDIR}/src/File.o \ - ${OBJECTDIR}/src/FilesystemScanner.o \ - ${OBJECTDIR}/src/FileSystem.o \ + ${OBJECTDIR}/src/FSMediaScanner.o \ ${OBJECTDIR}/src/AbstractMultiFileMovie.o \ ${OBJECTDIR}/src/AbstractMedia.o \ ${OBJECTDIR}/src/Movie.o @@ -106,25 +103,10 @@ ${OBJECTDIR}/src/LegacyVdrRecording.o: src/LegacyVdrRecording.cc ${RM} $@.d $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/LegacyVdrRecording.o src/LegacyVdrRecording.cc -${OBJECTDIR}/src/FileRepresentation.o: src/FileRepresentation.cc +${OBJECTDIR}/src/FSMediaScanner.o: src/FSMediaScanner.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileRepresentation.o src/FileRepresentation.cc - -${OBJECTDIR}/src/File.o: src/File.cc - ${MKDIR} -p ${OBJECTDIR}/src - ${RM} $@.d - $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/File.o src/File.cc - -${OBJECTDIR}/src/FilesystemScanner.o: src/FilesystemScanner.cc - ${MKDIR} -p ${OBJECTDIR}/src - ${RM} $@.d - $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FilesystemScanner.o src/FilesystemScanner.cc - -${OBJECTDIR}/src/FileSystem.o: src/FileSystem.cc - ${MKDIR} -p ${OBJECTDIR}/src - ${RM} $@.d - $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FileSystem.o src/FileSystem.cc + $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/FSMediaScanner.o src/FSMediaScanner.cc ${OBJECTDIR}/src/AbstractMultiFileMovie.o: src/AbstractMultiFileMovie.cc ${MKDIR} -p ${OBJECTDIR}/src diff --git a/libs/fsScan/nbproject/configurations.xml b/libs/fsScan/nbproject/configurations.xml index ca6b34a..9984a4c 100644 --- a/libs/fsScan/nbproject/configurations.xml +++ b/libs/fsScan/nbproject/configurations.xml @@ -8,10 +8,7 @@ include/AbstractMultiFileMovie.h include/Audio.h include/DVDImage.h - include/File.h - include/FileRepresentation.h - include/FileSystem.h - include/FilesystemScanner.h + include/FSMediaScanner.h include/LegacyVdrRecording.h include/MediaFactory.h include/Movie.h @@ -29,10 +26,7 @@ src/AbstractMultiFileMovie.cc src/Audio.cc src/DVDImage.cc - src/File.cc - src/FileRepresentation.cc - src/FileSystem.cc - src/FilesystemScanner.cc + src/FSMediaScanner.cc src/LegacyVdrRecording.cc src/MediaFactory.cc src/Movie.cc @@ -64,10 +58,11 @@ include ../networking/include + ../IO/include ../util/include ../vdr/include - -std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -ansi + -std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration _FILE_OFFSET_BITS=64 _GNU_SOURCE=1 @@ -82,6 +77,48 @@ + + + + + + + + + + diff --git a/libs/fsScan/nbproject/project.xml b/libs/fsScan/nbproject/project.xml index a104f65..f749866 100644 --- a/libs/fsScan/nbproject/project.xml +++ b/libs/fsScan/nbproject/project.xml @@ -8,7 +8,12 @@ cc h UTF-8 - + + ../IO + ../vdr + ../util + ../networking + diff --git a/libs/fsScan/src/AbstractMedia.cc b/libs/fsScan/src/AbstractMedia.cc index 27ad751..924f01a 100644 --- a/libs/fsScan/src/AbstractMedia.cc +++ b/libs/fsScan/src/AbstractMedia.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: AbstractMedia.cc * Created: 2. Juli 2012, 14 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include @@ -112,6 +112,11 @@ const char *cAbstractMedia::MediaType2Text(int Type) } } +bool cAbstractMedia::NeedsFurtherScan(void) const +{ + return false; +} + const char *cAbstractMedia::AbsolutePath(void) const { return keyPath.AbsolutePath(); diff --git a/libs/fsScan/src/AbstractMultiFileMovie.cc b/libs/fsScan/src/AbstractMultiFileMovie.cc index d20da87..f679511 100644 --- a/libs/fsScan/src/AbstractMultiFileMovie.cc +++ b/libs/fsScan/src/AbstractMultiFileMovie.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: AbstractMultiFileMovie.cc * Created: 3. Juli 2012, 07 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include diff --git a/libs/fsScan/src/Audio.cc b/libs/fsScan/src/Audio.cc index 8933c36..6c90fbc 100644 --- a/libs/fsScan/src/Audio.cc +++ b/libs/fsScan/src/Audio.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: Audio.cc * Created: 2. Juli 2012, 15 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include @@ -40,7 +40,7 @@ SupportedExtension cAudio::knownExtensions[] = { { "mp3", "audio/mpeg" }, { "mp4", "audio/x-mpeg4" }, { "m4a", "audio/x-m4" }, - { "mpg", "audio/mpeg" }, +// { "mpg", "audio/mpeg" }, { "mpp", "audio/x-musepack" }, { "ram", "audio/x-realaudio" }, { NULL, NULL } @@ -63,3 +63,8 @@ const char *cAudio::ContentType(const char* Extension) return NULL; } +bool cAudio::NeedsFurtherScan(void) const +{ +//TODO: common meta data: artist, title + return true; +} diff --git a/libs/fsScan/src/DVDImage.cc b/libs/fsScan/src/DVDImage.cc index 8c789b4..0d23ae1 100644 --- a/libs/fsScan/src/DVDImage.cc +++ b/libs/fsScan/src/DVDImage.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: DVDImage.cc * Created: 3. Juli 2012, 08 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include diff --git a/libs/fsScan/src/FSMediaScanner.cc b/libs/fsScan/src/FSMediaScanner.cc new file mode 100644 index 0000000..f4ac14e --- /dev/null +++ b/libs/fsScan/src/FSMediaScanner.cc @@ -0,0 +1,111 @@ +/** + * ======================== legal notice ====================== + * + * File: FSMediaScanner.cc + * Created: 2. Juli 2012, 13 + * Author: Geronimo + * Project: libfsScan: mediatypes and filesystem scanning + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void freeMediaCallback(void *elem) +{ + delete (cAbstractMedia *)elem; +} + +cFSMediaScanner::cFSMediaScanner() + : fileBufSize(512) + , pool(freeMediaCallback) + , mediaFactory(NULL) +{ +} + +cFSMediaScanner::~cFSMediaScanner() +{ + pool.clear(); + if (mediaFactory) delete mediaFactory; +} + +void cFSMediaScanner::SetMediaFactory(cMediaFactory* factory) +{ + mediaFactory = factory; +} + +// return true if "a" should be ordered before "b" +bool defaultMediaSortOrder(void *a, void *b) +{ + if (a == b) return false; + if (!a) return false; + if (!b) return true; + cAbstractMedia *m0 = (cAbstractMedia *)a; + cAbstractMedia *m1 = (cAbstractMedia *)b; + bool rv = false; + + if (m0->MediaType() == m1->MediaType()) + rv = strcasecmp(m0->Name(), m1->Name()) < 0; + else + rv = (m0->MediaType() - m1->MediaType()) < 0; + + return rv; +} + +void cFSMediaScanner::Refresh() +{ + if (!mediaFactory) return; + pool.clear(); + categories.clear(); + + mediaFactory->Scan4Media(pool); + cAbstractMedia::SupportedMediaType ot = cAbstractMedia::Invalid; + cAbstractMedia *m; + + pool.sort(defaultMediaSortOrder); + for (size_t i=0; i < pool.size(); ++i) { + m = (cAbstractMedia *) pool[i]; + if (m->MediaType() != ot) { + ot = m->MediaType(); + categories[ot] = i; + } + } +} + +cAbstractMedia *cFSMediaScanner::FindMedia(const char *Path) +{ + cAbstractMedia *rv = NULL, *tmp; + + for (size_t i=0; i < pool.size(); ++i) { + tmp = (cAbstractMedia *) pool[i]; + if (!strcmp(tmp->LogicalPath(), Path)) { + rv = tmp; + break; + } + } + return rv; +} diff --git a/libs/fsScan/src/File.cc b/libs/fsScan/src/File.cc deleted file mode 100644 index 477c5c8..0000000 --- a/libs/fsScan/src/File.cc +++ /dev/null @@ -1,181 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: File.cc - * Created: 21. Juli 2012, 12 - * Author: Geronimo - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#include -#include -#include -#include -#include -#include - -cFileSystem *cFile::fs = NULL; -static mode_t ReadMask = S_IRUSR | S_IRGRP | S_IROTH; -static mode_t WriteMask = S_IWUSR | S_IWGRP | S_IWOTH; -static mode_t ExecMask = S_IXUSR | S_IXGRP | S_IXOTH; - - -cFile::cFile(const char *Path) - : rep(NULL) -{ - if (!fs) fs = new cFileSystem(); - if (!Path) { - Path = getcwd(NULL, 0); - rep = fs->representationOfFile(Path); - free((char *) Path); - } - else rep = fs->representationOfFile(Path); -} - -cFile::cFile(const cFile &other) - : rep(other.rep) -{ - if (!fs) fs = new cFileSystem(); -} - -cFile::cFile(const cFile& Parent, const char* RelativePath) - : rep(NULL) -{ - if (!fs) fs = new cFileSystem(); - rep = fs->representationOfFile(Parent, RelativePath); -} - -cFile::cFile(const cFileRepresentation *fr) - : rep(fr) -{ - if (!fs) fs = new cFileSystem(); -} - -cFile::~cFile() -{ -} - -cFile &cFile::operator =(const cFile &other) -{ - rep = other.rep; - return *this; -} - -const char *cFile::AbsolutePath(void) const -{ - if (rep) return rep->Path(); - return NULL; -} - -bool cFile::Exists(void) const -{ - if (rep) return rep->exists; - return false; -} - -bool cFile::IsDirectory(void) const -{ - if (rep) return (rep->mode & S_IFMT) == S_IFDIR; - return false; -} - -bool cFile::IsFile(void) const -{ - if (rep) return (rep->mode & S_IFMT) == S_IFREG; - return false; -} - -bool cFile::IsSymbolic(void) const -{ - if (rep) return (rep->mode & S_IFMT) == S_IFLNK; - return false; -} - -bool cFile::CanRead(void) const -{ - if (rep) return rep->mode & ReadMask; - return false; -} - -bool cFile::CanWrite(void) const -{ - if (rep) return rep->mode & WriteMask; - return false; -} - -bool cFile::CanExecute(void) const -{ - if (rep) return rep->mode & ExecMask; - return false; -} - -off64_t cFile::Size(void) const -{ - if (rep) return rep->size; - return 0; -} - -ulong cFile::LastModified(void) const -{ - if (rep) return rep->lastModified; - return 0; -} - -cFile *cFile::Parent(void) const -{ - if (rep) return new cFile(rep->getParent()); - return NULL; -} - -const char *cFile::Name(void) const -{ - if (rep) return rep->name; - return NULL; -} - -void cFile::Cleanup(void) -{ - if (fs) { - delete fs; - fs = NULL; - } -} - -void cFile::VisitFiles(int (*cb)(void *, cFile *, const char *), void *opaque) -{ - if (!Exists() || !IsDirectory()) return; - struct dirent entryBuffer, *pE; - DIR *dir = opendir(AbsolutePath()); - - while (!readdir_r(dir, &entryBuffer, &pE) && pE) { - if (*(pE->d_name) == '.') continue; // don't bother with hidden stuff - cb(opaque, this, pE->d_name); - } - closedir(dir); -} - -char *cFile::toURI() const -{ - if (rep) return rep->toURI(); - return NULL; -} - -void cFile::SetVirtualRoot(bool isRoot) -{ - if (rep) ((cFileRepresentation *)rep)->SetVirtualRoot(isRoot); -} diff --git a/libs/fsScan/src/FileRepresentation.cc b/libs/fsScan/src/FileRepresentation.cc deleted file mode 100644 index 81599a3..0000000 --- a/libs/fsScan/src/FileRepresentation.cc +++ /dev/null @@ -1,132 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: FileRepresentation.cc - * Created: 21. Juli 2012, 12 - * Author: Geronimo - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -cFileRepresentation::cFileRepresentation(const char *Name) - : exists(false) - , isRoot(true) - , isVirtualRoot(true) - , mode(0) - , size(0) - , lastModified(0) - , name(NULL) - , path(NULL) - , parent(NULL) -{ - struct stat st; - - if (!stat(Name, &st)) { - name = strdup(Name); - exists = true; - mode = st.st_mode; - size = st.st_size; - lastModified = st.st_mtime; - } -} - -cFileRepresentation::cFileRepresentation(const cFileRepresentation *Parent, const char *Name) - : exists(false) - , isRoot(false) - , isVirtualRoot(false) - , mode(0) - , size(0) - , lastModified(0) - , name(strdup(Name)) - , path(NULL) - , parent(Parent) -{ - struct stat st; - - if (!stat(Path(), &st)) { - exists = true; - mode = st.st_mode; - size = st.st_size; - lastModified = st.st_mtime; - } -} - -cFileRepresentation::~cFileRepresentation() -{ - free(name); - free(path); -} - -const char *cFileRepresentation::Path() const -{ - if (!path) { - cStringBuilder sb; - - if (parent) sb.Append(parent->Path()); - sb.Append(cFileSystem::PathSeparator).Append(name); - path = sb.toString(); - } - return path; -} - -void cFileRepresentation::SetVirtualRoot(bool isRoot) -{ - isVirtualRoot = isRoot; -} - -char *cFileRepresentation::toURI() const -{ - cStringBuilder *sb = new cStringBuilder(); - const cFileRepresentation *f = this; - std::stack rev; - cURLEncoder *enc = cUrl::Encoder(); - char *tmp, *chk, *rv; - size_t stackSize; - - while (!f->isVirtualRoot) { - rev.push(f); - stackSize = rev.size(); - f = f->parent; - } - - for (;;) { - f = rev.top(); - rev.pop(); - chk = f->name + strlen(f->name) - 1; - if (*chk != cFileSystem::PathSeparator) sb->Append(cFileSystem::PathSeparator); - tmp = enc->Encode(f->name); - sb->Append(tmp); - free(tmp); - if (rev.empty()) break; - } - rv = sb->toString(); - delete sb; - - return rv; -} diff --git a/libs/fsScan/src/FileSystem.cc b/libs/fsScan/src/FileSystem.cc deleted file mode 100644 index 3891c97..0000000 --- a/libs/fsScan/src/FileSystem.cc +++ /dev/null @@ -1,132 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: FileSystem.cc - * Created: 21. Juli 2012, 12 - * Author: Geronimo - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#include -#include -#include -#include -#include -#include -#include - -char cFileSystem::PathSeparator = '/'; -char cFileSystem::RootPath[4] = { PathSeparator, 0, 0, 0 }; - -cFileSystem::cFileSystem() -{ -} - -cFileSystem::~cFileSystem() -{ - std::tr1::unordered_map::iterator it = fileCache.begin(); - - while (it != fileCache.end()) { - if (it->second) delete it->second; - ++it; - } -} - -cFileRepresentation *cFileSystem::cacheEntry(const char* Path) -{ - if (fileCache.empty()) return NULL; - std::tr1::unordered_map::iterator it = fileCache.find(Path); - - if (it != fileCache.end()) return it->second; - return NULL; -} - -cFileRepresentation *cFileSystem::representationOfFile(const cFile &Parent, const char* Path) -{ - cFileRepresentation *parentRep = (cFileRepresentation *) Parent.rep; - cFileRepresentation *tmp = NULL; - cStringBuilder *sb = new cStringBuilder(Parent.AbsolutePath()); - char *scratch = strdup(Path); - char *last = scratch + strlen(Path); - char *start = *scratch == PathSeparator ? scratch + 1 : scratch; - char *end = strchr(scratch, PathSeparator); - char *path; - - while (start < last) { - end = strchr(start, PathSeparator); - if (!end) end = start + strlen(start); - *end = 0; - sb->Append(PathSeparator).Append(start); - path = sb->toString(); - tmp = cacheEntry(path); - if (!tmp) { - tmp = new cFileRepresentation(parentRep, start); - fileCache[path] = tmp; - } - parentRep = tmp; - free(path); - start = end + 1; - } - free(scratch); - delete sb; - - if (tmp) return tmp; - return NULL; -} - -cFileRepresentation *cFileSystem::representationOfFile(const char* Path) -{ - cFileRepresentation *rv = cacheEntry(Path); - - if (!rv) { - cFileRepresentation *tmp = NULL; - char *scratch = strdup(Path); - char *p; - - for (p = strrchr(scratch, PathSeparator); !rv && p; p = strrchr(scratch, PathSeparator)) { - if (p > scratch) *p = 0; - else { - if (!(rv = cacheEntry(RootPath))) { - *p = 0; - tmp = new cFileRepresentation(RootPath); - fileCache[RootPath] = tmp; - break; - } - } - if ((tmp = cacheEntry(scratch))) break; - } - - if (tmp) { - cFileRepresentation *parent = tmp; - size_t poolSize = fileCache.size(); - const char *last = scratch + strlen(Path); - - for (p = scratch + strlen(scratch) + 1; p < last; p += strlen(p) + 1) { - if (!*(p - 1)) *(p - 1) = PathSeparator; - tmp = new cFileRepresentation(parent, p); - fileCache[scratch] = tmp; - poolSize = fileCache.size(); - parent = tmp; - } - rv = parent; - } - free(scratch); - } - return rv; -} - diff --git a/libs/fsScan/src/FilesystemScanner.cc b/libs/fsScan/src/FilesystemScanner.cc deleted file mode 100644 index cbe4b95..0000000 --- a/libs/fsScan/src/FilesystemScanner.cc +++ /dev/null @@ -1,111 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: FilesystemScanner.cc - * Created: 2. Juli 2012, 13 - * Author: Geronimo - * Project: libfsScan: mediatypes and filesystem scanning - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void freeMediaCallback(void *elem) -{ - delete (cAbstractMedia *)elem; -} - -cFilesystemScanner::cFilesystemScanner() - : fileBufSize(512) - , pool(freeMediaCallback) - , mediaFactory(NULL) -{ -} - -cFilesystemScanner::~cFilesystemScanner() -{ - pool.clear(); - if (mediaFactory) delete mediaFactory; -} - -void cFilesystemScanner::SetMediaFactory(cMediaFactory* factory) -{ - mediaFactory = factory; -} - -// return true if "a" should be ordered before "b" -bool defaultMediaSortOrder(void *a, void *b) -{ - if (a == b) return false; - if (!a) return false; - if (!b) return true; - cAbstractMedia *m0 = (cAbstractMedia *)a; - cAbstractMedia *m1 = (cAbstractMedia *)b; - bool rv = false; - - if (m0->MediaType() == m1->MediaType()) - rv = strcasecmp(m0->Name(), m1->Name()) < 0; - else - rv = (m0->MediaType() - m1->MediaType()) < 0; - - return rv; -} - -void cFilesystemScanner::Refresh() -{ - if (!mediaFactory) return; - pool.clear(); - categories.clear(); - - mediaFactory->Scan4Media(pool); - cAbstractMedia::SupportedMediaType ot = cAbstractMedia::Invalid; - cAbstractMedia *m; - - pool.sort(defaultMediaSortOrder); - for (size_t i=0; i < pool.size(); ++i) { - m = (cAbstractMedia *) pool[i]; - if (m->MediaType() != ot) { - ot = m->MediaType(); - categories[ot] = i; - } - } -} - -cAbstractMedia *cFilesystemScanner::FindMedia(const char *Path) -{ - cAbstractMedia *rv = NULL, *tmp; - - for (size_t i=0; i < pool.size(); ++i) { - tmp = (cAbstractMedia *) pool[i]; - if (!strcmp(tmp->LogicalPath(), Path)) { - rv = tmp; - break; - } - } - return rv; -} diff --git a/libs/fsScan/src/LegacyVdrRecording.cc b/libs/fsScan/src/LegacyVdrRecording.cc index 731d0f3..5ee635c 100644 --- a/libs/fsScan/src/LegacyVdrRecording.cc +++ b/libs/fsScan/src/LegacyVdrRecording.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: LegacyVdrRecording.cc * Created: 3. Juli 2012, 08 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include diff --git a/libs/fsScan/src/MediaFactory.cc b/libs/fsScan/src/MediaFactory.cc index 22b9044..4dec763 100644 --- a/libs/fsScan/src/MediaFactory.cc +++ b/libs/fsScan/src/MediaFactory.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: MediaFactory.cc * Created: 2. Juli 2012, 15 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -36,8 +37,9 @@ #include #include -cMediaFactory::cMediaFactory(const cFile &BaseDirectory) - : baseDirectory(BaseDirectory) +cMediaFactory::cMediaFactory(const cServerConfig &sc) + : config(sc) + , baseDirectory(sc.DocumentRoot()) , scratch(NULL) , scratchSize(1024) { @@ -61,7 +63,14 @@ void cMediaFactory::SetBaseDirectory(const cFile &dir) int cMediaFactory::createMedia(void *opaque, cFile *Parent, const char *Name) { if (!opaque) return -1; - cManagedVector *pool = (cManagedVector *) opaque; + cMediaFactory *mf = (cMediaFactory *) opaque; + + return mf->CreateMedia(Parent, Name); +} + +int cMediaFactory::CreateMedia(const cFile *Parent, const char *Name) +{ +// cManagedVector *pool = (cManagedVector *) opaque; cFile *curFile = new cFile(*Parent, Name); const char *mimeType = NULL; cAbstractMedia *rv = NULL; @@ -93,7 +102,7 @@ int cMediaFactory::createMedia(void *opaque, cFile *Parent, const char *Name) } delete tmp; } - if (!rv) curFile->VisitFiles(createMedia, opaque); + if (!rv) curFile->VisitFiles(createMedia, this); } else { const char *extension = strrchr(Name, '.'); @@ -117,7 +126,8 @@ int cMediaFactory::createMedia(void *opaque, cFile *Parent, const char *Name) } delete curFile; if (rv) { - pool->push_back(rv); + if (config.WantExtendedScan() && rv->NeedsFurtherScan()) Scan4MetaData(rv); + mediaPool->push_back(rv); return 0; } return -1; @@ -128,5 +138,11 @@ void cMediaFactory::Scan4Media(cManagedVector& pool) if (!baseDirectory.Exists() || !baseDirectory.IsDirectory()) return; baseDirectory.SetVirtualRoot(); - baseDirectory.VisitFiles(createMedia, &pool); + mediaPool = &pool; + baseDirectory.VisitFiles(createMedia, this); +} + +void cMediaFactory::Scan4MetaData(cAbstractMedia* media) +{ + //TODO: } diff --git a/libs/fsScan/src/Movie.cc b/libs/fsScan/src/Movie.cc index 759ff3d..a63ff19 100644 --- a/libs/fsScan/src/Movie.cc +++ b/libs/fsScan/src/Movie.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: Movie.cc * Created: 2. Juli 2012, 15 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include @@ -37,6 +37,7 @@ SupportedExtension cMovie::knownExtensions[] = { { "ogv", "video/ogg" }, { "mkv", "video/x-matroska" }, { "mov", "video/quicktime" }, + { "mpg", "video/mpeg" }, { "mpeg", "video/mpeg" }, { "swf", "application/x-shockwave-flash" }, { NULL, NULL } @@ -59,3 +60,8 @@ const char *cMovie::ContentType(const char* Extension) return NULL; } +bool cMovie::NeedsFurtherScan(void) const +{ +//TODO: common meta data: width, height, interlaced + return true; +} diff --git a/libs/fsScan/src/Picture.cc b/libs/fsScan/src/Picture.cc index 566c44c..19a02a1 100644 --- a/libs/fsScan/src/Picture.cc +++ b/libs/fsScan/src/Picture.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: Picture.cc * Created: 2. Juli 2012, 15 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include diff --git a/libs/fsScan/src/VdrRecording.cc b/libs/fsScan/src/VdrRecording.cc index 4fb61fa..03abccf 100644 --- a/libs/fsScan/src/VdrRecording.cc +++ b/libs/fsScan/src/VdrRecording.cc @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: VdrRecording.cc * Created: 3. Juli 2012, 08 * Author: Geronimo * Project: libfsScan: mediatypes and filesystem scanning - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #include diff --git a/libs/networking/include/Credentials.h b/libs/networking/include/Credentials.h index cdc7903..44dc17c 100644 --- a/libs/networking/include/Credentials.h +++ b/libs/networking/include/Credentials.h @@ -26,10 +26,11 @@ #define CREDENTIALS_H #include +#include #include #include -class cCredentials { +class cCredentials : public cPersistable { public: typedef std::tr1::unordered_map::const_iterator const_iterator; cCredentials(); @@ -39,8 +40,8 @@ public: const char *ApplicationRealm(void) const; void SetApplicationRealm(const char *ApplicationRealm = "knownUser@myApp"); - int Load(const char *FileName); - int Store(const char *FileName); + virtual int Load(const char *FileName); + virtual int Store(const char *FileName); void Put(const char *Key, cPrincipal *p); cPrincipal *Get(const char *Key); diff --git a/libs/networking/include/HTTPResponse.h b/libs/networking/include/HTTPResponse.h index dbc0969..0bb6d72 100644 --- a/libs/networking/include/HTTPResponse.h +++ b/libs/networking/include/HTTPResponse.h @@ -1,25 +1,25 @@ /** * ======================== legal notice ====================== - * + * * File: HTTPResponse.h * Created: 4. Juli 2012, 06 * Author: Geronimo * Project: libnetworking: classes for tcp/ip sockets and http-protocol handling - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef HTTPRESPONSE_H diff --git a/libs/networking/include/ServerConfig.h b/libs/networking/include/ServerConfig.h index 0f9efec..88789cb 100644 --- a/libs/networking/include/ServerConfig.h +++ b/libs/networking/include/ServerConfig.h @@ -1,57 +1,73 @@ /** * ======================== legal notice ====================== - * + * * File: ServerConfig.h * Created: 8. Juli 2012, 06 * Author: Geronimo * Project: libnetworking: classes for tcp/ip sockets and http-protocol handling - * + * * CMP - compound media player - * + * * is a client/server mediaplayer intended to play any media from any workstation * without the need to export or mount shares. cmps is an easy to use backend * with a (ready to use) HTML-interface. Additionally the backend supports * authentication via HTTP-digest authorization. * cmpc is a client with vdr-like osd-menues. - * + * * Copyright (c) 2012 Reinhard Mantey, some rights reserved! * published under Creative Commons by-sa * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * + * * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * + * * -------------------------------------------------------------- */ #ifndef SERVERCONFIG_H #define SERVERCONFIG_H +#include #include #include -class cServerConfig -{ +class cServerConfig : public cPersistable { public: - cServerConfig(int Port); + cServerConfig(const char *ConfigBaseDir); virtual ~cServerConfig(); bool AuthorizationRequired(void) { return authorizationRequired; } const char *AppIconPath(void) const { return appIconPath; } const char *DocumentRoot(void) const { return documentRoot; } - + bool WantExtendedScan(void) const { return wantExtendedScan; } + const char *CredentialsFile(void) const { return credentialsFile; } + const char *MediaInfo(void) const { return mediaInfo; } + const char *FFMpeg(void) const { return ffmpeg; } + void Dump(void); + virtual int Load(const char *FileName); + virtual int Store(const char *FileName); void SetAppIcon(const char *AppIcon); void SetAuthorizationRequired(bool Authorize) { authorizationRequired = Authorize; } + void SetConfigBaseDir(const char *ConfigBaseDir); + void SetCredentialsFile(const char *FileName); void SetDocumentRoot(const char *DocumentRoot); + void SetMediaInfo(const char *MediaInfo); + void SetFFMpeg(const char *FFMpeg); void SetPort(int port); + void SetWantExtendedScan(bool wantScan) { wantExtendedScan = wantScan; } private: cServerSocket server; cAuthorizations authorizations; bool authorizationRequired; + bool wantExtendedScan; + char *configBaseDir; + char *credentialsFile; char *documentRoot; char *appIconPath; + char *mediaInfo; + char *ffmpeg; friend class cHTTPServer; friend class cConnectionHandler; -}; + }; #endif /* SERVERCONFIG_H */ diff --git a/libs/networking/include/Url.h b/libs/networking/include/Url.h deleted file mode 100644 index f4dc1af..0000000 --- a/libs/networking/include/Url.h +++ /dev/null @@ -1,67 +0,0 @@ -/** - * ======================== legal notice ====================== - * - * File: Url.h - * Created: 4. Juli 2012, 05 - * Author: Geronimo - * Project: libnetworking: classes for tcp/ip sockets and http-protocol handling - * - * CMP - compound media player - * - * is a client/server mediaplayer intended to play any media from any workstation - * without the need to export or mount shares. cmps is an easy to use backend - * with a (ready to use) HTML-interface. Additionally the backend supports - * authentication via HTTP-digest authorization. - * cmpc is a client with vdr-like osd-menues. - * - * Copyright (c) 2012 Reinhard Mantey, some rights reserved! - * published under Creative Commons by-sa - * For details see http://creativecommons.org/licenses/by-sa/3.0/ - * - * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp - * - * -------------------------------------------------------------- - */ -#ifndef URL_H -#define URL_H - -#include -#include -#include -class cURLEncoder; -class cURLDecoder; - -class cUrl { -///< splits an url into machine readable parts: -///< from top-level sight, an url consists of url and querystring. Looking bit closer, -///< the url consists of toplevel and path, where as the querystring is a list of -///< name/value tuples with value being an optional part. -public: - cUrl(const char *RawURL); - virtual ~cUrl(); - const char *Parameter(const char *Name); - void SetParameter(const char* Name, const char* Value = NULL); - size_t EstimatedSize(void) const; ///< is a rough guess about the size of the final encoded url - void ParseURL(const char *URL); - char *ToString(void) const; ///< writes the url to a newly allocated buffer - int WriteBuf(char *buf, size_t bufSize) const; ///< writes the url to preexisting buffer - ///< returns the characters written. -1 as return value indicates a buffer overrun. - const char * Path() const { return path; } -#ifdef DEBUG - void Dump(void); -#endif - static void Cleanup(void); - static cURLEncoder *Encoder(void); - static cURLDecoder *Decoder(void); - -protected: - void ParseQueryString(const char *QueryString); - -private: - typedef std::tr1::unordered_map ParameterMap; - char *path; - ParameterMap parameters; - }; - -#endif /* URL_H */ - diff --git a/libs/networking/nbproject/Makefile-Debug.mk b/libs/networking/nbproject/Makefile-Debug.mk index e971c9e..8c52867 100644 --- a/libs/networking/nbproject/Makefile-Debug.mk +++ b/libs/networking/nbproject/Makefile-Debug.mk @@ -38,7 +38,6 @@ OBJECTFILES= \ ${OBJECTDIR}/src/HTTPRequest.o \ ${OBJECTDIR}/src/ServerSocket.o \ ${OBJECTDIR}/src/HTTPAuthorizationRequest.o \ - ${OBJECTDIR}/src/Url.o \ ${OBJECTDIR}/src/Principal.o \ ${OBJECTDIR}/src/Authorization.o \ ${OBJECTDIR}/src/ServerConfig.o \ @@ -60,8 +59,8 @@ OBJECTFILES= \ CFLAGS= # CC Compiler Flags -CCFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -ansi -CXXFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -ansi +CCFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration +CXXFLAGS=-std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration # Fortran Compiler Flags FFLAGS= @@ -85,100 +84,97 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libnetworking.a: ${OBJECTFILES} ${OBJECTDIR}/src/HTTPRequest.o: src/HTTPRequest.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPRequest.o src/HTTPRequest.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPRequest.o src/HTTPRequest.cc ${OBJECTDIR}/src/ServerSocket.o: src/ServerSocket.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ServerSocket.o src/ServerSocket.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ServerSocket.o src/ServerSocket.cc ${OBJECTDIR}/src/HTTPAuthorizationRequest.o: src/HTTPAuthorizationRequest.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPAuthorizationRequest.o src/HTTPAuthorizationRequest.cc - -${OBJECTDIR}/src/Url.o: src/Url.cc - ${MKDIR} -p ${OBJECTDIR}/src - ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Url.o src/Url.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPAuthorizationRequest.o src/HTTPAuthorizationRequest.cc ${OBJECTDIR}/src/Principal.o: src/Principal.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Principal.o src/Principal.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Principal.o src/Principal.cc ${OBJECTDIR}/src/Authorization.o: src/Authorization.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Authorization.o src/Authorization.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Authorization.o src/Authorization.cc ${OBJECTDIR}/src/ServerConfig.o: src/ServerConfig.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ServerConfig.o src/ServerConfig.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ServerConfig.o src/ServerConfig.cc ${OBJECTDIR}/src/HTTPServer.o: src/HTTPServer.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPServer.o src/HTTPServer.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPServer.o src/HTTPServer.cc ${OBJECTDIR}/src/ConnectionPoint.o: src/ConnectionPoint.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ConnectionPoint.o src/ConnectionPoint.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ConnectionPoint.o src/ConnectionPoint.cc ${OBJECTDIR}/src/HTTPResponse.o: src/HTTPResponse.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPResponse.o src/HTTPResponse.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPResponse.o src/HTTPResponse.cc ${OBJECTDIR}/src/ConnectionHandler.o: src/ConnectionHandler.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ConnectionHandler.o src/ConnectionHandler.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ConnectionHandler.o src/ConnectionHandler.cc ${OBJECTDIR}/src/Credentials.o: src/Credentials.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Credentials.o src/Credentials.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Credentials.o src/Credentials.cc ${OBJECTDIR}/src/HTTPRequestHandler.o: src/HTTPRequestHandler.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPRequestHandler.o src/HTTPRequestHandler.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPRequestHandler.o src/HTTPRequestHandler.cc ${OBJECTDIR}/src/HTTPMessage.o: src/HTTPMessage.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPMessage.o src/HTTPMessage.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPMessage.o src/HTTPMessage.cc ${OBJECTDIR}/src/HTTPFileResponse.o: src/HTTPFileResponse.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPFileResponse.o src/HTTPFileResponse.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPFileResponse.o src/HTTPFileResponse.cc ${OBJECTDIR}/src/HTTPParser.o: src/HTTPParser.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPParser.o src/HTTPParser.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPParser.o src/HTTPParser.cc ${OBJECTDIR}/src/ClientSocket.o: src/ClientSocket.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ClientSocket.o src/ClientSocket.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/ClientSocket.o src/ClientSocket.cc ${OBJECTDIR}/src/AbstractSocket.o: src/AbstractSocket.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractSocket.o src/AbstractSocket.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/AbstractSocket.o src/AbstractSocket.cc ${OBJECTDIR}/src/HTTPStatus.o: src/HTTPStatus.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d - $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPStatus.o src/HTTPStatus.cc + $(COMPILE.cc) -g -Wall -D_GNU_SOURCE=1 -D_REENTRANT -Iinclude -I../IO/include -I../util/include -I../vdr/include -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPStatus.o src/HTTPStatus.cc # Subprojects .build-subprojects: + cd ../vdr && ${MAKE} -f Makefile CONF=Debug + cd ../util && ${MAKE} -f Makefile CONF=Debug # Clean Targets .clean-conf: ${CLEAN_SUBPROJECTS} @@ -187,6 +183,8 @@ ${OBJECTDIR}/src/HTTPStatus.o: src/HTTPStatus.cc # Subprojects .clean-subprojects: + cd ../vdr && ${MAKE} -f Makefile CONF=Debug clean + cd ../util && ${MAKE} -f Makefile CONF=Debug clean # Enable dependency checking .dep.inc: .depcheck-impl diff --git a/libs/networking/nbproject/Makefile-Release.mk b/libs/networking/nbproject/Makefile-Release.mk index c5df60f..50a2158 100644 --- a/libs/networking/nbproject/Makefile-Release.mk +++ b/libs/networking/nbproject/Makefile-Release.mk @@ -38,7 +38,6 @@ OBJECTFILES= \ ${OBJECTDIR}/src/HTTPRequest.o \ ${OBJECTDIR}/src/ServerSocket.o \ ${OBJECTDIR}/src/HTTPAuthorizationRequest.o \ - ${OBJECTDIR}/src/Url.o \ ${OBJECTDIR}/src/Principal.o \ ${OBJECTDIR}/src/Authorization.o \ ${OBJECTDIR}/src/ServerConfig.o \ @@ -97,11 +96,6 @@ ${OBJECTDIR}/src/HTTPAuthorizationRequest.o: src/HTTPAuthorizationRequest.cc ${RM} $@.d $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/HTTPAuthorizationRequest.o src/HTTPAuthorizationRequest.cc -${OBJECTDIR}/src/Url.o: src/Url.cc - ${MKDIR} -p ${OBJECTDIR}/src - ${RM} $@.d - $(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/src/Url.o src/Url.cc - ${OBJECTDIR}/src/Principal.o: src/Principal.cc ${MKDIR} -p ${OBJECTDIR}/src ${RM} $@.d diff --git a/libs/networking/nbproject/configurations.xml b/libs/networking/nbproject/configurations.xml index 65b61b7..acb657c 100644 --- a/libs/networking/nbproject/configurations.xml +++ b/libs/networking/nbproject/configurations.xml @@ -1,5 +1,5 @@ - + include/Principal.h include/ServerConfig.h include/ServerSocket.h - include/Url.h src/Principal.cc src/ServerConfig.cc src/ServerSocket.cc - src/Url.cc include + ../IO/include ../util/include ../vdr/include - -std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -ansi + -std=gnu++0x -fomit-frame-pointer -fPIC -pthread -Wall -Wno-parentheses -Wno-switch -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration _GNU_SOURCE=1 _REENTRANT @@ -87,6 +86,38 @@ + + + + + + + + diff --git a/libs/networking/nbproject/private/configurations.xml b/libs/networking/nbproject/private/configurations.xml index fa15dc7..616cc91 100644 --- a/libs/networking/nbproject/private/configurations.xml +++ b/libs/networking/nbproject/private/configurations.xml @@ -1,5 +1,5 @@ - + Makefile diff --git a/libs/networking/nbproject/project.xml b/libs/networking/nbproject/project.xml index 45ed83d..33cec47 100644 --- a/libs/networking/nbproject/project.xml +++ b/libs/networking/nbproject/project.xml @@ -8,7 +8,11 @@ cc h UTF-8 - + + ../IO + ../vdr + ../util + diff --git a/libs/networking/networking.cbp b/libs/networking/networking.cbp index fc36817..9fbdf1b 100644 --- a/libs/networking/networking.cbp +++ b/libs/networking/networking.cbp @@ -7,7 +7,7 @@ diff --git a/libs/util/nbproject/private/configurations.xml b/libs/util/nbproject/private/configurations.xml index fa15dc7..616cc91 100644 --- a/libs/util/nbproject/private/configurations.xml +++ b/libs/util/nbproject/private/configurations.xml @@ -1,5 +1,5 @@ - + Makefile diff --git a/libs/util/nbproject/project.xml b/libs/util/nbproject/project.xml index a4df583..afebc06 100644 --- a/libs/util/nbproject/project.xml +++ b/libs/util/nbproject/project.xml @@ -8,7 +8,9 @@ cc h UTF-8 - + + ../vdr + diff --git a/libs/util/src/Url.cc b/libs/util/src/Url.cc new file mode 100644 index 0000000..e31637d --- /dev/null +++ b/libs/util/src/Url.cc @@ -0,0 +1,229 @@ +/** + * ======================== legal notice ====================== + * + * File: Url.cc + * Created: 4. Juli 2012, 05 + * Author: Geronimo + * Project: libutil - base classes used by other libraries + * + * CMP - compound media player + * + * is a client/server mediaplayer intended to play any media from any workstation + * without the need to export or mount shares. cmps is an easy to use backend + * with a (ready to use) HTML-interface. Additionally the backend supports + * authentication via HTTP-digest authorization. + * cmpc is a client with vdr-like osd-menues. + * + * Copyright (c) 2012 Reinhard Mantey, some rights reserved! + * published under Creative Commons by-sa + * For details see http://creativecommons.org/licenses/by-sa/3.0/ + * + * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp + * + * -------------------------------------------------------------- + */ +#include +#include +#include +#ifdef DEBUG +#include +#endif +#include +#include +#include + +static cURLEncoder * encoder = NULL; +static cURLDecoder * decoder = NULL; + +cUrl::cUrl(const char* RawURL) + : path(NULL) +{ + ParseURL(RawURL); +} + +cUrl::~cUrl() +{ + FREE(path); +} + +cURLDecoder* cUrl::Decoder(void) +{ + if (!decoder) decoder = new cURLDecoder(); + return decoder; +} + +cURLEncoder* cUrl::Encoder(void) +{ + if (!encoder) encoder = new cURLEncoder(); + return encoder; +} + +const char *cUrl::Parameter(const char* Name) +{ + std::tr1::unordered_map::iterator found = parameters.find(Name); + if (found != parameters.end()) return found->second.c_str(); + return NULL; +} + +void cUrl::SetParameter(const char* Name, const char* Value) +{ + std::string name = Name; + std::string value = Value ? Value : " "; + parameters[name] = value; +} + +size_t cUrl::EstimatedSize(void ) const +{ + size_t rv = parameters.size() * 3; + + if (path) rv += strlen(path) + 4; + ParameterMap::const_iterator pm = parameters.begin(); + + while (pm != parameters.end()) { + rv += pm->first.length() * 3; + rv += pm->second.length() * 3; + ++pm; + } + return rv; +} + +void cUrl::ParseURL(const char *URL) +{ + FREE(path); + parameters.clear(); + if (!URL) return; + const char *q = strchr(URL, '?'); // divider between url and querystring +// char *realURL; +// size_t l; + + if (!q) q = URL + strlen(URL); +// l = q - URL; +// realURL = (char *)malloc(l + 2); +// if (!realURL) return; +// strncpy(realURL, URL, l); +// realURL[l] = 0; + path = Decoder()->Decode(URL, q - URL); + if (*q) ParseQueryString(++q); +} + +void cUrl::ParseQueryString(const char* QueryString) +{ + if (!(QueryString && *QueryString)) return; + const char *start, *last; + char *scratch = strdup(QueryString); + char *p, *end; + size_t srcLen = strlen(QueryString); + + for (start = (const char *)scratch, end = (char *) start, last = scratch + srcLen; end && start < last; start = (const char *)++end) { + end = (char *) strchr(start, '&'); + if (!end) end = (char *)start + strlen(start); + *end = 0; + p = (char *) strchr(start, '='); + if (p) { + *p++ = 0; + char *pn = p ? Decoder()->Decode(start) : NULL; + char *pv = p ? Decoder()->Decode(p) : NULL; + + std::string name = pn; + std::string value = pv ? pv : " "; + + parameters[name] = value; + + free(pn); + free(pv); + } + else { + char *pn = Decoder()->Decode(start); + + std::string name = pn; + parameters[name] = " "; + free(pn); + } + } + free(scratch); +} + +char* cUrl::ToString(void) const +///< returns the address of the newly allocated buffer +{ + size_t bufSize = EstimatedSize(); + char *rv = (char *)malloc(bufSize); + + if (!rv) return NULL; + int n = WriteBuf(rv, bufSize); + + if (n < 0) { + bufSize += 128; + rv = (char *) realloc(rv, bufSize); + WriteBuf(rv, bufSize); + } + return rv; +} + +int cUrl::WriteBuf(char* buf, size_t bufSize) const +///< returns the characters written. -1 as return value indicates a buffer overrun. +{ + char *p, *tmp; + bool first = true; + int n = 0; + + if (path) n += snprintf(buf + n, bufSize - n, "%s", path); + p = buf + n; + ParameterMap::const_iterator pm = parameters.begin(); + + while (pm != parameters.end()) { + tmp = Encoder()->Encode(pm->first.c_str()); + if (p - buf + strlen(tmp) + 2 > bufSize) + return -1; + if (first) { + first = false; + *p++ = '?'; + } + else *p++ = '&'; + strcpy(p, tmp); + p += strlen(p); + FREE(tmp); + + if (strcmp(pm->second.c_str(), " ")) { + tmp = Encoder()->Encode(pm->second.c_str()); + if (p - buf + strlen(tmp) + 2 > bufSize) + return -1; + *p++ = '='; + strcpy(p, tmp); + p += strlen(p); + FREE(tmp); + } + ++pm; + } + p += strlen(p); + + return p - buf; +} + +#ifdef DEBUG +void cUrl::Dump(void ) +{ + ParameterMap::const_iterator pm = parameters.begin(); + + while (pm != parameters.end()) { + std::cout << "parameter [" << pm->first << "]"; + if (strcmp(pm->second.c_str(), " ")) + std::cout << " has value <|" << pm->second << "|>" << std::endl; + else + std::cout << " has NO value!" << std::endl; + ++pm; + } +} +#endif + +void cUrl::Cleanup(void ) +{ + if (encoder) { + delete encoder; + encoder = NULL; + } + if (decoder) { + delete decoder; + decoder = NULL; + } +} \ No newline at end of file diff --git a/libs/util/util.cbp b/libs/util/util.cbp index d582dc0..ae72cf4 100644 --- a/libs/util/util.cbp +++ b/libs/util/util.cbp @@ -7,7 +7,7 @@