Qt 4.8
qnetworksession.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 QNETWORKSESSION_H
43 #define QNETWORKSESSION_H
44 
45 #include <QtCore/qobject.h>
46 #include <QtCore/qstring.h>
47 #include <QtNetwork/qnetworkinterface.h>
48 #include <QtCore/qvariant.h>
49 #include <QtNetwork/qnetworkconfiguration.h>
50 
51 #ifndef QT_NO_BEARERMANAGEMENT
52 
53 #if defined(Q_OS_WIN) && defined(interface)
54 #undef interface
55 #endif
56 
58 
59 #ifndef QT_MOBILITY_BEARER
60 #include <QtCore/qshareddata.h>
62 QT_MODULE(Network)
63 #define QNetworkSessionExport Q_NETWORK_EXPORT
64 #else
65 #include "qmobilityglobal.h"
66 QTM_BEGIN_NAMESPACE
67 #define QNetworkSessionExport Q_BEARER_EXPORT
68 #endif
69 
72 {
73  Q_OBJECT
74 
75 public:
76  enum State {
77  Invalid = 0,
83  Roaming
84  };
85 
86  enum SessionError {
87  UnknownSessionError = 0,
91  InvalidConfigurationError
92  };
93 
94  explicit QNetworkSession(const QNetworkConfiguration &connConfig, QObject *parent = 0);
95  virtual ~QNetworkSession();
96 
97  bool isOpen() const;
98  QNetworkConfiguration configuration() const;
99 #ifndef QT_NO_NETWORKINTERFACE
100  QNetworkInterface interface() const;
101 #endif
102 
103  State state() const;
104  SessionError error() const;
105  QString errorString() const;
106  QVariant sessionProperty(const QString &key) const;
107  void setSessionProperty(const QString &key, const QVariant &value);
108 
109  quint64 bytesWritten() const;
110  quint64 bytesReceived() const;
111  quint64 activeTime() const;
112 
113  bool waitForOpened(int msecs = 30000);
114 
115 public Q_SLOTS:
116  void open();
117  void close();
118  void stop();
119 
120  //roaming related slots
121  void migrate();
122  void ignore();
123  void accept();
124  void reject();
125 
126 Q_SIGNALS:
127  void stateChanged(QNetworkSession::State);
128  void opened();
129  void closed();
131  void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
132  void newConfigurationActivated();
133 
134 protected:
135  virtual void connectNotify(const char *signal);
136  virtual void disconnectNotify(const char *signal);
137 
138 private:
141 };
142 
143 #ifndef QT_MOBILITY_BEARER
147 #else
148 QTM_END_NAMESPACE
149 #endif
150 
152 
153 #endif // QT_NO_BEARERMANAGEMENT
154 
155 #endif // QNETWORKSESSION_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define error(msg)
QNetworkSessionPrivate * d
static bool ignore(const char *test, const char *const *table)
Definition: qaxserver.cpp:660
State
This enum describes the connectivity state of the session.
#define Q_SLOTS
Definition: qobjectdefs.h:71
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
virtual void connectNotify(const char *signal)
This virtual function is called when something has been connected to signal in this object...
Definition: qobject.cpp:3142
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
unsigned __int64 quint64
Definition: qglobal.h:943
The State element defines configurations of objects and properties.
#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
#define QNetworkSessionExport
The QNetworkSession class provides control over the system&#39;s access points and enables session manage...
virtual void disconnectNotify(const char *signal)
This virtual function is called when something has been disconnected from signal in this object...
Definition: qobject.cpp:3162
int key
The QNetworkInterface class provides a listing of the host&#39;s IP addresses and network interfaces...
#define QT_END_HEADER
Definition: qglobal.h:137
int open(const char *, int,...)