summaryrefslogtreecommitdiff
path: root/cmps/serverlib/src
diff options
context:
space:
mode:
authorgeronimo <geronimo013@gmx.de>2012-07-25 06:38:28 +0200
committergeronimo <geronimo013@gmx.de>2012-07-25 06:38:28 +0200
commit774e09eef2d7761814e6f19fb462eb0fdc74f2d7 (patch)
treeca0c4e06afdb99139c7953a8dd5576a3bcd15e23 /cmps/serverlib/src
parentab7186c6c116629983dc506c4b53794026518455 (diff)
downloadcmp-774e09eef2d7761814e6f19fb462eb0fdc74f2d7.tar.gz
cmp-774e09eef2d7761814e6f19fb462eb0fdc74f2d7.tar.bz2
worked out different file class and improved media handling
Diffstat (limited to 'cmps/serverlib/src')
-rw-r--r--cmps/serverlib/src/HTMLListAssembler.cc50
-rw-r--r--cmps/serverlib/src/JSonListAssembler.cc31
-rw-r--r--cmps/serverlib/src/MediaFileHandler.cc14
3 files changed, 48 insertions, 47 deletions
diff --git a/cmps/serverlib/src/HTMLListAssembler.cc b/cmps/serverlib/src/HTMLListAssembler.cc
index c455fc1..bf190fe 100644
--- a/cmps/serverlib/src/HTMLListAssembler.cc
+++ b/cmps/serverlib/src/HTMLListAssembler.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: HTMLListAssembler.cc
* Created: 6. Juli 2012, 09
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* 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 <HTMLListAssembler.h>
@@ -98,27 +98,25 @@ cStringBuilder &cHTMLListAssembler::genDelim(cStringBuilder &sb)
cStringBuilder &cHTMLListAssembler::genMediaLink(cStringBuilder &sb, void *Element, bool odd)
{
cAbstractMedia *m = (cAbstractMedia *)Element;
- cUrl *uri = new cUrl(m->LogicalPath());
- char *lp = uri->ToString();
-
- sb.Append("<a class=\"");
- sb.Append(odd ? "odd" : "even");
- sb.Append("\" href=\"");
- sb.Append(lp);
- free(lp);
- sb.Append("\">");
- switch (m->MediaType()) {
- case cAbstractMedia::Audio: sb.Append("[A] "); break;
- case cAbstractMedia::Movie: sb.Append("[M] "); break;
- case cAbstractMedia::DVDImage: sb.Append("[D] "); break;
- case cAbstractMedia::LegacyVdrRecording: sb.Append("[L] "); break;
- case cAbstractMedia::VdrRecording: sb.Append("[V] "); break;
- case cAbstractMedia::Picture: sb.Append("[P] "); break;
- default: ;
- }
- sb.Append(m->Name());
- sb.Append("</a>");
+ if (m) {
+ sb.Append("<a class=\"");
+ sb.Append(odd ? "odd" : "even");
+ sb.Append("\" href=\"");
+ sb.Append(m->URI());
+ sb.Append("\">");
+ switch (m->MediaType()) {
+ case cAbstractMedia::Audio: sb.Append("[A] "); break;
+ case cAbstractMedia::Movie: sb.Append("[M] "); break;
+ case cAbstractMedia::DVDImage: sb.Append("[D] "); break;
+ case cAbstractMedia::LegacyVdrRecording: sb.Append("[L] "); break;
+ case cAbstractMedia::VdrRecording: sb.Append("[V] "); break;
+ case cAbstractMedia::Picture: sb.Append("[P] "); break;
+ default: ;
+ }
+ sb.Append(m->Name());
+ sb.Append("</a>");
+ }
return sb;
}
diff --git a/cmps/serverlib/src/JSonListAssembler.cc b/cmps/serverlib/src/JSonListAssembler.cc
index f49b8ec..05ff5cc 100644
--- a/cmps/serverlib/src/JSonListAssembler.cc
+++ b/cmps/serverlib/src/JSonListAssembler.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: JSonListAssembler.cc
* Created: 6. Juli 2012, 09
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* 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 <JSonListAssembler.h>
@@ -28,6 +28,7 @@
#include <Url.h>
cJSonListAssembler::cJSonListAssembler()
+ : writer(NULL)
{
}
@@ -58,17 +59,17 @@ bool cJSonListAssembler::OpenList(cStringBuilder &sb, std::map<int, size_t> &Cat
bool cJSonListAssembler::AddElement(cStringBuilder &sb, void *ListElement, bool odd)
{
cAbstractMedia *m = (cAbstractMedia *)ListElement;
- cUrl *uri = new cUrl(m->LogicalPath());
- char *lp = uri->ToString();
- writer->Object();
- writer->Key("name").Value(m->Name());
- writer->Key("type").Value(m->MediaType());
- writer->Key("path").Value(lp);
- free(lp);
- writer->EndObject();
+ if (m) {
+ writer->Object();
+ writer->Key("name").Value(m->Name());
+ writer->Key("type").Value(m->MediaType());
+ writer->Key("path").Value(m->URI());
+ writer->EndObject();
- return true;
+ return true;
+ }
+ return false;
}
bool cJSonListAssembler::CloseList(cStringBuilder &sb, size_t total, size_t start, uint delta)
diff --git a/cmps/serverlib/src/MediaFileHandler.cc b/cmps/serverlib/src/MediaFileHandler.cc
index b2e97a3..200c933 100644
--- a/cmps/serverlib/src/MediaFileHandler.cc
+++ b/cmps/serverlib/src/MediaFileHandler.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: MediaFileHandler.cc
* Created: 5. Juli 2012, 08
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: cmps - the backend (server) part of compound media player
- *
+ *
* 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 <MediaFileHandler.h>
@@ -40,6 +40,8 @@ cMediaFileHandler::~cMediaFileHandler()
cHTTPResponse *cMediaFileHandler::ProcessRequest(cHTTPRequest& Request)
{
+ isyslog("have to find requested media: >%s<", Request.Url().Path());
+
cAbstractMedia *media = FileSystemScanner()->FindMedia(Request.Url().Path());
isyslog("cMediaFileHandler::ProcessRequest ... %0X", media);