satengine/SatServer/Engine/inc/CSatBIPUtils.h
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CSatBIPUtils is responsible for handling Bearer Independent
       
    15                  Protocol data channels.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CSATBIPUTILS_H
       
    21 #define CSATBIPUTILS_H
       
    22 
       
    23 #include    <e32base.h>
       
    24 #include    <es_sock.h>
       
    25 #include    <etelpckt.h>
       
    26 #include    <etelmm.h>
       
    27 #include    <etelqos.h>
       
    28 #include    "MSatBIPUtils.h"
       
    29 #include    "MSatBIPEventNotifier.h"
       
    30 #include    "MSatEventObserver.h"
       
    31 #include    "MSatBIPDataChannel.h"
       
    32 
       
    33 class MSatBIPChannelStatusObserver;
       
    34 class MSatBIPDataAvailableObserver;
       
    35 class TSatChannelIdInfo;
       
    36 class MSatUtils;
       
    37 class CSatApnHandler;
       
    38 class CSatSActiveWrapper;
       
    39 class CSatBIPConnectionObserver;
       
    40 
       
    41 /**
       
    42  *  CSatBIPUtils is responsible for handling data channels used by
       
    43  *
       
    44  *  Bearer Independent Protocol (BIP)
       
    45  *
       
    46  *  @lib SatEngine.lib
       
    47  *  @since S60 3.0
       
    48  */
       
    49 class CSatBIPUtils : public CBase,
       
    50                      public MSatBIPUtils,
       
    51                      public MSatBIPEventNotifier,
       
    52                      public MSatEventObserver
       
    53     {
       
    54 public:  
       
    55 // Constructors and destructor
       
    56     /**
       
    57      * Two-phased constructor.
       
    58      * @param aUtils Reference to common Utils class
       
    59      */
       
    60     static CSatBIPUtils* NewL( MSatUtils& aUtils );
       
    61     
       
    62     /**
       
    63      * Destructor.
       
    64      */
       
    65     virtual ~CSatBIPUtils();
       
    66     
       
    67 // from base class MSatEventObserver
       
    68     /**
       
    69      * From MSatEventObserver
       
    70      * Handles event
       
    71      *
       
    72      * @since S60 3.0
       
    73      * @param aEvent Event that has occured
       
    74      */       
       
    75     void Event( TInt aEvent );
       
    76     
       
    77 // from base class MSatBIPUtils
       
    78     /**
       
    79      * From MSatBIPUtils 
       
    80      * Creates new data channel and returns reference to it
       
    81      *
       
    82      * @since S60 3.0
       
    83      * @param TSatBIPError code indicating the execution status.
       
    84      * @return Pointer to created data channel
       
    85      */
       
    86     MSatBIPDataChannel* CreateChannelL(
       
    87         const TSatBearerType aBearerType,
       
    88         TInt& aErrCode );
       
    89     
       
    90     /**
       
    91      * From MSatBIPUtils 
       
    92      * Request to close specified data channel.
       
    93      *
       
    94      * @since S60 3.0
       
    95      * @param aChannelId Identifies the channel to be closed.
       
    96      * @return TSatBIPError code indicating the execution status.
       
    97      */
       
    98     TInt CloseChannel( const TInt aChannelId );
       
    99 
       
   100     /**
       
   101      * From MSatBIPUtils 
       
   102      * Request to open new data channel
       
   103      *
       
   104      * @since S60 3.0
       
   105      * @param aChannelId Identifies the channel.
       
   106      * @param aErrCode TSatBIPError code indicating the execution status.
       
   107      * @return Pointer to requested data channel
       
   108      */
       
   109     MSatBIPDataChannel* DataChannel(
       
   110         const TInt aChannelId,
       
   111         TInt& aErrCode );
       
   112     
       
   113     /**
       
   114      * From MSatBIPUtils 
       
   115      * Generates channel status object from given 
       
   116      * parameters to be used in terminal responses.
       
   117      *
       
   118      * @since S60 3.0
       
   119      * @param aChannelId Data channel identifier.
       
   120      * @param aStatus Data channel's status.
       
   121      * @return channel status object that can be put into terminal responses.
       
   122      */
       
   123     RSat::TChannelStatus GenerateChannelStatusL(
       
   124         const TInt aChannelId,
       
   125         TInt aStatus );
       
   126 
       
   127     /**
       
   128      * From MSatBIPUtils 
       
   129      * Reference to APN handler
       
   130      *
       
   131      * @since S60 3.0
       
   132      * @return Interface reference to CSatApnHandler
       
   133      */
       
   134     MSatApnHandler& ApnHandler();
       
   135     
       
   136     /**
       
   137      * From MSatBIPUtils 
       
   138      * Status of the PDP Context
       
   139      *
       
   140      * @since S60 3.0
       
   141      * @return ETrue, if there is active PDP Context
       
   142      */
       
   143     TBool IsContextActive();
       
   144     
       
   145     /**
       
   146      * From MSatBIPUtils 
       
   147      * Request to close specified data channel.
       
   148      *
       
   149      * @since S60 3.0
       
   150      * @return Array containing all available data channels.
       
   151      */
       
   152     CArrayPtrFlat<MSatBIPDataChannel>* DataChannels();
       
   153     
       
   154 // from base class MSatBIPUtils
       
   155                 
       
   156     /**
       
   157      * From MSatBIPEventNotifier
       
   158      * Notification request for DataAvailable event.
       
   159      *
       
   160      * @since S60 3.0
       
   161      * @param aObserver An observer of the event.
       
   162      */
       
   163     void NotifyDataAvailable(
       
   164         MSatBIPDataAvailableObserver* aObserver );
       
   165 
       
   166     /**
       
   167      * From MSatBIPEventNotifier
       
   168      * Notification request for ChannelStatus event.
       
   169      *
       
   170      * @since S60 3.0
       
   171      * @param aObserver An observer of the event.
       
   172      */
       
   173     void NotifyChannelStatus(
       
   174         MSatBIPChannelStatusObserver* aObserver );
       
   175     
       
   176     /**
       
   177      * From MSatBIPEventNotifier 
       
   178      * Cancels DataAvailable event notification request.
       
   179      *
       
   180      * @since S60 3.0
       
   181      */
       
   182     void CancelDataAvailable();
       
   183     
       
   184     /**
       
   185      * From MSatBIPEventNotifier 
       
   186      * Cancels ChannelStatus event notification request.
       
   187      *
       
   188      * @since S60 3.0
       
   189      */
       
   190     void CancelChannelStatus();
       
   191 
       
   192 // New Member Function
       
   193     /**
       
   194      * DataAvailable event from data channel.
       
   195      *
       
   196      * @since S60 S60 3.0
       
   197      * @param aChannelId ID of the channel that called this function.
       
   198      * @param aLength Number of bytes available.
       
   199      */
       
   200     void DataAvailable( const TInt aChannelId, const TInt aLength );
       
   201     
       
   202     /**
       
   203      * ChannelStatus event from data channel.
       
   204      *
       
   205      * @since S60 S60 3.0
       
   206      * @param aChannelId ID of the channel that called this function.
       
   207      * @param aStatus Status that caused this event.
       
   208      */
       
   209     void ChannelStatus(
       
   210         const TInt aChannelId,
       
   211         const TInt aStatus );
       
   212 
       
   213     
       
   214     /**
       
   215      * Closes all active data channels. This function is called
       
   216      * when SAP is enabled or SAT Server closes
       
   217      * @since S60 S60 3.0
       
   218      */
       
   219     void CloseAllChannels();
       
   220 
       
   221     /**
       
   222      * Proposes QoS parameters for the last created primary or secondary context
       
   223      * and returns negotioated QoS parameters as a result.
       
   224      *
       
   225      * @since S60 S60 3.0
       
   226      * @param aQoSParams Requested QoS parameters to propose for the context
       
   227      * @return Negotioated QoS parameters, which may differ from requested
       
   228      *         parameters.
       
   229      */
       
   230     RPacketQoS::TQoSGPRSNegotiated ProposeQoSParametersL(
       
   231         const RPacketQoS::TQoSGPRSRequested& aQoSParams );
       
   232        
       
   233     /**
       
   234      * Gives reference to RPacketService
       
   235      *
       
   236      * @since S60 S60 3.0
       
   237      */
       
   238     RPacketService& PacketService();
       
   239     
       
   240     
       
   241     /**
       
   242      * Current status of the GPRS service
       
   243      *
       
   244      * @since S60 S60 3.0
       
   245      * @return Current status of the GPRS service
       
   246      */     
       
   247     RPacketService::TStatus ConnectionStatus() const;
       
   248         
       
   249     /**
       
   250      * Stop all udp connection.
       
   251      *
       
   252      * @since S60 S60 3.2
       
   253      */  
       
   254     void StopUdpLink();
       
   255         
       
   256     /**
       
   257      * Set the state for subconnection
       
   258      *
       
   259      * @since S60 S60 3.2
       
   260      * @param aSet State to be set
       
   261      */  
       
   262     void SetConnectionActivated( TBool aSet );
       
   263         
       
   264     /**
       
   265      * Get the state of connection
       
   266      *
       
   267      * @since S60 S60 3.2
       
   268      * @param aSet State to be set
       
   269      */  
       
   270     TBool IsConnectionActivated();
       
   271         
       
   272     /**
       
   273      * Set the state for subconnection
       
   274      *
       
   275      * @since S60 S60 3.2
       
   276      * @param aSet State to be set
       
   277      */  
       
   278     void SetSubConnectionActivated( TBool aSet );
       
   279         
       
   280     /**
       
   281      * Get the state of subconnection
       
   282      *
       
   283      * @since S60 S60 3.2
       
   284      * @param aSet State to be set
       
   285      */  
       
   286     TBool IsSubConnectionActivated();  
       
   287         
       
   288 private:
       
   289 
       
   290     /**
       
   291      * C++ default constructor.
       
   292      * @param aUtils Reference to common utils class
       
   293      */
       
   294     CSatBIPUtils( MSatUtils& aUtils );
       
   295 
       
   296     /**
       
   297      * By default Symbian 2nd phase constructor is private.
       
   298      */
       
   299     void ConstructL();
       
   300 
       
   301     /**
       
   302      * Defines next available channel ID
       
   303      * @return Pointer to next available channel id
       
   304      */
       
   305     TSatChannelIdInfo* AvailableChannelID();
       
   306     
       
   307     /**
       
   308      * Reference to RPacketContex handle
       
   309      * @return Error code indicating the success of function completion
       
   310      */
       
   311     TInt GprsService();
       
   312     
       
   313     /**
       
   314      * Number of contexts currently in Gprs service
       
   315      *
       
   316      * @since S60 S60 3.0
       
   317      * @return Number of active PDP contexts
       
   318      */  
       
   319     TInt ContextCount();
       
   320 
       
   321 private: // Data
       
   322 
       
   323     /**
       
   324      * Array containing all data channels
       
   325      * Own
       
   326      */
       
   327     CArrayPtrFlat<MSatBIPDataChannel>* iDataChannels;
       
   328 
       
   329     /**
       
   330      * DataAvailable event observer
       
   331      * Own
       
   332      */
       
   333     MSatBIPDataAvailableObserver* iDataAvailableObserver;
       
   334 
       
   335     /**
       
   336      * ChannelStatus event observer
       
   337      * Own
       
   338      */
       
   339     MSatBIPChannelStatusObserver* iChannelStatusObserver;
       
   340 
       
   341     /**
       
   342      * Main session to Socket Server
       
   343      * 
       
   344      */
       
   345     RSocketServ iSocketServer;
       
   346 
       
   347     /**
       
   348      * Indicates is there channel active or not
       
   349      * 
       
   350      */
       
   351     TBool iDataChannelActivated;
       
   352 
       
   353     /**
       
   354      * Array containing datachannel IDs
       
   355      * Own
       
   356      */
       
   357     CArrayPtrFlat<TSatChannelIdInfo>* iChannelIds;
       
   358 
       
   359     /**
       
   360      * Temporary Channel ID pointer, used for ~CSatBIPUtils to 
       
   361      * cleanup when AppendL leave. Look into ConstructL and
       
   362      * ~CSatBIPUtils to see how it be used.
       
   363      * Not Own
       
   364      */
       
   365     TSatChannelIdInfo* iChannelId;
       
   366    
       
   367    /**
       
   368      * Utils class
       
   369      * Not Own
       
   370      */
       
   371     MSatUtils& iUtils;
       
   372 
       
   373     /**
       
   374      * Blocker for synchronous requests
       
   375      * Own
       
   376      */
       
   377     CSatSActiveWrapper* iWrapper;
       
   378 
       
   379     /**
       
   380      * Classes for GPRS context activation
       
   381      * 
       
   382      */
       
   383     RPacketService iPacketService;
       
   384 
       
   385     /**
       
   386      * Indicates is the Session to PacketService active
       
   387      * 
       
   388      */
       
   389     TBool iPacketServiceActive;
       
   390 
       
   391     /**
       
   392      * Pointer to APN handler
       
   393      * Own
       
   394      */
       
   395     MSatApnHandler* iApnHandler;
       
   396 
       
   397     /**
       
   398      * Pointer to connection status observer
       
   399      * Own
       
   400      */
       
   401     CSatBIPConnectionObserver* iConnObserver;
       
   402         
       
   403     /**
       
   404      * Represent the primary PDP context
       
   405      * Own
       
   406      */
       
   407     RConnection iConnection;
       
   408         
       
   409     /**
       
   410      * Represent the secondary PDP context
       
   411      * Own
       
   412      */
       
   413     RSubConnection iSubConnection;
       
   414         
       
   415     /**
       
   416      * iSubConnectionActivated
       
   417      */
       
   418     TBool iSubConnectionActivated;
       
   419         
       
   420     /**
       
   421      * iConnectionActivated
       
   422      */
       
   423     TBool iConnectionActivated;
       
   424     };
       
   425 
       
   426 #endif      // CSATBIPUTILS_H
       
   427