wvuing/IMPSConnectionUI/ConnectionSrc/CIMPSPresenceAAConnectionImp.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     1 /*
       
     2 * Copyright (c) 2005 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:  AA connection implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <E32std.h>
       
    20 #include <CIMPSSAPSettings.h>
       
    21 #include <CIMPSSAPSettingsStore.h>
       
    22 #include <CPEngNWSessionSlotManager2.h>
       
    23 #include <CPEngNWSessionSlotID2.h>
       
    24 #include <sysutil.h>
       
    25 #include "CIMPSPresenceAAConnectionImp.h"
       
    26 #include "MCnUiConnectionHandler.h"
       
    27 #include "CCnUiBaseControlContext.h"
       
    28 #include "IMPSCommonUiDebugPrint.h"
       
    29 
       
    30 
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 // Two-phased constructor.
       
    34 CIMPSPresenceAAConnectionImp* CIMPSPresenceAAConnectionImp::NewL(
       
    35     CIMPSSAPSettingsStore* aSapStore )
       
    36     {
       
    37     CIMPSPresenceAAConnectionImp* self = new ( ELeave ) CIMPSPresenceAAConnectionImp( aSapStore );
       
    38 
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop( self ); //self
       
    42 
       
    43     return self;
       
    44     }
       
    45 
       
    46 
       
    47 // Destructor
       
    48 CIMPSPresenceAAConnectionImp::~CIMPSPresenceAAConnectionImp()
       
    49     {
       
    50     delete iConnHandler;
       
    51     }
       
    52 
       
    53 
       
    54 // C++ default constructor can NOT contain any code, that
       
    55 // might leave.
       
    56 //
       
    57 CIMPSPresenceAAConnectionImp::CIMPSPresenceAAConnectionImp( CIMPSSAPSettingsStore* aSapStore )
       
    58         : iSapStoreProxy( aSapStore )
       
    59     {
       
    60     }
       
    61 
       
    62 
       
    63 // Symbian OS default constructor can leave.
       
    64 void CIMPSPresenceAAConnectionImp::ConstructL()
       
    65     {
       
    66     iConnHandler = CreateConnHandlerL( iSapStoreProxy );
       
    67     }
       
    68 
       
    69 
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CIMPSPresenceAAConnectionImp::LoginL()
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 TInt CIMPSPresenceAAConnectionImp::LoginL( TIMPSConnectionClient aClient,
       
    76                                            TBool aShowDetailedError /* = EFalse */ )
       
    77     {
       
    78     // Check disk space
       
    79     if ( SysUtil::FFSSpaceBelowCriticalLevelL( NULL, 0 ) )
       
    80         {
       
    81         // Don't show any own notes here
       
    82         User::Leave( KErrDiskFull );
       
    83         }
       
    84 
       
    85     TInt retStatus = KErrNone;
       
    86     CCnUiBaseControlContext* cc = CCnUiBaseControlContext::NewLC( aClient,
       
    87                                                                   iSapStoreProxy,
       
    88                                                                   *iConnHandler );
       
    89 
       
    90     retStatus = cc->DoAALoginL( aShowDetailedError );
       
    91 
       
    92     CleanupStack::PopAndDestroy( cc ); //cc
       
    93     IMPSCUI_DP( D_IMPSCUI_LIT( "CIMPSPresenceAAConnectionImp::LoginL( %d ), retStatus=%d" ), aClient, retStatus );
       
    94     return retStatus;
       
    95     }
       
    96 
       
    97 
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CIMPSPresenceAAConnectionImp::LogoutL()
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 TInt CIMPSPresenceAAConnectionImp::LogoutL( TIMPSConnectionClient aClient,
       
   104                                             TBool aIsScheduled /* EFalse */ )
       
   105     {
       
   106     CCnUiBaseControlContext* cc = CCnUiBaseControlContext::NewLC( aClient,
       
   107                                                                   iSapStoreProxy,
       
   108                                                                   *iConnHandler );
       
   109     cc->DoAALogoutL( aIsScheduled );
       
   110     CleanupStack::PopAndDestroy( cc ); //cc
       
   111 
       
   112     IMPSCUI_DP( D_IMPSCUI_LIT( "CIMPSPresenceAAConnectionImp::LogoutL( %d )" ), aClient );
       
   113     return KErrNone;
       
   114     }
       
   115 
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CIMPSPresenceAAConnectionImp::LoggedInL()
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 TBool CIMPSPresenceAAConnectionImp::LoggedInL( TIMPSConnectionClient aClient )
       
   122     {
       
   123     return iConnHandler->TheClientLoggedInL( aClient );
       
   124     }
       
   125 
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CIMPSPresenceAAConnectionImp::PureServiceStatusL()
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 TPEngNWSessionSlotState CIMPSPresenceAAConnectionImp::PureServiceStatusL(
       
   132     const CPEngNWSessionSlotID2& aNWSessionSlotID )
       
   133     {
       
   134     return iConnHandler->ServiceStatusL( aNWSessionSlotID );
       
   135     }
       
   136 
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CIMPSPresenceAAConnectionImp::DefaultServerNameL()
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 HBufC* CIMPSPresenceAAConnectionImp::DefaultServerNameL( TIMPSConnectionClient aClient )
       
   143     {
       
   144     CIMPSSAPSettings* sapSettings = CIMPSSAPSettings::NewLC();
       
   145 
       
   146     TIMPSAccessGroup accessGroup;
       
   147     if ( aClient == EIMPSConnClientPEC )
       
   148         {
       
   149         accessGroup = EIMPSPECAccessGroup;
       
   150         }
       
   151     else
       
   152         {
       
   153         accessGroup = EIMPSIMAccessGroup;
       
   154         }
       
   155 
       
   156     // get the default sap
       
   157     iSapStoreProxy.SapStoreL().GetDefaultL( sapSettings, accessGroup );
       
   158 
       
   159     // get the sap name
       
   160     HBufC* sapName = sapSettings->SAPName().AllocL();
       
   161 
       
   162     CleanupStack::PopAndDestroy( sapSettings );
       
   163 
       
   164     return sapName;
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CIMPSPresenceAAConnectionImp::GetActiveNWSessionSlotIDL()
       
   169 //
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 CPEngNWSessionSlotID2* CIMPSPresenceAAConnectionImp::GetActiveNWSessionSlotIDL(
       
   173     TIMPSConnectionClient aClient )
       
   174     {
       
   175     CPEngNWSessionSlotManager2* slotManager = CPEngNWSessionSlotManager2::NewLC();
       
   176 
       
   177     CPEngNWSessionSlotID2* pattern = CPEngNWSessionSlotID2::NewLC();
       
   178     pattern->SetServiceAddressMatchAnyL();
       
   179     pattern->SetUserIdMatchAnyL();
       
   180     if ( aClient == EIMPSConnClientPEC )
       
   181         {
       
   182         pattern->SetAppIdL( KPEngAppIdPEC );
       
   183         }
       
   184     else
       
   185         {
       
   186         pattern->SetAppIdL( KPEngAppIdIM );
       
   187         }
       
   188 
       
   189     RPointerArray< CPEngNWSessionSlotID2 > array;
       
   190     TInt error( slotManager->GetNWSessionSlots( array,
       
   191                                                 *pattern,
       
   192                                                 EPEngNWPresenceSessionOpen ) );
       
   193 
       
   194     if ( error != KErrNone )
       
   195         {
       
   196         array.ResetAndDestroy();
       
   197         User::Leave( error );
       
   198         }
       
   199     CleanupStack::PopAndDestroy( 2, slotManager ); // pattern, slotManager
       
   200     CleanupStack::PushL( TCleanupItem( DestroyCloseModelArray, &array ) );
       
   201 
       
   202     CPEngNWSessionSlotID2* slotID = NULL;
       
   203 
       
   204     if ( array.Count() > 0 )
       
   205         {
       
   206         // only one active slot per application at the moment
       
   207         CPEngNWSessionSlotID2* tempSlotID = array[ 0 ];
       
   208 
       
   209         slotID = tempSlotID->CloneL();
       
   210         }
       
   211     else
       
   212         {
       
   213         // not found
       
   214         User::Leave( KErrNotFound );
       
   215         }
       
   216     CleanupStack::PopAndDestroy(); // array
       
   217     return slotID;
       
   218     }
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // CIMPSPresenceAAConnectionImp::DestroyCloseModelArray()
       
   222 //
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 void CIMPSPresenceAAConnectionImp::DestroyCloseModelArray( TAny* aObject )
       
   226     {
       
   227     reinterpret_cast< RPointerArray< CPEngNWSessionSlotID2 >* >( aObject )->ResetAndDestroy();
       
   228     }
       
   229 
       
   230 //  End of File
       
   231