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

0001 /*
0002     SPDX-FileCopyrightText: 2010-2011 Lamarque Souza <lamarque@kde.org>
0003     SPDX-FileCopyrightText: 2013 Lukas Tinkl <ltinkl@redhat.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #ifndef PLASMA_NM_MOBILE_CONNECTION_WIZARD_H
0009 #define PLASMA_NM_MOBILE_CONNECTION_WIZARD_H
0010 
0011 #include "plasmanm_editor_export.h"
0012 
0013 #include <QLabel>
0014 #include <QListWidget>
0015 #include <QRadioButton>
0016 #include <QWizardPage>
0017 
0018 #include <KComboBox>
0019 #include <KLineEdit>
0020 
0021 #include <NetworkManagerQt/ConnectionSettings>
0022 #include <NetworkManagerQt/Manager>
0023 
0024 #include "mobileproviders.h"
0025 
0026 class PLASMANM_EDITOR_EXPORT MobileConnectionWizard : public QWizard
0027 {
0028     Q_OBJECT
0029 public:
0030     /*
0031      * Do not use NetworkManager::ConnectionSettings::Bluetooth here, use either NetworkManager::ConnectionSettings::Gsm
0032      * or NetworkManager::ConnectionSettings::Cdma.
0033      */
0034     explicit MobileConnectionWizard(NetworkManager::ConnectionSettings::ConnectionType connectionType = NetworkManager::ConnectionSettings::Unknown,
0035                                     QWidget *parent = nullptr);
0036     ~MobileConnectionWizard() override;
0037 
0038     /*
0039      * Returns the information to configure one connection from the last wizard run.
0040      * The format is:
0041      * for GSM connections: provider's name + QList of Gsm NetworkIds for that provider (can be an empty QList) + QMap with apn information
0042      * where apn information is: dial number + apn + apn name (optional) + username (optional) + password (optional) + QList of name servers (optional)
0043      *
0044      * for CDMA connections: provider's name + QMap with cdma information.
0045      * where cdma information is: name (optional) + username (optional) + password (optional) + list of sids (optional)
0046      */
0047     QVariantList args();
0048 
0049     NetworkManager::ConnectionSettings::ConnectionType type() const
0050     {
0051         return mType;
0052     }
0053     MobileProviders::ErrorCodes getError();
0054 
0055 private Q_SLOTS:
0056     void introDeviceAdded(const QString &uni);
0057     void introDeviceRemoved(const QString &uni);
0058     void introStatusChanged(NetworkManager::Status);
0059     void slotEnablePlanEditBox(int index);
0060     void slotEnableProviderEdit(bool enable);
0061     void slotCheckProviderEdit();
0062     void slotCheckProviderList();
0063 
0064 private:
0065     QWizardPage *createIntroPage();
0066     QWizardPage *createCountryPage();
0067     QWizardPage *createProvidersPage();
0068     QWizardPage *createPlansPage();
0069     QWizardPage *createConfirmPage();
0070     void initializePage(int id) override;
0071     int nextId() const override;
0072 
0073     MobileProviders *mProviders;
0074     QString country;
0075     QString provider;
0076     QString apn;
0077     NetworkManager::ConnectionSettings::ConnectionType mType;
0078     bool mInitialMethodType;
0079 
0080     // Intro page
0081     KComboBox *mDeviceComboBox = nullptr;
0082     void introAddInitialDevices();
0083     void introRemoveAllDevices();
0084     void introAddDevice(const NetworkManager::Device::Ptr &device);
0085 
0086     // Country page
0087     QListWidget *mCountryList = nullptr;
0088 
0089     // Providers page
0090     QListWidget *mProvidersList = nullptr;
0091     QRadioButton *radioAutoProvider = nullptr;
0092     QRadioButton *radioManualProvider = nullptr;
0093     KLineEdit *lineEditProvider = nullptr;
0094 
0095     // Plan page
0096     KComboBox *mPlanComboBox = nullptr;
0097     KLineEdit *userApn = nullptr;
0098 
0099     // Confirm page
0100     QLabel *labelProvider = nullptr;
0101     QLabel *labelPlanLabel = nullptr;
0102     QLabel *labelPlan = nullptr;
0103     QLabel *labelApn = nullptr;
0104 };
0105 #endif // PLASMA_NM_MOBILE_CONNECTION_WIZARD_H