wvuing/IMPSConnectionUI/OperationStepSrc/CCnUiConnCloser.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Connection closer.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CCNUICONNCLOSER_H
       
    19 #define __CCNUICONNCLOSER_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <E32base.h>
       
    23 #include <impspresenceconnectionuiconstsng.h>
       
    24 #include <MPEngNWSessionOperationObserver2.h>
       
    25 
       
    26 
       
    27 //DATA TYPES
       
    28 
       
    29 /**
       
    30  * Connection closer state enumerations.
       
    31  * These state id's are reported to
       
    32  * given MCnUiOpProgressStateObserver
       
    33  * operation progress observer
       
    34  */
       
    35 enum TCnUiConnCloserState
       
    36     {
       
    37     ECnCloser_Idle = 100,                  ///<Idle state, no operation running
       
    38     ECnCloser_ProcessingPlugin = 101,      ///<Waiting client plug-in processing
       
    39     ECnCloser_ClosingSAPConnection = 102   ///<Waiting the SAP connection to close
       
    40     };
       
    41 
       
    42 
       
    43 
       
    44 //FORWARD DECLARATION
       
    45 class CIMPSSAPSettings;
       
    46 class MCnUiOpContext;
       
    47 class MCnUiConnectionHandler;
       
    48 class MCnUiClientPlugin;
       
    49 class MCnUiOpProgressStateObserver;
       
    50 class CPEngNWSessionSlotID2;
       
    51 
       
    52 // CLASS DECLARATION
       
    53 
       
    54 /**
       
    55  * Connection closer.
       
    56  * @since 2.1
       
    57  */
       
    58 NONSHARABLE_CLASS( CCnUiConnCloser ) : protected CActive,
       
    59         public MPEngNWSessionOperationObserver2
       
    60     {
       
    61 private: //helper class
       
    62     /**
       
    63      * Private helper class to manager
       
    64      * state information and notify state
       
    65      * observer.
       
    66      * @since 2.1
       
    67      */
       
    68     class TCloserStateProxy
       
    69         {
       
    70         public: //new methods
       
    71 
       
    72             /**
       
    73              * C++ default constructor.
       
    74              * @param aInitial The initial state.
       
    75              */
       
    76             TCloserStateProxy( TCnUiConnCloserState aInitial );
       
    77 
       
    78             /**
       
    79              * Sets new state observer. Observer may be NULL.
       
    80              * @since 2.1
       
    81              * @param aObs The observer to set and notify further
       
    82              * state changes.
       
    83              */
       
    84             void SetProgressObserver( MCnUiOpProgressStateObserver* aObs );
       
    85 
       
    86             /**
       
    87              * Sets new state and notifies registered observer if any..
       
    88              * @since 2.1
       
    89              * @param aNewState The new state.
       
    90              * @param aClient The client for which the state was entered
       
    91              */
       
    92             void Set( TCnUiConnCloserState aNewState, TIMPSConnectionClient aClient );
       
    93 
       
    94             /**
       
    95              * Gets current state.
       
    96              * @since 2.1
       
    97              * @return The current state.
       
    98              */
       
    99             TCnUiConnCloserState operator()();
       
   100 
       
   101 
       
   102         private: //data
       
   103 
       
   104             ///<Current state, owned
       
   105             TCnUiConnCloserState            iState ;
       
   106 
       
   107             ///<Observer, not owned, may be NULL
       
   108             MCnUiOpProgressStateObserver*   iObs;
       
   109 
       
   110         };
       
   111 
       
   112 
       
   113 public:  // Two-phased constructors and destructor
       
   114 
       
   115     /**
       
   116     * Two-phased constructor.
       
   117     */
       
   118     static CCnUiConnCloser* NewL();
       
   119 
       
   120     /**
       
   121     * Destructor.
       
   122     */
       
   123     virtual ~CCnUiConnCloser();
       
   124 
       
   125 
       
   126 private:
       
   127 
       
   128     /**
       
   129      * C++ default constructor.
       
   130      */
       
   131     CCnUiConnCloser();
       
   132 
       
   133 
       
   134 protected:  // From CActive
       
   135 
       
   136     /**
       
   137      * RunL().
       
   138      */
       
   139     void RunL();
       
   140 
       
   141 
       
   142     /**
       
   143      * RunError().
       
   144      *
       
   145      * @since 2.1
       
   146      * @param aError The leave code from RunL leave.
       
   147      * Stores this as iStatus member.
       
   148      * @return Always KErrNone.
       
   149      */
       
   150     TInt RunError( TInt aError );
       
   151 
       
   152 
       
   153     /**
       
   154      * DoCancel().
       
   155      *
       
   156      * @since 2.1
       
   157      */
       
   158     void DoCancel();
       
   159 
       
   160 
       
   161 public: // Methods from MPEngNWSessionOperationObserver2
       
   162 
       
   163     /**
       
   164      * From MPEngNWSessionOperationObserver2.
       
   165      * See it for details.
       
   166      *
       
   167      * @since 3.0
       
   168      */
       
   169     void HandleNWSessionOperationCompleteL(
       
   170         MPEngTransactionStatus2& aStatus,
       
   171         CPEngNWSessionSlot2& aNWSessionSlot,
       
   172         TInt aNWSessionSlotOperation );
       
   173 
       
   174     /**
       
   175      * From MPEngNWSessionOperationObserver2.
       
   176      * See it for details.
       
   177      *
       
   178      * @since 3.0
       
   179      */
       
   180     void HandleNWSessionOperationNotifyError(
       
   181         TInt aError,
       
   182         CPEngNWSessionSlot2& aNWSessionSlot,
       
   183         TInt aNWSessionSlotOperation );
       
   184 
       
   185 
       
   186 public: // New functions
       
   187 
       
   188     /**
       
   189      * Logout service.
       
   190      *
       
   191      * @since 2.1
       
   192      * @param aClient The client to login.
       
   193      * @param aSap The SAP to login.
       
   194      * @param aPlugin The client plugin to use in login processing.
       
   195      * @param aConnHandler The connection handler to use in login
       
   196      * @param aProgressObserver The possible progress observer,
       
   197      * may be NULL.
       
   198      * @return Operation status. This can be either local
       
   199      * error code coming from starting the operation
       
   200      * or real network error code.
       
   201      */
       
   202     TInt MakeLogoutForClient( TIMPSConnectionClient aClient,
       
   203                               const CIMPSSAPSettings& aSap,
       
   204                               MCnUiClientPlugin& aPlugin,
       
   205                               MCnUiConnectionHandler& aConnHandler,
       
   206                               MCnUiOpProgressStateObserver* aProgressObserver,
       
   207                               CPEngNWSessionSlotID2& aNWSessionSlotID );
       
   208 
       
   209 
       
   210     /**
       
   211      * Cancels the logout.
       
   212      *
       
   213      * @since 2.1
       
   214      */
       
   215     void CancelLogout();
       
   216 
       
   217 
       
   218     /**
       
   219      * Gets wether this connection closer
       
   220      * instance has really closed the network
       
   221      * connection or not.
       
   222      *
       
   223      * @since 2.1
       
   224      * @return ETrue if connection really closed.
       
   225      * Else EFalse.
       
   226      */
       
   227     TBool ConnectionReallyClosed();
       
   228 
       
   229 
       
   230 private: // New private helper methods
       
   231 
       
   232     /**
       
   233      * Waits the started asynchronous steps
       
   234      * to complete using the CActiveSchedulerWait.
       
   235      *
       
   236      * @since 2.1
       
   237      */
       
   238     void WaitCompletion();
       
   239 
       
   240 
       
   241     /**
       
   242      * Stops the previously started
       
   243      * CActiveSchedulerWait wait loop.
       
   244      *
       
   245      * @since 2.1
       
   246      */
       
   247     void Completed();
       
   248 
       
   249 
       
   250     /**
       
   251      * Handles the client logout request.
       
   252      * Starts asynchronous operation
       
   253      * if really needed.
       
   254      *
       
   255      * @since 2.1
       
   256      */
       
   257     void HandleClientLoggoutRequestL();
       
   258 
       
   259 
       
   260     /**
       
   261      * Issues plugin pre loggout processing.
       
   262      *
       
   263      * @since 2.1
       
   264      */
       
   265     void IssuePluginPreLoggoutProcessingL();
       
   266 
       
   267 
       
   268     /**
       
   269      * Issues SAP connection close processing.
       
   270      *
       
   271      * @since 2.1
       
   272      */
       
   273     void IssueSapConnectionCloseL();
       
   274 
       
   275 
       
   276     /**
       
   277      * Resets previoysly cached operation
       
   278      * parameters.
       
   279      * @since 2.1
       
   280      */
       
   281     void ResetCachedParameters();
       
   282 
       
   283 
       
   284     /**
       
   285      * Resets internal state flags.
       
   286      *
       
   287      * @since 2.1
       
   288      */
       
   289     void ResetStateFlags();
       
   290 
       
   291     /**
       
   292      * Handles operation completions
       
   293      *
       
   294      * @since 3.0
       
   295      */
       
   296     void HandleOperationCompletionsL();
       
   297 
       
   298     /**
       
   299      * Creates a network session slot copy
       
   300      *
       
   301      * @since 3.0
       
   302      */
       
   303     CPEngNWSessionSlotID2* CopyNWSessionSlotL( CPEngNWSessionSlotID2& aSessionSlot );
       
   304 
       
   305 
       
   306 
       
   307 private:    // Data
       
   308 
       
   309     ///< The internal state proxy, owned
       
   310     TCloserStateProxy               iState;
       
   311 
       
   312     ///<Active Scheduler Wait, owned
       
   313     CActiveSchedulerWait            iWait;
       
   314 
       
   315     ///<State flag. Was this operation canceled, owned
       
   316     TBool                           iCanceled;
       
   317 
       
   318     ///<State flag. Has this operation closed really NW connection, owned
       
   319     TBool                           iConnectionReallyClosed;
       
   320 
       
   321     ///<Cached operation resource, not owned
       
   322     MCnUiConnectionHandler*         iConnHandler;
       
   323 
       
   324     ///<Cached operation resource, not owned
       
   325     MCnUiClientPlugin*              iPlugin;
       
   326 
       
   327     ///<Cached operation resource, not owned
       
   328     const CIMPSSAPSettings*           iSap;
       
   329 
       
   330     ///<Cached operation resource
       
   331     TIMPSConnectionClient           iClient;
       
   332 
       
   333     MPEngTransactionStatus2*        iTransactionStatus;
       
   334 
       
   335     // owns: does not own
       
   336     CPEngNWSessionSlotID2*          iNWSessionSlotID;
       
   337 
       
   338     };
       
   339 
       
   340 #endif      // __CCNUICONNCLOSER_H
       
   341 
       
   342 // End of File