qtmobility/src/bearer/qnetworksession_s60_p.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 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 #if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE)
       
    68     #include <extendedconnpref.h>
       
    69 #endif
       
    70 
       
    71 QTM_BEGIN_NAMESPACE
       
    72 
       
    73 class ConnectionProgressNotifier;
       
    74 typedef void (*TOpenCUnSetdefaultifFunction)();
       
    75 
       
    76 class QNetworkSessionPrivate : public QObject, public CActive
       
    77 #ifdef SNAP_FUNCTIONALITY_AVAILABLE
       
    78                                , public MMobilityProtocolResp
       
    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 Q_SLOTS:
       
   133     void configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState);
       
   134     void configurationRemoved(const QNetworkConfiguration& config);
       
   135     void configurationAdded(const QNetworkConfiguration& config);
       
   136     
       
   137 private:
       
   138     TUint iapClientCount(TUint aIAPId) const;
       
   139     quint64 transferredData(TUint dataType) const;
       
   140     bool newState(QNetworkSession::State newState, TUint accessPointId = 0);
       
   141     void handleSymbianConnectionStatusChange(TInt aConnectionStatus, TInt aError, TUint accessPointId = 0);
       
   142     QNetworkConfiguration bestConfigFromSNAP(const QNetworkConfiguration& snapConfig) const;
       
   143     QNetworkConfiguration activeConfiguration(TUint32 iapId = 0) const;
       
   144     QNetworkInterface interface(TUint iapId) const;
       
   145 
       
   146 private: // data
       
   147     // The config set on QNetworkSession
       
   148     mutable QNetworkConfiguration publicConfig;
       
   149 
       
   150     // If publicConfig is a ServiceNetwork this is a copy of publicConfig.
       
   151     // If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual
       
   152     // ServiceNetwork configuration.
       
   153     mutable QNetworkConfiguration serviceConfig;
       
   154 
       
   155     // This is the actual active configuration currently in use by the session.
       
   156     // Either a copy of publicConfig or one of serviceConfig.children().
       
   157     mutable QNetworkConfiguration activeConfig;
       
   158     
       
   159     mutable QNetworkInterface activeInterface;
       
   160 
       
   161     QNetworkSession::State state;
       
   162     bool isOpen;
       
   163 
       
   164     QNetworkSession* q;
       
   165     QDateTime startTime;
       
   166 
       
   167     RLibrary iOpenCLibrary;
       
   168     TOpenCUnSetdefaultifFunction iDynamicUnSetdefaultif;
       
   169 
       
   170     mutable RSocketServ iSocketServ;
       
   171     mutable RConnection iConnection;
       
   172     mutable RConnectionMonitor iConnectionMonitor;
       
   173     ConnectionProgressNotifier* ipConnectionNotifier;
       
   174     
       
   175     bool iHandleStateNotificationsFromManager;
       
   176     bool iFirstSync;
       
   177     bool iStoppedByUser;
       
   178     bool iClosedByUser;
       
   179     
       
   180 #ifdef SNAP_FUNCTIONALITY_AVAILABLE    
       
   181     CActiveCommsMobilityApiExt* iMobility;
       
   182 #endif    
       
   183     
       
   184     QNetworkSession::SessionError iError;
       
   185     TInt iALREnabled;
       
   186     TBool iALRUpgradingConnection;
       
   187     TBool iConnectInBackground;
       
   188     
       
   189     QList<QString> iKnownConfigsBeforeConnectionStart;
       
   190     
       
   191     TUint32 iOldRoamingIap;
       
   192     TUint32 iNewRoamingIap;
       
   193 
       
   194     bool isOpening;
       
   195 
       
   196     friend class QNetworkSession;
       
   197     friend class ConnectionProgressNotifier;
       
   198 };
       
   199 
       
   200 class ConnectionProgressNotifier : public CActive
       
   201 {
       
   202 public:
       
   203     ConnectionProgressNotifier(QNetworkSessionPrivate& owner, RConnection& connection); 
       
   204     ~ConnectionProgressNotifier();
       
   205     
       
   206     void StartNotifications();
       
   207     void StopNotifications();
       
   208     
       
   209 protected: // From CActive
       
   210     void RunL();
       
   211     void DoCancel();
       
   212 
       
   213 private: // Data
       
   214     QNetworkSessionPrivate& iOwner;
       
   215     RConnection& iConnection;
       
   216     TNifProgressBuf iProgress;
       
   217     
       
   218 };
       
   219 
       
   220 QTM_END_NAMESPACE
       
   221 
       
   222 #endif //QNETWORKSESSIONPRIVATE_H
       
   223