SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent) : QWidget(parent), statsTimer(-1) { setupUi(this); #ifdef QT_NO_NETWORKINTERFACE interfaceName->setVisible(false); interfaceNameLabel->setVisible(false); interfaceGuid->setVisible(false); interfaceGuidLabel->setVisible(false); #endif session = new QNetworkSession(config, this); connect(session, SIGNAL(stateChanged(QNetworkSession::State)), this, SLOT(updateSession())); connect(session, SIGNAL(error(QNetworkSession::SessionError)), this, SLOT(updateSessionError(QNetworkSession::SessionError))); updateSession(); sessionId->setText(QString("0x%1").arg(qulonglong(session), 8, 16, QChar('0'))); configuration->setText(session->configuration().name()); connect(openSessionButton, SIGNAL(clicked()), this, SLOT(openSession())); connect(openSyncSessionButton, SIGNAL(clicked()), this, SLOT(openSyncSession())); connect(closeSessionButton, SIGNAL(clicked()), this, SLOT(closeSession())); connect(stopSessionButton, SIGNAL(clicked()), this, SLOT(stopSession())); #if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) connect(deleteSessionButton, SIGNAL(clicked()), this, SLOT(deleteSession())); #endif }
void SessionWidget::updateSession() { updateSessionState(session->state()); updateSessionError(session->error()); if (session->state() == QNetworkSession::Connected) statsTimer = startTimer(1000); else killTimer(statsTimer); if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint) bearer->setText(session->configuration().bearerName()); else { QNetworkConfigurationManager mgr; QNetworkConfiguration c = mgr.configurationFromIdentifier(session->sessionProperty("ActiveConfiguration").toString()); bearer->setText(c.bearerName()); } #ifndef QT_NO_NETWORKINTERFACE interfaceName->setText(session->interface().humanReadableName()); interfaceGuid->setText(session->interface().name()); #endif }