File indexing completed on 2024-06-23 05:14:14
0001 /* -*- mode: c++; c-basic-offset:4 -*- 0002 uiserver/uiserver_p.h 0003 0004 This file is part of Kleopatra, the KDE keymanager 0005 SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #pragma once 0010 0011 #include "uiserver.h" 0012 0013 #include "assuancommand.h" 0014 #include "assuanserverconnection.h" 0015 0016 #include <utils/wsastarter.h> 0017 0018 #include <QFile> 0019 #include <QTcpServer> 0020 0021 #include <assuan.h> 0022 0023 #include <algorithm> 0024 #include <memory> 0025 #include <vector> 0026 0027 namespace 0028 { 0029 template<typename Ex> 0030 void throw_(const QString &message) 0031 { 0032 throw Ex(message.toUtf8().constData()); 0033 } 0034 } 0035 0036 namespace Kleo 0037 { 0038 0039 class UiServer::Private : public QTcpServer 0040 { 0041 Q_OBJECT 0042 friend class ::Kleo::UiServer; 0043 UiServer *const q; 0044 0045 public: 0046 explicit Private(UiServer *qq); 0047 static bool isStaleAssuanSocket(const QString &socketName); 0048 0049 private: 0050 void makeListeningSocket(); 0051 // platform-specific creation impl for makeListeningSocket(): 0052 void doMakeListeningSocket(const QByteArray &encodedFileName); 0053 QString makeFileName(const QString &hint = QString()) const; 0054 void ensureDirectoryExists(const QString &path) const; 0055 static QString systemErrorString(); 0056 0057 protected: 0058 void incomingConnection(qintptr fd) override; 0059 0060 private Q_SLOTS: 0061 void slotConnectionClosed(Kleo::AssuanServerConnection *conn); 0062 0063 private: 0064 QFile file; 0065 std::vector<std::shared_ptr<AssuanCommandFactory>> factories; 0066 std::vector<std::shared_ptr<AssuanServerConnection>> connections; 0067 QString suggestedSocketName; 0068 QString actualSocketName; 0069 assuan_sock_nonce_t nonce; 0070 const WSAStarter _wsastarter; 0071 bool cryptoCommandsEnabled; 0072 }; 0073 0074 }