File indexing completed on 2024-07-14 12:42:07

0001 /*
0002     SPDX-FileCopyrightText: 2010-2012 Lamarque Souza <lamarque@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #ifndef PLASMA_NM_MOBILE_PROVIDERS_H
0008 #define PLASMA_NM_MOBILE_PROVIDERS_H
0009 
0010 #include <QDomDocument>
0011 #include <QHash>
0012 #include <QStringList>
0013 #include <QVariantMap>
0014 
0015 #include <NetworkManagerQt/ConnectionSettings>
0016 
0017 struct ProviderData {
0018     QStringList mccmncs;
0019     QString name;
0020 };
0021 
0022 class Q_DECL_EXPORT MobileProviders
0023 {
0024 public:
0025     static const QString ProvidersFile;
0026 
0027     enum ErrorCodes { Success, CountryCodesMissing, ProvidersMissing, ProvidersIsNull, ProvidersWrongFormat, ProvidersFormatNotSupported };
0028 
0029     MobileProviders();
0030     ~MobileProviders();
0031 
0032     QStringList getCountryList() const;
0033     QString countryFromLocale() const;
0034     QString getCountryName(const QString &key) const
0035     {
0036         return mCountries.value(key);
0037     }
0038     QStringList getProvidersList(QString country, NetworkManager::ConnectionSettings::ConnectionType type);
0039     QStringList getApns(const QString &provider);
0040     QStringList getNetworkIds(const QString &provider);
0041     QVariantMap getApnInfo(const QString &apn);
0042     QVariantMap getCdmaInfo(const QString &provider);
0043     QStringList getProvidersFromMCCMNC(const QString &mccmnc);
0044     QString getGsmNumber() const
0045     {
0046         return QStringLiteral("*99#");
0047     }
0048     QString getCdmaNumber() const
0049     {
0050         return QStringLiteral("#777");
0051     }
0052     inline ErrorCodes getError()
0053     {
0054         return mError;
0055     }
0056 
0057 private:
0058     ProviderData parseProvider(const QDomNode &providerNode);
0059 
0060     QHash<QString, QString> mCountries;
0061     QHash<QString, QString> mMccMncToName;
0062     QMap<QString, QDomNode> mProvidersGsm;
0063     QMap<QString, QDomNode> mProvidersCdma;
0064     QMap<QString, QDomNode> mApns;
0065     QStringList mNetworkIds;
0066     QDomDocument mDocProviders;
0067     QDomElement docElement;
0068     ErrorCodes mError;
0069     QString getNameByLocale(const QMap<QString, QString> &names) const;
0070 };
0071 
0072 #endif // PLASMA_NM_MOBILE_PROVIDERS_H