/* -*- mode: c++; c-basic-offset:4 -*- selftest/uiservercheck.cpp This file is part of Kleopatra, the KDE keymanager SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB SPDX-License-Identifier: GPL-2.0-or-later */ #include #include "uiservercheck.h" #include "implementation_p.h" #include #include // for Qt::escape #include #include #include using namespace Kleo; using namespace Kleo::_detail; namespace { class UiServerCheck : public SelfTestImplementation { public: explicit UiServerCheck() : SelfTestImplementation(i18nc("@title", "UiServer Connectivity")) { runTest(); } void runTest() { KleopatraClientCopy::Command command; { QEventLoop loop; loop.connect(&command, SIGNAL(finished()), SLOT(quit())); QMetaObject::invokeMethod(&command, "start", Qt::QueuedConnection); loop.exec(); } if (command.error()) { m_passed = false; m_error = i18n("not reachable"); m_explanation = xi18nc("@info", "Could not connect to UiServer: %1", command.errorString().toHtmlEscaped()); m_proposedFix = xi18nc("@info", "Check that your firewall is not set to block local connections " "(allow connections to localhost or 127.0.0.1)."); } else if (command.serverPid() != QCoreApplication::applicationPid()) { m_passed = false; m_error = i18n("multiple instances"); m_explanation = xi18nc("@info", "It seems another Kleopatra is running (with process-id %1)", command.serverPid()); m_proposedFix = xi18nc("@info", "Quit any other running instances of Kleopatra."); } else { m_passed = true; } } }; } std::shared_ptr Kleo::makeUiServerConnectivitySelfTest() { return std::shared_ptr(new UiServerCheck); }