File indexing completed on 2024-07-21 05:00:21

0001 /*
0002     SPDX-FileCopyrightText: 2016 Jan Grulich <jgrulich@redhat.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_KCM_H
0008 #define PLASMA_NM_KCM_H
0009 
0010 #include "connectioneditortabwidget.h"
0011 #include "handler.h"
0012 
0013 #include <KCModule>
0014 #include <ui_kcm.h>
0015 
0016 class KMessageWidget;
0017 
0018 class KCMNetworkmanagement : public KCModule
0019 {
0020     Q_OBJECT
0021 public:
0022     explicit KCMNetworkmanagement(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args);
0023     ~KCMNetworkmanagement() override;
0024 
0025     Q_INVOKABLE void onRequestCreateConnection(int connectionType, const QString &vpnType, const QString &specificType, bool shared);
0026     Q_INVOKABLE void onSelectedConnectionChanged(const QString &connectionPath);
0027     Q_INVOKABLE void onRequestExportConnection(const QString &connectionPath);
0028     Q_INVOKABLE void onRequestToChangeConnection(const QString &connectionName, const QString &connectionPath);
0029 
0030 public Q_SLOTS:
0031     void defaults() override;
0032     void load() override;
0033     void save() override;
0034 
0035 private Q_SLOTS:
0036     void onConnectionAdded(const QString &connection);
0037 
0038 private:
0039     struct ImportResult {
0040         bool success;
0041         QString errorMessage;
0042 
0043         static ImportResult pass();
0044         static ImportResult fail(const QString &message);
0045     };
0046 
0047     void addConnection(const NetworkManager::ConnectionSettings::Ptr &connectionSettings);
0048     [[nodiscard]] KCMNetworkmanagement::ImportResult importVpn();
0049     void kcmChanged(bool kcmChanged);
0050     void loadConnectionSettings(const NetworkManager::ConnectionSettings::Ptr &connectionSettings);
0051     void resetSelection();
0052 
0053     QString m_currentConnectionPath;
0054     QString m_createdConnectionUuid;
0055     Handler *const m_handler;
0056     ConnectionEditorTabWidget *m_tabWidget = nullptr;
0057     QTimer *m_timer = nullptr;
0058     KMessageWidget *m_errorWidget;
0059     Ui::KCMForm *const m_ui;
0060 };
0061 
0062 #endif