Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 58485bd2 authored by Martin Kacej's avatar Martin Kacej

mobile networks further basic interface

parent 1fbdb49b
......@@ -5,6 +5,8 @@ set (celluralsettings_SRCS celluralsettings.cpp)
add_library(kcm_mobile_cellural MODULE ${celluralsettings_SRCS})
target_link_libraries(kcm_mobile_cellural
KF5::NetworkManagerQt
KF5::ModemManagerQt
Qt5::DBus
Qt5::Gui
Qt5::Quick
......
......@@ -23,6 +23,17 @@
#include <KLocalizedString>
#include <KAboutData>
#include <NetworkManagerQt/Connection>
#include <NetworkManagerQt/ConnectionSettings>
#include <NetworkManagerQt/GsmSetting>
#include <NetworkManagerQt/CdmaSetting>
#if WITH_MODEMMANAGER_SUPPORT
#include <ModemManagerQt/Manager>
#include <ModemManagerQt/GenericTypes>
#include <ModemManagerQt/ModemDevice>
#endif
K_PLUGIN_FACTORY_WITH_JSON(CelluralSettingsFactory, "mobile_cellural.json", registerPlugin<CelluralSettings>();)
CelluralSettings::CelluralSettings(QObject* parent, const QVariantList& args) : KQuickAddons::ConfigModule(parent, args)
......@@ -31,6 +42,9 @@ CelluralSettings::CelluralSettings(QObject* parent, const QVariantList& args) :
"0.1", QString(), KAboutLicense::GPL);
about->addAuthor(i18n("Martin Kacej"), QString(), "m.kacej@atlas.sk");
setAboutData(about);
ModemManager::scanDevices();
this->getModemDevice();
this->setupMobileNetwork();
}
CelluralSettings::~CelluralSettings()
......@@ -48,4 +62,49 @@ void CelluralSettings::setMobileDataActive(bool active)
emit mobileDataActiveChanged(m_mobileDataActive);
}
QString CelluralSettings::getModemDevice()
{
ModemManager::ModemDevice::List list = ModemManager::modemDevices();
if (list.length() == 0)
return QString();
ModemManager::ModemDevice::Ptr device;
foreach (const ModemManager::ModemDevice::Ptr &md, list) {
ModemManager::Modem::Ptr m = md->modemInterface();
if (!m->isEnabled())
continue;
// TODO powerState ???
if (m->state() <= MM_MODEM_STATE_REGISTERED)
continue; // needs inspection
if (m->accessTechnologies() <= MM_MODEM_ACCESS_TECHNOLOGY_GSM)
continue;
if (m->currentCapabilities() <= MM_MODEM_CAPABILITY_GSM_UMTS)
continue;
device = md;
}
if (device) {
qWarning() << device->uni() << device->modemInterface()->uni();
return device->uni();
}
return QString();
}
void CelluralSettings::setupMobileNetwork()
{
ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(getModemDevice());
if (!modem)
return;
if (modem->bearers().count() == 0) {
qWarning() << "No bearers in modem found";
} else {
foreach (const ModemManager::Bearer::Ptr &p, modem->bearers()) {
qWarning() << p->properties();
}
}
}
QString CelluralSettings::getAPN()
{
return "some.ap.placeholder.com";
}
#include "celluralsettings.moc"
......@@ -33,6 +33,9 @@ public:
bool mobileDataActive();
void setMobileDataActive(bool active);
Q_SIGNAL void mobileDataActiveChanged(bool active);
Q_INVOKABLE QString getModemDevice();
void setupMobileNetwork();
Q_INVOKABLE QString getAPN();
private:
bool m_mobileDataActive;
......
......@@ -40,5 +40,23 @@ Kirigami.Page {
}
}
}
Kirigami.Separator {}
Column {
Controls.Label {
text: i18n("Access point name")
font.weight: Font.Bold
}
Row {
Controls.TextField {
text: kcm.getAPN()
}
Controls.ToolButton {
text: i18n("Edit APN")
}
}
}
Controls.Button {
text: i18n("Data usage")
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment