Ejemplo n.º 1
0
bool MythSocket::Announce(const QStringList &new_announce)
{
    if (!m_isValidated)
    {
        LOG(VB_GENERAL, LOG_ERR, LOC +
            "refusing to announce unvalidated socket");
        return false;
    }

    if (m_isAnnounced)
    {
        LOG(VB_GENERAL, LOG_ERR, LOC + "refusing to re-announce socket");
        return false;
    }

    WriteStringList(new_announce);

    QStringList tmplist;
    if (!ReadStringList(tmplist, true))
    {
        LOG(VB_GENERAL, LOG_ERR, LOC +
            QString("\n\t\t\tCould not read string list from server %1:%2")
            .arg(m_tcpSocket->peerAddress().toString())
            .arg(m_tcpSocket->peerPort()));
        m_announce.clear();
        m_isAnnounced = false;
    }
    else
    {
        m_announce = new_announce;
        m_isAnnounced = true;
    }

    return m_isAnnounced;
}
Ejemplo n.º 2
0
bool MythSocket::SendReceiveStringList(
    QStringList &strlist, uint min_reply_length, uint timeoutMS)
{
    if (!WriteStringList(strlist))
    {
        LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to send command.");
        return false;
    }

    if (!ReadStringList(strlist, timeoutMS))
    {
        LOG(VB_GENERAL, LOG_ERR, LOC + "No response.");
        return false;
    }

    if (min_reply_length && ((uint)strlist.size() < min_reply_length))
    {
        LOG(VB_GENERAL, LOG_ERR, LOC + "Response too short.");
        return false;
    }

    if (!strlist.empty() && strlist[0] == "BACKEND_MESSAGE")
    {
        LOG(VB_GENERAL, LOG_ERR, LOC + "Got MythEvent on non-event socket");
        return false;
    }

    return true;
}
Ejemplo n.º 3
0
void CCSVWriter::Write ( const CCachedLogInfo& cache
                       , const TFileName& fileName)
{
	std::ofstream authors ((fileName + _T(".authors.csv")).c_str());
	WriteStringList (authors, cache.GetLogInfo().GetAuthors());
	std::ofstream userRevPropNames ((fileName + _T(".revpropnames.csv")).c_str());
	WriteStringList (userRevPropNames, cache.GetLogInfo().GetUserRevProps());
	std::ofstream paths ((fileName + _T(".paths.csv")).c_str());
	WritePathList (paths, cache.GetLogInfo().GetPaths());

	std::ofstream changes ((fileName + _T(".changes.csv")).c_str());
	WriteChanges (changes, cache);
	std::ofstream merges ((fileName + _T(".merges.csv")).c_str());
	WriteMerges (merges, cache);
	std::ofstream userRevProps ((fileName + _T(".userrevprops.csv")).c_str());
	WriteRevProps (userRevProps, cache);

	std::ofstream revisions ((fileName + _T(".revisions.csv")).c_str());
	WriteRevisions (revisions, cache);
	std::ofstream skipranges ((fileName + _T(".skipranges.csv")).c_str());
    WriteSkipRanges (skipranges, cache);
}
Ejemplo n.º 4
0
bool MythSocket::Validate(uint timeout_ms, bool error_dialog_desired)
{
    if (m_isValidated)
        return true;

    QStringList strlist(QString("MYTH_PROTO_VERSION %1 %2")
                        .arg(MYTH_PROTO_VERSION).arg(MYTH_PROTO_TOKEN));

    WriteStringList(strlist);

    if (!ReadStringList(strlist, timeout_ms) || strlist.empty())
    {
        LOG(VB_GENERAL, LOG_ERR, "Protocol version check failure.\n\t\t\t"
                "The response to MYTH_PROTO_VERSION was empty.\n\t\t\t"
                "This happens when the backend is too busy to respond,\n\t\t\t"
                "or has deadlocked due to bugs or hardware failure.");
        return m_isValidated;
    }

    if (strlist[0] == "REJECT" && (strlist.size() >= 2))
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("Protocol version or token mismatch "
                    "(frontend=%1/%2,backend=%3/\?\?)\n")
            .arg(MYTH_PROTO_VERSION).arg(MYTH_PROTO_TOKEN).arg(strlist[1]));

        QObject *GUIcontext = gCoreContext->GetGUIObject();
        if (error_dialog_desired && GUIcontext)
        {
            QStringList list(strlist[1]);
            QCoreApplication::postEvent(
                GUIcontext, new MythEvent("VERSION_MISMATCH", list));
        }
    }
    else if (strlist[0] == "ACCEPT")
    {
        LOG(VB_GENERAL, LOG_NOTICE, QString("Using protocol version %1")
            .arg(MYTH_PROTO_VERSION));
        m_isValidated = true;
    }
    else
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("Unexpected response to MYTH_PROTO_VERSION: %1")
            .arg(strlist[0]));
    }

    return m_isValidated;
}