connectivitylayer/isce/isaaccessextension_dll/inc/pep.h
changeset 0 63b37f68c1ce
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2009 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 the License "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32def.h>                     // For TUint16
       
    21 #include <e32cmn.h>                     // For TDesC8
       
    22 #include <klib.h>                       // For DBase
       
    23 #include "iadinternaldefinitions.h"
       
    24 #include "peptransceiver.h"
       
    25 #include "iadtrace.h"                   // For ASSERT_RESET_ALWAYS
       
    26 
       
    27 class DRouter;
       
    28 class MIAD2ChannelApi;
       
    29 class DPep;
       
    30 class DPipeHandler;
       
    31 
       
    32 enum TPipeState
       
    33         {
       
    34         ECreating,
       
    35         ECreatingEnabled,
       
    36         EDisabled,
       
    37         EDisabling,
       
    38         EEnabling,
       
    39         EEnabled,
       
    40 //TBR        
       
    41         EEnableEnabled,
       
    42         EDisabledDisabled,
       
    43         EDisabledEnabled,
       
    44         EEnabledDisabled,
       
    45         EEnabledEnabled,
       
    46         EDisconnected,
       
    47         };
       
    48 
       
    49 
       
    50 NONSHARABLE_CLASS(DPipeState) : public DBase
       
    51     {
       
    52     public:
       
    53 
       
    54         DPipeState(DPep& aPep);
       
    55         //virtual ~DPipeState();
       
    56         void NextState(TPipeState aNextState);
       
    57         virtual void EnterState();
       
    58         // Pipe events 
       
    59         virtual void PnsPipeCreatedInd(){ ASSERT_RESET_ALWAYS( 0, 0 ); };
       
    60         virtual void PnsPipeEnabledInd(){ ASSERT_RESET_ALWAYS( 0, 0 ); };
       
    61         virtual void PnsPipeRedirectedInd(){ ASSERT_RESET_ALWAYS( 0, 0 ); };
       
    62         virtual void PnsPipeResetInd(){ ASSERT_RESET_ALWAYS( 0, 0 ); };
       
    63         virtual void PnsPipeDisabledInd(){ ASSERT_RESET_ALWAYS( 0, 0 ); };
       
    64         virtual TInt PnsPepConnectReq( const TDesC8& aData ){ aData;ASSERT_RESET_ALWAYS( 0, 0 ); return KErrNotFound; };
       
    65         virtual TInt PnsPepResetReq( const TDesC8& aData ){ aData;ASSERT_RESET_ALWAYS( 0, 0 ); return KErrNotFound; };
       
    66         virtual TInt PnsPepDisconnectReq(const TDesC8& aData);
       
    67         virtual TInt PnsPepEnableReq( const TDesC8& aData ){ aData;ASSERT_RESET_ALWAYS( 0, 0 ); return KErrNotFound; };
       
    68         virtual TInt PnsPepDisableReq( const TDesC8& aData ){ aData;ASSERT_RESET_ALWAYS( 0, 0 ); return KErrNotFound; };
       
    69         virtual TInt RxPnsPipeData( const TDesC8& aData ){ aData;ASSERT_RESET_ALWAYS( 0, 0 ); return KErrNotFound; };
       
    70         virtual TInt TxPnsPipeData( TDes8& aData );
       
    71 
       
    72         DPep& iPep;// TODO: public?
       
    73 
       
    74     };
       
    75 
       
    76 
       
    77 NONSHARABLE_CLASS(DDisconnected) : public DPipeState
       
    78     {
       
    79     public:
       
    80 
       
    81         DDisconnected(DPep& aPep);
       
    82         // Override base class functions cause should not be allowed to do nothing at all, just to be removed.
       
    83         TInt PnsPepDisconnectReq( const TDesC8& aData ){ aData;ASSERT_RESET_ALWAYS( 0, 0 ); return KErrNotFound; };
       
    84         // TxPnsPipeData in base class already appropriate returns KErrOverFlow.
       
    85 
       
    86     };
       
    87 
       
    88 // Creating state comes when pep is created, use cases pipe creation and pipe redirection (new pep).
       
    89 // Default is disabled.
       
    90 NONSHARABLE_CLASS( DCreating ) : public DPipeState
       
    91     {
       
    92 
       
    93     public:
       
    94 
       
    95         DCreating( DPep& aPep );
       
    96         TInt PnsPepConnectReq( const TDesC8& aReq );
       
    97         void PnsPipeCreatedInd();
       
    98         void PnsPipeRedirectedInd();
       
    99 
       
   100     };
       
   101 // Creating / redirecting an enabled pipe.
       
   102 NONSHARABLE_CLASS( DCreatingEnabled ) : public DPipeState
       
   103     {
       
   104 
       
   105     public:
       
   106 
       
   107         DCreatingEnabled( DPep& aPep );
       
   108         void PnsPipeCreatedInd();
       
   109         void PnsPipeRedirectedInd();
       
   110 
       
   111     };
       
   112 
       
   113 NONSHARABLE_CLASS(DDisabled) : public DPipeState
       
   114     {
       
   115     public:
       
   116 
       
   117         DDisabled(DPep& aPep);
       
   118         void EnterState();
       
   119         TInt PnsPepEnableReq(const TDesC8& aData);
       
   120         TInt PnsPepResetReq(const TDesC8& aData);
       
   121         TInt PnsPepDisableReq(const TDesC8& aData);
       
   122         void PnsPipeRedirectedInd(); 
       
   123         void PnsPipeDisabledInd();
       
   124 
       
   125     };
       
   126 
       
   127 NONSHARABLE_CLASS( DDisabling ) : public DPipeState
       
   128     {
       
   129 
       
   130     public:
       
   131 
       
   132         DDisabling( DPep& aPep );
       
   133         void EnterState();
       
   134         void PnsPipeDisabledInd();
       
   135 
       
   136     };
       
   137 
       
   138 NONSHARABLE_CLASS( DEnabled ) : public DPipeState
       
   139     {
       
   140     public:
       
   141 
       
   142         DEnabled(DPep& aPep);
       
   143         void EnterState();
       
   144         TInt PnsPepEnableReq(const TDesC8& aData);
       
   145         TInt RxPnsPipeData( const TDesC8& aData );
       
   146         TInt TxPnsPipeData( TDes8& aData );
       
   147         TInt PnsPepResetReq(const TDesC8& aData);
       
   148         TInt PnsPepDisableReq(const TDesC8& aData);
       
   149         void PnsPipeEnabledInd();
       
   150 
       
   151     };
       
   152 
       
   153 NONSHARABLE_CLASS( DEnabling ) : public DPipeState
       
   154     {
       
   155 
       
   156     public:
       
   157 
       
   158         DEnabling( DPep& aPep );
       
   159         void PnsPipeEnabledInd();
       
   160         void PnsPipeRedirectedInd();
       
   161 
       
   162     };
       
   163 
       
   164 //TBR
       
   165 NONSHARABLE_CLASS( DEnableEnabled ) : public DEnabled
       
   166     {
       
   167 
       
   168     public:
       
   169 
       
   170         DEnableEnabled( DPep& aPep );
       
   171         void EnterState();
       
   172 
       
   173     };
       
   174 //TBR
       
   175 NONSHARABLE_CLASS( DEnabledEnabled ) : public DPipeState
       
   176     {
       
   177     public:
       
   178 
       
   179         DEnabledEnabled( DPep& aPep);
       
   180         void PnsPipeResetInd();
       
   181 
       
   182     };
       
   183 
       
   184 NONSHARABLE_CLASS( DEnabledDisabled ) : public DPipeState
       
   185     {
       
   186     public:
       
   187 
       
   188         DEnabledDisabled( DPep& aPep);
       
   189         void EnterState();
       
   190         void PnsPipeResetInd();
       
   191 
       
   192     };
       
   193 
       
   194 NONSHARABLE_CLASS( DDisabledEnabled ) : public DPipeState
       
   195     {
       
   196     public:
       
   197 
       
   198         DDisabledEnabled( DPep& aPep);
       
   199         void PnsPipeResetInd();
       
   200 
       
   201     };
       
   202 
       
   203 NONSHARABLE_CLASS( DDisabledDisabled ) : public DPipeState
       
   204     {
       
   205     public:
       
   206 
       
   207         DDisabledDisabled( DPep& aPep);
       
   208         void PnsPipeResetInd();
       
   209 
       
   210     };
       
   211 
       
   212 NONSHARABLE_CLASS( DPep ) : public DBase
       
   213 {
       
   214 
       
   215 public:
       
   216 
       
   217     DPep( DRouter* aDl, MIAD2ChannelApi* aUl, TUint16 aChannelId, DPipeHandler& aHandler  );
       
   218     ~DPep();
       
   219     TUint8 GetPipeHandle()
       
   220         {
       
   221         return iPipeHandle;
       
   222         };
       
   223     
       
   224     TUint16 ChannelId()
       
   225         {
       
   226         return iChannelId;
       
   227         }
       
   228     
       
   229     void NextState(TPipeState aState);
       
   230     virtual TInt ReceiveMessage(const TDesC8& aMsg, MIAD2ChannelApi* aToCb);
       
   231     virtual TInt SendMessage(TDes8& aMsg, TUint16 aFromChannel);
       
   232     TInt SendPepConnectResp(const TDesC8& aData);
       
   233     TInt SendPepResetResp(const TDesC8& aData);
       
   234     TInt SendPepDisconnectResp(const TDesC8& aData);
       
   235     TInt SendPepEnableResp(const TDesC8& aData);
       
   236     TInt SendPepDisableResp(const TDesC8& aData);
       
   237     TInt RxPipeData(const TDesC8& aData);
       
   238     TInt TxPipeData(TDes8& aData);
       
   239     void PipeDisabling();
       
   240     void PipeDisabled();
       
   241     void PipeEnabled();
       
   242     void PipeDisableDisabled();
       
   243     void PipeEnableEnabled();
       
   244 
       
   245 #if (NCP_COMMON_SOS_VERSION_SUPPORT >= SOS_VERSION_95)
       
   246     void SetLoaned( MIAD2ChannelApi* aCh );
       
   247     void SetLoanReturned( MIAD2ChannelApi* aOldCh );
       
   248 #endif
       
   249 
       
   250 protected:
       
   251 
       
   252     void HandlePnPipeSbNegotiatedFC( const TDesC8& aMessage );
       
   253 
       
   254 protected:
       
   255 
       
   256     DRouter*                iRouter;
       
   257     TUint8                  iPipeHandle;
       
   258     TUint8                  iChannelId;
       
   259     DPipeHandler&           iPipeHandler;
       
   260 
       
   261     MIAD2ChannelApi*        iChannel; // must be pointer due to it is not always available
       
   262     DPepTransceiver*        iDecoratedRx;
       
   263     DPepTransceiver*        iDecoratedTx;
       
   264     DPepTransceiver         iMainTxRx; // the one having pointers other classes
       
   265 
       
   266 // StateMachine states:
       
   267     DCreating                   iCreating;
       
   268     DCreatingEnabled            iCreatingEnabled;
       
   269     DDisabled                   iDisabled;
       
   270     DDisabling                  iDisabling;
       
   271     DEnabling                   iEnabling;
       
   272     DEnabled                    iEnabled;
       
   273 //TBR
       
   274     DEnableEnabled              iEnableEnabled;
       
   275     DDisabledDisabled           iDisabledDisabled;
       
   276     DDisabledEnabled            iDisabledEnabled;
       
   277     DEnabledDisabled            iEnabledDisabled;
       
   278     DEnabledEnabled             iEnabledEnabled;
       
   279     DDisconnected               iDisconnected;
       
   280 
       
   281     DPipeState*                 iCurrentState;
       
   282 };
       
   283