Warning, file /pim/kleopatra/src/selftest/uiservercheck.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* -*- mode: c++; c-basic-offset:4 -*- 0002 selftest/uiservercheck.cpp 0003 0004 This file is part of Kleopatra, the KDE keymanager 0005 SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #include <config-kleopatra.h> 0011 0012 #include "uiservercheck.h" 0013 0014 #include "implementation_p.h" 0015 0016 #include <libkleopatraclient/core/command.h> 0017 0018 #include <QCoreApplication> 0019 #include <QEventLoop> 0020 #include <QTextDocument> // for Qt::escape 0021 0022 #include <KLocalizedString> 0023 0024 using namespace Kleo; 0025 using namespace Kleo::_detail; 0026 0027 namespace 0028 { 0029 0030 class UiServerCheck : public SelfTestImplementation 0031 { 0032 public: 0033 explicit UiServerCheck() 0034 : SelfTestImplementation(i18nc("@title", "UiServer Connectivity")) 0035 { 0036 runTest(); 0037 } 0038 0039 void runTest() 0040 { 0041 KleopatraClientCopy::Command command; 0042 0043 { 0044 QEventLoop loop; 0045 loop.connect(&command, SIGNAL(finished()), SLOT(quit())); 0046 QMetaObject::invokeMethod(&command, "start", Qt::QueuedConnection); 0047 loop.exec(); 0048 } 0049 0050 if (command.error()) { 0051 m_passed = false; 0052 m_error = i18n("not reachable"); 0053 m_explanation = xi18nc("@info", "Could not connect to UiServer: <message>%1</message>", command.errorString().toHtmlEscaped()); 0054 m_proposedFix = xi18nc("@info", 0055 "<para>Check that your firewall is not set to block local connections " 0056 "(allow connections to <resource>localhost</resource> or <resource>127.0.0.1</resource>).</para>"); 0057 } else if (command.serverPid() != QCoreApplication::applicationPid()) { 0058 m_passed = false; 0059 m_error = i18n("multiple instances"); 0060 m_explanation = xi18nc("@info", "It seems another <application>Kleopatra</application> is running (with process-id %1)", command.serverPid()); 0061 m_proposedFix = xi18nc("@info", "Quit any other running instances of <application>Kleopatra</application>."); 0062 } else { 0063 m_passed = true; 0064 } 0065 } 0066 }; 0067 } 0068 0069 std::shared_ptr<SelfTest> Kleo::makeUiServerConnectivitySelfTest() 0070 { 0071 return std::shared_ptr<SelfTest>(new UiServerCheck); 0072 }