コード例 #1
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();
    }
コード例 #2
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());
        }
    }