wvuing/IMPSConnectionUI/OperationStepSrc/CCnUiConnOpener.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 opener.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CCNUICONNOPENER_H
       
    19 #define __CCNUICONNOPENER_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  * NOTE!! The states ECnOpener_ClosingOwnedSAPConnection &
       
    36  * ECnOpenerClosingInterferingSAPConnection
       
    37  * perform real network operations, but canceling
       
    38  * those isn't supported.
       
    39  */
       
    40 enum TCnUiConnOpenerState
       
    41     {
       
    42     ECnOpenerIdle = 0,                  ///<Idle state, no operation running
       
    43     ECnOpenerOpeningSAPConnection = 1,  ///<Waiting the SAP connection to open
       
    44     ECnOpenerProcessingPlugin = 2,      ///<Waiting client plug-in processing
       
    45     ECnOpenerClosingOwnedSAPConnection = 3,   ///<Waiting the SAP connection to close
       
    46     ECnOpenerClosingInterferingSAPConnection = 4   ///<Waiting the SAP connection to close
       
    47     };
       
    48 
       
    49 
       
    50 
       
    51 //FORWARD DECLARATION
       
    52 class CIMPSSAPSettings;
       
    53 class MCnUiConnectionHandler;
       
    54 class MCnUiClientPlugin;
       
    55 class MCnUiOpProgressStateObserver;
       
    56 class CPEngNWSessionSlotID2;
       
    57 class MPEngTransactionStatus2;
       
    58 
       
    59 // CLASS DECLARATION
       
    60 
       
    61 /**
       
    62  * Connection opener.
       
    63  * @since 2.1
       
    64  */
       
    65 NONSHARABLE_CLASS( CCnUiConnOpener ) : protected CActive,
       
    66         public MPEngNWSessionOperationObserver2
       
    67     {
       
    68 private: //helper class
       
    69 
       
    70     /**
       
    71      * Private helper class to manager
       
    72      * state information and notify state
       
    73      * observer.
       
    74      * @since 2.1
       
    75      */
       
    76     class TOpenerStateProxy
       
    77         {
       
    78         public: //new methods
       
    79             /**
       
    80              * C++ default constructor.
       
    81              * @param aInitial The initial state.
       
    82              */
       
    83             TOpenerStateProxy( TCnUiConnOpenerState aInitial );
       
    84 
       
    85             /**
       
    86              * Sets new state observer. Observer may be NULL.
       
    87              * @since 2.1
       
    88              * @param aObs The observer to set and notify further
       
    89              * state changes.
       
    90              */
       
    91             void SetProgressObserver( MCnUiOpProgressStateObserver* aObs );
       
    92 
       
    93             /**
       
    94              * Sets new state and notifies registered observer if any..
       
    95              * @since 2.1
       
    96              * @param aNewState The new state.
       
    97              * @param aClient The client for which the state was entered
       
    98              */
       
    99             void Set( TCnUiConnOpenerState aNewState, TIMPSConnectionClient aClient );
       
   100 
       
   101             /**
       
   102              * Gets current state.
       
   103              * @since 2.1
       
   104              * @return The current state.
       
   105              */
       
   106             TCnUiConnOpenerState operator()();
       
   107 
       
   108 
       
   109         private: //data
       
   110 
       
   111             ///<Current state, owned
       
   112             TCnUiConnOpenerState            iState ;
       
   113 
       
   114             ///<Observer, not owned, may be NULL
       
   115             MCnUiOpProgressStateObserver*   iObs;
       
   116         };
       
   117 
       
   118 
       
   119 public:  // Two-phased constructors and destructor
       
   120 
       
   121     /**
       
   122     * Two-phased constructor.
       
   123     */
       
   124     static CCnUiConnOpener* NewL();
       
   125 
       
   126     /**
       
   127     * Destructor.
       
   128     */
       
   129     virtual ~CCnUiConnOpener();
       
   130 
       
   131 
       
   132 private:
       
   133 
       
   134     /**
       
   135      * C++ default constructor.
       
   136      */
       
   137     CCnUiConnOpener();
       
   138 
       
   139     /**
       
   140      * By default Symbian 2nd phase constructor is private.
       
   141      */
       
   142     void ConstructL();
       
   143 
       
   144 
       
   145 public: // New functions
       
   146 
       
   147     /**
       
   148      * Login service.
       
   149      *
       
   150      * @since 2.1
       
   151      * @param aClient The client to login.
       
   152      * @param aSap The SAP to login.
       
   153      * @param aPlugin The client plug-in to use in login processing.
       
   154      * @param aConnHandler The connection handler to use in login
       
   155      * @param aProgressObserver The possible progress observer,
       
   156      * may be NULL.
       
   157      * @return Operation status. This can be either local
       
   158      * error code coming from starting the operation
       
   159      * or real network error code.
       
   160      */
       
   161     TInt MakeLoginForClient( TIMPSConnectionClient aClient,
       
   162                              const CIMPSSAPSettings& aSap,
       
   163                              MCnUiClientPlugin& aPlugin,
       
   164                              MCnUiConnectionHandler& aConnHandler,
       
   165                              MCnUiOpProgressStateObserver* aProgressObserver,
       
   166                              CPEngNWSessionSlotID2& aNWSessionSlotID );
       
   167 
       
   168 
       
   169     /**
       
   170      * Cancels the login.
       
   171      *
       
   172      * @since 2.1
       
   173      */
       
   174     void CancelLogin();
       
   175 
       
   176 public: // Methods from MPEngNWSessionOperationObserver2
       
   177 
       
   178     /**
       
   179      * From MPEngNWSessionOperationObserver2.
       
   180      * See it for details.
       
   181      *
       
   182      * @since 3.0
       
   183      */
       
   184     void HandleNWSessionOperationCompleteL(
       
   185         MPEngTransactionStatus2& aStatus,
       
   186         CPEngNWSessionSlot2& aNWSessionSlot,
       
   187         TInt aNWSessionSlotOperation );
       
   188 
       
   189     /**
       
   190      * From MPEngNWSessionOperationObserver2.
       
   191      * See it for details.
       
   192      *
       
   193      * @since 3.0
       
   194      */
       
   195     void HandleNWSessionOperationNotifyError(
       
   196         TInt aError,
       
   197         CPEngNWSessionSlot2& aNWSessionSlot,
       
   198         TInt aNWSessionSlotOperation );
       
   199 
       
   200 public: // methods from CActive
       
   201     /**
       
   202      * From CActive.
       
   203      * @see CActive
       
   204      */
       
   205     void RunL();
       
   206 
       
   207     /**
       
   208      * From CActive.
       
   209      * @see CActive
       
   210      */
       
   211     void DoCancel();
       
   212 
       
   213     /**
       
   214      * From CActive.
       
   215      * @see CActive
       
   216      */
       
   217     TInt RunError( TInt aError );
       
   218 
       
   219     /**
       
   220      * From CActive.
       
   221      * @since S60 v3.0
       
   222      * @see CActive
       
   223      */
       
   224     void Cancel();
       
   225 
       
   226     /**
       
   227      * From CActive.
       
   228      * @since S60 v3.0
       
   229      * @see CActive
       
   230      */
       
   231     TBool IsActive() const;
       
   232 
       
   233     /**
       
   234     * Verifies SAP compulsory contents.
       
   235     *
       
   236     * @since 2.1
       
   237     * @param aSap The SAP to check
       
   238     * @return KErrNone if has required compulsory settings,
       
   239     * else KConnUiErrorSapMissingCompulsoryFields.
       
   240     */
       
   241     static TInt CheckConnOpenCompulsorySettingsL( const CIMPSSAPSettings& aSap );
       
   242 
       
   243 private: // New private helper methods
       
   244 
       
   245     /**
       
   246      * Waits the started asynchronous steps
       
   247      * to complete using the CActiveSchedulerWait.
       
   248      * @param aWaiter which CActiveSchedulerWait to start
       
   249      *
       
   250      * @since 2.1
       
   251      */
       
   252     void WaitCompletion( CActiveSchedulerWait& aWaiter );
       
   253 
       
   254 
       
   255     /**
       
   256      * Stops the previously started
       
   257      * CActiveSchedulerWait wait loop.
       
   258      * @param aWaiter which CActiveSchedulerWait to stop
       
   259      *
       
   260      * @since 2.1
       
   261      */
       
   262     void Completed( CActiveSchedulerWait& aWaiter );
       
   263 
       
   264 
       
   265     /**
       
   266      * Starts the SAP login if needed.
       
   267      *
       
   268      * @since 2.1
       
   269      * @param aCloseOfInterferingConnectionAllowed If ETrue then
       
   270      * possibly existing interfering SAP connection is tried to
       
   271      * close. If EFalse, then it isn't.
       
   272      */
       
   273     void HandleSapConnectionOpenRequestL( TBool aCloseOfInterferingConnectionAllowed );
       
   274 
       
   275 
       
   276     /**
       
   277      * Issues the real asynhronous SAP
       
   278      * connection open.
       
   279      *
       
   280      * @since 2.1
       
   281      */
       
   282     void IssueConnectionOpenL();
       
   283 
       
   284 
       
   285     /**
       
   286      * Handles SAP connection succesfully
       
   287      * opened case. Checks has the SAP enough
       
   288      * capabilites for current client etc.
       
   289      *
       
   290      * @since 2.1
       
   291      */
       
   292     void HandleSapConnectionOpenedL();
       
   293 
       
   294 
       
   295     /**
       
   296      * Issues the client post login processing.
       
   297      *
       
   298      * @since 2.1
       
   299      */
       
   300     void IssuePluginPostLoginProcessingL();
       
   301 
       
   302 
       
   303     /**
       
   304      * Closes the owned NW connection and sets client logged out
       
   305      * @since 2.1
       
   306      */
       
   307     void UndoConnectionStateChanges();
       
   308 
       
   309 
       
   310     /**
       
   311      * Issues the connection close.
       
   312      *
       
   313      * Connection close is needed when the
       
   314      * SAP doesn't have enough capabilities
       
   315      * for client or the login is canceled
       
   316      * after the network connection is
       
   317      * succesfully opened.
       
   318      *
       
   319      * @since 2.1
       
   320      */
       
   321     void IssueSapConnectionCloseIfNeededL();
       
   322 
       
   323 
       
   324     /**
       
   325      * Issues the close of interfering SAP connection.
       
   326      *
       
   327      * Interfering SAP connection is silently closed
       
   328      * when there is noticed to be a open SAP
       
   329      * connection but no known client is
       
   330      * logged in.
       
   331      *
       
   332      * @since 2.1
       
   333      */
       
   334     void IssueCloseOfInterferingSapConnectionL();
       
   335 
       
   336 
       
   337     /**
       
   338      * Resets previously cached operation
       
   339      * parameters.
       
   340      * @since 2.1
       
   341      */
       
   342     void ResetCachedParameters();
       
   343 
       
   344 
       
   345     /**
       
   346      * Resets internal state flags.
       
   347      *
       
   348      * @since 2.1
       
   349      */
       
   350     void ResetStateFlags();
       
   351 
       
   352     /**
       
   353      * Handles operation completions
       
   354      *
       
   355      * @since 3.0
       
   356      */
       
   357     void HandleOperationCompletionsL();
       
   358 
       
   359     /**
       
   360      * Creates a network session slot copy
       
   361      *
       
   362      * @since 3.0
       
   363      */
       
   364     CPEngNWSessionSlotID2* CopyNWSessionSlotL( CPEngNWSessionSlotID2& aSessionSlot );
       
   365 
       
   366 
       
   367 private:    // Data
       
   368 
       
   369     ///< The internal state proxy, owned
       
   370     TOpenerStateProxy               iState;
       
   371 
       
   372     ///<Active Scheduler Wait, owned
       
   373     CActiveSchedulerWait            iOpenWait;
       
   374 
       
   375     ///<Active Scheduler Wait, for PEC waiting, owned
       
   376     CActiveSchedulerWait            iCancelWaiter;
       
   377 
       
   378     ///<State flag. Did this operation open the SAP connection, owned
       
   379     TBool                           iOwnsSapConnection;
       
   380 
       
   381     ///<State flag. Was this operation canceled, owned
       
   382     TBool                           iCanceled;
       
   383 
       
   384     ///<Cached operation resource, not owned
       
   385     MCnUiConnectionHandler*         iConnHandler;
       
   386 
       
   387     ///<Cached operation resource, not owned
       
   388     MCnUiClientPlugin*              iPlugin;
       
   389 
       
   390     ///<Cached operation resource, not owned
       
   391     const CIMPSSAPSettings*           iSap;
       
   392 
       
   393     ///<Cached operation resource, owned
       
   394     TIMPSConnectionClient           iClient;
       
   395 
       
   396     MPEngTransactionStatus2*        iTransactionStatus;
       
   397     TInt                            iStatusInt;
       
   398 
       
   399     // owns: network session slot id
       
   400     CPEngNWSessionSlotID2*          iNWSessionSlotID;
       
   401 
       
   402     };
       
   403 
       
   404 #endif      // __CCNUICONNOPENER_H
       
   405 
       
   406 // End of File