convergedconnectionhandler/cchclientapi/src/cchuiconnectionhandler.cpp
branchRCL_3
changeset 16 df4dfb214df5
parent 11 6134b5029079
equal deleted inserted replaced
15:43658d24f35d 16:df4dfb214df5
    23 #include <cmconnectionmethoddef.h>
    23 #include <cmconnectionmethoddef.h>
    24 #include <ConnectionUiUtilities.h>
    24 #include <ConnectionUiUtilities.h>
    25 #include <cmconnectionmethodext.h>
    25 #include <cmconnectionmethodext.h>
    26 #include <WEPSecuritySettingsUI.h>
    26 #include <WEPSecuritySettingsUI.h>
    27 #include <WPASecuritySettingsUI.h>
    27 #include <WPASecuritySettingsUI.h>
       
    28 #include <cmmanager.h>
       
    29 #include <cmpluginpacketdatadef.h>
    28 
    30 
    29 #include "cchuilogger.h"
    31 #include "cchuilogger.h"
    30 #include "cchuicchhandler.h"
    32 #include "cchuicchhandler.h"
    31 #include "cchuispshandler.h"
    33 #include "cchuispshandler.h"
    32 #include "cchuiconnectionhandler.h"
    34 #include "cchuiconnectionhandler.h"
   608         User::Leave( err );
   610         User::Leave( err );
   609         }
   611         }
   610     
   612     
   611     CCHUIDEBUG( "CCchUiConnectionHandler::SetSnapToUseL - OUT" );
   613     CCHUIDEBUG( "CCchUiConnectionHandler::SetSnapToUseL - OUT" );
   612     } 
   614     } 
   613     
   615 
       
   616 // ---------------------------------------------------------------------------
       
   617 // CCchUiConnectionHandler::ConnectionMethodAlreadyExistsL
       
   618 // ---------------------------------------------------------------------------
       
   619 //
       
   620 TBool CCchUiConnectionHandler::ConnectionMethodAlreadyExistsL(
       
   621     TUint32 aIapId, RCmDestinationExt& aTargetSnap ) const
       
   622     {
       
   623     CCHUIDEBUG( "CCchUiConnectionHandler::ConnectionMethodAlreadyExistsL - IN" );
       
   624     
       
   625     TBool returnVal = EFalse;
       
   626     TInt conMethodCount = aTargetSnap.ConnectionMethodCount();
       
   627 
       
   628     for ( TInt i( 0 ) ; i < conMethodCount && !returnVal; i ++ )
       
   629         {
       
   630         RCmConnectionMethodExt cm = aTargetSnap.ConnectionMethodL( i );
       
   631         CleanupClosePushL( cm );
       
   632         
       
   633         TUint32 bearerType = cm.GetIntAttributeL( CMManager::ECmBearerType );
       
   634         if ( bearerType == iCmManagerExt.GetConnectionMethodInfoIntL(
       
   635             aIapId, CMManager::ECmBearerType ) )
       
   636             {
       
   637             HBufC* buffer = NULL;
       
   638             HBufC* bufferToCompare = NULL;
       
   639             
       
   640             switch( bearerType )
       
   641                 {
       
   642                 case KUidWlanBearerType:
       
   643                     CCHUIDEBUG( "ConnectionMethodAlreadyExistsL - KUidWlanBearerType" );
       
   644                     buffer = iCmManagerExt.GetConnectionMethodInfoStringL(
       
   645                         aIapId, CMManager::EWlanSSID );
       
   646                     CleanupStack::PushL( buffer );
       
   647                     bufferToCompare =
       
   648                         cm.GetStringAttributeL( CMManager::EWlanSSID );
       
   649                     if ( buffer->Compare( *bufferToCompare ) == 0 )
       
   650                         {
       
   651                         returnVal = ETrue;
       
   652                         }
       
   653                     CleanupStack::PopAndDestroy( buffer );
       
   654                     delete bufferToCompare;
       
   655                     bufferToCompare = NULL;
       
   656                     break;
       
   657                 case KUidPacketDataBearerType:
       
   658                     CCHUIDEBUG( "ConnectionMethodAlreadyExistsL - KUidPacketDataBearerType" );
       
   659                     buffer = iCmManagerExt.GetConnectionMethodInfoStringL(
       
   660                         aIapId, CMManager::EPacketDataAPName );
       
   661                     CleanupStack::PushL( buffer );
       
   662                     bufferToCompare =
       
   663                         cm.GetStringAttributeL( CMManager::EPacketDataAPName );
       
   664                     if ( buffer->Compare( *bufferToCompare ) == 0 )
       
   665                         {
       
   666                         returnVal = ETrue;
       
   667                         }
       
   668                     CleanupStack::PopAndDestroy( buffer );
       
   669                     delete bufferToCompare;
       
   670                     bufferToCompare = NULL;
       
   671                     break;
       
   672                 default:
       
   673                     break;
       
   674                 }
       
   675             }
       
   676         CleanupStack::PopAndDestroy( &cm );
       
   677         }
       
   678     CCHUIDEBUG2( "CCchUiConnectionHandler::ConnectionMethodAlreadyExistsL - return = %d", returnVal );
       
   679     
       
   680     return returnVal;
       
   681     }
       
   682 
   614 // ---------------------------------------------------------------------------
   683 // ---------------------------------------------------------------------------
   615 // Copies specific iap from specific snap to target snap
   684 // Copies specific iap from specific snap to target snap
   616 // ---------------------------------------------------------------------------
   685 // ---------------------------------------------------------------------------
   617 //
   686 //
   618 void CCchUiConnectionHandler::CopyIapToServiceSnapL( 
   687 void CCchUiConnectionHandler::CopyIapToServiceSnapL( 
   640         }
   709         }
   641     else
   710     else
   642         {
   711         {
   643         CleanupClosePushL( targetSnap );
   712         CleanupClosePushL( targetSnap );
   644         }
   713         }
   645     CCHUIDEBUG( "CopyIapToServiceSnapL - Get source connection");    
   714     
   646     
   715     if( !ConnectionMethodAlreadyExistsL( aSourceIap, targetSnap ) )
   647     RCmConnectionMethodExt sourceConn = 
       
   648         iCmManagerExt.ConnectionMethodL( aSourceIap );       
       
   649     CleanupClosePushL( sourceConn );
       
   650     
       
   651     TInt conMethodCount = targetSnap.ConnectionMethodCount();
       
   652     TUint32 sourceIapId = sourceConn.GetIntAttributeL( CMManager::ECmIapId );
       
   653     TBool matchFound( EFalse );
       
   654     
       
   655     for ( TInt ndx = 0 ; ndx < conMethodCount && matchFound == 0; ndx ++ )
       
   656         {
       
   657         RCmConnectionMethodExt cm = targetSnap.ConnectionMethodL( ndx );
       
   658         CleanupClosePushL( cm );
       
   659         
       
   660         TUint32 targetIapId = cm.GetIntAttributeL( CMManager::ECmIapId );
       
   661         
       
   662         if( targetIapId == sourceIapId )
       
   663             {
       
   664             matchFound = ETrue;
       
   665             }
       
   666         CleanupStack::PopAndDestroy( &cm );
       
   667         }
       
   668     if( !matchFound )
       
   669         {
   716         {
   670         CCHUIDEBUG( 
   717         CCHUIDEBUG( 
   671           "CopyIapToServiceSnapL - Get source connection ok -> add connection");
   718             "CopyIapToServiceSnapL - connection not exists -> add connection" );
   672         
   719         
   673         targetSnap.AddConnectionMethodL( sourceConn.CreateCopyL() );
   720         RCmConnectionMethodExt sourceConn = 
   674         }
   721             iCmManagerExt.ConnectionMethodL( aSourceIap );       
   675     CleanupStack::PopAndDestroy( &sourceConn );
   722         CleanupClosePushL( sourceConn );
   676     CleanupStack::PopAndDestroy( &targetSnap );      
   723         
       
   724         RCmConnectionMethodExt newConnection = sourceConn.CreateCopyL();
       
   725         CleanupClosePushL( newConnection );
       
   726         targetSnap.AddConnectionMethodL( newConnection );
       
   727         CleanupStack::PopAndDestroy( &newConnection );
       
   728         CleanupStack::PopAndDestroy( &sourceConn );
       
   729         
       
   730         targetSnap.UpdateL();
       
   731         }
       
   732     
       
   733     CleanupStack::PopAndDestroy( &targetSnap ); 
   677     
   734     
   678     CCHUIDEBUG( "CCchUiConnectionHandler::CopyIapToServiceSnapL - OUT" );
   735     CCHUIDEBUG( "CCchUiConnectionHandler::CopyIapToServiceSnapL - OUT" );
   679     }     
   736     }     
   680     
   737     
   681 // ---------------------------------------------------------------------------
   738 // ---------------------------------------------------------------------------