wvuing/IMPSConnectionUI/OperationStepSrc/CCnUiNWDisconnectUiCntrlStep.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003 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:  Network connection close UI control.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <E32std.h>
       
    20 #include <CIMPSSAPSettings.h>
       
    21 #include <CPEngNWSessionSlotID2.h>
       
    22 
       
    23 #include "CCnUiNWDisconnectUiCntrlStep.h"
       
    24 #include "CCnUiConnCloser.h"
       
    25 
       
    26 #include "MCnUiUiControlContext.h"
       
    27 #include "MCnUiUiFacade.h"
       
    28 #include "MCnUiSignaller.h"
       
    29 #include "MCnUiConnectionHandler.h"
       
    30 #include "MCnUiClientPlugin.h"
       
    31 
       
    32 #include "CnUiErrors.h"
       
    33 
       
    34 
       
    35 
       
    36 // ================= MEMBER FUNCTIONS =======================
       
    37 // Two-phased constructor.
       
    38 CCnUiNWDisconnectUiCntrlStep* CCnUiNWDisconnectUiCntrlStep::NewLC(
       
    39     MCnUiUiControlContext& aCCntxt,
       
    40     CIMPSSAPSettings& aLogoutSap,
       
    41     RArray< TIMPSConnectionClient >& aDisconnectedClients,
       
    42     TBool aMainLevelOperation,
       
    43     const CPEngNWSessionSlotID2& aNWSessionSlotID )
       
    44     {
       
    45     CCnUiNWDisconnectUiCntrlStep* self = new ( ELeave )
       
    46     CCnUiNWDisconnectUiCntrlStep( aCCntxt,
       
    47                                   aLogoutSap,
       
    48                                   aDisconnectedClients,
       
    49                                   aMainLevelOperation );
       
    50     CleanupStack::PushL( self );
       
    51     self->ConstructL( aNWSessionSlotID );
       
    52     return self;
       
    53     }
       
    54 
       
    55 
       
    56 // Destructor
       
    57 CCnUiNWDisconnectUiCntrlStep::~CCnUiNWDisconnectUiCntrlStep()
       
    58     {
       
    59     iClientsToDisconn.Reset();
       
    60     }
       
    61 
       
    62 // C++ default constructor can NOT contain any code, that
       
    63 // might leave.
       
    64 //
       
    65 CCnUiNWDisconnectUiCntrlStep::CCnUiNWDisconnectUiCntrlStep(
       
    66     MCnUiUiControlContext& aCCntxt,
       
    67     CIMPSSAPSettings& aLogoutSap,
       
    68     RArray< TIMPSConnectionClient >& aDisconnectedClients,
       
    69     TBool aMainLevelOperation )
       
    70         : CCnUiLogoutUiCntrlStep( aCCntxt, aLogoutSap ),
       
    71         iRequestedDisconnClients( aDisconnectedClients ),
       
    72         iMainlevelOperation( aMainLevelOperation )
       
    73     {
       
    74     }
       
    75 
       
    76 
       
    77 // Symbian OS default constructor can leave.
       
    78 void CCnUiNWDisconnectUiCntrlStep::ConstructL( const CPEngNWSessionSlotID2& aNWSessionSlotID )
       
    79     {
       
    80     CCnUiLogoutUiCntrlStep::ConstructL( aNWSessionSlotID );
       
    81     }
       
    82 
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CCnUiNWDisconnectUiCntrlStep::HandleCompleteL()
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 TCnUiHandleCompleteStatus CCnUiNWDisconnectUiCntrlStep::HandleCompleteL()
       
    89     {
       
    90     //client disconnect went ok
       
    91 
       
    92     //if there has been a client to really logout,
       
    93     //it is the first one in iClientsToDisconn
       
    94     if ( iClientsToDisconn.Count() > 0 )
       
    95         {
       
    96         //add it among disconnected clients
       
    97         TIMPSConnectionClient clientId = iClientsToDisconn[ 0 ];
       
    98         User::LeaveIfError( iRequestedDisconnClients.Append( clientId ) );
       
    99 
       
   100         //and remove from internal count array
       
   101         iClientsToDisconn.Remove( 0 );
       
   102         }
       
   103 
       
   104 
       
   105     //If there is more clients to disconnect, do it
       
   106     if ( iClientsToDisconn.Count() > 0 )
       
   107         {
       
   108         //there is still clients to disconnect
       
   109         return ECnUiRestartStep;
       
   110         }
       
   111     else
       
   112         {
       
   113         //all disconnects done
       
   114         return ECnUiStepContinueTeardown;
       
   115         }
       
   116     }
       
   117 
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CCnUiNWDisconnectUiCntrlStep::UndoStepL()
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 void CCnUiNWDisconnectUiCntrlStep::UndoStepL()
       
   124     {
       
   125     //nothing to undo
       
   126     }
       
   127 
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CCnUiNWDisconnectUiCntrlStep::DoInitLogoutStepL()
       
   131 // Template method
       
   132 // -----------------------------------------------------------------------------
       
   133 //
       
   134 TInt CCnUiNWDisconnectUiCntrlStep::DoInitLogoutStepL( TIMPSConnectionClient& aClient )
       
   135     {
       
   136     if ( !iInitDone )
       
   137         {
       
   138         //NWDisconnect initialization is done only at first run round
       
   139 
       
   140         //if this disconnect is main level operation, then
       
   141         //here is needed check for simultaneous operations, else not
       
   142         if ( iMainlevelOperation )
       
   143             {
       
   144             if ( iCCntxt.Signaller().OperationRunning() )
       
   145                 {
       
   146                 ShowSimultaneousLoginOperationNoteL();
       
   147                 return KCnUiErrorLoginOperationAlreadyInUse;
       
   148                 }
       
   149             }
       
   150 
       
   151         //gather the disconnect data & clients
       
   152         InitNWDisconnectL();
       
   153         iInitDone = ETrue;
       
   154         if ( iClientsToDisconn.Count() == 0 )
       
   155             {
       
   156             //there isn't any clients to disconnect
       
   157             return KCnUiErrorNoClientsToDisconnect;
       
   158             }
       
   159         }
       
   160 
       
   161     //in all rounds a next client is initialized for logout
       
   162     //index zero indicates here that the first client id is handled
       
   163     if ( iClientsToDisconn.Count() > 0 )
       
   164         {
       
   165         aClient = iClientsToDisconn[ 0 ];
       
   166         return ECnUiLogoutInitContinue;
       
   167         }
       
   168 
       
   169     else
       
   170         {
       
   171         //no more clients to logout
       
   172         return KErrNone; //breaks away from RunStepL() with KErrNone
       
   173         }
       
   174     }
       
   175 
       
   176 
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CCnUiNWDisconnectUiCntrlStep::DoShowLogoutOkNoteL()
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 void CCnUiNWDisconnectUiCntrlStep::DoShowLogoutOkNoteL( TIMPSConnectionClient aClient )
       
   183     {
       
   184     switch ( aClient )
       
   185         {
       
   186         case EIMPSConnClientPEC:
       
   187             {
       
   188             iCCntxt.Ui().ShowNoteL( ECnUiDisconnectedPEC );
       
   189             break;
       
   190             }
       
   191 
       
   192         case EIMPSConnClientIM:
       
   193             {
       
   194             iCCntxt.Ui().ShowNoteL( ECnUiDisconnectedIM );
       
   195             break;
       
   196             }
       
   197         }
       
   198     }
       
   199 
       
   200 // -----------------------------------------------------------------------------
       
   201 // CCnUiNWDisconnectUiCntrlStep::InitNWDisconnectL()
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 void CCnUiNWDisconnectUiCntrlStep::InitNWDisconnectL()
       
   205     {
       
   206     //external parameters
       
   207     iRequestedDisconnClients.Reset();
       
   208     iLogoutSap.Reset();
       
   209 
       
   210     //internal count array
       
   211     iClientsToDisconn.Reset();
       
   212 
       
   213     MCnUiConnectionHandler& connHandler = iCCntxt.ConnHandler();
       
   214     //
       
   215     if ( connHandler.GetLoggedInSapL( iLogoutSap, EIMPSConnClientIM ) )
       
   216         {
       
   217         //get clients to be disconnected
       
   218         //NOTE!! All currently connected clients needs to be disconnected
       
   219         //so no filtering here
       
   220         connHandler.GetLoggedInClientsL( iClientsToDisconn );
       
   221         }
       
   222     }
       
   223 
       
   224 
       
   225 
       
   226 //  End of File