MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

Network connectivity in Harmattan applications

MeeGo 1.2 Harmattan networking features are provided by the Qt Network API connection manager framework. Qt Network API is a Qt module that contains classes for establishing network connections, session and cookie management, and other network programming functions.

Using connectivity

MeeGo 1.2 Harmattan has a centralised connectivity management system that handles the application's connectivity needs within the overall device context, allowing you to concentrate on a single application at a time.

Network connections are handled with the QNetworkAccessManager object, which manages sending and receiving network packages in Qt Network API. An application usually needs only one QNetworkAccessManager. The data and headers of network requests are contained within QNetworkReply and QNetworkRequest objects. A common basic usage goes like this:

QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QUrl url("http://www.developer.nokia.com/");
QNetworkReply *reply = manager->get(QNetworkRequest(url));

Applications must be able to separate between situations where connection is being asked due to user interaction or because of a background event such as a timed event, a dropped connection or a failed connection attempt. The user trying to browse the web in the office WLAN is an entirely different situation from automatic email updating while roaming in a foreign GPRS network.

New connection attempts that are not triggered by some user interaction are established with ConnectInBackground property in QNetworkSession::sessionProperty:

QNetworkConfigurationManager manager;
QNetworkConfiguration cfg = manager.defaultConfiguration();
QNetworkSession* session = new QNetworkSession(cfg);
session->setSessionProperty("ConnectInBackground", true);
session->open();

Applications operating outside the Qt framework can use the libconic Internet connectivity API. For more information, see the libconic library in the Platform API reference.

Connectivity considerations

There are some further considerations to take into account. The overall impact of the following is likely to be minimal, as a well-designed application that uses the connectivity APIs correctly handles all the transitions automatically. The connectivity considerations for the Harmattan platform include:

  • Different connection modes
    MeeGo 1.2 Harmattan devices have a variety of possible device states such as Flight mode and Power saving mode that affect available network connection types. For example, in Power saving mode, no automatic connections are ever created and existing connections are monitored with an idle timer that terminates unused connections. When your application uses the connectivity APIs correctly, these situations are handled in an optimal manner.
  • Traversing between different networks
    The device always tries to stay connected to best available network, and will change between networks without asking from applications.
  • Power consumption during network usage
    Accessing network resources adds to the power consumption of the device. Therefore, try to minimise the time that the application spends accessing the network. In many cases, it is good idea use the heartbeat feature to synchronise the usage of such resources and maximise the battery life.