tests/manual/bearerex/bearerex.cpp
changeset 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the test suite of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "bearerex.h"
       
    43 
       
    44 #include <QtNetwork>
       
    45 
       
    46 Q_DECLARE_METATYPE(QNetworkConfiguration)
       
    47 
       
    48 BearerEx::BearerEx(QWidget* parent)
       
    49      : QMainWindow(parent)
       
    50 {
       
    51     setupUi(this);
       
    52     
       
    53     createMenus();
       
    54     
       
    55     connect(&m_NetworkConfigurationManager, SIGNAL(updateCompleted()), this, SLOT(configurationsUpdateCompleted()));
       
    56     connect(&m_NetworkConfigurationManager, SIGNAL(configurationAdded(const QNetworkConfiguration&)),
       
    57             this, SLOT(configurationAdded(const QNetworkConfiguration&)));
       
    58     connect(&m_NetworkConfigurationManager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)),
       
    59             this, SLOT(configurationRemoved(const QNetworkConfiguration&)));
       
    60     connect(&m_NetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)),
       
    61             this, SLOT(onlineStateChanged(bool)));
       
    62     connect(&m_NetworkConfigurationManager, SIGNAL(configurationChanged(const QNetworkConfiguration&)),
       
    63             this, SLOT(configurationChanged(const QNetworkConfiguration&)));
       
    64     showConfigurations();
       
    65 }
       
    66 
       
    67 void BearerEx::createMenus()
       
    68 {
       
    69     QAction* act1 = new QAction(tr("Show Details"), this);
       
    70     menuBar()->addAction(act1);
       
    71     connect(act1, SIGNAL(triggered()), this, SLOT(on_showDetailsButton_clicked()));
       
    72 
       
    73     QAction* exitAct = new QAction(tr("Exit"), this);
       
    74     menuBar()->addAction(exitAct);
       
    75     connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
       
    76 }
       
    77 
       
    78 void BearerEx::showConfigurations()
       
    79 {
       
    80     listWidget->clear();
       
    81     QListWidgetItem* listItem;
       
    82     
       
    83     QNetworkConfiguration defaultConfig = m_NetworkConfigurationManager.defaultConfiguration();
       
    84     if (defaultConfig.type() == QNetworkConfiguration::UserChoice) {
       
    85         listItem = new QListWidgetItem();
       
    86         QFont font = listItem->font();
       
    87         font.setBold(true);
       
    88         font.setUnderline(true);
       
    89         listItem->setFont(font);        
       
    90         listItem->setText("       UserChoice");
       
    91         listItem->setData(Qt::UserRole, qVariantFromValue(defaultConfig));
       
    92         listWidget->addItem(listItem);
       
    93     }
       
    94     
       
    95     QList<QNetworkConfiguration> configurations = m_NetworkConfigurationManager.allConfigurations();
       
    96     for (int i=0; i<configurations.count(); i++)
       
    97     {
       
    98         listItem = new QListWidgetItem();
       
    99         QString text;
       
   100         if (configurations[i].type() == QNetworkConfiguration::InternetAccessPoint) {
       
   101             text.append("(IAP,");
       
   102         } else if (configurations[i].type() == QNetworkConfiguration::ServiceNetwork) {
       
   103             text.append("(SNAP,");
       
   104         }
       
   105         
       
   106         if ((configurations[i].state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
       
   107             text.append("Act) ");
       
   108         } else if ((configurations[i].state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
       
   109             text.append("Disc) ");
       
   110         } else {
       
   111             text.append("Def) ");
       
   112         }
       
   113         text.append(configurations[i].name());
       
   114         
       
   115         if (defaultConfig.isValid() && defaultConfig == configurations[i]) {
       
   116             QFont font = listItem->font();
       
   117             font.setBold(true);
       
   118             font.setUnderline(true);
       
   119             listItem->setFont(font);        
       
   120         }
       
   121         listItem->setText(text);
       
   122         listItem->setData(Qt::UserRole, qVariantFromValue(configurations[i]));
       
   123         listWidget->addItem(listItem);
       
   124     }
       
   125 }
       
   126 
       
   127 void BearerEx::on_updateConfigurationsButton_clicked()
       
   128 {
       
   129     m_NetworkConfigurationManager.updateConfigurations();
       
   130 }
       
   131 
       
   132 void BearerEx::on_updateListButton_clicked()
       
   133 {
       
   134     showConfigurations();
       
   135 }
       
   136 
       
   137 void BearerEx::on_showDetailsButton_clicked()
       
   138 {
       
   139     QListWidgetItem* item = listWidget->currentItem();
       
   140     if (!item) {
       
   141         return;
       
   142     }
       
   143 
       
   144 	QNetworkConfiguration networkConfiguration = qVariantValue<QNetworkConfiguration>(item->data(Qt::UserRole));
       
   145 	DetailedInfoDialog infoDialog(&networkConfiguration,this);
       
   146 	infoDialog.exec();
       
   147 }
       
   148 
       
   149 void BearerEx::on_createSessionButton_clicked()
       
   150 {
       
   151     QListWidgetItem* item = listWidget->currentItem();
       
   152     if (!item) {
       
   153         return;
       
   154     }    
       
   155     QNetworkConfiguration networkConfiguration = qVariantValue<QNetworkConfiguration>(item->data(Qt::UserRole));
       
   156     int newTabIndex = mainTabWidget->count();
       
   157     SessionTab* newTab = new SessionTab(&networkConfiguration,&m_NetworkConfigurationManager,eventListWidget,newTabIndex-1);
       
   158     QString label = QString("S")+QString::number(newTabIndex-1);
       
   159     mainTabWidget->insertTab(newTabIndex,newTab,label);
       
   160     mainTabWidget->setCurrentIndex(newTabIndex);
       
   161 }
       
   162 
       
   163 void BearerEx::on_clearEventListButton_clicked()
       
   164 {
       
   165     eventListWidget->clear();
       
   166 }
       
   167 
       
   168 void BearerEx::configurationAdded(const QNetworkConfiguration& config)
       
   169 {
       
   170     QListWidgetItem* listItem = new QListWidgetItem();
       
   171     listItem->setText(QString("Added: ")+config.name());
       
   172     eventListWidget->addItem(listItem);
       
   173 }
       
   174 
       
   175 void BearerEx::configurationRemoved(const QNetworkConfiguration& config)
       
   176 {
       
   177     QListWidgetItem* listItem = new QListWidgetItem();
       
   178     listItem->setText(QString("Removed: ")+config.name());
       
   179     eventListWidget->addItem(listItem);
       
   180 }
       
   181 
       
   182 void BearerEx::onlineStateChanged(bool isOnline)
       
   183 {
       
   184     QListWidgetItem* listItem = new QListWidgetItem();
       
   185     QFont font = listItem->font();
       
   186     font.setBold(true);
       
   187     listItem->setFont(font);        
       
   188     if (isOnline) {
       
   189         listItem->setText(QString("> Online"));
       
   190     } else {
       
   191         listItem->setText(QString("< Offline"));
       
   192     }
       
   193     eventListWidget->addItem(listItem);
       
   194 }
       
   195 
       
   196 void BearerEx::configurationChanged(const QNetworkConfiguration & config)
       
   197 {
       
   198     QListWidgetItem* listItem = new QListWidgetItem();
       
   199     QString state;
       
   200     switch (config.state())
       
   201     {
       
   202         case QNetworkConfiguration::Undefined:
       
   203             state = "Undef : ";
       
   204             break;
       
   205         case QNetworkConfiguration::Defined:
       
   206             state = "Def : ";
       
   207             break;
       
   208         case QNetworkConfiguration::Discovered:
       
   209             state = "Disc : ";
       
   210             break;
       
   211         case QNetworkConfiguration::Active:
       
   212             state = "Act : ";
       
   213             break;
       
   214     }
       
   215     listItem->setText(state+config.name());
       
   216     eventListWidget->addItem(listItem);
       
   217 }
       
   218 
       
   219 void BearerEx::configurationsUpdateCompleted()
       
   220 {
       
   221     QMessageBox msgBox;
       
   222     msgBox.setStandardButtons(QMessageBox::Close);
       
   223     msgBox.setText("Configurations update completed.");
       
   224     msgBox.exec();
       
   225 }
       
   226 
       
   227 DetailedInfoDialog::DetailedInfoDialog(QNetworkConfiguration* apNetworkConfiguration, QWidget * parent)
       
   228     : QDialog(parent)
       
   229 {
       
   230     setupUi(this);
       
   231 
       
   232     tableWidget->setColumnCount(2);
       
   233     int rowCount = 2;
       
   234     
       
   235     if (apNetworkConfiguration->type() == QNetworkConfiguration::ServiceNetwork) {
       
   236         rowCount = rowCount + apNetworkConfiguration->children().count();
       
   237     }
       
   238 
       
   239 	tableWidget->setRowCount(rowCount);
       
   240 	tableWidget->setColumnWidth(1,250);
       
   241 	tableWidget->setItem(0, 0, new QTableWidgetItem(tr("Name")));
       
   242 	tableWidget->setItem(0, 1, new QTableWidgetItem(apNetworkConfiguration->name()));
       
   243 	tableWidget->setItem(1, 0, new QTableWidgetItem(tr("Id")));
       
   244 	tableWidget->setItem(1, 1, new QTableWidgetItem(apNetworkConfiguration->identifier()));
       
   245     if (apNetworkConfiguration->type() == QNetworkConfiguration::ServiceNetwork) {
       
   246         for (int i=0; i<apNetworkConfiguration->children().count(); i++) {
       
   247             tableWidget->setItem(i+2, 0, new QTableWidgetItem(QString("IAP")+QString::number(i+1)));
       
   248             tableWidget->setItem(i+2, 1, new QTableWidgetItem(apNetworkConfiguration->children()[i].name()));
       
   249         }
       
   250     }
       
   251     
       
   252     tableWidget->setFocusPolicy(Qt::NoFocus);
       
   253 
       
   254 #ifdef Q_OS_SYMBIAN
       
   255     this->showMaximized();
       
   256 #endif
       
   257 }
       
   258 
       
   259 SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration,
       
   260                        QNetworkConfigurationManager* configManager,
       
   261                        QListWidget* eventListWidget,
       
   262                        int index,
       
   263                        BearerEx * parent)
       
   264     : QWidget(parent), m_http(0), m_eventListWidget(eventListWidget),
       
   265      m_index(index), m_httpRequestOngoing(false), m_alrEnabled (false)
       
   266 {
       
   267     setupUi(this);
       
   268 
       
   269     m_ConfigManager = configManager;
       
   270     m_NetworkSession = new QNetworkSession(*apNetworkConfiguration);
       
   271 
       
   272     // Update initial Session state to UI
       
   273     newState(m_NetworkSession->state());
       
   274 
       
   275     connect(m_NetworkSession, SIGNAL(newConfigurationActivated()), this, SLOT(newConfigurationActivated()));
       
   276     connect(m_NetworkSession, SIGNAL(stateChanged(QNetworkSession::State)),
       
   277             this, SLOT(stateChanged(QNetworkSession::State)));
       
   278     connect(m_NetworkSession, SIGNAL(opened()), this, SLOT(opened()));
       
   279     connect(m_NetworkSession, SIGNAL(closed()), this, SLOT(closed()));
       
   280     connect(m_NetworkSession, SIGNAL(error(QNetworkSession::SessionError)), this, SLOT(error(QNetworkSession::SessionError)));
       
   281     
       
   282     if (apNetworkConfiguration->type() == QNetworkConfiguration::InternetAccessPoint) {
       
   283         snapLabel->hide();
       
   284         snapLineEdit->hide();
       
   285         alrButton->hide();
       
   286         iapLineEdit->setText(apNetworkConfiguration->name()+" ("+apNetworkConfiguration->identifier()+")");
       
   287     } else if (apNetworkConfiguration->type() == QNetworkConfiguration::ServiceNetwork) {
       
   288         snapLineEdit->setText(apNetworkConfiguration->name()+" ("+apNetworkConfiguration->identifier()+")");
       
   289     }
       
   290     bearerLineEdit->setText(apNetworkConfiguration->bearerName());
       
   291     sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+
       
   292                                  QString(" / ")+
       
   293                                  QString::number(m_NetworkSession->bytesReceived()));
       
   294     snapLineEdit->setFocusPolicy(Qt::NoFocus);
       
   295     iapLineEdit->setFocusPolicy(Qt::NoFocus);
       
   296     bearerLineEdit->setFocusPolicy(Qt::NoFocus);
       
   297     sentRecDataLineEdit->setFocusPolicy(Qt::NoFocus);
       
   298     stateLineEdit->setFocusPolicy(Qt::NoFocus);
       
   299 }
       
   300 
       
   301 SessionTab::~SessionTab()
       
   302 {
       
   303     // Need to be nulled, because modal dialogs may return after destruction of this object and
       
   304     // use already released resources.
       
   305     delete m_NetworkSession;
       
   306     m_NetworkSession = NULL;
       
   307     delete m_http;
       
   308     m_http = NULL;
       
   309 }
       
   310 
       
   311 void SessionTab::on_createQHttpButton_clicked()
       
   312 {
       
   313     if (m_httpRequestOngoing) {
       
   314         return;
       
   315     }
       
   316 
       
   317     if (m_http) {
       
   318         disconnect(m_http, 0, 0, 0);
       
   319         delete m_http;
       
   320     }
       
   321     m_http = new QHttp(this);
       
   322     createQHttpButton->setText("Recreate QHttp");
       
   323     connect(m_http, SIGNAL(done(bool)), this, SLOT(done(bool)));    
       
   324 }
       
   325 
       
   326 void SessionTab::on_sendRequestButton_clicked()
       
   327 {
       
   328     if (m_http) {
       
   329         QString urlstring("http://www.google.com");
       
   330         QUrl url(urlstring);
       
   331         m_http->setHost(url.host(), QHttp::ConnectionModeHttp, url.port() == -1 ? 0 : url.port());
       
   332         m_http->get(urlstring);
       
   333         m_httpRequestOngoing = true;
       
   334     } else {
       
   335         QMessageBox msgBox;
       
   336         msgBox.setStandardButtons(QMessageBox::Close);
       
   337         msgBox.setText("QHttp not created.\nCreate QHttp First.");
       
   338         msgBox.exec();
       
   339     }
       
   340 }
       
   341 
       
   342 void SessionTab::on_openSessionButton_clicked()
       
   343 {
       
   344     m_NetworkSession->open();
       
   345     if (m_NetworkSession->isOpen()) {
       
   346         newState(m_NetworkSession->state()); 
       
   347     }
       
   348 }
       
   349 
       
   350 void SessionTab::on_closeSessionButton_clicked()
       
   351 {
       
   352     m_NetworkSession->close();
       
   353     if (!m_NetworkSession->isOpen()) {
       
   354         newState(m_NetworkSession->state()); 
       
   355     }
       
   356 }
       
   357 
       
   358 void SessionTab::on_stopConnectionButton_clicked()
       
   359 {
       
   360     m_NetworkSession->stop();
       
   361 }
       
   362 
       
   363 void SessionTab::on_alrButton_clicked()
       
   364 {
       
   365     if (!m_alrEnabled) {
       
   366         connect(m_NetworkSession, SIGNAL(preferredConfigurationChanged(const QNetworkConfiguration&, bool)),
       
   367                 this, SLOT(preferredConfigurationChanged(const QNetworkConfiguration&, bool)));
       
   368         alrButton->setText("Disable ALR");
       
   369         m_alrEnabled = true;
       
   370     } else {
       
   371         disconnect(m_NetworkSession, SIGNAL(preferredConfigurationChanged(const QNetworkConfiguration&, bool)), 0, 0);
       
   372         alrButton->setText("Enable ALR");
       
   373         m_alrEnabled = false;
       
   374     }
       
   375 }
       
   376 
       
   377 void SessionTab::on_deleteSessionButton_clicked()
       
   378 {
       
   379     setWindowTitle("Bearer Example");
       
   380     delete this;
       
   381 }
       
   382 
       
   383 void SessionTab::newConfigurationActivated()
       
   384 {
       
   385     QMessageBox msgBox;
       
   386     msgBox.setText("New configuration activated.");
       
   387     msgBox.setInformativeText("Do you want to accept new configuration?");
       
   388     msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
       
   389     msgBox.setDefaultButton(QMessageBox::Yes);
       
   390     if (msgBox.exec() == QMessageBox::Yes) {
       
   391         m_NetworkSession->accept();
       
   392         iapLineEdit->setText(m_config.name()+" ("+m_config.identifier()+")");
       
   393     } else {
       
   394         m_NetworkSession->reject();
       
   395     }
       
   396 }
       
   397 
       
   398 void SessionTab::preferredConfigurationChanged(const QNetworkConfiguration& config, bool /*isSeamless*/)
       
   399 {
       
   400     m_config =  config;
       
   401     QMessageBox msgBox;
       
   402     msgBox.setText("Roaming to new configuration.");
       
   403     msgBox.setInformativeText("Do you want to migrate to "+config.name()+"?");
       
   404     msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
       
   405     msgBox.setDefaultButton(QMessageBox::Yes);
       
   406     if (msgBox.exec() == QMessageBox::Yes) {
       
   407         m_NetworkSession->migrate();
       
   408     } else {
       
   409         m_NetworkSession->ignore();
       
   410     }
       
   411 }
       
   412 
       
   413 void SessionTab::opened()
       
   414 {
       
   415     QListWidgetItem* listItem = new QListWidgetItem();
       
   416     QFont font = listItem->font();
       
   417     font.setBold(true);
       
   418     listItem->setFont(font);        
       
   419     listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+QString("Opened"));
       
   420     m_eventListWidget->addItem(listItem);
       
   421     
       
   422     QVariant identifier = m_NetworkSession->property("ActiveConfiguration");
       
   423     if (!identifier.isNull()) {
       
   424         QString configId = identifier.toString();
       
   425         QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId);
       
   426         if (config.isValid()) {
       
   427             iapLineEdit->setText(config.name()+" ("+config.identifier()+")");
       
   428         }
       
   429     }
       
   430 
       
   431     if (m_NetworkSession->configuration().type() == QNetworkConfiguration::UserChoice) {
       
   432         QVariant identifier = m_NetworkSession->property("UserChoiceConfiguration");
       
   433         if (!identifier.isNull()) {
       
   434             QString configId = identifier.toString();
       
   435             QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId);
       
   436             if (config.isValid() && (config.type() == QNetworkConfiguration::ServiceNetwork)) {
       
   437                 snapLineEdit->setText(config.name());
       
   438             }
       
   439         }
       
   440     }
       
   441 }
       
   442 
       
   443 void SessionTab::closed()
       
   444 {
       
   445     QListWidgetItem* listItem = new QListWidgetItem();
       
   446     QFont font = listItem->font();
       
   447     font.setBold(true);
       
   448     listItem->setFont(font);        
       
   449     listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+QString("Closed"));
       
   450     m_eventListWidget->addItem(listItem);
       
   451 }
       
   452 
       
   453 QString SessionTab::stateString(QNetworkSession::State state)
       
   454 {
       
   455     QString stateString;
       
   456     switch (state)
       
   457     {
       
   458         case QNetworkSession::Invalid:
       
   459             stateString = "Invalid";
       
   460             break;
       
   461         case QNetworkSession::NotAvailable:
       
   462             stateString = "NotAvailable";
       
   463             break;
       
   464         case QNetworkSession::Connecting:
       
   465             stateString = "Connecting";
       
   466             break;
       
   467         case QNetworkSession::Connected:
       
   468             stateString = "Connected";
       
   469             break;
       
   470         case QNetworkSession::Closing:
       
   471             stateString = "Closing";
       
   472             break;
       
   473         case QNetworkSession::Disconnected:
       
   474             stateString = "Disconnected";
       
   475             break;
       
   476         case QNetworkSession::Roaming:
       
   477             stateString = "Roaming";
       
   478             break;
       
   479     }
       
   480     return stateString;
       
   481 }
       
   482 
       
   483 void SessionTab::stateChanged(QNetworkSession::State state)    
       
   484 {
       
   485     newState(state);
       
   486     
       
   487     QListWidgetItem* listItem = new QListWidgetItem();
       
   488     listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+stateString(state));
       
   489     m_eventListWidget->addItem(listItem);
       
   490 }
       
   491 
       
   492 void SessionTab::newState(QNetworkSession::State state)
       
   493 {
       
   494     QVariant identifier = m_NetworkSession->property("ActiveConfiguration");
       
   495     if (state == QNetworkSession::Connected && !identifier.isNull()) {
       
   496         QString configId = identifier.toString();
       
   497         QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId);
       
   498         if (config.isValid()) {
       
   499             iapLineEdit->setText(config.name()+" ("+config.identifier()+")");
       
   500             bearerLineEdit->setText(config.bearerName());
       
   501         }
       
   502     } else {
       
   503         bearerLineEdit->setText(m_NetworkSession->configuration().bearerName());
       
   504     }
       
   505 
       
   506     QString active;
       
   507     if (m_NetworkSession->isOpen()) {
       
   508         active = " (O)";
       
   509     }
       
   510     stateLineEdit->setText(stateString(state)+active);
       
   511 }
       
   512 
       
   513 void SessionTab::error(QNetworkSession::SessionError error)
       
   514 {
       
   515     QListWidgetItem* listItem = new QListWidgetItem();
       
   516     QMessageBox msgBox;
       
   517     msgBox.setStandardButtons(QMessageBox::Close);
       
   518     
       
   519     QString errorString;
       
   520     switch (error)
       
   521     {
       
   522         case QNetworkSession::UnknownSessionError:
       
   523             errorString = "UnknownSessionError";
       
   524             break;
       
   525         case QNetworkSession::SessionAbortedError:
       
   526             errorString = "SessionAbortedError";
       
   527             break;
       
   528         case QNetworkSession::RoamingError:
       
   529             errorString = "RoamingError";
       
   530             break;
       
   531         case QNetworkSession::OperationNotSupportedError:
       
   532             errorString = "OperationNotSupportedError";
       
   533             break;
       
   534         case QNetworkSession::InvalidConfigurationError:
       
   535             errorString = "InvalidConfigurationError";
       
   536             break;
       
   537     }
       
   538     listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+errorString);
       
   539     m_eventListWidget->addItem(listItem);
       
   540     
       
   541     msgBox.setText(errorString);
       
   542     msgBox.exec();
       
   543 }
       
   544 
       
   545 void SessionTab::done(bool error)
       
   546 {
       
   547     m_httpRequestOngoing = false;
       
   548 
       
   549     QMessageBox msgBox;
       
   550     msgBox.setStandardButtons(QMessageBox::Close);
       
   551     if (error) {
       
   552         msgBox.setText("HTTP request failed.");
       
   553     } else {
       
   554         QString result(m_http->readAll());
       
   555         msgBox.setText(QString("HTTP request finished successfully.\nReceived ")+QString::number(result.length())+QString(" bytes."));
       
   556     }
       
   557     msgBox.exec();
       
   558     // Check if the networksession still exists - it may have gone after returning from
       
   559     // the modal dialog (in the case that app has been closed, and deleting QHttp will
       
   560     // trigger the done() invokation).
       
   561     if (m_NetworkSession) {
       
   562         sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+
       
   563                                      QString(" / ")+
       
   564                                      QString::number(m_NetworkSession->bytesReceived()));
       
   565     } else {
       
   566         sentRecDataLineEdit->setText("Data amounts not available.");
       
   567     }
       
   568 }
       
   569 
       
   570 // End of file
       
   571