Beispiel #1
0
void QIcdEngine::initialize()
{
    QMutexLocker locker(&mutex);

    // Setup DBus Interface for ICD
    m_dbusInterface = new QDBusInterface(ICD_DBUS_API_INTERFACE,
                                         ICD_DBUS_API_PATH,
                                         ICD_DBUS_API_INTERFACE,
                                         QDBusConnection::systemBus(),
                                         this);
    connect(&m_scanTimer, SIGNAL(timeout()), this, SLOT(finishAsyncConfigurationUpdate()));
    m_scanTimer.setSingleShot(true);

    /* Turn on IAP state monitoring */
    startListeningStateSignalsForAllConnections();

    /* Turn on IAP add/remove monitoring */
    iapMonitor->setup(this);

    /* We create a default configuration which is a pseudo config */
    QNetworkConfigurationPrivate *cpPriv = new IcdNetworkConfigurationPrivate;
    cpPriv->name = "UserChoice";
    cpPriv->state = QNetworkConfiguration::Discovered;
    cpPriv->isValid = true;
    cpPriv->id = OSSO_IAP_ANY;
    cpPriv->type = QNetworkConfiguration::UserChoice;
    cpPriv->purpose = QNetworkConfiguration::UnknownPurpose;
    cpPriv->roamingSupported = false;

    QNetworkConfigurationPrivatePointer ptr(cpPriv);
    userChoiceConfigurations.insert(cpPriv->id, ptr);

    doRequestUpdate();
}
Beispiel #2
0
bool QIcdEngine::ensureDBusConnection()
{
    if (m_dbusInterface)
        return true;

    // Setup DBus Interface for ICD
    m_dbusInterface = new QDBusInterface(ICD_DBUS_API_INTERFACE,
                                         ICD_DBUS_API_PATH,
                                         ICD_DBUS_API_INTERFACE,
                                         QDBusConnection::systemBus(),
                                         this);

    if (!m_dbusInterface->isValid()) {
        delete m_dbusInterface;
        m_dbusInterface = 0;

        if (!m_icdServiceWatcher) {
            m_icdServiceWatcher = new QDBusServiceWatcher(ICD_DBUS_API_INTERFACE,
                                                          QDBusConnection::systemBus(),
                                                          QDBusServiceWatcher::WatchForOwnerChange,
                                                          this);

            connect(m_icdServiceWatcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
                    this, SLOT(icdServiceOwnerChanged(QString,QString,QString)));
        }

        return false;
    }

    connect(&m_scanTimer, SIGNAL(timeout()), this, SLOT(finishAsyncConfigurationUpdate()));
    m_scanTimer.setSingleShot(true);

    /* Turn on IAP state monitoring */
    startListeningStateSignalsForAllConnections();

    /* Turn on IAP add/remove monitoring */
    iapMonitor = new IapMonitor;
    iapMonitor->setup(this);

    /* We create a default configuration which is a pseudo config */
    QNetworkConfigurationPrivate *cpPriv = new IcdNetworkConfigurationPrivate;
    cpPriv->name = "UserChoice";
    cpPriv->state = QNetworkConfiguration::Discovered;
    cpPriv->isValid = true;
    cpPriv->id = OSSO_IAP_ANY;
    cpPriv->type = QNetworkConfiguration::UserChoice;
    cpPriv->purpose = QNetworkConfiguration::UnknownPurpose;
    cpPriv->roamingSupported = false;

    QNetworkConfigurationPrivatePointer ptr(cpPriv);
    userChoiceConfigurations.insert(cpPriv->id, ptr);

    doRequestUpdate();

    getIcdInitialState();

    return true;
}
Beispiel #3
0
bool QBBEngine::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
    Q_UNUSED(eventType);
    Q_UNUSED(result);

    bps_event_t * const event = static_cast<bps_event_t *>(message);

    Q_ASSERT(event);

    if (bps_event_get_domain(event) == netstatus_get_domain()) {
        qBearerDebug() << Q_FUNC_INFO << "got update request.";
        doRequestUpdate();
    }

    return false;
}
Beispiel #4
0
void QBBEngine::initialize()
{
    if (initialized) {
        qWarning() << Q_FUNC_INFO << "called, but instance already initialized.";
        return;
    }

    instanceStorage()->setLocalData(new EngineInstanceHolder(this));

    if (netstatus_request_events(0) != BPS_SUCCESS) {
        qWarning() << Q_FUNC_INFO << "cannot register for network events. Polling enabled.";

        const QMutexLocker locker(&pollingMutex);
        pollingRequired = true;
    } else {
        QAbstractEventDispatcher::instance()->installEventFilter(this);
    }

    doRequestUpdate();
}
Beispiel #5
0
void QGenericEngine::requestUpdate()
{
    doRequestUpdate();
}
Beispiel #6
0
void QGenericEngine::initialize()
{
    doRequestUpdate();
}
Beispiel #7
0
void QBBEngine::updateConfiguration(const char *interface)
{
    netstatus_interface_details_t *details = 0;

    if (netstatus_get_interface_details(interface, &details) != BPS_SUCCESS) {
        qBearerDebug() << Q_FUNC_INFO << "cannot retrieve details for interface" << interface;

        return;
    }

    const QString name = QString::fromLatin1(netstatus_interface_get_name(details));
    const QString id = idForName(name);


    const netstatus_interface_type_t type = netstatus_interface_get_type(details);
    const netstatus_ip_status_t ipStatus = netstatus_interface_get_ip_status(details);

    netstatus_free_interface_details(&details);

    QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined;

    if (ipStatus == NETSTATUS_IP_STATUS_OK)
        state |= QNetworkConfiguration::Active;

    QMutexLocker locker(&mutex);

    if (accessPointConfigurations.contains(id)) {
        QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);

        bool changed = false;

        QMutexLocker ptrLocker(&ptr->mutex);

        if (!ptr->isValid) {
            ptr->isValid = true;
            changed = true;
        }

        if (ptr->name != name) {
            ptr->name = name;
            changed = true;
        }

        if (ptr->id != id) {
            ptr->id = id;
            changed = true;
        }

        if (ptr->state != state) {
            ptr->state = state;
            changed = true;
        }

        const netstatus_ip_status_t oldIpStatus = ptr->oldIpStatus;
        ptr->oldIpStatus = ipStatus;

        ptrLocker.unlock();

        locker.unlock();

        if (changed) {
            qBearerDebug() << Q_FUNC_INFO << "configuration changed:" << interface;

            Q_EMIT configurationChanged(ptr);
        } else {
            // maybe Wifi has changed but gateway not yet ready etc.
            qBearerDebug() << Q_FUNC_INFO << "configuration has not changed.";
            if (oldIpStatus != ipStatus) { // if IP status changed
                if (ipStatus != NETSTATUS_IP_STATUS_OK
                        && ipStatus != NETSTATUS_IP_STATUS_ERROR_NOT_UP
                        && ipStatus != NETSTATUS_IP_STATUS_ERROR_NOT_CONFIGURED) {
                    // work around race condition in netstatus API by just checking
                    // again in 300 ms
                    QTimer::singleShot(300, this, SLOT(doRequestUpdate()));
                }
            }
        }

        return;
    }

    QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate);

    ptr->name = name;
    ptr->isValid = true;
    ptr->id = id;
    ptr->state = state;
    ptr->type = QNetworkConfiguration::InternetAccessPoint;
    ptr->bearerType = interfaceType(type);

    accessPointConfigurations.insert(id, ptr);
    configurationInterface.insert(id, name);

    locker.unlock();

    qBearerDebug() << Q_FUNC_INFO << "configuration added:" << interface;

    Q_EMIT configurationAdded(ptr);
}
Beispiel #8
0
void QBBEngine::requestUpdate()
{
    doRequestUpdate();
}
Beispiel #9
0
void QConnmanEngine::requestUpdate()
{
    QMutexLocker locker(&mutex);
    QTimer::singleShot(0, this, SLOT(doRequestUpdate()));
}