Qt 4.8
qnetworksession_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtNetwork module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QNETWORKSESSIONPRIVATE_H
43 #define QNETWORKSESSIONPRIVATE_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "qnetworksession.h"
58 #include "QtCore/qsharedpointer.h"
59 
60 #ifndef QT_NO_BEARERMANAGEMENT
61 
62 #ifdef Q_OS_SYMBIAN
63 class RConnection;
64 class RSocket;
65 class RHostResolver;
66 #endif
67 
69 
71 {
72  Q_OBJECT
73 
74  friend class QNetworkSession;
75 
76 public:
78  state(QNetworkSession::Invalid), isOpen(false), mutex(QMutex::Recursive)
79  {}
81  {}
82 
83  //called by QNetworkSession constructor and ensures
84  //that the state is immediately updated (w/o actually opening
85  //a session). Also this function should take care of
86  //notification hooks to discover future state changes.
87  virtual void syncStateWithInterface() = 0;
88 
89 #ifndef QT_NO_NETWORKINTERFACE
90  virtual QNetworkInterface currentInterface() const = 0;
91 #endif
92  virtual QVariant sessionProperty(const QString &key) const = 0;
93  virtual void setSessionProperty(const QString &key, const QVariant &value) = 0;
94 
95  virtual void open() = 0;
96  virtual void close() = 0;
97  virtual void stop() = 0;
98 
99  virtual void setALREnabled(bool /*enabled*/) {}
100  virtual void migrate() = 0;
101  virtual void accept() = 0;
102  virtual void ignore() = 0;
103  virtual void reject() = 0;
104 
105  virtual QString errorString() const = 0; //must return translated string
106  virtual QNetworkSession::SessionError error() const = 0;
107 
108  virtual quint64 bytesWritten() const = 0;
109  virtual quint64 bytesReceived() const = 0;
110  virtual quint64 activeTime() const = 0;
111 
112 #ifdef Q_OS_SYMBIAN
113  // get internal RConnection (not thread safe, call only from thread that owns the QNetworkSession)
114  static RConnection* nativeSession(QNetworkSession&);
115  virtual RConnection* nativeSession() = 0;
116  // open socket using the internal RConnection (thread safe)
117  static TInt nativeOpenSocket(QNetworkSession& session, RSocket& socket, TUint family, TUint type, TUint protocol);
118  // open host resolver using the internal RConnection (thread safe)
119  static TInt nativeOpenHostResolver(QNetworkSession& session, RHostResolver& resolver, TUint family, TUint protocol);
120 #endif
121 protected:
123  {
124  return config.d;
125  }
126 
129  {
130  config.d = ptr;
131  }
132 
133 Q_SIGNALS:
134  //releases any pending waitForOpened() calls
135  void quitPendingWaitsForOpened();
136 
139  void closed();
141  void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
142 
143 protected:
145 
146  // The config set on QNetworkSession.
148 
149  // If publicConfig is a ServiceNetwork this is a copy of publicConfig.
150  // If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual
151  // ServiceNetwork configuration.
153 
154  // This is the actual active configuration currently in use by the session.
155  // Either a copy of publicConfig or one of serviceConfig.children().
157 
159  bool isOpen;
160 
162 };
163 
165 
167 
168 #endif // QT_NO_BEARERMANAGEMENT
169 
170 #endif // QNETWORKSESSIONPRIVATE_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QExplicitlySharedDataPointer< QNetworkConfigurationPrivate > d
QVariant sessionProperty(const QString &key) const
Returns the value for property key.
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The QMutex class provides access serialization between threads.
Definition: qmutex.h:60
QNetworkConfigurationPrivatePointer privateConfiguration(const QNetworkConfiguration &config) const
quint64 activeTime() const
Returns the number of seconds that the session has been active.
void migrate()
Instructs the session to roam to the new access point.
void reject()
The new access point is not suitable for the application.
#define error(msg)
void stateChanged(QNetworkSession::State)
This signal is emitted whenever the state of the network session changes.
static bool ignore(const char *test, const char *const *table)
Definition: qaxserver.cpp:660
State
This enum describes the connectivity state of the session.
QNetworkConfiguration serviceConfig
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
QNetworkConfiguration activeConfig
virtual void setALREnabled(bool)
Q_GUI_EXPORT QString errorString(EGLint code=eglGetError())
Definition: qegl.cpp:743
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.
Definition: qglobal.h:89
void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless)
This signal is emitted when the preferred configuration/access point for the session changes...
void accept()
Instructs the session to permanently accept the new access point.
unsigned __int64 quint64
Definition: qglobal.h:943
void setPrivateConfiguration(QNetworkConfiguration &config, QNetworkConfigurationPrivatePointer ptr) const
quint64 bytesWritten() const
Returns the amount of data sent in bytes; otherwise 0.
QNetworkSession::State state
const T * ptr(const T &t)
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
State state() const
Returns the state of the session.
QNetworkConfiguration publicConfig
The QNetworkSession class provides control over the system&#39;s access points and enables session manage...
bool isOpen() const
Returns true if this session is open.
quint64 bytesReceived() const
Returns the amount of data received in bytes; otherwise 0.
#define Q_NETWORK_EXPORT
Definition: qglobal.h:1452
int key
void stop()
Invalidates all open sessions against the network interface and therefore stops the underlying networ...
void closed()
This signal is emitted when the network session has been closed.
The QNetworkInterface class provides a listing of the host&#39;s IP addresses and network interfaces...
void setSessionProperty(const QString &key, const QVariant &value)
Sets the property value on the session.
void newConfigurationActivated()
This signal is emitted once the session has roamed to the new access point.
void close()
Decreases the session counter on the associated network configuration.
int open(const char *, int,...)