Skip to content
This repository has been archived by the owner on Apr 15, 2023. It is now read-only.

Commit

Permalink
[tvheadend] check the response from the auth command properly. displa…
Browse files Browse the repository at this point in the history
…y error message when an error is detected. closes #131
  • Loading branch information
opdenkamp authored and zeroniak committed Feb 19, 2013
1 parent c4448d3 commit 128db85
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions addons/pvr.hts/src/HTSPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ void CHTSPConnection::ReadResult(htsmsg_t *m, CHTSResult &result, const char* st
XBMC->Log(LOG_ERROR, "%s - '%s' failed - access denied", __FUNCTION__, strAction);
else
XBMC->Log(LOG_ERROR, "%s - command failed - access denied", __FUNCTION__);
XBMC->QueueNotification(QUEUE_ERROR, "Access denied");
result.status = PVR_ERROR_REJECTED;
}

Expand All @@ -396,6 +397,7 @@ void CHTSPConnection::ReadResult(htsmsg_t *m, CHTSResult &result, const char* st
XBMC->Log(LOG_ERROR, "%s - '%s' failed - %s", __FUNCTION__, strAction, strError.c_str());
else
XBMC->Log(LOG_ERROR, "%s - command failed - %s", __FUNCTION__, strError.c_str());
XBMC->QueueNotification(QUEUE_ERROR, "Command failed: %s", strError.c_str());
result.status = PVR_ERROR_REJECTED;
}
}
Expand Down Expand Up @@ -527,19 +529,34 @@ bool CHTSPConnection::Auth(void)
if (!TransmitMessage(m))
{
XBMC->Log(LOG_ERROR, "CHTSPConnection - %s - failed to transmit auth command", __FUNCTION__);
XBMC->QueueNotification(QUEUE_ERROR, "Access denied");
return false;
}

m = ReadMessage(g_iConnectTimeout * 1000, g_iConnectTimeout * 1000);
if (m == NULL || m->hm_data == NULL)
CHTSResult result;
result.message = ReadMessage(g_iConnectTimeout * 1000, g_iConnectTimeout * 1000);
if (result.message == NULL)
{
if (m)
htsmsg_destroy(m);
XBMC->Log(LOG_ERROR, "CHTSPConnection - %s - failed to get a reply from the auth command", __FUNCTION__);
XBMC->QueueNotification(QUEUE_ERROR, "Access denied");
return false;
}
else if (result.NoAccess())
{
// access denied
XBMC->Log(LOG_ERROR, "%s - auth failed - access denied", __FUNCTION__);
XBMC->QueueNotification(QUEUE_ERROR, "Access denied");
return false;
}
else if (result.IsError())
{
// server reported an error
string strError = result.GetErrorMessage();
XBMC->Log(LOG_ERROR, "%s - auth failed - %s", __FUNCTION__, strError.c_str());
XBMC->QueueNotification(QUEUE_ERROR, "Access denied");
return false;
}

htsmsg_destroy(m);
return true;
}

Expand Down

0 comments on commit 128db85

Please sign in to comment.