File indexing completed on 2024-12-08 04:32:17

0001 /*
0002     Copyright (C) 2009-2010 Collabora Ltd <info@collabora.co.uk>
0003       @author George Goldberg <george.goldberg@collabora.co.uk>
0004       @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
0005     Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
0006 
0007     This program is free software; you can redistribute it and/or
0008     modify it under the terms of the GNU General Public
0009     License as published by the Free Software Foundation; either
0010     version 2 of the License, or (at your option) any later version.
0011 
0012     This program is distributed in the hope that it will be useful,
0013     but WITHOUT ANY WARRANTY; without even the implied warranty of
0014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015     GNU General Public License for more details.
0016 
0017     You should have received a copy of the GNU Lesser General Public License
0018     along with this program.  If not, see <http://www.gnu.org/licenses/>.
0019 */
0020 #ifndef INVITATIONSRFBSERVER_H
0021 #define INVITATIONSRFBSERVER_H
0022 
0023 #include "rfbserver.h"
0024 
0025 namespace KWallet {
0026     class Wallet;
0027 }
0028 
0029 namespace KDNSSD {
0030     class PublicService;
0031 }
0032 
0033 class InvitationsRfbServer : public RfbServer
0034 {
0035     Q_OBJECT
0036 public:
0037     static InvitationsRfbServer *instance;
0038     static void init();
0039 
0040     const QString& desktopPassword() const;
0041     void setDesktopPassword(const QString&);
0042     const QString& unattendedPassword() const;
0043     void setUnattendedPassword(const QString&);
0044     bool allowUnattendedAccess() const;
0045 
0046 Q_SIGNALS:
0047     void passwordChanged(const QString&);
0048 
0049 public Q_SLOTS:
0050     bool start() override;
0051     void stop() override;
0052     void toggleUnattendedAccess(bool allow);
0053     void openKWallet();
0054     void closeKWallet();
0055     void saveSecuritySettings();
0056 
0057 protected:
0058     InvitationsRfbServer();
0059     ~InvitationsRfbServer() override;
0060     PendingRfbClient* newClient(rfbClientPtr client) override;
0061 
0062 private Q_SLOTS:
0063     void walletOpened(bool);
0064 
0065 private:
0066     KDNSSD::PublicService *m_publicService = nullptr;
0067     bool m_allowUnattendedAccess;
0068     QString m_desktopPassword;
0069     QString m_unattendedPassword;
0070     KWallet::Wallet *m_wallet = nullptr;
0071 
0072     QString readableRandomString(int);
0073     Q_DISABLE_COPY(InvitationsRfbServer)
0074 };
0075 
0076 #endif // INVITATIONSRFBSERVER_H