summaryrefslogtreecommitdiff
path: root/libs/networking
diff options
context:
space:
mode:
authorgeronimo <geronimo013@gmx.de>2012-07-29 13:11:47 (GMT)
committergeronimo <geronimo013@gmx.de>2012-07-29 13:11:47 (GMT)
commit85cb3f04252b0228830903b21c08bb64e9919c18 (patch)
tree5c00dbd8d296861aa56cca598ee2a36e51971822 /libs/networking
parent736033f3d532c4814eeff84db5dbf99f0249df6e (diff)
downloadcmp-85cb3f04252b0228830903b21c08bb64e9919c18.tar.gz
cmp-85cb3f04252b0228830903b21c08bb64e9919c18.tar.bz2
changed server setup to config file, little rearrangement of sources
Diffstat (limited to 'libs/networking')
-rw-r--r--libs/networking/include/Credentials.h7
-rw-r--r--libs/networking/include/HTTPResponse.h12
-rw-r--r--libs/networking/include/ServerConfig.h38
-rw-r--r--libs/networking/include/Url.h67
-rw-r--r--libs/networking/nbproject/Makefile-Debug.mk50
-rw-r--r--libs/networking/nbproject/Makefile-Release.mk6
-rw-r--r--libs/networking/nbproject/configurations.xml39
-rw-r--r--libs/networking/nbproject/private/configurations.xml2
-rw-r--r--libs/networking/nbproject/project.xml6
-rw-r--r--libs/networking/networking.cbp9
-rw-r--r--libs/networking/networking.layout30
-rw-r--r--libs/networking/networking.layout.save24
-rw-r--r--libs/networking/src/ConnectionHandler.cc12
-rw-r--r--libs/networking/src/HTTPResponse.cc12
-rw-r--r--libs/networking/src/ServerConfig.cc127
-rw-r--r--libs/networking/src/Url.cc229
16 files changed, 270 insertions, 400 deletions
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 <Principal.h>
+#include <Persistable.h>
#include <string>
#include <tr1/unordered_map>
-class cCredentials {
+class cCredentials : public cPersistable {
public:
typedef std::tr1::unordered_map<std::string, cPrincipal *>::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: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* 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: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* 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 <Persistable.h>
#include <ServerSocket.h>
#include <Authorization.h>
-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: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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 <stddef.h>
-#include <string>
-#include <tr1/unordered_map>
-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<std::string, std::string> 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 @@
<?xml version="1.0" encoding="UTF-8"?>
-<configurationDescriptor version="80">
+<configurationDescriptor version="84">
<logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
<logicalFolder name="HeaderFiles"
displayName="Header Files"
@@ -22,7 +22,6 @@
<itemPath>include/Principal.h</itemPath>
<itemPath>include/ServerConfig.h</itemPath>
<itemPath>include/ServerSocket.h</itemPath>
- <itemPath>include/Url.h</itemPath>
</logicalFolder>
<logicalFolder name="ResourceFiles"
displayName="Resource Files"
@@ -49,7 +48,6 @@
<itemPath>src/Principal.cc</itemPath>
<itemPath>src/ServerConfig.cc</itemPath>
<itemPath>src/ServerSocket.cc</itemPath>
- <itemPath>src/Url.cc</itemPath>
</logicalFolder>
<logicalFolder name="TestFiles"
displayName="Test Files"
@@ -75,10 +73,11 @@
<ccTool>
<incDir>
<pElem>include</pElem>
+ <pElem>../IO/include</pElem>
<pElem>../util/include</pElem>
<pElem>../vdr/include</pElem>
</incDir>
- <commandLine>-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</commandLine>
+ <commandLine>-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</commandLine>
<preprocessorList>
<Elem>_GNU_SOURCE=1</Elem>
<Elem>_REENTRANT</Elem>
@@ -87,6 +86,38 @@
</ccTool>
<archiverTool>
</archiverTool>
+ <requiredProjects>
+ <makeArtifact PL="../vdr"
+ CT="3"
+ CN="Debug"
+ AC="true"
+ BL="true"
+ WD="../vdr"
+ BC="${MAKE} -f Makefile CONF=Debug"
+ CC="${MAKE} -f Makefile CONF=Debug clean"
+ OP="${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libvdr.a">
+ </makeArtifact>
+ <makeArtifact PL="../util"
+ CT="3"
+ CN="Debug"
+ AC="true"
+ BL="true"
+ WD="../util"
+ BC="${MAKE} -f Makefile CONF=Debug"
+ CC="${MAKE} -f Makefile CONF=Debug clean"
+ OP="${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libutil.a">
+ </makeArtifact>
+ <makeArtifact PL="../IO"
+ CT="3"
+ CN="Debug"
+ AC="true"
+ BL="false"
+ WD="../IO"
+ BC="${MAKE} -f Makefile CONF=Debug"
+ CC="${MAKE} -f Makefile CONF=Debug clean"
+ OP="${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/libio.a">
+ </makeArtifact>
+ </requiredProjects>
</compileType>
</conf>
<conf name="Release" type="3">
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 @@
<?xml version="1.0" encoding="UTF-8"?>
-<configurationDescriptor version="80">
+<configurationDescriptor version="84">
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="Debug" type="3">
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 @@
<cpp-extensions>cc</cpp-extensions>
<header-extensions>h</header-extensions>
<sourceEncoding>UTF-8</sourceEncoding>
- <make-dep-projects/>
+ <make-dep-projects>
+ <make-dep-project>../IO</make-dep-project>
+ <make-dep-project>../vdr</make-dep-project>
+ <make-dep-project>../util</make-dep-project>
+ </make-dep-projects>
<sourceRootList/>
<confList>
<confElem>
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 @@
<Option compiler="gcc" />
<Build>
<Target title="Debug">
- <Option output="libnetworking" prefix_auto="1" extension_auto="1" />
+ <Option output="networking" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Debug/" />
<Option type="2" />
@@ -19,7 +19,7 @@
</Compiler>
</Target>
<Target title="Release">
- <Option output="libnetworking" prefix_auto="1" extension_auto="1" />
+ <Option output="networking" prefix_auto="1" extension_auto="1" />
<Option working_dir="" />
<Option object_output="obj/Release/" />
<Option type="2" />
@@ -35,11 +35,12 @@
</Target>
</Build>
<Compiler>
- <Add option="-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" />
+ <Add option="-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" />
<Add option="-D_REENTRANT" />
<Add option="-D_GNU_SOURCE=1" />
<Add directory="../vdr/include" />
<Add directory="../util/include" />
+ <Add directory="../IO/include" />
<Add directory="include" />
</Compiler>
<Unit filename="include/AbstractSocket.h" />
@@ -59,7 +60,6 @@
<Unit filename="include/Principal.h" />
<Unit filename="include/ServerConfig.h" />
<Unit filename="include/ServerSocket.h" />
- <Unit filename="include/Url.h" />
<Unit filename="src/AbstractSocket.cc" />
<Unit filename="src/Authorization.cc" />
<Unit filename="src/ClientSocket.cc" />
@@ -77,7 +77,6 @@
<Unit filename="src/Principal.cc" />
<Unit filename="src/ServerConfig.cc" />
<Unit filename="src/ServerSocket.cc" />
- <Unit filename="src/Url.cc" />
<Extensions>
<code_completion />
<envvars />
diff --git a/libs/networking/networking.layout b/libs/networking/networking.layout
index ec82f77..d908ef8 100644
--- a/libs/networking/networking.layout
+++ b/libs/networking/networking.layout
@@ -1,44 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
- <File name="src/HTTPFileResponse.cc" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="src/ConnectionHandler.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
- <Cursor1 position="0" topLine="0" />
+ <Cursor1 position="1551" topLine="0" />
</Cursor>
</File>
- <File name="include/HTTPResponse.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="include/ConnectionPoint.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="include/ConnectionHandler.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="src/ConnectionPoint.cc" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="src/ConnectionHandler.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="src/HTTPFileResponse.cc" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
- <Cursor1 position="1551" topLine="0" />
+ <Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="include/ConnectionPoint.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="include/HTTPMessage.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="include/HTTPMessage.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="include/ConnectionHandler.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="src/ConnectionPoint.cc" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="src/HTTPMessage.cc" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="src/HTTPMessage.cc" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="include/ServerConfig.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor>
+ <Cursor1 position="1684" topLine="0" />
+ </Cursor>
+ </File>
+ <File name="include/HTTPResponse.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
+ <File name="src/ServerConfig.cc" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor>
+ <Cursor1 position="1670" topLine="0" />
+ </Cursor>
+ </File>
</CodeBlocks_layout_file>
diff --git a/libs/networking/networking.layout.save b/libs/networking/networking.layout.save
index 5cfe8a9..d0cb4d6 100644
--- a/libs/networking/networking.layout.save
+++ b/libs/networking/networking.layout.save
@@ -1,7 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
- <File name="include/HTTPResponse.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="src/ConnectionHandler.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor>
+ <Cursor1 position="1551" topLine="0" />
+ </Cursor>
+ </File>
+ <File name="include/ConnectionPoint.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
@@ -16,29 +21,34 @@
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="src/HTTPMessage.cc" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="include/HTTPMessage.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="include/ConnectionPoint.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="include/ConnectionHandler.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="include/HTTPMessage.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="src/HTTPMessage.cc" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="include/ConnectionHandler.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="include/ServerConfig.h" open="1" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
- <File name="src/ConnectionHandler.cc" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <File name="include/HTTPResponse.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
- <Cursor1 position="1551" topLine="0" />
+ <Cursor1 position="0" topLine="0" />
+ </Cursor>
+ </File>
+ <File name="src/ServerConfig.cc" open="1" top="1" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
+ <Cursor>
+ <Cursor1 position="1538" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
diff --git a/libs/networking/src/ConnectionHandler.cc b/libs/networking/src/ConnectionHandler.cc
index abed00f..4e87750 100644
--- a/libs/networking/src/ConnectionHandler.cc
+++ b/libs/networking/src/ConnectionHandler.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: ConnectionHandler.cc
* Created: 4. Juli 2012, 07
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* 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
- *
+ *
* --------------------------------------------------------------
*/
#include <ConnectionHandler.h>
diff --git a/libs/networking/src/HTTPResponse.cc b/libs/networking/src/HTTPResponse.cc
index e9ae8eb..f76fff5 100644
--- a/libs/networking/src/HTTPResponse.cc
+++ b/libs/networking/src/HTTPResponse.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: HTTPResponse.cc
* Created: 4. Juli 2012, 06
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* 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
- *
+ *
* --------------------------------------------------------------
*/
#include <HTTPResponse.h>
diff --git a/libs/networking/src/ServerConfig.cc b/libs/networking/src/ServerConfig.cc
index a339497..0b29d8a 100644
--- a/libs/networking/src/ServerConfig.cc
+++ b/libs/networking/src/ServerConfig.cc
@@ -1,47 +1,60 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: ServerConfig.cc
* Created: 8. Juli 2012, 06
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* 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
- *
+ *
* --------------------------------------------------------------
*/
#include <ServerConfig.h>
+#include <ConfigReader.h>
+#include <LineReader.h>
+#include <FileReader.h>
+#include <File.h>
#include <Logging.h>
#include <util.h>
#include <sys/stat.h>
#include <sys/types.h>
-cServerConfig::cServerConfig(int Port)
- : server(Port, 5)
+cServerConfig::cServerConfig(const char *ConfigBaseDir)
+ : server(12345, 5)
+ , authorizationRequired(false)
+ , wantExtendedScan(false)
+ , configBaseDir(ConfigBaseDir ? strdup(ConfigBaseDir) : NULL)
+ , credentialsFile(NULL)
, documentRoot(NULL)
, appIconPath(NULL)
+ , mediaInfo(NULL)
+ , ffmpeg(NULL)
{
}
cServerConfig::~cServerConfig()
{
- FREE(appIconPath);
+ FREE(configBaseDir);
FREE(documentRoot);
+ FREE(appIconPath);
+ FREE(mediaInfo);
+ FREE(ffmpeg);
}
-void cServerConfig::SetAppIcon(const char* AppIcon)
+void cServerConfig::SetAppIcon(const char *AppIcon)
{
struct stat st;
@@ -53,13 +66,103 @@ void cServerConfig::SetAppIcon(const char* AppIcon)
else esyslog("ERROR: failed to stat application icon! %s", AppIcon);
}
-void cServerConfig::SetDocumentRoot(const char* DocumentRoot)
+void cServerConfig::SetConfigBaseDir(const char *ConfigBaseDir)
+{
+ free(configBaseDir);
+ configBaseDir = ConfigBaseDir ? strdup(ConfigBaseDir) : NULL;
+}
+
+void cServerConfig::SetCredentialsFile(const char *FileName)
+{
+ free(credentialsFile);
+ credentialsFile = FileName ? strdup(FileName) : NULL;
+}
+
+void cServerConfig::SetDocumentRoot(const char *DocumentRoot)
{
free(documentRoot);
documentRoot = DocumentRoot ? strdup(DocumentRoot) : NULL;
}
+void cServerConfig::SetMediaInfo(const char *MediaInfo)
+{
+ free(mediaInfo);
+ mediaInfo = MediaInfo ? strdup(MediaInfo) : NULL;
+}
+
+void cServerConfig::SetFFMpeg(const char* FFMpeg)
+{
+ free(ffmpeg);
+ ffmpeg = FFMpeg ? strdup(FFMpeg) : NULL;
+}
+
void cServerConfig::SetPort(int port)
{
server.SetPort(port);
-} \ No newline at end of file
+}
+
+void cServerConfig::Dump(void)
+{
+ isyslog("server-config - socket #%d", server.Port());
+ isyslog("server-config - authorization required: %s", authorizationRequired ? "yes" : "no");
+ isyslog("server-config - do extended scan: %s", wantExtendedScan ? "yes" : "no");
+ isyslog("server-config - application dir: %s", configBaseDir);
+ isyslog("server-config - credentials file: %s", credentialsFile);
+ isyslog("server-config - media root: %s", documentRoot);
+ isyslog("server-config - app icon: %s", appIconPath);
+ isyslog("server-config - mediainfo: %s", mediaInfo);
+ isyslog("server-config - ffmpeg: %s", ffmpeg);
+}
+
+int cServerConfig::Load(const char* FileName)
+{
+ cConfigReader *cr = new cConfigReader(new cLineReader(new cFileReader(new cFile(configBaseDir, FileName))));
+ cConfigReader::ConfigEntry *ce;
+ int numberOfEntries = 0;
+
+ while ((ce = cr->ReadValue())) {
+ std::string name = std::get<0>(*ce);
+
+ if (!strcmp("media-root", name.c_str())) {
+ SetDocumentRoot(std::get<1>(*ce).c_str());
+ ++numberOfEntries;
+ }
+ else if (!strcmp("favicon", name.c_str())) {
+ SetAppIcon(std::get<1>(*ce).c_str());
+ ++numberOfEntries;
+ }
+ else if (!strcmp("cmps-port", name.c_str())) {
+ SetPort(atoi(std::get<1>(*ce).c_str()));
+ ++numberOfEntries;
+ }
+#ifdef NOT_YET
+ else if (!strcmp("want-auth", name.c_str())) {
+ SetAuthorizationRequired(!strcasecmp("true", std::get<1>(*ce).c_str()));
+ ++numberOfEntries;
+ }
+#endif
+ else if (!strcmp("want-meta", name.c_str())) {
+ SetWantExtendedScan(!strcasecmp("true", std::get<1>(*ce).c_str()));
+ ++numberOfEntries;
+ }
+ else if (!strcmp("mediainfo", name.c_str())) {
+ SetMediaInfo(std::get<1>(*ce).c_str());
+ ++numberOfEntries;
+ }
+ else if (!strcmp("ffmpeg", name.c_str())) {
+ SetFFMpeg(std::get<1>(*ce).c_str());
+ ++numberOfEntries;
+ }
+ delete ce;
+ }
+ cr->Close();
+ delete cr;
+
+ return numberOfEntries > 0;
+}
+
+int cServerConfig::Store(const char* FileName)
+{
+ //TODO:
+ return 0;
+}
diff --git a/libs/networking/src/Url.cc b/libs/networking/src/Url.cc
deleted file mode 100644
index ce951e6..0000000
--- a/libs/networking/src/Url.cc
+++ /dev/null
@@ -1,229 +0,0 @@
-/**
- * ======================== legal notice ======================
- *
- * File: Url.cc
- * Created: 4. Juli 2012, 05
- * Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
- * 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
- *
- * --------------------------------------------------------------
- */
-#include <Url.h>
-#include <Codec.h>
-#include <util.h>
-#ifdef DEBUG
-#include <iostream>
-#endif
-#include <stdio.h>
-#include <string.h>
-#include <vector>
-
-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<std::string, std::string>::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