File indexing completed on 2024-07-21 07:58:07

0001 /*
0002     SPDX-FileCopyrightText: 2019 Bruce Anderson <banderson19com@san.rr.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef PLASMA_NM_WIREGUARD_PEER_WIDGET_H
0008 #define PLASMA_NM_WIREGUARD_PEER_WIDGET_H
0009 
0010 #include "plasmanm_editor_export.h"
0011 
0012 #include <QDialog>
0013 
0014 #include "settingwidget.h"
0015 #include <NetworkManagerQt/WireguardSetting>
0016 
0017 class PLASMANM_EDITOR_EXPORT WireGuardPeerWidget : public QDialog
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     explicit WireGuardPeerWidget(const QVariantMap &peerData, QWidget *parent = nullptr, Qt::WindowFlags f = {});
0023     ~WireGuardPeerWidget() override;
0024 
0025     QVariantMap setting() const;
0026     bool isValid();
0027     enum EndPointValid { BothValid, AddressValid, PortValid, BothInvalid };
0028     static WireGuardPeerWidget::EndPointValid isEndpointValid(QString &, QString &);
0029 
0030 Q_SIGNALS:
0031     void notifyValid();
0032 
0033 private:
0034     void setBackground(QWidget *w, bool result) const;
0035     void checkPublicKeyValid();
0036     void checkPresharedKeyValid();
0037     void checkAllowedIpsValid();
0038     void checkEndpointValid();
0039     void updatePeerWidgets();
0040     void saveKeepAlive();
0041     void saveKeyFlags();
0042     void slotWidgetChanged();
0043 
0044     class Private;
0045     Private *const d;
0046 };
0047 
0048 #endif // PLASMA_NM_WIREGUARD_PEER_WIDGET_H