PECengine/PresenceManager2/SrcNWSessionSlot/CPEngNWSessionOpenOp.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     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:  Operation handler for opening the network session.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "CPEngNWSessionOpenOp.h"
       
    20 #include "PEngLoginDataCodec.h"
       
    21 #include "CPEngNWSessionSlotID2Imp.h"
       
    22 #include "CPEngNWSessionProxy.h"
       
    23 #include "PresenceDebugPrint.h"
       
    24 #include <CoreApplicationUIsSDKCRKeys.h>
       
    25 #include <centralrepository.h>
       
    26 #include <PEngPresenceEngineConsts2.h>
       
    27 #include <CPEngNWSessionSlotID2.h>
       
    28 
       
    29 
       
    30 
       
    31 //LOCAL constants
       
    32 #ifdef _DEBUG
       
    33 namespace
       
    34     {
       
    35     //Panic
       
    36     _LIT( KPEngNWSessionOpenOpPanic, "PEngNWOpenOp" );
       
    37 
       
    38     //Panic reasons
       
    39     enum TPEngNWSessionOpenOpPanicReasons
       
    40         {
       
    41         ENWSessionOpenOpInUse = 1,
       
    42         };
       
    43 
       
    44     void PEngNWSessionOpenOpPanic( TPEngNWSessionOpenOpPanicReasons aPanicReason )
       
    45         {
       
    46         User::Panic( KPEngNWSessionOpenOpPanic, aPanicReason );
       
    47         }
       
    48     }
       
    49 #endif
       
    50 
       
    51 
       
    52 // ================= MEMBER FUNCTIONS =======================
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CPEngNWSessionOpenOp::NewL()
       
    56 // -----------------------------------------------------------------------------
       
    57 CPEngNWSessionOpenOp* CPEngNWSessionOpenOp::NewL( TInt aPriority,
       
    58                                                   CPEngNWSessionProxy& aNWSessionProxy,
       
    59                                                   CPEngNWSessionSlot2& aInterface,
       
    60                                                   const CIMPSSAPSettings& aImpsSap,
       
    61                                                   MPEngNWSessionOperationObserver2& aObserver )
       
    62     {
       
    63     CPEngNWSessionOpenOp* self = new ( ELeave ) CPEngNWSessionOpenOp( aPriority,
       
    64                                                                       aNWSessionProxy,
       
    65                                                                       aInterface,
       
    66                                                                       aObserver );
       
    67     CleanupStack::PushL( self );
       
    68     self->ConstructL( aImpsSap );
       
    69     CleanupStack::Pop( self );
       
    70 
       
    71     return self;
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CPEngNWSessionOpenOp::~CPEngNWSessionOpenOp()
       
    76 // -----------------------------------------------------------------------------
       
    77 CPEngNWSessionOpenOp::~CPEngNWSessionOpenOp()
       
    78     {
       
    79     CActive::Cancel();
       
    80     delete iLoginData;
       
    81     }
       
    82 
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CPEngNWSessionOpenOp::CPEngNWSessionOpenOp()
       
    86 // -----------------------------------------------------------------------------
       
    87 CPEngNWSessionOpenOp::CPEngNWSessionOpenOp( TInt aPriority,
       
    88                                             CPEngNWSessionProxy& aNWSessionProxy,
       
    89                                             CPEngNWSessionSlot2& aInterface,
       
    90                                             MPEngNWSessionOperationObserver2& aObserver )
       
    91         : CPEngNWSessionOperation( aPriority, aNWSessionProxy, aInterface, aObserver )
       
    92     {
       
    93     }
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CPEngNWSessionOpenOp::ConstructL()
       
    98 // -----------------------------------------------------------------------------
       
    99 void CPEngNWSessionOpenOp::ConstructL( const CIMPSSAPSettings& aImpsSap )
       
   100     {
       
   101     //Is network access allowed?
       
   102     CheckNetworkAccessAllowedL();
       
   103 
       
   104     //Let the base to do its construction stuff
       
   105     CPEngNWSessionOpenOp::BaseConstructL();
       
   106     iLoginData = PEngLoginDataCodec::PackLoginDataL( aImpsSap );
       
   107     }
       
   108 
       
   109 
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CPEngNWSessionOpenOp::IssueNWSessionOpen()
       
   113 // -----------------------------------------------------------------------------
       
   114 void CPEngNWSessionOpenOp::IssueNWSessionOpen()
       
   115     {
       
   116     __ASSERT_DEBUG( !IsActive(),
       
   117                     PEngNWSessionOpenOpPanic( ENWSessionOpenOpInUse ) );
       
   118 
       
   119     TInt err = iNWSessionProxy.OpenSession( *iLoginData, iStatus );
       
   120     HandleOperationIssued( err, EPEngNWSSOpNWSessionOpen );
       
   121     }
       
   122 
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CPEngNWSessionOpenOp::DoCancel()
       
   126 // -----------------------------------------------------------------------------
       
   127 void CPEngNWSessionOpenOp::DoCancel()
       
   128     {
       
   129     iNWSessionProxy.CancelOpenSession();
       
   130     NotifyObserverFromCancel();
       
   131     }
       
   132 
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // CPEngNWSessionOpenOp::DoHandleOpCompleted()
       
   136 // -----------------------------------------------------------------------------
       
   137 void CPEngNWSessionOpenOp::DoHandleOpCompleted( TInt aError )
       
   138     {
       
   139     PENG_DP( D_PENG_LIT( "CPEngNWSessionSlot2::OpenNWPresenceSession() - completed [%d]" ), aError );
       
   140 
       
   141     //Suppress unreferenced parameter warning
       
   142     ( void ) aError;
       
   143     }
       
   144 
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CPEngNWSessionOpenOp::CheckNetworkAccessAllowedL()
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CPEngNWSessionOpenOp::CheckNetworkAccessAllowedL()
       
   151     {
       
   152     TBool connectionAllowed = ETrue;
       
   153 
       
   154     //Dig out the real status
       
   155     CRepository* cenRep = CRepository::NewLC( KCRUidCoreApplicationUIs );
       
   156     TInt status = ECoreAppUIsNetworkConnectionAllowed;
       
   157     cenRep->Get( KCoreAppUIsNetworkConnectionAllowed, status );
       
   158     if ( status == ECoreAppUIsNetworkConnectionNotAllowed )
       
   159         {
       
   160         connectionAllowed = EFalse;
       
   161         }
       
   162     CleanupStack::PopAndDestroy(); //cenRep
       
   163 
       
   164     //Handle the case
       
   165     if ( !connectionAllowed )
       
   166         {
       
   167         User::Leave( KErrAccessDenied );
       
   168         }
       
   169     }
       
   170 
       
   171 
       
   172 
       
   173 // End of file
       
   174 
       
   175