×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    49

    Qt 4.7.0 incompatible with Qt Mobility 1.0.2 (Bearer management)?

    I have an application that is build with Nokia Qt SDK (Qt 4.6.3 + Mobility 1.0.2). It asks for an access point, initializes and opens QNetworkSession, and sends HTTP requests.

    My application works fine on E51 and E52 with Qt 4.6.3 (+ mobility 1.0.2). However, after upgrading Qt 4.7.0 I have noticed that my access point management is broken.

    Findings:

    QNetworkSession::open() works fine and I can see the open WLAN/3G connection.

    QNetworkAccessManager::post() does not use the open QNetworkSession. Instead it always opens a new connection using default network destination/Access point. On E51 there is no default access point(s), hence I get the "Select access point" user query. This leads to various problems. For example, if I open QNetworkSession with wlan_1 and select wlan_2 from the list the WLAN connection is left active until I close the application. However, If I open QNetworkSession with wlan_1 and select wlan_1 from the list the connection goes down after the request is finished.


    Anyone else faced similar behavior? Is Qt 4.7.0 backwards compatible with 4.6.3? It is a bug or?

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Qt 4.7.0 incompatible with Qt Mobility 1.0.2 (Bearer management)?

    No, Qt 4.7.0 is incompatible with Qt Mobility 1.0.2 Bearer Management as Bearer Management was moved from Qt Mobility to Qt.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    49

    Re: Qt 4.7.0 incompatible with Qt Mobility 1.0.2 (Bearer management)?

    I have done some experiments while trying to migrate my code to use Qt 4.7.0 Bearer Management. After migrating my code to Qt 4.7.0 the behavior is similar to what I said in my first post.

    Environment:
    E51 and E52 with Qt 4.7.0 (Qt mobility is not installed!)
    Win 7 x64 / Win XP x86: QtCreator 2.0.1 with S60 5th edition SDK + Qt SDK 4.7.0 + latest open c plugin (No mobility installed)

    Here is a code example just for testing purposes:
    main.cpp
    Code:
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
        BearerTest *bt = new BearerTest(&a);
        QTimer::singleShot(10, bt, SLOT(Test()));
        QTimer::singleShot(20000, bt, SLOT(Quit()));
        return a.exec();
    }
    bearertest.h
    Code:
    #ifndef BEARERTEST_H
    #define BEARERTEST_H
    #include <QtCore>
    #include <QtNetwork>
    class BearerTest : public QObject
    {
        Q_OBJECT
    public:
        explicit BearerTest(QObject *parent = 0);
    public slots:
        void Test();
        void Quit() { qDebug() << "Quit";  QCoreApplication::exit(); }
        void StateChanged(bool);
    };
    #endif // BEARERTEST_H
    bearertest.cpp
    Code:
    void BearerTest::Test()
    {
        // Open network session using this configuration
        QNetworkConfigurationManager *configManager = new QNetworkConfigurationManager(this);
        connect(configManager, SIGNAL(onlineStateChanged(bool)), SLOT(StateChanged(bool)));
        QNetworkConfiguration config = configManager->configurationFromIdentifier("I_8"); // define your own config != default config
        if(!config.isValid())
        {
            qDebug() << "Invalid configuration: " + config.name() + " - " + config.identifier();
            return;
        }
        qDebug() << "Using " + config.name() + " - " + config.identifier();
        QNetworkSession *session = new QNetworkSession(config, this);
        session->open();
        if(!session->waitForOpened(10000))
        {
            qDebug() << session->errorString();
            return;
        }
        /*QEventLoop loop;
        QTimer::singleShot(5000, &loop, SLOT(quit()));
        loop.exec();*/
        qDebug() << "QNetworkSession::isOpen(): " + QVariant(session->isOpen()).toString();
        qDebug() << "QNetworkConfigurationManager::isOnline(): " + QVariant(configManager->isOnline()).toString();
        if(session->isOpen())
        {
            // Request should be performed using already open QNetworkSession?
            QNetworkAccessManager *nam = new QNetworkAccessManager(this);
            qDebug() << "Post...";
            nam->post(QNetworkRequest(QUrl("http://www.google.com")), "Hello world");
        }
    }
    void BearerTest::StateChanged(bool isOnline)
    {
        qDebug() << "* QNetworkConfigurationManager::isOnline() : " + QVariant(isOnline).toString();
    }
    Output:
    Code:
    2010-10-13 10:58:36 "Using wlan_1 - I_8" 
    2010-10-13 10:58:38 "QNetworkSession::isOpen(): true" 
    2010-10-13 10:58:38 "QNetworkConfigurationManager::isOnline(): false" 
    2010-10-13 10:58:38 Post... 
    2010-10-13 10:58:38 "* QNetworkConfigurationManager::isOnline() : true" 
    2010-10-13 10:58:55 Quit 
    /* After uncommenting the eventloop related rows  after waitForOpened */
    2010-10-13 11:04:04 "Using wlan_1 - I_8" 
    2010-10-13 11:04:06 "* QNetworkConfigurationManager::isOnline() : true" 
    2010-10-13 11:04:11 "QNetworkSession::isOpen(): true" 
    2010-10-13 11:04:11 "QNetworkConfigurationManager::isOnline(): true" 
    2010-10-13 11:04:11 Post... 
    2010-10-13 11:04:24 Quit
    Results (similar to my first post):

    1. QNetworkAccessManager does not use the open QNetworkSession.
    2. QNAM::post() opens new connection using default AP.
    3. On devices without default configuration, the connection prompt is displayed.
    4. QNCM::isOnline() status is not updated after waitForOpened. Waiting for a while (QCoreApplication::processEvents did not help) updates QNCM online state. However, QNetworkSession is still ignored and new connection opened using default AP.
    5. While testing this "feature", don't use default configuration because it hides this behavior! Instead, I'll recommend you to use different bearer types (e.g. 3g and WLAN) so you can see that both connections are opened during the process.
    6. By inspecting the IP addresses on the server side we can see that the HTTP request comes through the connection opened by QNAM.



    In additon to this, I have converted this Maemo application to Symbian. This problem can be reproduced using it (note 5th comment above!). After the application opens connection automatically via AP1 (requires 2 rounds because QNetworkConfigurationManager::isOnline is not updated during first round) the QNAM::post opens new connection beside of it via default AP...

    Does anyone have comments on this? Is there anything else I can try or test?

    PS. If you think that this is worth of a new thread, please feel free and detach this post from this thread.

  4. #4
    Registered User
    Join Date
    Jul 2009
    Posts
    3

    Re: Qt 4.7.0 incompatible with Qt Mobility 1.0.2 (Bearer management)?

    Hi,

    in Qt 4.7 QNetworkAccessManager uses its own internal QNetworkConfigurations / QNetworkSessions to control the access automatically.
    When used together with external QNetworkSession (i.e. outside of QNetworkAccessManager), they conflict.

    If one wishes to manually control the interface as with Qt 4.6.x and use QNetworkAccessManager Qt 4.7, you need to feed the QNAM with invalid
    QNetworkConfiguration. That tells QNAM not to do any bearer management. I.e. do a:
    networkAccessManager->setConfiguration(QNetworkConfiguration());

    Hope this helps,
    Juha

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    49

    Re: Qt 4.7.0 incompatible with Qt Mobility 1.0.2 (Bearer management)?

    Thanks for the reply.

    I was looking a bit more this "Qt 4.7.0 way" to manage internal QNetworkSessions. The following snippet simplifies the code quite a lot and I'm also able to use active configurations:

    Code:
    QNetworkConfigurationManager *configManager = new QNetworkConfigurationManager(this);
    QNetworkConfiguration config = configManager->configurationFromIdentifier("I_8");
    if(config.isValid())
    {
    	QNetworkAccessManager *nam = new QNetworkAccessManager(this);
    	nam->setConfiguration(config);
    	nam->post(QNetworkRequest(QUrl("http://www.google.com")), "Hello world");
    }
    However, there is one major drawback. With my previous solution I was able to access the IP address via QNetworkSession::interface() prior to the communication. Is there any ways to access the internal Interface via QNAM? The interface itself is opened during the request so it is obvious that the IP address is not available before that, but what about after/during the request?

Similar Threads

  1. Qt Creator code completion not working with Qt Mobility for Symbian
    By ceefour in forum [Archived] Qt Mobility Project
    Replies: 4
    Last Post: 2011-09-10, 05:02
  2. Replies: 35
    Last Post: 2010-09-13, 12:05
  3. Replies: 3
    Last Post: 2010-06-30, 01:17
  4. Qt mobility Bearer error when search for WLAN
    By Zombieisme in forum [Archived] Qt Mobility Project
    Replies: 0
    Last Post: 2010-06-21, 12:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •