dbcreator/commsdatcreator/src/cdcprocessorvpn.cpp
changeset 56 dd6aaa97e7b1
parent 0 5a93021fdf25
equal deleted inserted replaced
52:bbe4544dfd31 56:dd6aaa97e7b1
       
     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:   Implementation of the class CProcessorVpn
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "cdcprocessorvpn.h"
       
    24 #include "cdclogger.h"
       
    25 #include "cdctagcontainer.h"
       
    26 
       
    27 #include <cmpluginvpndef.h>
       
    28 #include <cmpluginbaseeng.h>
       
    29 #include <cmconnectionmethoddef.h>
       
    30 #include <cmdestinationext.h>
       
    31 #include <cmmanagerext.h>
       
    32 #include <datamobilitycommsdattypes.h>
       
    33 
       
    34 using namespace CMManager;
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 const TUint32 KDefaultPortNum = 80;
       
    39 
       
    40 // ================= MEMBER FUNCTIONS =======================
       
    41 
       
    42 // ---------------------------------------------------------
       
    43 // CProcessorVpn::NewL
       
    44 // ---------------------------------------------------------
       
    45 //
       
    46 CProcessorVpn* CProcessorVpn::NewL( CReaderBase* aFileReader,
       
    47                                     RCmManagerExt& aCmManager,
       
    48                                     RPointerArray< RCmConnectionMethodExt >& aPluginArray,
       
    49                                     RPointerArray< HBufC >& aPluginNames,
       
    50                                     RPointerArray< HBufC >& aUnderLying )
       
    51     {
       
    52     CProcessorVpn* self = new ( ELeave ) CProcessorVpn( aFileReader,
       
    53                                                         aCmManager,
       
    54                                                         aPluginArray,
       
    55                                                         aPluginNames,
       
    56                                                         aUnderLying );
       
    57     CleanupStack::PushL( self );
       
    58 
       
    59     // From base class
       
    60     self->ConstructL();
       
    61     CleanupStack::Pop( self ); // self
       
    62     return self;
       
    63     }
       
    64     
       
    65     
       
    66 // ---------------------------------------------------------
       
    67 // CProcessorVpn::~CProcessorVpn
       
    68 // ---------------------------------------------------------
       
    69 //
       
    70 CProcessorVpn::~CProcessorVpn()
       
    71     {
       
    72     }
       
    73      
       
    74      
       
    75 // ---------------------------------------------------------
       
    76 // CProcessorVpn::ConstructL
       
    77 // ---------------------------------------------------------
       
    78 //
       
    79 void CProcessorVpn::ConstructL()
       
    80     {
       
    81     }
       
    82 
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // CProcessorVpn::CProcessorVpn
       
    86 // ---------------------------------------------------------
       
    87 //
       
    88 CProcessorVpn::CProcessorVpn( CReaderBase* aFileReader,
       
    89                               RCmManagerExt& aCmManager,
       
    90                               RPointerArray< RCmConnectionMethodExt >& aPluginArray,
       
    91                               RPointerArray< HBufC >& aPluginNames,
       
    92                               RPointerArray< HBufC >& aUnderLying  ) :
       
    93                               
       
    94                               CProcessorBase( aFileReader,
       
    95                                               aCmManager,
       
    96                                               aPluginArray,
       
    97                                               aPluginNames )
       
    98     {
       
    99     iUnderLying = &aUnderLying;
       
   100     iBearerType = KPluginVPNBearerTypeUid;
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------
       
   104 // CProcessorVpn::ProcessTagL
       
   105 // ---------------------------------------------------------
       
   106 //
       
   107 void CProcessorVpn::ProcessUnderLyingL( RPointerArray< RCmDestinationExt >& aDestArray,
       
   108                                         RPointerArray< HBufC >& aDestNames )
       
   109     {
       
   110     iDestArray = &aDestArray;
       
   111     iDestName = &aDestNames;
       
   112     
       
   113     for( TInt i(0); i < iUnderLying->Count(); i++ )
       
   114         {
       
   115         // Finds the vpn IAP by its name
       
   116         RCmConnectionMethodExt* iPlugin = FindPluginL( (*iUnderLying)[i] );
       
   117         if( iPlugin != NULL )
       
   118             {
       
   119             CLOG_WRITE_FORMAT( "Underlying set for:%S", (*iUnderLying)[i] );  
       
   120             
       
   121             // Finds the underlying IAP by its name
       
   122             i++;
       
   123             RCmConnectionMethodExt* up = FindPluginL( (*iUnderLying)[i] );
       
   124             if( up != NULL )
       
   125                 {
       
   126                 iPlugin->SetIntAttributeL( ECmNextLayerIapId,
       
   127                             up->GetIntAttributeL( ECmIapId ) );
       
   128                 iPlugin->UpdateL();                            
       
   129 
       
   130                 CLOG_WRITE_FORMAT( "Underlying IAP Set:%S", (*iUnderLying)[i] );  
       
   131                 }
       
   132             else
       
   133                 {
       
   134                 // Underlyinf can be destination. If not IAP finds destination.
       
   135                 RCmDestinationExt* ud = FindDestinationL( (*iUnderLying)[i] );
       
   136                 if( ud != NULL )
       
   137                     {
       
   138                     iPlugin->SetIntAttributeL( ECmNextLayerSNAPId, ud->Id() );
       
   139                     iPlugin->UpdateL();                            
       
   140 
       
   141                     CLOG_WRITE_FORMAT( "Underlying SNAP Set: %S", (*iUnderLying)[i] );  
       
   142                     }
       
   143                 }    
       
   144             }
       
   145         }
       
   146     }
       
   147 
       
   148 
       
   149 // ---------------------------------------------------------
       
   150 // CProcessorVpn::ProcessTagL
       
   151 // ---------------------------------------------------------
       
   152 //
       
   153 void CProcessorVpn::ProcessSpecialFieldsL( TInt aField, HBufC* aPtrTag, TInt /*aDx*/ )
       
   154     {
       
   155         CLOG_WRITE_FORMAT( "field: %d", aField );  
       
   156         switch ( aField )
       
   157             {
       
   158 	        case ECmProxyProtocolName:
       
   159 	        	{
       
   160 	        	// Do not enable proxy in this case yet
       
   161 	        	iPlugin.SetStringAttributeL( aField, *aPtrTag );
       
   162 	        	break;
       
   163 	        	}
       
   164             
       
   165             case ECmProxyServerName:
       
   166                 {
       
   167                 // First set proxy usage to enabled
       
   168                 if( !iProxyEnabled )
       
   169                     {
       
   170                     iPlugin.SetBoolAttributeL( ECmProxyUsageEnabled, ETrue );
       
   171                     iProxyEnabled = ETrue;
       
   172                     }
       
   173                 // Long text
       
   174                 iPlugin.SetStringAttributeL( aField, *aPtrTag );
       
   175                 break;
       
   176                 }
       
   177             case ECmProxyPortNumber:
       
   178                 {
       
   179                 // First set proxy usage to enabled
       
   180                 if( !iProxyEnabled )
       
   181                     {
       
   182                     iPlugin.SetBoolAttributeL( ECmProxyUsageEnabled, ETrue );
       
   183                     iProxyEnabled = ETrue;
       
   184                     }
       
   185                  // TUint32 and should be read as text.
       
   186                 TPtrC16 portptr = aPtrTag->Right( aPtrTag->Length() );
       
   187                 TLex16 lex( portptr );
       
   188                 TUint32 portnum( 0 );
       
   189                 if ( lex.Val( portnum, EDecimal ) == KErrNone )
       
   190                     {
       
   191                     iPlugin.SetIntAttributeL( aField, portnum );
       
   192                     }
       
   193                 else 
       
   194                     {
       
   195                     //no valid data is given - default value is used
       
   196                     iPlugin.SetIntAttributeL( aField, KDefaultPortNum );
       
   197                     CLOG_WRITE( "! Error : Invalid port number. Default:80");  
       
   198                     }
       
   199                 break;
       
   200                 }
       
   201             case EVPN_IapName: // Underlying IAP/destination
       
   202                 {
       
   203                 if( !iName )
       
   204                     {
       
   205                     TInt len = aPtrTag->Length();
       
   206                 
       
   207                     iName = HBufC::NewL( 8 + len );
       
   208                     TPtr name = iName->Des();
       
   209                     name.Append( _L( "VPN to " ) );
       
   210                     name.Append( *aPtrTag );
       
   211                     
       
   212                     SetGeneralFieldL( ECmName, iName );
       
   213                     
       
   214                     }
       
   215                     
       
   216                 // Adds vpnIAP name - underlying IAP/Dest name pair to a list
       
   217                 if( iName )
       
   218                     {
       
   219                     iUnderLying->AppendL( iName->AllocL() );
       
   220                     iUnderLying->AppendL( aPtrTag->AllocL() );
       
   221                     }
       
   222                 break;
       
   223                 }
       
   224             case EVpnServicePolicy:
       
   225             ////case ECmName:                //fall through
       
   226                 {
       
   227                 iPlugin.SetStringAttributeL( aField, *aPtrTag );
       
   228                 if( !iName )
       
   229                     {
       
   230                     iName = aPtrTag->AllocLC();
       
   231                     }
       
   232 
       
   233                 break;
       
   234                 }
       
   235             default:
       
   236                 {
       
   237                 break;
       
   238                 }
       
   239             }//switch
       
   240     }
       
   241 
       
   242 // End of File.