diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-07-28 04:12:30 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-07-28 04:45:11 (GMT) |
commit | 71ef5269c03d6230e6ebbf6f3c0b6f8836739ec3 (patch) | |
tree | fcb25ebcade8ee6daba797c9aa88e6880aeea709 /src/plugins | |
parent | a259bd2841b3ce7e34bb18990332bd497f97cdd0 (diff) | |
download | Qt-71ef5269c03d6230e6ebbf6f3c0b6f8836739ec3.zip Qt-71ef5269c03d6230e6ebbf6f3c0b6f8836739ec3.tar.gz Qt-71ef5269c03d6230e6ebbf6f3c0b6f8836739ec3.tar.bz2 |
Cherry pick fix for QTMOBILITY-408 from Qt Mobility.
7f9a8ebcfe86d3df428707888c3ab5fcd10226a4
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/bearer/icd/qnetworksession_impl.cpp | 59 | ||||
-rw-r--r-- | src/plugins/bearer/icd/qnetworksession_impl.h | 8 |
2 files changed, 34 insertions, 33 deletions
diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp index aeac620..e8e5183 100644 --- a/src/plugins/bearer/icd/qnetworksession_impl.cpp +++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp @@ -235,7 +235,7 @@ void QNetworkSessionPrivateImpl::updateIdentifier(const QString &newId) } -quint64 QNetworkSessionPrivateImpl::getStatistics(bool sent) const +QNetworkSessionPrivateImpl::Statistics QNetworkSessionPrivateImpl::getStatistics() const { /* This could be also implemented by using the Maemo::Icd::statistics() * that gets the statistics data for a specific IAP. Change if @@ -243,56 +243,51 @@ quint64 QNetworkSessionPrivateImpl::getStatistics(bool sent) const */ Maemo::Icd icd; QList<Maemo::IcdStatisticsResult> stats_results; - quint64 counter_rx = 0, counter_tx = 0; + Statistics stats = { 0, 0, 0}; - if (!icd.statistics(stats_results)) { - return 0; - } + if (!icd.statistics(stats_results)) + return stats; foreach (const Maemo::IcdStatisticsResult &res, stats_results) { - if (res.params.network_attrs & ICD_NW_ATTR_IAPNAME) { - /* network_id is the IAP UUID */ - if (QString(res.params.network_id.data()) == activeConfig.identifier()) { - counter_tx = res.bytes_sent; - counter_rx = res.bytes_received; - } - } else { - /* We probably will never get to this branch */ - IcdNetworkConfigurationPrivate *icdConfig = - toIcdConfig(privateConfiguration(activeConfig)); + if (res.params.network_attrs & ICD_NW_ATTR_IAPNAME) { + /* network_id is the IAP UUID */ + if (QString(res.params.network_id.data()) == activeConfig.identifier()) { + stats.txData = res.bytes_sent; + stats.rxData = res.bytes_received; + stats.activeTime = res.time_active; + } + } else { + /* We probably will never get to this branch */ + IcdNetworkConfigurationPrivate *icdConfig = + toIcdConfig(privateConfiguration(activeConfig)); - icdConfig->mutex.lock(); - if (res.params.network_id == icdConfig->network_id) { - counter_tx = res.bytes_sent; - counter_rx = res.bytes_received; - } - icdConfig->mutex.unlock(); - } + icdConfig->mutex.lock(); + if (res.params.network_id == icdConfig->network_id) { + stats.txData = res.bytes_sent; + stats.rxData = res.bytes_received; + stats.activeTime = res.time_active; + } + icdConfig->mutex.unlock(); + } } - if (sent) - return counter_tx; - else - return counter_rx; + return stats; } quint64 QNetworkSessionPrivateImpl::bytesWritten() const { - return getStatistics(true); + return getStatistics().txData; } quint64 QNetworkSessionPrivateImpl::bytesReceived() const { - return getStatistics(false); + return getStatistics().rxData; } quint64 QNetworkSessionPrivateImpl::activeTime() const { - if (startTime.isNull()) { - return 0; - } - return startTime.secsTo(QDateTime::currentDateTime()); + return getStatistics().activeTime; } diff --git a/src/plugins/bearer/icd/qnetworksession_impl.h b/src/plugins/bearer/icd/qnetworksession_impl.h index c43b1f0..390e508 100644 --- a/src/plugins/bearer/icd/qnetworksession_impl.h +++ b/src/plugins/bearer/icd/qnetworksession_impl.h @@ -170,6 +170,12 @@ private: QNetworkConfigurationManager manager; QIcdEngine *engine; + struct Statistics { + quint64 txData; + quint64 rxData; + quint64 activeTime; + }; + // The config set on QNetworkSession. QNetworkConfiguration config; @@ -186,7 +192,7 @@ private: friend class IcdListener; void updateState(QNetworkSession::State); void updateIdentifier(const QString &newId); - quint64 getStatistics(bool sent) const; + Statistics getStatistics() const; void cleanupSession(void); void updateProxyInformation(); |