qtmobility/src/bearer/qnetworksession.h
branchRCL_3
changeset 10 cd2778e5acfe
equal deleted inserted replaced
9:5d007b20cfd0 10:cd2778e5acfe
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QNETWORKSESSION_H
       
    43 #define QNETWORKSESSION_H
       
    44 
       
    45 #include "qmobilityglobal.h"
       
    46 
       
    47 #include <QtCore/qobject.h>
       
    48 #include <QtCore/qshareddata.h>
       
    49 #include <QtCore/qstring.h>
       
    50 #include <QtNetwork/qnetworkinterface.h>
       
    51 #include <QtCore/qvariant.h>
       
    52 #include "qnetworkconfiguration.h"
       
    53 
       
    54 
       
    55 QT_BEGIN_HEADER
       
    56 
       
    57 QTM_BEGIN_NAMESPACE
       
    58 
       
    59 class QNetworkSessionPrivate;
       
    60 class Q_BEARER_EXPORT QNetworkSession : public QObject
       
    61 {
       
    62     Q_OBJECT
       
    63 public:
       
    64     enum State {
       
    65         Invalid = 0,
       
    66         NotAvailable,
       
    67         Connecting,
       
    68         Connected,
       
    69         Closing,
       
    70         Disconnected,
       
    71         Roaming
       
    72     };
       
    73 
       
    74     enum SessionError {
       
    75         UnknownSessionError = 0,
       
    76         SessionAbortedError,
       
    77         RoamingError,
       
    78         OperationNotSupportedError,
       
    79         InvalidConfigurationError
       
    80     };
       
    81 
       
    82     explicit QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0);
       
    83     virtual ~QNetworkSession();
       
    84 
       
    85     bool isOpen() const;
       
    86     QNetworkConfiguration configuration() const;
       
    87     QNetworkInterface interface() const;
       
    88 
       
    89     State state() const;
       
    90     SessionError error() const;
       
    91     QString errorString() const;
       
    92     QVariant sessionProperty(const QString& key) const;
       
    93     void setSessionProperty(const QString& key, const QVariant& value);
       
    94 
       
    95     quint64 bytesWritten() const;
       
    96     quint64 bytesReceived() const;
       
    97     quint64 activeTime() const;
       
    98     
       
    99     bool waitForOpened(int msecs = 30000);
       
   100 
       
   101 public Q_SLOTS:
       
   102     void open();
       
   103     void close();
       
   104     void stop();
       
   105 
       
   106     //roaming related slots
       
   107     void migrate();
       
   108     void ignore();
       
   109     void accept();
       
   110     void reject();
       
   111 
       
   112 
       
   113 Q_SIGNALS:
       
   114     void stateChanged(QNetworkSession::State);
       
   115     void opened();
       
   116     void closed();
       
   117     void error(QNetworkSession::SessionError);
       
   118     void preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless);
       
   119     void newConfigurationActivated();
       
   120 
       
   121 protected:
       
   122     virtual void connectNotify(const char *signal);
       
   123     virtual void disconnectNotify(const char *signal);
       
   124 
       
   125 private:
       
   126     QNetworkSessionPrivate* d;
       
   127     friend class QNetworkSessionPrivate;
       
   128     };
       
   129 
       
   130 QTM_END_NAMESPACE
       
   131 
       
   132 QT_END_HEADER
       
   133 
       
   134 #endif //QNETWORKSESSION_H