Example #1
0
QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
{
    QNetworkConfigurationManagerPrivate *ptr = connManager_ptr.loadAcquire();
    int shutdown = appShutdown.loadAcquire();
    if (!ptr && !shutdown) {
        static QBasicMutex connManager_mutex;
        QMutexLocker locker(&connManager_mutex);
        if (!(ptr = connManager_ptr.loadAcquire())) {
            ptr = new QNetworkConfigurationManagerPrivate;

            if (QCoreApplicationPrivate::mainThread() == QThread::currentThread()) {
                // right thread or no main thread yet
                ptr->addPreAndPostRoutine();
                ptr->initialize();
            } else {
                // wrong thread, we need to make the main thread do this
                QObject *obj = new QObject;
                QObject::connect(obj, SIGNAL(destroyed()), ptr, SLOT(addPreAndPostRoutine()), Qt::DirectConnection);
                ptr->initialize(); // this moves us to the right thread
                obj->moveToThread(QCoreApplicationPrivate::mainThread());
                obj->deleteLater();
            }

            connManager_ptr.storeRelease(ptr);
        }
    }
    return ptr;
}
Example #2
0
/*!
    Returns the capabilities supported by the current platform.
*/
QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabilities() const
{
    QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
    if (priv)
        return priv->capabilities();

    return QNetworkConfigurationManager::Capabilities(0);
}
Example #3
0
/*!
    Returns \c true if the system is considered to be connected to another device via an active
    network interface; otherwise returns \c false.

    This is equivalent to the following code snippet:

    \snippet code/src_network_bearer_qnetworkconfigmanager.cpp 0

    \sa onlineStateChanged()
*/
bool QNetworkConfigurationManager::isOnline() const
{
    QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
    if (priv)
        return priv->isOnline();

    return false;
}
Example #4
0
/*!
    Returns the QNetworkConfiguration for \a identifier; otherwise returns an
    invalid QNetworkConfiguration.

    \sa QNetworkConfiguration::identifier()
*/
QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier(const QString &identifier) const
{
    QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
    if (priv)
        return priv->configurationFromIdentifier(identifier);

    return QNetworkConfiguration();
}
Example #5
0
/*!
    Returns the list of configurations which comply with the given \a filter.

    By default this function returns all (defined and undefined) configurations.

    A wireless network with a particular SSID may only be accessible in a
    certain area despite the fact that the system has a valid configuration
    for it. Therefore the filter flag may be used to limit the list to
    discovered and possibly connected configurations only.

    If \a filter is set to zero this function returns all possible configurations.

    Note that this function returns the states for all configurations as they are known at
    the time of this function call. If for instance a configuration of type WLAN is defined
    the system may have to perform a WLAN scan in order to determine whether it is
    actually available. To obtain the most accurate state updateConfigurations() should
    be used to update each configuration's state. Note that such an update may require
    some time. It's completion is signalled by updateCompleted(). In the absence of a
    configuration update this function returns the best estimate at the time of the call.
    Therefore, if WLAN configurations are of interest, it is recommended that
    updateConfigurations() is called once after QNetworkConfigurationManager
    instantiation (WLAN scans are too time consuming to perform in constructor).
    After this the data is kept automatically up-to-date as the system reports
    any changes.
*/
QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNetworkConfiguration::StateFlags filter) const
{
    QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
    if (priv)
        return priv->allConfigurations(filter);

    return QList<QNetworkConfiguration>();
}
Example #6
0
/*!
    Returns the default configuration to be used. This function always returns a discovered
    configuration; otherwise an invalid configuration.

    In some cases it may be required to call updateConfigurations() and wait for the
    updateCompleted() signal before calling this function.

    \sa allConfigurations()
*/
QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const
{
    QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
    if (priv)
        return priv->defaultConfiguration();

    return QNetworkConfiguration();
}
Example #7
0
static void connManager_cleanup()
{
    // this is not atomic or thread-safe!
    int shutdown = appShutdown.fetchAndStoreAcquire(1);
    Q_ASSERT(shutdown == 0);
    Q_UNUSED(shutdown);
    QNetworkConfigurationManagerPrivate *cmp = connManager_ptr.fetchAndStoreAcquire(0);
    if (cmp)
        cmp->cleanup();
}
Example #8
0
QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
{
    static bool initialized = false;

    QNetworkConfigurationManagerPrivate *m = connManager();
    if (!initialized) {
        initialized = true;
        m->updateConfigurations();
    }

    return m;
}
Example #9
0
/*!
    Constructs a QNetworkConfigurationManager with the given \a parent.
*/
QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent )
    : QObject(parent)
{
    QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();

    connect(priv, SIGNAL(configurationAdded(QNetworkConfiguration)),
            this, SIGNAL(configurationAdded(QNetworkConfiguration)));
    connect(priv, SIGNAL(configurationRemoved(QNetworkConfiguration)),
            this, SIGNAL(configurationRemoved(QNetworkConfiguration)));
    connect(priv, SIGNAL(configurationUpdateComplete()),
            this, SIGNAL(updateCompleted()));
    connect(priv, SIGNAL(onlineStateChanged(bool)), 
            this, SIGNAL(onlineStateChanged(bool)));
    connect(priv, SIGNAL(configurationChanged(QNetworkConfiguration)),
            this, SIGNAL(configurationChanged(QNetworkConfiguration)));

    priv->enablePolling();
}
void IapMonitor::iapRemoved(const QString &iap_id)
{
    QString id = iap_id;
    d->deleteConfiguration(id);
}
Example #11
0
/*!
    Frees the resources associated with the QNetworkConfigurationManager object.
*/
QNetworkConfigurationManager::~QNetworkConfigurationManager()
{
    QNetworkConfigurationManagerPrivate *priv = connManager();

    priv->disablePolling();
}
Example #12
0
/*!
    Initiates an update of all configurations. This may be used to initiate WLAN scans or other
    time consuming updates which may be required to obtain the correct state for configurations.

    This call is asynchronous. On completion of this update the updateCompleted() signal is
    emitted. If new configurations are discovered or old ones were removed or changed the update
    process may trigger the emission of one or multiple configurationAdded(),
    configurationRemoved() and configurationChanged() signals.

    If a configuration state changes as a result of this update all existing QNetworkConfiguration
    instances are updated automatically.

    \sa allConfigurations()
*/
void QNetworkConfigurationManager::updateConfigurations()
{
    QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
    if (priv)
        priv->performAsyncConfigurationUpdate();
}
Example #13
0
/*!
    Frees the resources associated with the QNetworkConfigurationManager object.
*/
QNetworkConfigurationManager::~QNetworkConfigurationManager()
{
    QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
    if (priv)
        priv->disablePolling();
}