#include "search_control.h"
#include "common_messages.h"

bool NRTYServer::EnableSearch() {
    SendGlobalMessage<TMessagePessimizeDocfetcherBan>(false);
    const auto& result = SendGlobalMessage<TMessageSearchServerControl>(TMessageSearchServerControl::sscaStart);
    return result.IsRunning();
}

bool NRTYServer::DisableSearch() {
    SendGlobalMessage<TMessagePessimizeDocfetcherBan>(false);
    const auto& result = SendGlobalMessage<TMessageSearchServerControl>(TMessageSearchServerControl::sscaStop);
    return result.IsRunning();
}

bool NRTYServer::CheckSearch() {
    const auto& result = SendGlobalMessage<TMessageSearchServerControl>();
    return result.IsRunning();
}

bool NRTYServer::BanSearch() {
    const bool result = SendGlobalMessage<TMessageSearchServerControl>(TMessageSearchServerControl::sscaStop).IsRunning();
    SendGlobalMessage<TMessagePessimizeDocfetcherBan>(true);
    return result;
}
