summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchriszero <zerov83@gmail.com>2014-11-17 21:38:09 +0100
committerchriszero <zerov83@gmail.com>2014-11-17 21:38:09 +0100
commitfc243d8bfde7c24168b67f90341e7d0d114114b2 (patch)
treec8756fd61712d63801f2085959ac1b9468533af6
parent23f9f7712bfa33b5a488a447a6fabe6035cc3240 (diff)
downloadvdr-plugin-plex-fc243d8bfde7c24168b67f90341e7d0d114114b2.tar.gz
vdr-plugin-plex-fc243d8bfde7c24168b67f90341e7d0d114114b2.tar.bz2
Removed c++11 dependency
-rw-r--r--Config.cpp5
-rw-r--r--Config.h6
-rw-r--r--ControlServer.cpp5
-rw-r--r--ControlServer.h6
-rw-r--r--Makefile2
-rw-r--r--PlexHTTPRequestHandler.cpp29
-rw-r--r--PlexServer.cpp3
-rw-r--r--PlexServer.h4
-rw-r--r--Plexservice.cpp11
-rw-r--r--Plexservice.h6
-rw-r--r--SubscriptionManager.cpp21
-rw-r--r--SubscriptionManager.h12
-rw-r--r--XmlObject.cpp18
-rw-r--r--XmlObject.h2
-rw-r--r--cPlexOsdItem.cpp2
-rw-r--r--plex.cpp39
-rw-r--r--plexgdm.cpp5
-rw-r--r--plexgdm.h8
18 files changed, 115 insertions, 69 deletions
diff --git a/Config.cpp b/Config.cpp
index ff4b721..f8a706a 100644
--- a/Config.cpp
+++ b/Config.cpp
@@ -1,6 +1,11 @@
#include "Config.h"
+Config::Config() {
+ s_username = "username";
+ s_password = "password";
+}
+
std::string Config::GetUUID() {
if(s_uuid.empty()) {
using Poco::UUIDGenerator;
diff --git a/Config.h b/Config.h
index 3bc805a..c089b4e 100644
--- a/Config.h
+++ b/Config.h
@@ -35,8 +35,8 @@ public:
return instance;
}
- std::string s_username = "username";
- std::string s_password = "password";
+ std::string s_username;
+ std::string s_password;
bool HideMainMenuEntry;
bool DisableRemote;
@@ -50,7 +50,7 @@ public:
private:
- Config() {}
+ Config();
std::string s_uuid;
std::string s_hostname;
};
diff --git a/ControlServer.cpp b/ControlServer.cpp
index 439dc7a..c727e20 100644
--- a/ControlServer.cpp
+++ b/ControlServer.cpp
@@ -3,6 +3,11 @@
namespace plexclient
{
+ControlServer::ControlServer() {
+ m_pSvs = new Poco::Net::ServerSocket(3200);;
+ m_pSrv = new Poco::Net::HTTPServer(new PlexReqHandlerFactory, *m_pSvs, new Poco::Net::HTTPServerParams);
+}
+
void ControlServer::Start() {
// start the HTTPServer
m_pSrv->start();
diff --git a/ControlServer.h b/ControlServer.h
index 55f8299..f349533 100644
--- a/ControlServer.h
+++ b/ControlServer.h
@@ -25,10 +25,10 @@ public:
void Stop();
private:
- ControlServer() {};
+ ControlServer();
- Poco::Net::ServerSocket *m_pSvs = new Poco::Net::ServerSocket(3200);;
- Poco::Net::HTTPServer *m_pSrv = new Poco::Net::HTTPServer(new PlexReqHandlerFactory, *m_pSvs, new Poco::Net::HTTPServerParams);
+ Poco::Net::ServerSocket *m_pSvs;
+ Poco::Net::HTTPServer *m_pSrv;
};
diff --git a/Makefile b/Makefile
index 1344831..551c4c7 100644
--- a/Makefile
+++ b/Makefile
@@ -71,7 +71,7 @@ TMPDIR ?= /tmp
export CFLAGS = $(call PKGCFG,cflags)
export CXXFLAGS = $(call PKGCFG,cxxflags)
-CXXFLAGS += -std=gnu++0x -Wunused-variable -Wunused-parameter
+##CXXFLAGS += -std=gnu++0x -Wunused-variable -Wunused-parameter
ifeq ($(CFLAGS),)
$(error CFLAGS not set)
diff --git a/PlexHTTPRequestHandler.cpp b/PlexHTTPRequestHandler.cpp
index c0c01b1..f18001c 100644
--- a/PlexHTTPRequestHandler.cpp
+++ b/PlexHTTPRequestHandler.cpp
@@ -1,5 +1,6 @@
#include "PlexHTTPRequestHandler.h"
#include <vdr/remote.h>
+#include <vdr/keys.h>
#include <unistd.h>
namespace plexclient
@@ -38,8 +39,8 @@ void PlexHTTPRequestHandler::AddHeaders(Poco::Net::HTTPServerResponse& response,
std::map<std::string, std::string> PlexHTTPRequestHandler::ParseQuery(std::string query) {
std::map<std::string, std::string> querymap;
Poco::StringTokenizer queryTokens(query, "&");
- for(auto& token : queryTokens) {
- Poco::StringTokenizer subTokens(token, "=");
+ for(Poco::StringTokenizer::Iterator token = queryTokens.begin() ; token != queryTokens.end(); ++token) {
+ Poco::StringTokenizer subTokens(*token, "=");
querymap[subTokens[0]] = subTokens[1];
}
return querymap;
@@ -58,12 +59,12 @@ void PlexHTTPRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request
void SubscribeRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response){
// parse query
Poco::URI uri(request.getURI());
- auto query = ParseQuery(uri.getQuery()); // port=32400&commandID=0&protocol=http
+ std::map<std::string, std::string> query = ParseQuery(uri.getQuery()); // port=32400&commandID=0&protocol=http
std::string path = uri.getPath(); // /player/timeline/subscribe
std::string uuid = request.get("X-Plex-Client-Identifier");
- int port = std::stoi(query["port"]);
- int command = std::stoi(query["commandID"]);
+ int port = atoi(query["port"].c_str());
+ int command = atoi(query["commandID"].c_str());
SubscriptionManager::GetInstance().AddSubscriber(Subscriber(query["protocol"], request.getHost(), port, uuid, command));
AddHeaders(response, request);
@@ -99,9 +100,9 @@ void ResourceRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request
void PlayerRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response){
Poco::URI uri(request.getURI());
//Poco::StringTokenizer pathTokens(uri, "/");
- auto query = ParseQuery(uri.getQuery());
+ std::map<std::string, std::string> query = ParseQuery(uri.getQuery());
- if(query.find("wait") != query.end() && std::stoi(query["wait"]) == 1) {
+ if(query.find("wait") != query.end() && atoi(query["wait"].c_str()) == 1) {
usleep(900 * 1000);
}
@@ -155,25 +156,25 @@ void PlayerRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request,
}
else if(request.getURI().find("/navigation")!= std::string::npos) {
if(request.getURI().find("/moveUp")!= std::string::npos) {
- cRemote::Put(eKeys::kUp);
+ cRemote::Put(kUp);
}
else if(request.getURI().find("/moveDown")!= std::string::npos) {
- cRemote::Put(eKeys::kDown);
+ cRemote::Put(kDown);
}
else if(request.getURI().find("/moveLeft")!= std::string::npos) {
- cRemote::Put(eKeys::kLeft);
+ cRemote::Put(kLeft);
}
else if(request.getURI().find("/moveRight")!= std::string::npos) {
- cRemote::Put(eKeys::kRight);
+ cRemote::Put(kRight);
}
else if(request.getURI().find("/select")!= std::string::npos) {
- cRemote::Put(eKeys::kOk);
+ cRemote::Put(kOk);
}
else if(request.getURI().find("/home")!= std::string::npos) {
- cRemote::Put(eKeys::kMenu);
+ cRemote::Put(kMenu);
}
else if(request.getURI().find("/back")!= std::string::npos) {
- cRemote::Put(eKeys::kBack);
+ cRemote::Put(kBack);
}
}
diff --git a/PlexServer.cpp b/PlexServer.cpp
index 94ba0e8..4eb1245 100644
--- a/PlexServer.cpp
+++ b/PlexServer.cpp
@@ -1,3 +1,4 @@
+#include <vdr/tools.h>
#include "PlexServer.h"
namespace plexclient
@@ -31,7 +32,7 @@ PlexServer::PlexServer(std::string data, std::string ip)
}
std::string PlexServer::GetUri() {
- return std::string("http://") + m_sIpAddress + ":" + std::to_string(m_nPort);
+ return std::string("http://") + m_sIpAddress + ":" + std::string(itoa(m_nPort));
}
PlexServer::~PlexServer()
diff --git a/PlexServer.h b/PlexServer.h
index 61438d3..3de2ae2 100644
--- a/PlexServer.h
+++ b/PlexServer.h
@@ -64,8 +64,8 @@ public:
private:
std::string m_sDiscovery;
- int m_nOwned = 0;
- int m_nMaster = 0;
+ int m_nOwned;
+ int m_nMaster;
std::string m_sRole;
std::string m_sContentType;
std::string m_sUuid;
diff --git a/Plexservice.cpp b/Plexservice.cpp
index cf6a252..066abe2 100644
--- a/Plexservice.cpp
+++ b/Plexservice.cpp
@@ -7,6 +7,7 @@ namespace plexclient
Plexservice::Plexservice(PlexServer *server)
{
pServer = server;
+ USERAGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17";
}
Plexservice::~Plexservice()
@@ -78,6 +79,7 @@ void Plexservice::Authenticate()
{
if(m_sToken.empty()) {
GetMyPlexToken();
+ //m_sToken = "";
}
try {
GetHttpSession(true);
@@ -172,8 +174,8 @@ MediaContainer* Plexservice::GetMediaContainer(std::string fullUrl) {
Poco::URI fileuri(fullUrl);
- std::unique_ptr<Poco::Net::HTTPRequest> pRequest(new Poco::Net::HTTPRequest(Poco::Net::HTTPRequest::HTTP_GET,
- fileuri.getPath(), Poco::Net::HTTPMessage::HTTP_1_1));
+ Poco::Net::HTTPRequest* pRequest = new Poco::Net::HTTPRequest(Poco::Net::HTTPRequest::HTTP_GET,
+ fileuri.getPath(), Poco::Net::HTTPMessage::HTTP_1_1);
pRequest->add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17");
@@ -188,7 +190,7 @@ MediaContainer* Plexservice::GetMediaContainer(std::string fullUrl) {
pRequest->add("X-Plex-Provides", "player");
pRequest->add("X-Plex-Version", "0.0.1a");
- auto session = new Poco::Net::HTTPClientSession(fileuri.getHost(), fileuri.getPort());
+ Poco::Net::HTTPClientSession* session = new Poco::Net::HTTPClientSession(fileuri.getHost(), fileuri.getPort());
session->sendRequest(*pRequest);
Poco::Net::HTTPResponse response;
@@ -196,6 +198,9 @@ MediaContainer* Plexservice::GetMediaContainer(std::string fullUrl) {
std::cout << "URI: " << session->getHost() << "[" << pRequest->getURI() << "]" << std::endl;
+ delete pRequest;
+ delete session;
+
MediaContainer* pAllsections = new MediaContainer(&rs);
//Poco::StreamCopier::copyStream(rs, std::cout);
return pAllsections;
diff --git a/Plexservice.h b/Plexservice.h
index a935ef2..aad20a9 100644
--- a/Plexservice.h
+++ b/Plexservice.h
@@ -49,10 +49,10 @@ public:
static MediaContainer* GetMediaContainer(std::string fullUrl);
private:
- const std::string USERAGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17";
+ std::string USERAGENT;
- Poco::Net::HTTPClientSession *m_pPlexSession = 0;
- PlexServer *pServer = 0;
+ Poco::Net::HTTPClientSession *m_pPlexSession;
+ PlexServer *pServer;
std::string m_sToken;
Poco::Net::HTTPClientSession* GetHttpSession(bool createNew = false);
diff --git a/SubscriptionManager.cpp b/SubscriptionManager.cpp
index 47f917d..c3e97b6 100644
--- a/SubscriptionManager.cpp
+++ b/SubscriptionManager.cpp
@@ -18,36 +18,37 @@ SubscriptionManager::SubscriptionManager()
}
void SubscriptionManager::Notify() {
- mutex.lock();
+ //mutex.lock();
//TODO: Implement
- for(auto subs : m_mSubcribers) {
- subs.second.SendUpdate(GetMsg(std::to_string(subs.second.m_iCommandId)), false);
+ for(std::map<std::string, Subscriber>::iterator it = m_mSubcribers.begin() ; it != m_mSubcribers.end(); ++it) {
+ Subscriber subs = it->second;
+ subs.SendUpdate(GetMsg(std::string(itoa(subs.m_iCommandId))), false);
}
- mutex.unlock();
+ //mutex.unlock();
}
void SubscriptionManager::AddSubscriber(Subscriber subs) {
- mutex.lock();
+ //mutex.lock();
m_mSubcribers[subs.GetUuid()] = subs;
std::cout << "AddSubscriber: " << subs.to_string() << std::endl;
- mutex.unlock();
+ //mutex.unlock();
}
void SubscriptionManager::RemoveSubscriber(std::string uuid) {
- mutex.lock();
+ //mutex.lock();
if(m_mSubcribers.find(uuid) != m_mSubcribers.end()) {
m_mSubcribers.erase(uuid);
}
- mutex.unlock();
+ //mutex.unlock();
}
std::string SubscriptionManager::GetMsg(std::string commandId) {
PlayerGetCurrentPosition();
int time = PlayerCurrent;
- bool paused = PlayerPaused;
+ //bool paused = PlayerPaused;
std::stringstream msg;
msg << "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
@@ -93,7 +94,7 @@ void Subscriber::SendUpdate(std::string msg, bool isNav) {
pRequest->add("X-Plex-Provides", "player");
pRequest->add("X-Plex-Version", "0.0.1a");
- auto session = new Poco::Net::HTTPClientSession(m_sHost, m_iPort);
+ Poco::Net::HTTPClientSession* session = new Poco::Net::HTTPClientSession(m_sHost, m_iPort);
std::ostream& oustr = session->sendRequest(*pRequest);
oustr << msg;
}
diff --git a/SubscriptionManager.h b/SubscriptionManager.h
index a411256..44ec899 100644
--- a/SubscriptionManager.h
+++ b/SubscriptionManager.h
@@ -1,10 +1,11 @@
#ifndef SUBSCRIPTIONMANAGER_H
#define SUBSCRIPTIONMANAGER_H
+#include <vdr/tools.h>
#include <string>
#include <iostream>
#include <map>
-#include <mutex>
+//#include <mutex>
#include <sstream>
#include "player.h"
@@ -26,7 +27,8 @@ class Subscriber
void SendUpdate(std::string msg, bool isNav);
virtual std::string to_string() {
- return "Subscriber-> Host: " + m_sHost + "; Port:" + std::to_string(m_iPort) + "; Uuid:" + m_sUuid + "; CmdID:" + std::to_string(m_iCommandId);
+ return "Subscriber-> Host: " + m_sHost + "; Port: " + std::string(itoa(m_iPort)) + "; Uuid:" + m_sUuid + "; CmdID:" + std::string(itoa(m_iCommandId));
+ return "";
}
private:
@@ -53,7 +55,7 @@ public:
private:
SubscriptionManager();
- std::mutex mutex;
+ //std::mutex mutex;
std::map<std::string, Subscriber> m_mSubcribers;
};
@@ -70,8 +72,8 @@ class ActionManager
private:
ActionManager();
- std::string m_sAction = "";
- bool m_isAction = false;
+ std::string m_sAction;
+ bool m_isAction;
};
}
diff --git a/XmlObject.cpp b/XmlObject.cpp
index 41a9d39..923d2d1 100644
--- a/XmlObject.cpp
+++ b/XmlObject.cpp
@@ -25,7 +25,7 @@ int XmlObject::GetNodeValueAsInt(Poco::XML::Node* pNode)
int value = 0;
if(pNode != 0) {
try {
- value = std::stoi(pNode->getNodeValue());
+ value = atoi(pNode->getNodeValue().c_str());
} catch(Poco::Exception) {}
}
return value;
@@ -36,7 +36,7 @@ long XmlObject::GetNodeValueAsLong(Poco::XML::Node* pNode)
long value = 0;
if(pNode != 0) {
try {
- value = std::stol(pNode->getNodeValue());
+ value = atol(pNode->getNodeValue().c_str());
} catch(Poco::Exception) {}
}
return value;
@@ -56,7 +56,7 @@ Poco::Timestamp XmlObject::GetNodeValueAsTimeStamp(Poco::XML::Node* pNode)
Poco::Timestamp value;
if(pNode != 0) {
try {
- long lValue = std::stol(pNode->nodeValue());
+ long lValue = atol(pNode->nodeValue().c_str());
value = Poco::Timestamp(lValue);
} catch (Poco::Exception) {}
}
@@ -65,20 +65,20 @@ Poco::Timestamp XmlObject::GetNodeValueAsTimeStamp(Poco::XML::Node* pNode)
MediaType XmlObject::GetNodeValueAsMediaType(Poco::XML::Node* pNode)
{
- MediaType type = MediaType::UNDEF;
+ MediaType type = UNDEF;
if(pNode != 0) {
std::string sType = pNode->nodeValue();
if (Poco::icompare(sType, "photo") == 0) {
- type = MediaType::PHOTO;
+ type = PHOTO;
} else if (Poco::icompare(sType, "movie") == 0) {
- type = MediaType::MOVIE;
+ type = MOVIE;
} else if (Poco::icompare(sType, "music") == 0) {
- type = MediaType::MUSIC;
+ type = MUSIC;
} else if (Poco::icompare(sType, "show") == 0) {
- type = MediaType::SHOW;
+ type = SHOW;
} else if (Poco::icompare(sType, "season") == 0) {
- type = MediaType::SHOW;
+ type = SHOW;
}
}
return type;
diff --git a/XmlObject.h b/XmlObject.h
index d227af7..d8af778 100644
--- a/XmlObject.h
+++ b/XmlObject.h
@@ -1,6 +1,8 @@
#ifndef XMLOBJECT_H
#define XMLOBJECT_H
+#include <cstdlib>
+
#include <Poco/DOM/Document.h>
#include <Poco/Timestamp.h>
#include <Poco/String.h>
diff --git a/cPlexOsdItem.cpp b/cPlexOsdItem.cpp
index 6ee51c1..b76f577 100644
--- a/cPlexOsdItem.cpp
+++ b/cPlexOsdItem.cpp
@@ -31,4 +31,4 @@ plexclient::Directory* cPlexOsdItem::GetAttachedDirectory() {
cPlexOsdItem::~cPlexOsdItem()
{
-} \ No newline at end of file
+}
diff --git a/plex.cpp b/plex.cpp
index dcd1142..60fd6e7 100644
--- a/plex.cpp
+++ b/plex.cpp
@@ -1,3 +1,24 @@
+///
+/// @file play.cpp @brief A play plugin for VDR.
+///
+/// Copyright (c) 2012, 2013 by Johns. All Rights Reserved.
+///
+/// Contributor(s): Dennis Bendlin
+///
+/// License: AGPLv3
+///
+/// This program is free software: you can redistribute it and/or modify
+/// it under the terms of the GNU Affero General Public License as
+/// published by the Free Software Foundation, either version 3 of the
+/// License.
+///
+/// This program is distributed in the hope that it will be useful,
+/// but WITHOUT ANY WARRANTY; without even the implied warranty of
+/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+/// GNU Affero General Public License for more details.
+///
+/// $Id: 269426d9bc0f37cc7c07b21716c345e57148aecb $
+//////////////////////////////////////////////////////////////////////////////
#include "ControlServer.h"
#include "SubscriptionManager.h"
#include "plex.h"
@@ -596,20 +617,18 @@ void cPlexBrowser::CreateMenu() {
Clear();
// Directory or Video?
if(pCont->m_vDirectories.size() > 0) {
- v_Dir = &pCont->m_vDirectories;
- for(auto& pDir : pCont->m_vDirectories) {
- if(pDir.m_eType != plexclient::MediaType::MUSIC && pDir.m_eType != plexclient::MediaType::PHOTO) {
- Add(new cPlexOsdItem( pDir.m_sTitle.c_str(), &pDir) );
- }
+ for(std::vector<plexclient::Directory>::iterator it = pCont->m_vDirectories.begin(); it != pCont->m_vDirectories.end(); ++it) {
+ plexclient::Directory *pDir = &(*it);
+ Add(new cPlexOsdItem( pDir->m_sTitle.c_str(), pDir) );
}
}
-
- if (pCont->m_vVideos.size() > 0) {
- for(auto& v_Vid : pCont->m_vVideos) {
- Add(new cPlexOsdItem( v_Vid.m_sTitle.c_str(), &v_Vid) );
- }
+ if(pCont->m_vVideos.size() > 0) {
+ for(std::vector<plexclient::Video>::iterator it = pCont->m_vVideos.begin(); it != pCont->m_vVideos.end(); ++it) {
+ plexclient::Video *vid = &(*it); // cast raw pointer
+ Add(new cPlexOsdItem( vid->m_sTitle.c_str(), vid) );
+ }
}
if(Count() < 1) {
diff --git a/plexgdm.cpp b/plexgdm.cpp
index bca152c..12e1e8a 100644
--- a/plexgdm.cpp
+++ b/plexgdm.cpp
@@ -5,6 +5,11 @@ namespace plexclient
plexgdm::plexgdm()
{
+ _discoverMessage = "M-SEARCH * HTTP/1.0";
+ _clientHeader = "* HTTP/1.0";
+ _multicastAddress = "239.0.0.250";
+ _clientUpdatePort = 32412;
+
m_discoverAdress = Poco::Net::SocketAddress(_multicastAddress, 32414);
m_clientRegisterGroup = Poco::Net::SocketAddress(_multicastAddress, 32413);
diff --git a/plexgdm.h b/plexgdm.h
index e46f3b6..f48f07f 100644
--- a/plexgdm.h
+++ b/plexgdm.h
@@ -62,12 +62,12 @@ protected:
volatile bool m_discoveryIsRunning;
volatile bool m_registrationIsRunning;
- std::string _discoverMessage = "M-SEARCH * HTTP/1.0";
- std::string _clientHeader = "* HTTP/1.0";
+ std::string _discoverMessage;
+ std::string _clientHeader;
std::string _clientData;
std::string _clientId;
- std::string _multicastAddress = "239.0.0.250";
- int _clientUpdatePort = 32412;
+ std::string _multicastAddress;
+ int _clientUpdatePort;
PlexServer *m_pServer;
};