qtmobility/src/bearer/qnetworksession_maemo_p.h
changeset 0 cfcbf08528c4
child 2 5822d84012fb
child 4 90517678cc4f
equal deleted inserted replaced
-1:000000000000 0:cfcbf08528c4
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 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 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 for the convenience
       
    50 // of the QLibrary class.  This header file may change from
       
    51 // version to version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 #include "qnetworkconfigmanager_maemo_p.h"
       
    56 #include "qnetworksession.h"
       
    57 
       
    58 #include <qnetworksession.h>
       
    59 #include <QNetworkInterface>
       
    60 #include <QDateTime>
       
    61 
       
    62 #ifdef Q_WS_MAEMO_6
       
    63 #include <icd/dbus_api.h>
       
    64 #endif
       
    65 
       
    66 QTM_BEGIN_NAMESPACE
       
    67 
       
    68 class QNetworkSessionPrivate : public QObject
       
    69 {
       
    70     Q_OBJECT
       
    71 public:
       
    72     QNetworkSessionPrivate() : 
       
    73         tx_data(0), rx_data(0), m_activeTime(0), isOpen(false),
       
    74 #ifdef Q_WS_MAEMO_6
       
    75         connectFlags(ICD_CONNECTION_FLAG_USER_EVENT),
       
    76 #else
       
    77         connectFlags(0),
       
    78 #endif
       
    79         currentState(QNetworkSession::Invalid)
       
    80     {
       
    81     }
       
    82 
       
    83     ~QNetworkSessionPrivate()
       
    84     {
       
    85 	cleanupSession();
       
    86     }
       
    87 
       
    88     //called by QNetworkSession constructor and ensures
       
    89     //that the state is immediately updated (w/o actually opening
       
    90     //a session). Also this function should take care of 
       
    91     //notification hooks to discover future state changes.
       
    92     void syncStateWithInterface();
       
    93 
       
    94     QNetworkInterface currentInterface() const;
       
    95     QVariant sessionProperty(const QString& key) const;
       
    96     void setSessionProperty(const QString& key, const QVariant& value);
       
    97 
       
    98     void open();
       
    99     void close();
       
   100     void stop();
       
   101     void migrate();
       
   102     void accept();
       
   103     void ignore();
       
   104     void reject();
       
   105 
       
   106     QString errorString() const; //must return translated string
       
   107     QNetworkSession::SessionError error() const;
       
   108 
       
   109     quint64 bytesWritten() const;
       
   110     quint64 bytesReceived() const;
       
   111     quint64 activeTime() const;
       
   112 
       
   113 private:
       
   114     void updateStateFromServiceNetwork();
       
   115     void updateStateFromActiveConfig();
       
   116 
       
   117 Q_SIGNALS:
       
   118     //releases any pending waitForOpened() calls
       
   119     void quitPendingWaitsForOpened();
       
   120 
       
   121 private Q_SLOTS:
       
   122     void do_open();
       
   123     void networkConfigurationsChanged();
       
   124     void configurationChanged(const QNetworkConfiguration &config);
       
   125     void updateProxies(QNetworkSession::State newState);
       
   126 
       
   127 private:
       
   128     QNetworkConfigurationManager manager;
       
   129 
       
   130     quint64 tx_data;
       
   131     quint64 rx_data;
       
   132     quint64 m_activeTime;
       
   133 
       
   134     // The config set on QNetworkSession.
       
   135     QNetworkConfiguration publicConfig;
       
   136 
       
   137     // If publicConfig is a ServiceNetwork this is a copy of publicConfig.
       
   138     // If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual
       
   139     // ServiceNetwork configuration.
       
   140     QNetworkConfiguration serviceConfig;
       
   141 
       
   142     // This is the actual active configuration currently in use by the session.
       
   143     // Either a copy of publicConfig or one of serviceConfig.children().
       
   144     QNetworkConfiguration activeConfig;
       
   145 
       
   146     QNetworkConfiguration& copyConfig(QNetworkConfiguration &fromConfig, QNetworkConfiguration &toConfig, bool deepCopy = true);
       
   147     void clearConfiguration(QNetworkConfiguration &config);
       
   148     void cleanupAnyConfiguration();
       
   149 
       
   150     QNetworkSession::State state;
       
   151     bool isOpen;
       
   152     bool opened;
       
   153     icd_connection_flags connectFlags;
       
   154 
       
   155     QNetworkSession::SessionError lastError;
       
   156 
       
   157     QNetworkSession* q;
       
   158     friend class QNetworkSession;
       
   159 
       
   160     QDateTime startTime;
       
   161     QString currentNetworkInterface;
       
   162     friend class IcdListener;
       
   163     void updateState(QNetworkSession::State);
       
   164     void updateIdentifier(QString &newId);
       
   165     quint64 getStatistics(bool sent) const;
       
   166     void cleanupSession(void);
       
   167 
       
   168     void updateProxyInformation();
       
   169     void clearProxyInformation();
       
   170     QNetworkSession::State currentState;
       
   171 };
       
   172 
       
   173 QTM_END_NAMESPACE
       
   174 
       
   175 #endif //QNETWORKSESSIONPRIVATE_H
       
   176