45 #include <QtNetwork/qnetworksession.h> 46 #include <QtNetwork/private/qnetworkconfigmanager_p.h> 48 #include <QtCore/qdatetime.h> 49 #include <QtCore/qdebug.h> 50 #include <QtCore/qmutex.h> 51 #include <QtCore/qstringlist.h> 53 #ifndef QT_NO_BEARERMANAGEMENT 85 #include "qnetworksession_impl.moc" 99 qRegisterMetaType<QBearerEngineImpl::ConnectionError>(
"QBearerEngineImpl::ConnectionError");
101 switch (publicConfig.type()) {
103 activeConfig = publicConfig;
106 qRegisterMetaType<QNetworkConfigurationPrivatePointer>(
"QNetworkConfigurationPrivatePointer");
116 serviceConfig = publicConfig;
126 networkConfigurationsChanged();
131 if (serviceConfig.isValid()) {
134 }
else if (!isOpen) {
138 emit stateChanged(state);
147 emit stateChanged(state);
149 engine->connectToId(activeConfig.identifier());
154 emit quitPendingWaitsForOpened();
160 if (serviceConfig.isValid()) {
172 if (serviceConfig.isValid()) {
178 emit stateChanged(state);
180 engine->disconnectFromId(activeConfig.identifier());
182 sessionManager()->forceSessionClose(activeConfig);
207 #ifndef QT_NO_NETWORKINTERFACE 213 QString interface = engine->getInterfaceFromId(activeConfig.identifier());
214 if (interface.isEmpty())
223 if (engine && engine->requiresPolling() &&
225 return sessionTimeout >= 0 ? sessionTimeout * 10000 : -1;
235 if (engine && engine->requiresPolling() &&
237 int timeout = value.
toInt();
241 sessionTimeout = timeout / 10000;
254 return tr(
"Unknown session error.");
256 return tr(
"The session was aborted by the user or system.");
258 return tr(
"The requested operation is not supported by the system.");
260 return tr(
"The specified configuration cannot be used.");
262 return tr(
"Roaming was aborted or is not possible.");
278 return engine->bytesWritten(activeConfig.identifier());
285 return engine->bytesReceived(activeConfig.identifier());
304 if (activeConfig != config) {
310 activeConfig = config;
318 emit newConfigurationActivated();
322 if (state != oldState)
323 emit stateChanged(state);
328 if (serviceConfig.children().isEmpty())
333 if (state != oldState)
334 emit stateChanged(state);
343 state = engine->sessionStateForId(activeConfig.identifier());
345 bool oldActive = isOpen;
348 if (!oldActive && isOpen)
349 emit quitPendingWaitsForOpened();
350 if (oldActive && !isOpen)
353 if (oldState != state)
354 emit stateChanged(state);
359 if (serviceConfig.isValid())
360 updateStateFromServiceNetwork();
362 updateStateFromActiveConfig();
364 startTime = engine->startTime(activeConfig.identifier());
369 if (serviceConfig.isValid() &&
370 (config->
id == serviceConfig.identifier() || config->
id == activeConfig.identifier())) {
371 updateStateFromServiceNetwork();
372 }
else if (config->
id == activeConfig.identifier()) {
373 updateStateFromActiveConfig();
379 if (activeConfig == config) {
392 if (activeConfig.identifier() == id) {
393 networkConfigurationsChanged();
412 if (--sessionTimeout <= 0) {
421 #endif // QT_NO_BEARERMANAGEMENT The QVariant class acts like a union for the most common Qt data types.
Q_GLOBAL_STATIC(QNetworkSessionManagerPrivate, sessionManager)
static QNetworkInterface interfaceFromName(const QString &name)
Returns a QNetworkInterface object for the interface named name.
#define QT_END_NAMESPACE
This macro expands to.
void forcedSessionClose(const QNetworkConfiguration &config)
uint toTime_t() const
Returns the datetime as the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).
State
This enum describes the connectivity state of the session.
QVariant sessionProperty(const QString &key) const
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QList< QNetworkConfiguration > children() const
Returns all sub configurations of this network configuration in priority order.
void updateStateFromActiveConfig()
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
The QObject class is the base class of all Qt objects.
void updateStateFromServiceNetwork()
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
SessionError
This enum describes the session errors that can occur.
The QNetworkConfiguration class provides an abstraction of one or more access point configurations...
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual QNetworkSession::SessionError error() const =0
void forceSessionClose(const QNetworkConfiguration &config)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
void forcedSessionClose(const QNetworkConfiguration &config)
void networkConfigurationsChanged()
QNetworkConfigurationManagerPrivate * qNetworkConfigurationManagerPrivate()
QString errorString() const
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
~QNetworkSessionManagerPrivate()
QNetworkSessionManagerPrivate(QObject *parent=0)
void setSessionProperty(const QString &key, const QVariant &value)
static QBearerEngineImpl * getEngineFromId(const QString &id)
quint64 bytesWritten() const
void syncStateWithInterface()
QNetworkSession::SessionError error() const
QObject * parent() const
Returns a pointer to the parent object.
StateFlags state() const
Returns the current state of the configuration.
virtual bool hasIdentifier(const QString &id)=0
QList< QBearerEngine * > engines() const
QNetworkInterface currentInterface() const
static QDateTime currentDateTime()
Returns the current datetime, as reported by the system clock, in the local time zone.
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces...
void configurationChanged(QNetworkConfigurationPrivatePointer config)
quint64 activeTime() const
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
quint64 bytesReceived() const