Skip to content

Commit 970a29a

Browse files
committed
Change default port to 9090
1 parent 395f447 commit 970a29a

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

hardware/Kodi.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ CKodiNode::CKodiNode(boost::asio::io_service *pIos, const int pHwdID, const int
131131
{
132132
m_stoprequested = false;
133133
m_Busy = false;
134+
m_Stoppable = false;
134135

135136
m_Ios = pIos;
136137
m_HwdID = pHwdID;
@@ -256,6 +257,9 @@ void CKodiNode::handleMessage(std::string& pMessage)
256257
{
257258
if ((root.isMember("result") && (root.isMember("id"))))
258259
{
260+
bool bCanShutdown = false;
261+
bool bCanHibernate = false;
262+
bool bCanSuspend = false;
259263
int iMessageID = root["id"].asInt();
260264
switch (iMessageID)
261265
{
@@ -335,9 +339,6 @@ void CKodiNode::handleMessage(std::string& pMessage)
335339
case 4: //Shutdown details response
336340
{
337341
std::string sAction = "Nothing";
338-
bool bCanShutdown = false;
339-
bool bCanHibernate = false;
340-
bool bCanSuspend = false;
341342
if (root["result"].isMember("canshutdown"))
342343
{
343344
bCanShutdown = root["result"]["canshutdown"].asBool();
@@ -375,6 +376,22 @@ void CKodiNode::handleMessage(std::string& pMessage)
375376
if (root["result"] != "OK")
376377
_log.Log(LOG_ERROR, "Kodi: (%s) Send Command Failed: '%s'", m_Name.c_str(), root["result"].asCString());
377378
break;
379+
case 7: //Can Shutdown response (after connect)
380+
handleWrite(std::string("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":5}"));
381+
if (root["result"].isMember("canshutdown"))
382+
{
383+
bCanShutdown = root["result"]["canshutdown"].asBool();
384+
}
385+
if (root["result"].isMember("canhibernate"))
386+
{
387+
bCanHibernate = root["result"]["canhibernate"].asBool();
388+
}
389+
if (root["result"].isMember("cansuspend"))
390+
{
391+
bCanSuspend = root["result"]["cansuspend"].asBool();
392+
}
393+
m_Stoppable = (bCanShutdown || bCanHibernate || bCanSuspend);
394+
break;
378395
default:
379396
_log.Log(LOG_ERROR, "Kodi: (%s) Message error, unknown ID found: '%s'", m_Name.c_str(), pMessage.c_str());
380397
}
@@ -445,7 +462,7 @@ void CKodiNode::handleConnect()
445462
}
446463
m_Socket->async_read_some(boost::asio::buffer(m_Buffer, sizeof m_Buffer),
447464
boost::bind(&CKodiNode::handleRead, shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
448-
handleWrite(std::string("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":5}"));
465+
handleWrite(std::string("{\"jsonrpc\":\"2.0\",\"method\":\"System.GetProperties\",\"params\":{\"properties\":[\"canhibernate\",\"cansuspend\",\"canshutdown\"]},\"id\":7}"));
449466
}
450467
else
451468
{
@@ -643,7 +660,7 @@ bool CKodiNode::SendShutdown()
643660
std::string sMessage = "{\"jsonrpc\":\"2.0\",\"method\":\"System.GetProperties\",\"params\":{\"properties\":[\"canhibernate\",\"cansuspend\",\"canshutdown\"]},\"id\":4}";
644661
handleWrite(sMessage);
645662

646-
return false;
663+
return m_Stoppable;
647664
}
648665

649666
std::vector<boost::shared_ptr<CKodiNode> > CKodi::m_pNodes;

hardware/Kodi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class CKodiNode : public boost::enable_shared_from_this<CKodiNode>
8383
protected:
8484
bool m_stoprequested;
8585
bool m_Busy;
86+
bool m_Stoppable;
8687

8788
private:
8889
void handleConnect();

www/app/HardwareController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ define(['app'], function (app) {
13531353
$('#updelclr #nodedelete').attr("class", "btnstyle3-dis");
13541354
$("#hardwarecontent #kodinodeparamstable #nodename").val("");
13551355
$("#hardwarecontent #kodinodeparamstable #nodeip").val("");
1356-
$("#hardwarecontent #kodinodeparamstable #nodeport").val("8080");
1356+
$("#hardwarecontent #kodinodeparamstable #nodeport").val("9090");
13571357

13581358
var oTable = $('#kodinodestable').dataTable();
13591359
oTable.fnClearTable();
@@ -1388,7 +1388,7 @@ define(['app'], function (app) {
13881388
$('#updelclr #nodeupdate').attr("class", "btnstyle3-dis");
13891389
$("#hardwarecontent #kodinodeparamstable #nodename").val("");
13901390
$("#hardwarecontent #kodinodeparamstable #nodeip").val("");
1391-
$("#hardwarecontent #kodinodeparamstable #nodeport").val("8080");
1391+
$("#hardwarecontent #kodinodeparamstable #nodeport").val("9090");
13921392
}
13931393
else {
13941394
var oTable = $('#kodinodestable').dataTable();

www/views/hardware.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ <h1 data-i18n="Nodes">Nodes</h1>
412412
</tr>
413413
<tr>
414414
<td align="right" style="width:110px"><label for="nodeip"><span data-i18n="IP Address">IP Address</span>:</label></td>
415-
<td><input type="text" id="nodeip" style="width: 350px; padding: .2em;" class="text ui-widget-content ui-corner-all" />&nbsp;&nbsp;(<span data-i18n="Username"/>:<span data-i18n="Password"/>@<span data-i18n="IP Address" />)</td>
415+
<td><input type="text" id="nodeip" style="width: 350px; padding: .2em;" class="text ui-widget-content ui-corner-all" /></td>
416416
</tr>
417417
<tr>
418418
<td align="right" style="width:110px"><label for="nodetimeout"><span data-i18n="Port">Port</span>:</label></td>

0 commit comments

Comments
 (0)