X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=homescreen%2Fsrc%2Fstatusbarmodel.cpp;h=447466d2673f723f39e9b1cc7cb1eb10b20a975d;hb=b2c08ec4a30e5acf3cb1851f71bda88bc542f7d1;hp=5e63b7dbe523d6ddbdd0af2001676e1f1c9c8d91;hpb=58ecf2c3229ab677ca39095b52ab88b1a41861bd;p=apps%2Fhomescreen.git diff --git a/homescreen/src/statusbarmodel.cpp b/homescreen/src/statusbarmodel.cpp index 5e63b7d..447466d 100644 --- a/homescreen/src/statusbarmodel.cpp +++ b/homescreen/src/statusbarmodel.cpp @@ -17,10 +17,8 @@ #include "statusbarmodel.h" #include "statusbarserver.h" - -#include - -#include "network.h" +#include +#include class StatusBarModel::Private { @@ -33,14 +31,12 @@ public: StatusBarServer server; QString iconList[StatusBarServer::SupportedCount]; Network *network; + WifiAdapter *wifi_a; }; StatusBarModel::Private::Private(StatusBarModel *parent) : q(parent) { - QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerObject("/StatusBar", &server); - dbus.registerService("org.agl.homescreen"); connect(&server, &StatusBarServer::statusIconChanged, [&](int placeholderIndex, const QString &icon) { if (placeholderIndex < 0 || StatusBarServer::SupportedCount <= placeholderIndex) return; if (iconList[placeholderIndex] == icon) return; @@ -63,16 +59,21 @@ StatusBarModel::~StatusBarModel() delete d; } -void StatusBarModel::init(QUrl &url, QQmlContext *context) +void StatusBarModel::init(QQmlContext *context) { - d->network = new Network(url, context); + d->network = new Network(false, context); context->setContextProperty("network", d->network); + d->wifi_a = static_cast(d->network->findAdapter("wifi")); + Q_CHECK_PTR(d->wifi_a); - QObject::connect(d->network, &Network::wifiConnectedChanged, this, &StatusBarModel::onWifiConnectedChanged); - QObject::connect(d->network, &Network::wifiEnabledChanged, this, &StatusBarModel::onWifiEnabledChanged); - QObject::connect(d->network, &Network::wifiStrengthChanged, this, &StatusBarModel::onWifiStrengthChanged); + QObject::connect(d->wifi_a, &WifiAdapter::wifiConnectedChanged, + this, &StatusBarModel::onWifiConnectedChanged); + QObject::connect(d->wifi_a, &WifiAdapter::wifiEnabledChanged, + this, &StatusBarModel::onWifiEnabledChanged); + QObject::connect(d->wifi_a, &WifiAdapter::wifiStrengthChanged, + this, &StatusBarModel::onWifiStrengthChanged); - setWifiStatus(d->network->wifiConnected(), d->network->wifiEnabled(), d->network->wifiStrength()); + setWifiStatus(d->wifi_a->wifiConnected(), d->wifi_a->wifiEnabled(), d->wifi_a->wifiStrength()); } void StatusBarModel::setWifiStatus(bool connected, bool enabled, int strength) @@ -92,18 +93,18 @@ void StatusBarModel::setWifiStatus(bool connected, bool enabled, int strength) void StatusBarModel::onWifiConnectedChanged(bool connected) { - setWifiStatus(connected, d->network->wifiEnabled(), d->network->wifiStrength()); + setWifiStatus(connected, d->wifi_a->wifiEnabled(), d->wifi_a->wifiStrength()); } void StatusBarModel::onWifiEnabledChanged(bool enabled) { - setWifiStatus(d->network->wifiConnected(), enabled, d->network->wifiStrength()); + setWifiStatus(d->wifi_a->wifiConnected(), enabled, d->wifi_a->wifiStrength()); } void StatusBarModel::onWifiStrengthChanged(int strength) { qInfo() << "Strength changed: " << strength; - setWifiStatus(d->network->wifiConnected(), d->network->wifiEnabled(), strength); + setWifiStatus(d->wifi_a->wifiConnected(), d->wifi_a->wifiEnabled(), strength); } int StatusBarModel::rowCount(const QModelIndex &parent) const