qtmobility/src/bearer/qnetworksession_s60_p.h
changeset 0 cfcbf08528c4
child 2 5822d84012fb
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 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"
       
    57 
       
    58 #include <QDateTime>
       
    59 
       
    60 #include <e32base.h>
       
    61 #include <CommDbConnPref.h>
       
    62 #include <es_sock.h>
       
    63 #include <rconnmon.h>
       
    64 #ifdef SNAP_FUNCTIONALITY_AVAILABLE
       
    65     #include <comms-infras/cs_mobility_apiext.h>
       
    66 #endif
       
    67 
       
    68 typedef int(*TOpenCSetdefaultifFunction)(const struct ifreq*);
       
    69 
       
    70 QTM_BEGIN_NAMESPACE
       
    71 
       
    72 class ConnectionProgressNotifier;
       
    73 
       
    74 #ifdef SNAP_FUNCTIONALITY_AVAILABLE
       
    75 class QNetworkSessionPrivate : public QObject, public CActive, public MMobilityProtocolResp, 
       
    76                                public MConnectionMonitorObserver
       
    77 #else
       
    78 class QNetworkSessionPrivate : public QObject, public CActive, public MConnectionMonitorObserver
       
    79 #endif
       
    80 {
       
    81     Q_OBJECT
       
    82 public:
       
    83     QNetworkSessionPrivate(); 
       
    84     ~QNetworkSessionPrivate();
       
    85     
       
    86     //called by QNetworkSession constructor and ensures
       
    87     //that the state is immediately updated (w/o actually opening
       
    88     //a session). Also this function should take care of 
       
    89     //notification hooks to discover future state changes.
       
    90     void syncStateWithInterface();
       
    91 
       
    92     QNetworkInterface currentInterface() const;
       
    93     QVariant sessionProperty(const QString& key) const;
       
    94     void setSessionProperty(const QString& key, const QVariant& value);
       
    95     
       
    96     void setALREnabled(bool enabled);
       
    97 
       
    98     void open();
       
    99     void close(bool allowSignals = true);
       
   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     quint64 bytesWritten() const;
       
   109     quint64 bytesReceived() const;
       
   110     quint64 activeTime() const;
       
   111     
       
   112 #ifdef SNAP_FUNCTIONALITY_AVAILABLE    
       
   113 public: // From MMobilityProtocolResp
       
   114     void PreferredCarrierAvailable(TAccessPointInfo aOldAPInfo,
       
   115                                    TAccessPointInfo aNewAPInfo,
       
   116                                    TBool aIsUpgrade,
       
   117                                    TBool aIsSeamless);
       
   118 
       
   119     void NewCarrierActive(TAccessPointInfo aNewAPInfo, TBool aIsSeamless);
       
   120 
       
   121     void Error(TInt aError);
       
   122 #endif    
       
   123 
       
   124 Q_SIGNALS:
       
   125     //releases any pending waitForOpened() calls
       
   126     void quitPendingWaitsForOpened();
       
   127     
       
   128 protected: // From CActive
       
   129     void RunL();
       
   130     void DoCancel();
       
   131     
       
   132 private: // MConnectionMonitorObserver
       
   133     void EventL(const CConnMonEventBase& aEvent);
       
   134     
       
   135 private:
       
   136     TUint iapClientCount(TUint aIAPId) const;
       
   137     quint64 transferredData(TUint dataType) const;
       
   138     bool newState(QNetworkSession::State newState, TUint accessPointId = 0);
       
   139     void handleSymbianConnectionStatusChange(TInt aConnectionStatus, TInt aError, TUint accessPointId = 0);
       
   140     QNetworkConfiguration bestConfigFromSNAP(const QNetworkConfiguration& snapConfig) const;
       
   141     QNetworkConfiguration activeConfiguration(TUint32 iapId = 0) const;
       
   142     QNetworkInterface interface(TUint iapId) const;
       
   143 
       
   144 private: // data
       
   145     // The config set on QNetworkSession
       
   146     mutable QNetworkConfiguration publicConfig;
       
   147 
       
   148     // If publicConfig is a ServiceNetwork this is a copy of publicConfig.
       
   149     // If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual
       
   150     // ServiceNetwork configuration.
       
   151     mutable QNetworkConfiguration serviceConfig;
       
   152 
       
   153     // This is the actual active configuration currently in use by the session.
       
   154     // Either a copy of publicConfig or one of serviceConfig.children().
       
   155     mutable QNetworkConfiguration activeConfig;
       
   156     
       
   157     mutable QNetworkInterface activeInterface;
       
   158 
       
   159     QNetworkSession::State state;
       
   160     bool isOpen;
       
   161 
       
   162     QNetworkSession* q;
       
   163     QDateTime startTime;
       
   164 
       
   165     RLibrary iOpenCLibrary;
       
   166     TOpenCSetdefaultifFunction iDynamicSetdefaultif;
       
   167 
       
   168     mutable RSocketServ iSocketServ;
       
   169     mutable RConnection iConnection;
       
   170     mutable RConnectionMonitor iConnectionMonitor;
       
   171     ConnectionProgressNotifier* ipConnectionNotifier;
       
   172 #ifdef SNAP_FUNCTIONALITY_AVAILABLE    
       
   173     CActiveCommsMobilityApiExt* iMobility;
       
   174 #endif    
       
   175     
       
   176     QNetworkSession::SessionError iError;
       
   177     TInt iALREnabled;
       
   178     TBool iALRUpgradingConnection;
       
   179     
       
   180     QList<QString> iKnownConfigsBeforeConnectionStart;
       
   181     
       
   182     TUint32 iOldRoamingIap;
       
   183     TUint32 iNewRoamingIap;
       
   184 
       
   185     friend class QNetworkSession;
       
   186     friend class ConnectionProgressNotifier;
       
   187 };
       
   188 
       
   189 class ConnectionProgressNotifier : public CActive
       
   190 {
       
   191 public:
       
   192     ConnectionProgressNotifier(QNetworkSessionPrivate& owner, RConnection& connection); 
       
   193     ~ConnectionProgressNotifier();
       
   194     
       
   195     void StartNotifications();
       
   196     void StopNotifications();
       
   197     
       
   198 protected: // From CActive
       
   199     void RunL();
       
   200     void DoCancel();
       
   201 
       
   202 private: // Data
       
   203     QNetworkSessionPrivate& iOwner;
       
   204     RConnection& iConnection;
       
   205     TNifProgressBuf iProgress;
       
   206     
       
   207 };
       
   208 
       
   209 QTM_END_NAMESPACE
       
   210 
       
   211 #endif //QNETWORKSESSIONPRIVATE_H
       
   212