bool CScrobbler::HandleSubmission(CStdString &strResponse) { if (strResponse.IsEmpty()) return false; std::vector<CStdString> vecTokens; CUtil::Tokenize(strResponse, vecTokens, " \n\r"); if (vecTokens[0] == "OK") { CLog::Log(LOGDEBUG, "%s: Submission succeeded!", m_strLogPrefix.c_str()); ClearErrorState(); return true; } else if (vecTokens[0] == "BADSESSION") { CLog::Log(LOGDEBUG, "%s: Submission failed! "\ "REASON: Bad session. Forcing new handshake.", m_strLogPrefix.c_str()); ClearSession(); } else if (vecTokens[0] == "FAILED") { CLog::Log(LOGDEBUG, "%s: Submission failed! "\ "REASON: %s", m_strLogPrefix.c_str(), strResponse.c_str()); } else CLog::Log(LOGDEBUG, "%s: Submission failed! "\ "REASON: Unspecified.", m_strLogPrefix.c_str()); return false; }
//------------------------------------------------------------------------------ void FBasicTokenParser::ResetParser(TCHAR const* SourceBuffer, int32 StartingLineNumber) { Input = SourceBuffer; InputLen = FCString::Strlen(Input); InputPos = 0; PrevPos = 0; PrevLine = 1; InputLine = StartingLineNumber; ClearCachedComment(); ClearErrorState(); }
bool CScrobbler::HandleHandshake(CStdString &strResponse) { if (strResponse.IsEmpty()) return false; std::vector<CStdString> vecTokens; CUtil::Tokenize(strResponse, vecTokens, " \n\r"); if (vecTokens[0] == "OK") { if (vecTokens.size() >= 4) { m_strSessionID = vecTokens[1]; m_strNowPlayingURL = vecTokens[2]; m_strSubmissionURL = vecTokens[3]; CLog::Log(LOGDEBUG, "%s: Handshake succeeded!", m_strLogPrefix.c_str()); CLog::Log(LOGDEBUG, "%s: SessionID is %s", m_strLogPrefix.c_str(), m_strSessionID.c_str()); CLog::Log(LOGDEBUG, "%s: NP URL is %s", m_strLogPrefix.c_str(), m_strNowPlayingURL.c_str()); CLog::Log(LOGDEBUG, "%s: Submit URL is %s", m_strLogPrefix.c_str(), m_strSubmissionURL.c_str()); ClearErrorState(); return true; } CLog::Log(LOGERROR, "%s: Handshake failed! Received malformed "\ "reply.", m_strLogPrefix.c_str()); } else if (vecTokens[0] == "BANNED") { CLog::Log(LOGERROR, "%s: Handshake failed! Client is banned! "\ "Disabling submissions. Subsequent scrobbles will be cached. "\ "Please update your client to the newest version. ", m_strLogPrefix.c_str()); if (m_failedHandshakeDelay == 0) { NotifyUser(SCROBBLER_USER_ERROR_BANNED); } } else if (vecTokens[0] == "BADAUTH") { CLog::Log(LOGERROR, "%s: Handshake failed! Authentication failed! "\ "Disabling submissions. Subsequent scrobbles will be cached. "\ "Please enter the correct credentials to re-enable scrobbling. ", m_strLogPrefix.c_str()); if (m_failedHandshakeDelay == 0) { NotifyUser(SCROBBLER_USER_ERROR_BADAUTH); } } else if (vecTokens[0] == "BADTIME") { CLog::Log(LOGDEBUG, "%s: Handshake failed! Timestamp is invalid! "\ "Disabling submissions. Subsequent scrobbles will be cached. "\ "Please correct the system time and restart the application. ", m_strLogPrefix.c_str()); } else if (vecTokens[0] == "FAILED") { CLog::Log(LOGDEBUG, "%s: Handshake failed! REASON: %s! ", m_strLogPrefix.c_str(), strResponse.c_str()); } else CLog::Log(LOGDEBUG, "%s: Handshake failed! REASON: Unspecified!", m_strLogPrefix.c_str()); return false; }
void CScrobbler::ResetState() { ClearSession(); ClearSubmissionState(); ClearErrorState(); }