alwayson_net_plugin/pdpcontextmanager2/inc/taostate.h
changeset 0 5a93021fdf25
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2004,2006 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:  State base class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef T_TAOSTATE_H
       
    21 #define T_TAOSTATE_H
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <e32std.h>
       
    25 
       
    26 #include "maoconnectionmanager.h"
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class MAOStateContext;
       
    30 class MAOStatePool;
       
    31 
       
    32 // CLASS DESCRIPTION
       
    33 
       
    34 /**
       
    35  *  State base class.
       
    36  *  New states should derive directly from this.
       
    37  *
       
    38  *  @lib PDPContextManager2.lib
       
    39  *  @since S60 v3.1
       
    40  */
       
    41 NONSHARABLE_CLASS( TAOState )
       
    42     {
       
    43 public: // Data types
       
    44 
       
    45     /**  State name enums */
       
    46     enum TAOStateName
       
    47         {
       
    48         EStateInit = 0,
       
    49         EStateStarting,
       
    50         EStateDisabled,
       
    51         EStateConnecting,
       
    52         EStateConnected,
       
    53         EStateDisconnected,
       
    54         EStateWaiting,
       
    55         EStateUnconnected,
       
    56         EStateResetFactorySettings,
       
    57         EStateExternalConnection,
       
    58         EStateLastItem  // this item used for indicating 
       
    59                         // the number of members of this enum.
       
    60                         // It should be always the last even if the 
       
    61                         // enum extracted.
       
    62         };
       
    63 
       
    64 public: // Constructors & destructors
       
    65 
       
    66     /**
       
    67      * Constructor.
       
    68      *
       
    69      * @since S60 v3.1
       
    70      * @param aStateContext Reference to MAOStateContext
       
    71      * @param aStatePool Reference to MAOStatePool
       
    72      * @return Pointer to created object.
       
    73      */
       
    74     TAOState( MAOStateContext& aStateContext, MAOStatePool& aStatePool );
       
    75     
       
    76 public: // New methods
       
    77 
       
    78     /**
       
    79      * Returns state name (ID).
       
    80      *
       
    81      * @since S60 v3.1
       
    82      * @return TAOStateName
       
    83      */
       
    84     virtual TAOStateName StateName() const = 0;
       
    85 
       
    86     /**
       
    87      * Notification from PDP context activation is received
       
    88      * through this method.
       
    89      *
       
    90      * @since S60 v3.1
       
    91      * @return New state or NULL if state is not
       
    92      *         needed to be changed.
       
    93      */
       
    94     virtual TAOState* HandlePDPContextActivatedL();
       
    95     
       
    96     /**
       
    97      * Notification from PDP context activation failure
       
    98      * is received through this method.
       
    99      *
       
   100      * @since S60 v3.1
       
   101      * @return New state or NULL if state is not
       
   102      *         needed to be changed.
       
   103      */
       
   104     virtual TAOState* HandlePDPContextActivationFailedL();
       
   105     
       
   106     /**
       
   107      * Notification from PDP context disconnect is received
       
   108      * through this method.
       
   109      *
       
   110      * @since S60 v3.1
       
   111      * @param aReason: Disconnect reason
       
   112      * @return New state or NULL if state is not
       
   113      *         needed to be changed.
       
   114      */
       
   115     virtual TAOState* HandlePDPContextDisconnectedL( TInt aReason );
       
   116     
       
   117     /**
       
   118      * Notification from network change is receive through
       
   119      * this method.
       
   120      *
       
   121      * @since S60 v3.1
       
   122      * @param aNetworkType: New network type
       
   123      * @return New state or NULL if state is not
       
   124      *         needed to ba changed.
       
   125      */
       
   126     virtual TAOState* HandleNetworkChangedL(
       
   127         MAOConnectionManager::TNetworkType aNetworkType );
       
   128     
       
   129     /**
       
   130      * Notification from succesful RAU is received
       
   131      * through this method.
       
   132      *
       
   133      * @since S60 v3.1
       
   134      * @return New state or NULL if state is not
       
   135      *         needed to ba changed.
       
   136      */
       
   137     virtual TAOState* HandleSuccesfulRAUEventL();
       
   138 
       
   139     /**
       
   140      * Notification from retry timer triggering
       
   141      * is received through this method.
       
   142      *
       
   143      * @since S60 v3.1
       
   144      * @return New state or NULL if state is not
       
   145      *         needed to ba changed.
       
   146      */
       
   147     virtual TAOState* HandleRetryTimerTriggeredL();
       
   148         
       
   149     /**
       
   150      * Notification from connection timer triggering
       
   151      * is received through this method.
       
   152      *
       
   153      * @since S60 v3.1
       
   154      * @return New state or NULL if state is not
       
   155      *         needed to ba changed.
       
   156      */
       
   157     virtual TAOState* HandleConnectionTimerTriggeredL();
       
   158     
       
   159     /**
       
   160      * Notifications from new settings is received through
       
   161      * this method.
       
   162      *
       
   163      * @since S60 v3.1
       
   164      * @return New state or NULL if state is not
       
   165      *         needed to be changed.
       
   166      */
       
   167     virtual TAOState* HandleSettingsReceivedL();
       
   168     
       
   169     /**
       
   170      * Notifications from PDP context data transfer block notification
       
   171      * received through this method.
       
   172      *
       
   173      * @since S60 v3.1
       
   174      * @return New state or NULL if state is not
       
   175      *         needed to be changed.
       
   176      */
       
   177     virtual TAOState* HandlePDPContextTemporarilyBlockedL();
       
   178     
       
   179     /**
       
   180      * Handles error. Always leads to disconnected state.
       
   181      *
       
   182      * @since S60 v3.1
       
   183      * @return TAOStateDisconnected*
       
   184      */
       
   185     virtual TAOState* HandleGeneralError();
       
   186     
       
   187     /**
       
   188      * Handles enable always on request.
       
   189      *
       
   190      * @since S60 v3.1
       
   191      * @return New state or NULL if state is not
       
   192      *         needed to be changed.
       
   193      */
       
   194     virtual TAOState* HandleEnableAlwaysOnL();
       
   195     
       
   196     /**
       
   197      * Changes state from disconnected state.
       
   198      *
       
   199      * @since S60 v3.1
       
   200      * @param aReason: Disconnect reason
       
   201      * @return New state or NULL if state is not
       
   202      *         needed to be changed.
       
   203      */
       
   204     virtual TAOState* HandleSwitchFromDisconnectedL(
       
   205         MAOConnectionManager::TFailureReason aReason );
       
   206         
       
   207     /**
       
   208      * Handles connection deleted notification.
       
   209      *
       
   210      * @since S60 v3.1
       
   211      * @return New state or NULL if state is not
       
   212      *         needed to be changed.
       
   213      */
       
   214     virtual TAOState* HandleConnectionDeletedL();
       
   215     
       
   216     /**
       
   217      * Handles reset factory settings notification.
       
   218      * If this is overridden it must be remembered that
       
   219      * connection MUST be closed after this method has been
       
   220      * called. Otherwise factory resetting will fail.
       
   221      *
       
   222      * @since S60 v3.1
       
   223      * @param aReset: ETrue will indicate reset, EFalse completion of reset
       
   224      * @return New state or NULL if state is not
       
   225      *         needed to be changed.
       
   226      */
       
   227     virtual TAOState* HandleResetFactorySettingsL( TBool aReset );
       
   228         
       
   229     /**
       
   230      * Handles external connection creation notification.
       
   231      *
       
   232      * @since 3.0
       
   233      */
       
   234     virtual TAOState* HandleExternalConnectionCreatedL();
       
   235         
       
   236     /**
       
   237      * Handles unconnect timer trigger notification.
       
   238      *
       
   239      * @since 3.0
       
   240      */
       
   241     virtual TAOState* HandleUnconnectTimerExpiredL();
       
   242         
       
   243 protected: // New methods
       
   244 
       
   245     /**
       
   246      * Cancels all operations        
       
   247      *
       
   248      * @since S60 v3.1
       
   249      */
       
   250     void CancelAll();
       
   251     
       
   252     /**
       
   253      * Setting a flag
       
   254      *
       
   255      * @since S60 v3.1
       
   256      * @param aFlag flag to set 
       
   257      */
       
   258     inline void SetFlag( TUint aFlag );
       
   259     
       
   260     /**
       
   261      * Clears a flag
       
   262      *
       
   263      * @since S60 v3.1
       
   264      * @param aFlag flag to clear 
       
   265      */
       
   266     inline void ClearFlag( TUint aFlag );
       
   267     
       
   268     /**
       
   269      * Checks if flag is set
       
   270      *
       
   271      * @since S60 v3.1
       
   272      * @param aFlag flag to check
       
   273      * @return ETrue if the checked flag is on else EFalse
       
   274      */
       
   275     inline TBool CheckFlag( TUint aFlag );
       
   276     
       
   277     /**
       
   278      * Clears all flags
       
   279      *
       
   280      * @since S60 v3.1
       
   281      */
       
   282     inline void ClearFlags();
       
   283     
       
   284     /**
       
   285      * Checks if Always On should be enabled
       
   286      *
       
   287      * @since S60 v3.1
       
   288      * @return ETrue if Always On should be enabled else EFalse
       
   289      */
       
   290     TBool EnableAlwaysOn();
       
   291     
       
   292     /**
       
   293      * Cancels all timers
       
   294      *
       
   295      * @since S60 v3.1
       
   296      */
       
   297     void CancelTimers();
       
   298     
       
   299     /**
       
   300      * Sets always on mode to TSY
       
   301      *
       
   302      * @since S60 v3.1
       
   303      */
       
   304     void SetAlwaysOnModeL();
       
   305     
       
   306     /**
       
   307      * Basic handling for connection deletion
       
   308      *
       
   309      * @since S60 v3.1
       
   310      * @return TAOState*
       
   311      */
       
   312     TAOState* DoHandleConnectionDeletedL();
       
   313     
       
   314     /**
       
   315      * Activates PDP context
       
   316      *
       
   317      * @since S60 v3.1
       
   318      * @return TAOState*
       
   319      */
       
   320     TAOState* DoActivatePDPContextL();
       
   321     
       
   322 
       
   323 protected: // data
       
   324 
       
   325     /**
       
   326      * Ref: State context
       
   327      */
       
   328     MAOStateContext& iStateContext;
       
   329     
       
   330     /**
       
   331      * Ref: State pool
       
   332      */
       
   333     MAOStatePool& iStatePool;
       
   334     
       
   335     /**
       
   336      * Internal state flag
       
   337      */
       
   338     TUint iFlags;
       
   339     };
       
   340     
       
   341 // inline methods    
       
   342 #include "../inl/taostate.inl"
       
   343 
       
   344 #endif // T_TAOSTATE_H