From 216db1e9eb1800df1969ba3fd6755f898a0b2526 Mon Sep 17 00:00:00 2001 From: chriszero Date: Tue, 17 Feb 2015 19:33:13 +0100 Subject: Authentication --- Plexservice.cpp | 12 ++++++------ Plexservice.h | 1 + plex.cpp | 14 +++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Plexservice.cpp b/Plexservice.cpp index 76de898..a61caec 100644 --- a/Plexservice.cpp +++ b/Plexservice.cpp @@ -39,10 +39,9 @@ std::string Plexservice::GetMyPlexToken() { static bool done; static std::string myToken; - + //todo: cache token in file or db - if(!done || myToken.empty()) { - std::cout << "Get Token" << std::endl; + if(!done) { std::stringstream ss; Poco::Base64Encoder b64(ss); @@ -77,6 +76,7 @@ std::string Plexservice::GetMyPlexToken() plexSession.detachSocket(); } catch (Poco::Exception &exc) { esyslog("[plex]Exception in %s s%", __func__, exc.displayText().c_str() ); + done = true; } } @@ -120,7 +120,7 @@ std::shared_ptr Plexservice::GetSection(std::string section, boo if(section[0]=='/') { // Full URI? uri = section; } else { - uri = Poco::format("%s/%s", m_vUriStack.top(), section);// m_vUriStack.top() + "/" + section; + uri = Poco::format("%s/%s", m_vUriStack.top(), section); } pRequest = CreateRequest(uri); @@ -132,10 +132,10 @@ std::shared_ptr Plexservice::GetSection(std::string section, boo Poco::Net::HTTPResponse response; std::istream &rs = m_pPlexSession->receiveResponse(response); - dsyslog("[plex] URI: %s[s%]", m_pPlexSession->getHost().c_str(), pRequest->getURI().c_str()); + dsyslog("[plex] URI: http://%s:32400%s", m_pPlexSession->getHost().c_str(), pRequest->getURI().c_str()); std::shared_ptr pAllsections(new MediaContainer(&rs, *pServer)); - //Poco::StreamCopier::copyStream(rs, std::cout); + delete pRequest; return pAllsections; diff --git a/Plexservice.h b/Plexservice.h index e96bf16..e2cab4b 100644 --- a/Plexservice.h +++ b/Plexservice.h @@ -65,6 +65,7 @@ private: Poco::Net::HTTPClientSession* GetHttpSession(bool createNew = false); Poco::Net::HTTPRequest* CreateRequest(std::string path); + }; } diff --git a/plex.cpp b/plex.cpp index 710c70f..3707d88 100644 --- a/plex.cpp +++ b/plex.cpp @@ -67,9 +67,9 @@ eOSState cPlexBrowser::ProcessKey(eKeys key) // call standard function state = cOsdMenu::ProcessKey(key); - if (state || key != kNone) { - dsyslog("[plex]%s: state=%d key=%d\n", __FUNCTION__, state, key); - } + //if (state || key != kNone) { + // dsyslog("[plex]%s: state=%d key=%d\n", __FUNCTION__, state, key); + //} switch (state) { case osUnknown: @@ -118,7 +118,7 @@ eOSState cPlexBrowser::ProcessSelected() if(item->IsDir()) { plexclient::Directory* pDir = item->GetAttachedDirectory(); pCont = pService->GetSection(pDir->m_sKey); - //SetTitle(pDir->m_sTitle.c_str()); + //SetTitle(pDir->m_sTitle); CreateMenu(); return osContinue; } @@ -214,9 +214,9 @@ eOSState cPlayMenu::ProcessKey(eKeys key) { eOSState state; - if (key != kNone) { - dsyslog("[plex]%s: key=%d\n", __FUNCTION__, key); - } + //if (key != kNone) { + // dsyslog("[plex]%s: key=%d\n", __FUNCTION__, key); + //} // call standard function state = cOsdMenu::ProcessKey(key); -- cgit v1.2.3