Пример #1
0
TechnologyModel::TechnologyModel(QAbstractListModel* parent)
  : QAbstractListModel(parent),
    m_manager(NULL),
    m_tech(NULL),
    m_scanning(false),
    m_changesInhibited(false),
    m_uneffectedChanges(false),
    m_scanResultsReady(false)
{
    m_manager = NetworkManagerFactory::createInstance();

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    setRoleNames(roleNames());
#endif
    connect(m_manager, SIGNAL(availabilityChanged(bool)),
            this, SLOT(managerAvailabilityChanged(bool)));

    connect(m_manager,
            SIGNAL(technologiesChanged()),
            this,
            SLOT(updateTechnologies()));

    connect(m_manager,
            SIGNAL(servicesChanged()),
            this,
            SLOT(updateServiceList()));
}
Пример #2
0
void NetworkManager::disconnectTechnologies()
{
    if (m_manager) {
        disconnect(m_manager, SIGNAL(TechnologyAdded(QDBusObjectPath,QVariantMap)),
                   this, SLOT(technologyAdded(QDBusObjectPath,QVariantMap)));
        disconnect(m_manager, SIGNAL(TechnologyRemoved(QDBusObjectPath)),
                   this, SLOT(technologyRemoved(QDBusObjectPath)));
    }

    Q_FOREACH (NetworkTechnology *tech, m_technologiesCache)
        tech->deleteLater();

    if (!m_technologiesCache.isEmpty()) {
        m_technologiesCache.clear();
        Q_EMIT technologiesChanged();
    }
}
Пример #3
0
void QOfonoNetworkOperator::propertyChanged(const QString &property, const QDBusVariant &dbusvalue)
{
    QVariant value = dbusvalue.variant();
    d_ptr->properties.insert(property,value);

    if (property == QLatin1String("Name")) {
        Q_EMIT nameChanged(value.value<QString>());
    } else if (property == QLatin1String("Status")) {
        Q_EMIT statusChanged(value.value<QString>());
    } else if (property == QLatin1String("MobileCountryCode")) {
        Q_EMIT mccChanged(value.value<QString>());
    } else if (property == QLatin1String("MobileNetworkCode")) {
        Q_EMIT mncChanged(value.value<QString>());
    } else if (property == QLatin1String("Technologies")) {
        Q_EMIT technologiesChanged(value.value<QStringList>());
    } else if (property == QLatin1String("AdditionalInformation")) {
        Q_EMIT additionalInfoChanged(value.value<QString>());
    }
}
Пример #4
0
void NetworkManager::getTechnologiesReply(QDBusPendingCallWatcher *call)
{
    Q_ASSERT(call);

    pr_dbg() << "Got reply with technolgies";

    QDBusPendingReply<ConnmanObjectList> reply = *call;
    if (reply.isError()) {

        pr_dbg() << "Error getTechnologiesReply:" << reply.error().message();

        disconnectFromConnman();

        // TODO: set up timer to reconnect in a bit
        //QTimer::singleShot(10000,this,SLOT(connectToConnman()));
    } else {

        ConnmanObjectList lst = reply.value();
        ConnmanObject obj;
        foreach (obj, lst) { // TODO: consider optimizations

            NetworkTechnology *tech = new NetworkTechnology(obj.objpath.path(),
                    obj.properties, this);

            m_technologiesCache.insert(tech->type(), tech);

            pr_dbg() << "Technology: " << tech->type();
            pr_dbg() << "\tConnected:" << tech->connected();
            pr_dbg() << "\tPowered:" << tech->powered();
        }

        connect(m_manager,
                SIGNAL(TechnologyAdded(const QDBusObjectPath &, const QVariantMap &)),
                this,
                SLOT(technologyAdded(const QDBusObjectPath &, const QVariantMap &)));

        connect(m_manager,
                SIGNAL(TechnologyRemoved(const QDBusObjectPath &)),
                this,
                SLOT(technologyRemoved(const QDBusObjectPath &)));

        emit technologiesChanged();
    }
Пример #5
0
void NetworkManager::getTechnologiesReply(QDBusPendingCallWatcher *call)
{
    Q_ASSERT(call);
    QDBusPendingReply<ConnmanObjectList> reply = *call;
    if (reply.isError()) {
        qDebug() << "Error getTechnologiesReply: " << reply.error().message();
        disconnectFromConnman();
        // TODO: set up timer to reconnect in a bit
        //QTimer::singleShot(10000,this,SLOT(connectToConnman()));
    } else {
        ConnmanObjectList lst = reply.value();
        ConnmanObject obj;
        foreach (obj, lst) { // TODO: consider optimizations
            NetworkTechnology *tech = new NetworkTechnology(obj.objpath.path(),
                    obj.properties, this);
            m_technologiesCache.insert(tech->type(), tech);
            qDebug() << "From NT: " << tech->type() << " " << tech->connected() << " " << tech->powered();
        }
        if (!m_technologiesCache.isEmpty()) {
            emit technologiesChanged(m_technologiesCache, QStringList());
        }
    }
Пример #6
0
TechnologyModel::TechnologyModel(QAbstractListModel* parent)
  : QAbstractListModel(parent),
    m_manager(NULL),
    m_tech(NULL),
    m_scanning(false),
    m_changesInhibited(false),
    m_uneffectedChanges(false)
{
    m_manager = NetworkManagerFactory::createInstance();

    connect(m_manager, SIGNAL(availabilityChanged(bool)),
            this, SLOT(managerAvailabilityChanged(bool)));

    connect(m_manager,
            SIGNAL(technologiesChanged()),
            this,
            SLOT(updateTechnologies()));

    connect(m_manager,
            SIGNAL(servicesChanged()),
            this,
            SLOT(updateServiceList()));
}