voipplugins/voipadapters/cpvoipadapter/src/CWPVoIPAdapter.cpp
changeset 0 a4daefaec16c
child 9 bddb6d4447db
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2005-2009 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:  Receives and stores VoIP settings.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32base.h>
       
    21 #include <CWPAdapter.h>
       
    22 #include <CWPCharacteristic.h>
       
    23 #include <CWPParameter.h>
       
    24 #include <WPVoIPAdapter.rsg>
       
    25 #include <WPAdapterUtil.h> // Adapter utils
       
    26 #include <s32mem.h>        // RDesWriteStream
       
    27 #include <s32strm.h>
       
    28 #include <e32des8.h>
       
    29 #include <utf.h> // Unicode conversion
       
    30 #include <featmgr.h>
       
    31 #include <cmmanagerext.h>
       
    32 #include <cmdestinationext.h>
       
    33 #include <cmconnectionmethoddef.h>
       
    34 #include <crcseprofileentry.h>
       
    35 #include <crcseprofileregistry.h>
       
    36 #include <crcseaudiocodecentry.h>
       
    37 #include <crcseaudiocodecregistry.h>
       
    38 
       
    39 #include "CWPVoIPAdapter.h"
       
    40 #include "CWPVoIPItem.h"
       
    41 
       
    42 // The following four includes are because of SIP User Agent Header.
       
    43 #include "CSIPProfileRegistryObserver.h"
       
    44 #include <sipmanagedprofile.h>
       
    45 #include <sipprofileregistryobserver.h>
       
    46 #include <sipmanagedprofileregistry.h>
       
    47 
       
    48 // LOCAL CONSTANTS
       
    49 // Application related constants
       
    50 _LIT( KVoIPAdapterName, "WPVoIPAdapter");
       
    51 _LIT( KVoIPAppID,       "w9013" );  // OMA CP registration document for VoIP
       
    52 _LIT8( KVoIPAppID8,     "w9013" );  // OMA CP registration document for VoIP
       
    53 _LIT8( KSIPAppID8,      "w9010" );  // OMA CP registration document for SIP
       
    54 _LIT8( KSCCPAppID8,     "w9018" );  // OMA CP registration document for SCCP
       
    55 _LIT8( KNATFWAppID8,    "w902E" );  // OMA CP registration document for NATFW
       
    56 _LIT8( KPresenceAppId8, "ap0002" ); // OMA CP registration document for 
       
    57                                     // SIMPLE Presence
       
    58 _LIT8( KSNAPAppID8,     "w904C" );  // OMA CP registration document for 
       
    59                                     // Destination Networks
       
    60 // Characterictic clear text names.
       
    61 _LIT( KCODEC16,         "CODEC" );
       
    62 _LIT( KVOIPURIS16,      "VOIPURIS" );
       
    63 
       
    64 // VoIP profile parameters.
       
    65 // OMA CP registration document for VoIP, w9013.txt.
       
    66 _LIT( KParmSMPORT,               "SMPORT" );
       
    67 _LIT( KParmEMPORT,               "EMPORT" );
       
    68 _LIT( KParmMEDIAQOS,             "MEDIAQOS" );
       
    69 _LIT( KParmNODTMFIB,             "NODTMFIB" );
       
    70 _LIT( KParmNODTMFOOB,            "NODTMFOOB" );
       
    71 _LIT( KParmSECURECALLPREF,       "SECURECALLPREF" );
       
    72 _LIT( KParmRTCP,                 "RTCP" );
       
    73 _LIT( KParmUAHTERMINALTYPE,      "UAHTERMINALTYPE" );
       
    74 _LIT( KParmUAHWLANMAC,           "UAHWLANMAC" );
       
    75 _LIT( KParmUAHSTRING,            "UAHSTRING" );
       
    76 _LIT( KParmPROFILELOCKEDTOIAP,   "PROFILELOCKEDTOIAP" );
       
    77 _LIT( KParmVOIPPLUGINUID,        "VOIPPLUGINUID" );
       
    78 _LIT( KParmALLOWVOIPOVERWCDMA,   "ALLOWVOIPOVERWCDMA" );
       
    79 _LIT( KParmVOIPDIGITS,           "VOIPDIGITS" );
       
    80 _LIT( KParmIGNDOMPART,           "IGNDOMPART" );
       
    81 _LIT( KParmAABUDDYREQUEST,       "AABUDDYREQUEST" );
       
    82 _LIT( KParmADDUSERPHONE,         "ADDUSERPHONE" );
       
    83 _LIT( KParmSIPCONNTESTURI,       "SIPCONNTESTURI" );
       
    84 _LIT( KParmPROVIDERURI,          "PROVIDERURI" );
       
    85 _LIT( KParmMINSE,                "MINSE" );
       
    86 _LIT( KParmSESSIONEXP,           "SESSIONEXP" );
       
    87 _LIT( KParmBRANDINGURI,          "BRANDINGURI" );
       
    88 _LIT( KParmNATPROTOCOL,          "NATPROTOCOL" );
       
    89 _LIT( KParmAUTOENABLE,           "AUTOENABLE" );
       
    90 _LIT( KParmIMENABLED,            "IMENABLED" );
       
    91 
       
    92 // RESOURCE parameters.
       
    93 // OMA CP registration document for VoIP, w9013.txt.
       
    94 // RESOURCETYPE indicates if the following parameters are for a codec, SIP 
       
    95 // specific (URIs), Handover or VoIP Presence settings.
       
    96 _LIT( KParmMEDIASUBTYPE,         "MEDIASUBTYPE" );// Codec.
       
    97 _LIT( KParmPRIORITYINDEX,        "PRIORITYINDEX" );// Codec.
       
    98 _LIT( KParmJITTERBUFFERSIZE,     "JITTERBUFFERSIZE" );// Codec.
       
    99 _LIT( KParmOCTETALIGN,           "OCTET-ALIGN" );// Codec.
       
   100 _LIT( KParmMODESET,              "MODE-SET" );// Codec.
       
   101 _LIT( KParmMODECHANGEPERIOD,     "MODE-CHANGE-PERIOD" );// Codec.
       
   102 _LIT( KParmMODECHANGENEIGHBOR,   "MODE-CHANGE-NEIGHBOR" );// Codec.
       
   103 _LIT( KParmPTIME,                "PTIME" );// Codec.
       
   104 _LIT( KParmMAXPTIME,             "MAXPTIME" );// Codec.
       
   105 _LIT( KParmVAD,                  "VAD" );// Codec.
       
   106 _LIT( KParmANNEXB,               "ANNEXB" );// Codec.
       
   107 _LIT( KParmMAXRED,               "MAXRED" );// Codec.
       
   108 _LIT( KParmIPVOICEMAILBOXURI,    "IPVOICEMAILBOXURI" );// VMBX.
       
   109 _LIT( KParmVMBXLISTENURI,        "VMBXLISTENURI" );// VMBX.
       
   110 _LIT( KParmRESUBSCRIBE,          "RESUBSCRIBE" );// VMBX.
       
   111 
       
   112 // For other purposes.
       
   113 _LIT8( KHexPrefix,              "0x" ); // For parsing PLUGINUID.
       
   114 const TUint KTempStringlength( 200 ); // For SIP User-Agent Header.
       
   115 const TInt KMaxCharsInTUint32( 10 );
       
   116 const TInt KTen( 10 ); 
       
   117 
       
   118 static const TInt32 KNotSaved( -1 );
       
   119 
       
   120 // Following lines are for enabling debug prints.
       
   121 #ifdef _DEBUG
       
   122 #define DBG_PRINT(p) RDebug::Print(_L(p))
       
   123 #define DBG_PRINT2(p,a) RDebug::Print(_L(p),a)
       
   124 #else
       
   125 #define DBG_PRINT(p)
       
   126 #define DBG_PRINT2(p,a)
       
   127 #endif // _DEBUG
       
   128 
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CWPVoIPAdapter::CWPVoIPAdapter
       
   132 // ---------------------------------------------------------------------------
       
   133 //
       
   134 CWPVoIPAdapter::CWPVoIPAdapter() : CWPAdapter()
       
   135     {
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // CWPVoIPAdapter::ConstructL
       
   140 // ---------------------------------------------------------------------------
       
   141 //
       
   142 void CWPVoIPAdapter::ConstructL()
       
   143     {
       
   144     DBG_PRINT( "CWPVoIPAdapter::ConstructL - begin" );
       
   145     TFileName fileName;
       
   146     Dll::FileName( fileName );
       
   147     iTitle = WPAdapterUtil::ReadHBufCL( fileName, KVoIPAdapterName, 
       
   148         R_QTN_SM_HEAD_VOIP );
       
   149     iUids = HBufC8::NewL( 0 );
       
   150     iCurrentVoIPItem = NULL;
       
   151 
       
   152     FeatureManager::InitializeLibL();
       
   153     iFeatMgrInitialized = ETrue;
       
   154 
       
   155     DBG_PRINT( "CWVoIPAdapter::ConstructL - Checking VoIP support." );
       
   156     if ( !FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
       
   157         {
       
   158         DBG_PRINT( "CWVoIPAdapter::ConstructL - VoIP not supported; leave." );
       
   159         User::Leave( KErrNotSupported );
       
   160         }
       
   161     DBG_PRINT( "CWPVoIPAdapter::ConstructL - end" );
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // CWPVoIPAdapter::NewL
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 CWPVoIPAdapter* CWPVoIPAdapter::NewL()
       
   169     {
       
   170     DBG_PRINT( "CWPVoIPAdapter::NewL - begin" );
       
   171     CWPVoIPAdapter* self = new (ELeave) CWPVoIPAdapter;
       
   172     CleanupStack::PushL( self );
       
   173     self->ConstructL();
       
   174     CleanupStack::Pop( self );
       
   175     DBG_PRINT( "CWVoIPAdapter::NewL - end" );
       
   176     return self;
       
   177     }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // CWPVoIPAdapter::~CWPVoIPAdapter
       
   181 // ---------------------------------------------------------------------------
       
   182 //
       
   183 CWPVoIPAdapter::~CWPVoIPAdapter()
       
   184     {
       
   185     DBG_PRINT( "CWVoIPAdapter::~CWPVoIPAdapter - begin" );
       
   186     delete iTitle;
       
   187     delete iUids;
       
   188     iDatas.ResetAndDestroy();
       
   189     iDatas.Close();
       
   190 
       
   191     if ( iFeatMgrInitialized )
       
   192         {
       
   193         FeatureManager::UnInitializeLib();
       
   194         }
       
   195 
       
   196     DBG_PRINT( "CWVoIPAdapter::~CWPVoIPAdapter - end" );
       
   197     //lint -e{1740} iCurrentCodec is deleted in another class
       
   198     }
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CWPVoIPAdapter::ContextExtension
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 TInt CWPVoIPAdapter::ContextExtension( MWPContextExtension*& aExtension )
       
   205     {
       
   206     aExtension = this;
       
   207     return KErrNone;
       
   208     }
       
   209 
       
   210 // ---------------------------------------------------------------------------
       
   211 // CWPVoIPAdapter::SaveDataL
       
   212 // ---------------------------------------------------------------------------
       
   213 //
       
   214 const TDesC8& CWPVoIPAdapter::SaveDataL( TInt aIndex ) const
       
   215     {
       
   216     return iDatas[aIndex]->SaveData();
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // CWPVoIPAdapter::DeleteL
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 void CWPVoIPAdapter::DeleteL( const TDesC8& aSaveData )
       
   224     {
       
   225     DBG_PRINT( "CWVoIPAdapter::DeleteL - begin" );
       
   226     TUint tId;
       
   227     TLex8 lex( aSaveData );
       
   228     TInt err( KErrNone );            
       
   229     err = lex.Val( tId );
       
   230     if ( KErrNone == err )
       
   231         {
       
   232         CRCSEProfileRegistry* cRCSEProfileRegistry = 
       
   233             CRCSEProfileRegistry::NewLC();
       
   234         cRCSEProfileRegistry->DeleteL( tId );
       
   235         
       
   236         // set CS preferred if last VoIP profile deleted
       
   237         RArray<TUint32> voipIds;
       
   238         cRCSEProfileRegistry->GetAllIdsL( voipIds );
       
   239         if ( KErrNone == voipIds.Count()  )
       
   240             {
       
   241             CWPVoIPItem* cVoIPItem = CWPVoIPItem::NewL();
       
   242             CleanupStack::PushL( cVoIPItem );
       
   243             cVoIPItem->SetTelephonyPreferenceL( CWPVoIPItem::ECSPreferred );
       
   244             CleanupStack::PopAndDestroy( cVoIPItem );
       
   245             }
       
   246         voipIds.Close();  
       
   247         CleanupStack::PopAndDestroy( cRCSEProfileRegistry );
       
   248         }// if
       
   249     DBG_PRINT( "CWVoIPAdapter::DeleteL - end" );
       
   250     }
       
   251 
       
   252 // ---------------------------------------------------------------------------
       
   253 // CWPVoIPAdapter::Uid
       
   254 // ---------------------------------------------------------------------------
       
   255 //
       
   256 TUint32 CWPVoIPAdapter::Uid() const
       
   257     {
       
   258     return iDtor_ID_Key.iUid; 
       
   259     }
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // CWPVoIPAdapter::DetailsL
       
   263 // ---------------------------------------------------------------------------
       
   264 //
       
   265 TInt CWPVoIPAdapter::DetailsL( TInt /*aItem*/, MWPPairVisitor& /*aVisitor */ )
       
   266     {
       
   267     return KErrNotSupported;
       
   268     }  
       
   269 
       
   270 // ---------------------------------------------------------------------------
       
   271 // CWPVoIPAdapter::SummaryCount
       
   272 // ---------------------------------------------------------------------------
       
   273 //
       
   274 TInt CWPVoIPAdapter::ItemCount() const
       
   275     {
       
   276     return iDatas.Count();
       
   277     }
       
   278 
       
   279 // ---------------------------------------------------------------------------
       
   280 // CWPVoIPAdapter::SummaryTitle
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 const TDesC16& CWPVoIPAdapter::SummaryTitle( TInt /*aIndex*/ ) const
       
   284     {
       
   285     return *iTitle;
       
   286     }
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 // CWPVoIPAdapter::SummaryText
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 const TDesC16& CWPVoIPAdapter::SummaryText( TInt aIndex ) const
       
   293     {
       
   294     return iDatas[aIndex]->Name();
       
   295     }
       
   296 
       
   297 // ---------------------------------------------------------------------------
       
   298 // CWPVoIPAdapter::SaveL
       
   299 // ---------------------------------------------------------------------------
       
   300 //
       
   301 void CWPVoIPAdapter::SaveL( TInt aIndex )
       
   302     {
       
   303     DBG_PRINT( "CWVoIPAdapter::SaveL - begin" );
       
   304 
       
   305     CWPVoIPItem* voipItem = iDatas[aIndex];
       
   306 
       
   307     if ( voipItem->NapDef() && voipItem->NapDef()->Data().Length() <= 
       
   308         KMaxCharsInTUint32 )
       
   309         {
       
   310         // Get WAP ID.
       
   311         TPckgBuf<TUint32> uid;
       
   312         uid.Copy( voipItem->NapDef()->Data( 0 ) );
       
   313         TUint32 wapId( uid() );
       
   314         // Get corresponding IAP ID.
       
   315         TUint32 iapId = IapIdFromWapIdL( wapId );
       
   316         voipItem->SetIapId( iapId );
       
   317         }
       
   318 
       
   319     voipItem->StoreL();
       
   320     voipItem = NULL;
       
   321     DBG_PRINT( "CWVoIPAdapter::SaveL - end" );
       
   322     }
       
   323 
       
   324 // ---------------------------------------------------------------------------
       
   325 // CWPVoIPAdapter::CanSetAsDefault
       
   326 // ---------------------------------------------------------------------------
       
   327 //
       
   328 TBool CWPVoIPAdapter::CanSetAsDefault( TInt /*aIndex*/ ) const
       
   329     {
       
   330     return EFalse;
       
   331     }
       
   332 
       
   333 // ---------------------------------------------------------------------------
       
   334 // CWPVoIPAdapter::SetAsDefaultL
       
   335 // ---------------------------------------------------------------------------
       
   336 //
       
   337 void CWPVoIPAdapter::SetAsDefaultL( TInt /*aIndex*/ )
       
   338     {
       
   339     // From VoIP release 3.0 onwards VoIP profiles cannot be set as default
       
   340     // => this mehod does nothing but is present because of inheritance.
       
   341     }
       
   342 
       
   343 // ---------------------------------------------------------------------------
       
   344 // CWPVoIPAdapter::VisitL
       
   345 // ---------------------------------------------------------------------------
       
   346 //
       
   347 void CWPVoIPAdapter::VisitL( CWPCharacteristic& aCharacteristic )
       
   348     {
       
   349     DBG_PRINT( "CWVoIPAdapter::VisitL( characteristic ) - begin" );
       
   350     
       
   351     switch( aCharacteristic.Type() )
       
   352         {
       
   353         // Core VoIP settings.
       
   354         case KWPApplication:
       
   355             {
       
   356             DBG_PRINT(
       
   357                  "CWVoIPAdapter::VisitL(characteristic) - case APPLICATION" );
       
   358             iCurrentCharacteristic = KWPApplication;
       
   359             iCurrentVoIPItem = CWPVoIPItem::NewL();
       
   360             aCharacteristic.AcceptL( *this );
       
   361             // If VoIP settings, append the item into iDatas array and leave
       
   362             // iCurrentVoIPItem to point to it.
       
   363             if ( iAppID == KVoIPAppID ) 
       
   364                 {
       
   365                 User::LeaveIfError( iDatas.Append( iCurrentVoIPItem ) );
       
   366                 }
       
   367             else // else the settigs are no longer of type VoIP.
       
   368                 {
       
   369                 DBG_PRINT( 
       
   370                     "CWVoIPAdapter::VisitL( characteristic ) - no VoIP." );
       
   371                 delete iCurrentVoIPItem;
       
   372                 iCurrentVoIPItem = NULL;
       
   373                 }
       
   374             break;
       
   375             }
       
   376         // Codec and SIP profile specific settings.
       
   377         case KWPNamedCharacteristic:
       
   378             {
       
   379             iCurrentCharacteristic = KWPNamedCharacteristic;
       
   380             //lint -e{961} No need for else statement here
       
   381             if ( aCharacteristic.Name().Compare( KCODEC16() ) == 0 )
       
   382                 {
       
   383                 DBG_PRINT(
       
   384                     "CWVoIPAdapter::VisitL( characteristic ) - case CODEC" );
       
   385                 iCurrentCodec = CWPVoIPCodec::NewL();
       
   386                 iSetCodec = ETrue;
       
   387                 aCharacteristic.AcceptL( *this ); 
       
   388                 iCurrentVoIPItem->AddCodecL( iCurrentCodec );
       
   389                 iSetCodec = EFalse;
       
   390                 }
       
   391             else if ( aCharacteristic.Name().Compare( KVOIPURIS16() ) == 0 )
       
   392                 {
       
   393                 DBG_PRINT(
       
   394                     "CWVoIPAdapter::VisitL(characteristic) - case VOIPURIS" );
       
   395                 iSetVoipUris = ETrue;
       
   396                 aCharacteristic.AcceptL( *this );
       
   397                 iSetVoipUris = EFalse;
       
   398                 }
       
   399             break;
       
   400             }
       
   401         default:
       
   402             break;
       
   403         }
       
   404     DBG_PRINT( "CWVoIPAdapter::VisitL( characteristic ) - end" );
       
   405     }
       
   406 
       
   407 // ---------------------------------------------------------------------------
       
   408 // CWPVoIPAdapter::GetSavingInfoL
       
   409 // ---------------------------------------------------------------------------
       
   410 //
       
   411 void CWPVoIPAdapter::GetSavingInfoL( TInt aIndex, 
       
   412     RPointerArray<HBufC8>& aSavingInfo )
       
   413     {
       
   414     // APPID into place [0].
       
   415     aSavingInfo.AppendL( KVoIPAppID8().AllocL() );
       
   416     // APPREF into place [1].
       
   417     aSavingInfo.AppendL( iDatas[aIndex]->AppRef()->AllocL() );
       
   418     // Profile id into place [2].
       
   419     aSavingInfo.AppendL( iDatas[aIndex]->SaveData().AllocL() );
       
   420     }
       
   421 
       
   422 // ---------------------------------------------------------------------------
       
   423 // CWPVoIPAdapter::VisitL
       
   424 // ---------------------------------------------------------------------------
       
   425 //
       
   426 void CWPVoIPAdapter::VisitL( CWPParameter& aParameter )
       
   427     {
       
   428     DBG_PRINT( "CWVoIPAdapter::VisitL( parameter ) - begin" );
       
   429     // tmpValue holds the value converted from Unicode to UTF8.
       
   430     HBufC8* tmpValue = HBufC8::NewLC( aParameter.Value().Length() ); // CS:1
       
   431     TPtr8 ptrTmpValue( tmpValue->Des() );
       
   432     CnvUtfConverter::ConvertFromUnicodeToUtf8( ptrTmpValue, 
       
   433         aParameter.Value() );    
       
   434     TInt tIntParameterValue( 0 );
       
   435     
       
   436     switch( aParameter.ID() )
       
   437         {
       
   438         case EWPParameterAppRef:
       
   439             {
       
   440             iCurrentVoIPItem->SetAppRefL( tmpValue->Des() );
       
   441             break;
       
   442             }
       
   443         case EWPParameterAppID:
       
   444             {
       
   445             iAppID.Set( aParameter.Value() );
       
   446             break;
       
   447             }
       
   448         // Here case 0 are handled the VoIP parameters that are extensions  
       
   449         // to OMA Client Provisioning parameter set.
       
   450         case 0:
       
   451             //lint -e{961} No need for else statement here
       
   452             if ( aParameter.Name().Compare( KParmSMPORT ) == 0 )
       
   453                 {
       
   454                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   455                     {
       
   456                     iCurrentVoIPItem->SetStartMediaPort( tIntParameterValue );
       
   457                     }// if
       
   458                 }
       
   459             else if ( aParameter.Name().Compare( KParmEMPORT ) == 0 )
       
   460                 {
       
   461                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   462                     {
       
   463                     iCurrentVoIPItem->SetEndMediaPort( tIntParameterValue );
       
   464                     }//if
       
   465                 }// else if
       
   466             else if ( aParameter.Name().Compare( KParmMEDIAQOS ) == 0 )
       
   467                 {
       
   468                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   469                     {
       
   470                     iCurrentVoIPItem->SetMediaQoS( tIntParameterValue );
       
   471                     }// if
       
   472                 }// else if
       
   473             else if ( aParameter.Name().Compare( KParmNODTMFIB ) == 0 )
       
   474                 {
       
   475                 iCurrentVoIPItem->SetDTMFInBand( 0 );
       
   476                 }// else if
       
   477             else if ( aParameter.Name().Compare( KParmNODTMFOOB ) == 0 )
       
   478                 {
       
   479                 iCurrentVoIPItem->SetDTMFOutBand( 0 );
       
   480                 }
       
   481             else if ( aParameter.Name().Compare( KParmSECURECALLPREF ) == 0 )
       
   482                 {
       
   483                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   484                     {
       
   485                     iCurrentVoIPItem->SetSecureCallPref( tIntParameterValue );
       
   486                     }// if
       
   487                 }// else if
       
   488 
       
   489             else if ( aParameter.Name().Compare( KParmRTCP ) == 0 )
       
   490                 {
       
   491                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   492                     {
       
   493                     iCurrentVoIPItem->SetRTCP( tIntParameterValue );
       
   494                     }// if
       
   495                 }// else if
       
   496 
       
   497             else if ( aParameter.Name().Compare( 
       
   498                 KParmUAHTERMINALTYPE ) == 0 )
       
   499                 {
       
   500                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   501                     {
       
   502                     iCurrentVoIPItem->SetUAHTerminalType( 
       
   503                         tIntParameterValue );
       
   504                     }// if
       
   505                 }// else if
       
   506 
       
   507             else if ( aParameter.Name().Compare( KParmUAHWLANMAC ) == 0 )
       
   508                 {
       
   509                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   510                     {
       
   511                     iCurrentVoIPItem->SetUAHWLANMAC( tIntParameterValue );
       
   512                     }// if
       
   513                 }// else if
       
   514 
       
   515             else if ( aParameter.Name().Compare( KParmUAHSTRING ) == 0 )
       
   516                 {
       
   517                 iCurrentVoIPItem->SetUAHStringL( aParameter.Value() );
       
   518                 }
       
   519 
       
   520             else if ( aParameter.Name().Compare( 
       
   521                 KParmPROFILELOCKEDTOIAP ) == 0 )
       
   522                 {
       
   523                 iCurrentVoIPItem->SetProfileLockedToIAP( 1 );
       
   524                 }
       
   525 
       
   526             else if ( aParameter.Name().Compare( KParmVOIPPLUGINUID ) == 0 )
       
   527                 {
       
   528                 TInt hexStart ( tmpValue->Find( KHexPrefix() ) );
       
   529                 if ( hexStart == KErrNotFound )
       
   530                     {
       
   531                     hexStart = KErrNone;
       
   532                     }
       
   533                 else
       
   534                     {
       
   535                     hexStart = KHexPrefix().Length();
       
   536                     }
       
   537                 TUint32 paramValue;
       
   538                 TLex8 lex( tmpValue->Des().Mid( hexStart ));
       
   539                 TInt err( KErrNone );
       
   540                 err = lex.Val( paramValue, EHex );
       
   541                 if ( KErrNone == err && paramValue <= KMaxTInt )
       
   542                     {
       
   543                     iCurrentVoIPItem->SetVoIPPluginUid( paramValue );
       
   544                     }// if
       
   545                 }// else if
       
   546 
       
   547             else if ( aParameter.Name().Compare( 
       
   548                 KParmALLOWVOIPOVERWCDMA ) == 0 )
       
   549                 {
       
   550                 iCurrentVoIPItem->SetAllowVoIPOverWCDMA( 1 );
       
   551                 }
       
   552             
       
   553             else if ( aParameter.Name().Compare( KParmVOIPDIGITS ) == 0 )
       
   554                 {
       
   555                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   556                     {
       
   557                     iCurrentVoIPItem->SetVoIPDigits( tIntParameterValue );
       
   558                     }
       
   559                 }
       
   560 
       
   561             else if ( aParameter.Name().Compare( KParmIGNDOMPART ) == 0 )
       
   562                 {
       
   563                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   564                     {
       
   565                     iCurrentVoIPItem->SetDomainPartIgnoreRule( 
       
   566                         tIntParameterValue );
       
   567                     }
       
   568                 }
       
   569 
       
   570             else if ( KErrNone == aParameter.Name().Compare( 
       
   571                 KParmADDUSERPHONE ) )
       
   572                 {
       
   573                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   574                     {
       
   575                     iCurrentVoIPItem->SetAddUserPhone( tIntParameterValue );
       
   576                     }
       
   577                 }
       
   578 
       
   579             else if ( KErrNone == aParameter.Name().Compare( 
       
   580                 KParmSIPCONNTESTURI ) )
       
   581                 {
       
   582                 iCurrentVoIPItem->SetSipConnTestAddressL( 
       
   583                     aParameter.Value() );
       
   584                 }
       
   585 
       
   586             else if ( KErrNone == aParameter.Name().Compare( 
       
   587                 KParmPROVIDERURI ) )
       
   588                 {
       
   589                 iCurrentVoIPItem->SetServiceProviderBookmarkL( 
       
   590                     aParameter.Value() );
       
   591                 }
       
   592 
       
   593             else if ( KErrNone == aParameter.Name().Compare( KParmMINSE ) )
       
   594                 {
       
   595                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   596                     {
       
   597                     iCurrentVoIPItem->SetSipMinSe( tIntParameterValue );
       
   598                     }
       
   599                 }
       
   600 
       
   601             else if ( KErrNone == aParameter.Name().Compare( 
       
   602                 KParmSESSIONEXP ) )
       
   603                 {
       
   604                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   605                     {
       
   606                     iCurrentVoIPItem->SetSipSessionExpires( 
       
   607                         tIntParameterValue );
       
   608                     }
       
   609                 }
       
   610 
       
   611             else if ( KErrNone == aParameter.Name().Compare( 
       
   612                 KParmBRANDINGURI ) )
       
   613                 {
       
   614                 iCurrentVoIPItem->SetBrandingDataAddressL( 
       
   615                     aParameter.Value() );
       
   616                 }
       
   617 
       
   618             else if ( KErrNone == aParameter.Name().Compare( 
       
   619                 KParmAABUDDYREQUEST ) )
       
   620                 {
       
   621                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   622                     {
       
   623                     iCurrentVoIPItem->SetAutoAcceptBuddyRequest( 
       
   624                         tIntParameterValue );
       
   625                     }
       
   626                 }                               
       
   627 
       
   628             // VoiceMailBox parameter.
       
   629             else if ( KErrNone == aParameter.Name().Compare( 
       
   630                 KParmIPVOICEMAILBOXURI ) )
       
   631                 {
       
   632                 iCurrentVoIPItem->SetIPVoiceMailBoxURIL(
       
   633                     aParameter.Value() );
       
   634                 }
       
   635 
       
   636             // VoiceMailBox parameter.
       
   637             else if ( KErrNone == aParameter.Name().Compare( 
       
   638                 KParmVMBXLISTENURI ) )
       
   639                 {
       
   640                 iCurrentVoIPItem->SetVoiceMailBoxListenURIL( 
       
   641                     aParameter.Value() );
       
   642                 }
       
   643                 
       
   644             // VoiceMailBox parameter.
       
   645             else if ( KErrNone == aParameter.Name().Compare( 
       
   646                 KParmRESUBSCRIBE ) )
       
   647                 {
       
   648                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   649                     {
       
   650                     iCurrentVoIPItem->SetReSubscribeInterval( 
       
   651                         tIntParameterValue );
       
   652                     }
       
   653                 }
       
   654 
       
   655             else if ( KErrNone == aParameter.Name().Compare( 
       
   656                 KParmNATPROTOCOL ) )
       
   657                 {                
       
   658                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   659                     {
       
   660                     iCurrentVoIPItem->SetUsedNatProtocol( 
       
   661                         tIntParameterValue );                    
       
   662                     }
       
   663                 }     
       
   664                 
       
   665             else if ( KErrNone == aParameter.Name().Compare( 
       
   666                 KParmAUTOENABLE ) )
       
   667                 {
       
   668                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   669                     {
       
   670                     iCurrentVoIPItem->SetAutoEnableService( 
       
   671                         tIntParameterValue );
       
   672                     }
       
   673                 }             
       
   674             else if ( KErrNone == aParameter.Name().Compare( 
       
   675                 KParmIMENABLED ) )
       
   676                 {
       
   677                 iCurrentVoIPItem->EnableIm();
       
   678                 }
       
   679 
       
   680             // Codec parameter.    
       
   681             else if ( aParameter.Name().Compare( KParmMEDIASUBTYPE ) == 0 
       
   682                 && iSetCodec )
       
   683                 {
       
   684                 typedef CWPVoIPCodec CMediaSubType;
       
   685 
       
   686                 DescToInt( tmpValue, tIntParameterValue );
       
   687 
       
   688                 switch ( tIntParameterValue )
       
   689                     {
       
   690                     case CMediaSubType::EAMR:
       
   691                         {
       
   692                         iCurrentCodec->SetMediaSubtypeNameL( 
       
   693                             KAudioCodecAMR() );
       
   694                         }
       
   695                     break;
       
   696 
       
   697                     case CMediaSubType::EiLBC:
       
   698                         {
       
   699                         iCurrentCodec->SetMediaSubtypeNameL( 
       
   700                             KAudioCodeciLBC() );
       
   701                         }
       
   702                     break;
       
   703 
       
   704                     case CMediaSubType::EPCMA:
       
   705                         {
       
   706                         iCurrentCodec->SetMediaSubtypeNameL( 
       
   707                             KAudioCodecPCMA() );
       
   708                         }
       
   709                     break;
       
   710 
       
   711                     case CMediaSubType::EPCMU:
       
   712                         {
       
   713                         iCurrentCodec->SetMediaSubtypeNameL( 
       
   714                             KAudioCodecPCMU() );
       
   715                         }
       
   716                     break;
       
   717 
       
   718                     case CMediaSubType::ECN:
       
   719                         {
       
   720                         iCurrentCodec->SetMediaSubtypeNameL( 
       
   721                             KAudioCodecCN() );
       
   722                         }
       
   723                     break;
       
   724 
       
   725                     case CMediaSubType::EG729:
       
   726                         {
       
   727                         iCurrentCodec->SetMediaSubtypeNameL( 
       
   728                             KAudioCodecG729() );
       
   729                         }
       
   730                     break;
       
   731 
       
   732                     case CMediaSubType::EAMRWB:
       
   733                         {
       
   734                         iCurrentCodec->SetMediaSubtypeNameL( 
       
   735                             KAudioCodecAMRWB() );
       
   736                         }
       
   737                     break;
       
   738 
       
   739                     case CMediaSubType::EVMRWB:
       
   740                     case CMediaSubType::EEVRC:
       
   741                     case CMediaSubType::EEVRC0:
       
   742                     case CMediaSubType::ESMV:
       
   743                     case CMediaSubType::ESMV0:
       
   744                     case CMediaSubType::EG726_40:
       
   745                     case CMediaSubType::EG726_32:
       
   746                     case CMediaSubType::EG726_24:
       
   747                     case CMediaSubType::EG726_16:
       
   748                     case CMediaSubType::EGSMEFR:
       
   749                     case CMediaSubType::EGSMFR:
       
   750                     default:
       
   751                         {
       
   752                         // Error or not supported => Codec deleted later.
       
   753                         iCurrentCodec->SetMediaSubtypeNameL( 
       
   754                             KNullDesC() );
       
   755                         }
       
   756                     }// switch
       
   757                 }
       
   758             // Codec parameter.                    
       
   759             else if ( aParameter.Name().Compare( KParmPRIORITYINDEX ) == 0 
       
   760                 && iSetCodec )
       
   761                 {
       
   762                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   763                     {
       
   764                     iCurrentCodec->iPriorityIndex = tIntParameterValue;
       
   765                     }
       
   766                 }
       
   767             // Codec parameter.    
       
   768             else if ( aParameter.Name().Compare( KParmJITTERBUFFERSIZE ) == 0
       
   769                 && iSetCodec )
       
   770                 {
       
   771                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   772                     {
       
   773                     iCurrentCodec->iJitterBufferSize = tIntParameterValue;
       
   774                     }
       
   775                 }
       
   776             // Codec parameter.    
       
   777             else if ( aParameter.Name().Compare( KParmOCTETALIGN ) == 0 
       
   778                 && iSetCodec )
       
   779                 {
       
   780                 iCurrentCodec->iOctetAlign = 1;
       
   781                 }
       
   782             // Codec parameter.    
       
   783             else if ( aParameter.Name().Compare( KParmMODESET ) == 0 
       
   784                 && iSetCodec )
       
   785                 {
       
   786                 TLex8 lexModeSet( tmpValue->Des() );
       
   787                 TChar tmpChar;
       
   788 
       
   789                 while ( lexModeSet.Peek() != 0 )                
       
   790                     {
       
   791                     TInt32 tmpModeSetValue ( 0 );
       
   792                     TBool cycle ( ETrue );
       
   793                     TBool stateDigit ( ETrue );
       
   794                     TBool numberExists ( EFalse );
       
   795                     
       
   796                     while ( cycle ) 
       
   797                         {
       
   798                         switch( stateDigit )
       
   799                             {
       
   800                             case ETrue:
       
   801                                 {
       
   802                                 if ( lexModeSet.Peek() != 0 )
       
   803                                     {
       
   804                                     tmpChar = lexModeSet.Get();
       
   805                                     if ( tmpChar.IsDigit() )
       
   806                                         {
       
   807                                         // for example: 25 =  2 * 10 + 5
       
   808                                         //             257 = 25 * 10 + 7  
       
   809                                         tmpModeSetValue = tmpModeSetValue * KTen 
       
   810                                                  + tmpChar.GetNumericValue();
       
   811                                         numberExists = ETrue;
       
   812                                         }
       
   813                                     else
       
   814                                         {
       
   815                                         stateDigit = EFalse;
       
   816                                         }
       
   817                                     }
       
   818                                 else
       
   819                                     {
       
   820                                     stateDigit = EFalse;    
       
   821                                     }
       
   822                                 break;
       
   823                                 }
       
   824                                 
       
   825                             case EFalse:
       
   826                                 {
       
   827                                 cycle = EFalse;
       
   828                                 break;
       
   829                                 }
       
   830                             }
       
   831                         }
       
   832                         if ( numberExists )
       
   833                             {
       
   834                             iCurrentCodec->iModeSet.Append( tmpModeSetValue );
       
   835                             }
       
   836                     }
       
   837                 }
       
   838                 
       
   839             // Codec parameter.    
       
   840             else if ( aParameter.Name().Compare( KParmMODECHANGEPERIOD ) == 0
       
   841                 && iSetCodec )
       
   842                 {
       
   843                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   844                     {
       
   845                     iCurrentCodec->iModeChangePeriod = tIntParameterValue;  
       
   846                     }
       
   847                 }
       
   848             // Codec parameter.    
       
   849             else if ( 
       
   850                 aParameter.Name().Compare( KParmMODECHANGENEIGHBOR ) == 0
       
   851                 && iSetCodec )
       
   852                 {
       
   853                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   854                     {
       
   855                     iCurrentCodec->iModeChangeNeighbor = tIntParameterValue;
       
   856                     }
       
   857                 }
       
   858             // Codec parameter.    
       
   859             else if ( aParameter.Name().Compare( KParmPTIME ) == 0 
       
   860                 && iSetCodec )
       
   861                 {
       
   862                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   863                     {
       
   864                     iCurrentCodec->iPTime = tIntParameterValue;
       
   865                     }
       
   866                 }
       
   867             // Codec parameter.    
       
   868             else if ( aParameter.Name().Compare( KParmMAXPTIME ) == 0 
       
   869                 && iSetCodec )
       
   870                 {
       
   871                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   872                     {
       
   873                     iCurrentCodec->iMaxPTime = tIntParameterValue;
       
   874                     }
       
   875                 }
       
   876 
       
   877             // Codec parameter.    
       
   878             else if ( aParameter.Name().Compare( KParmVAD ) == 0 
       
   879                 && iSetCodec )
       
   880                 {
       
   881                 iCurrentCodec->iVAD = 1;
       
   882                 }
       
   883 
       
   884             // Codec parameter.    
       
   885             else if ( aParameter.Name().Compare( KParmANNEXB ) == 0 
       
   886                 && iSetCodec )
       
   887                 {
       
   888                 iCurrentCodec->iAnnexB = 1;
       
   889                 }
       
   890             // Codec parameter.
       
   891             else if ( aParameter.Name().Compare( KParmMAXRED ) == 0 
       
   892                 && iSetCodec )
       
   893                 {
       
   894                 if ( KErrNone == DescToInt( tmpValue, tIntParameterValue ) )
       
   895                     {
       
   896                     iCurrentCodec->iMaxRed = tIntParameterValue;
       
   897                     }
       
   898                 }
       
   899             break; // case 0:
       
   900             
       
   901         case EWPParameterProviderID: // APPLICATION/PROVIDER-ID
       
   902             iCurrentVoIPItem->SetProviderIdL( aParameter.Value() );
       
   903             break;
       
   904 
       
   905         case EWPParameterName: // APPLICATION/NAME
       
   906             iCurrentVoIPItem->SetNameL( aParameter.Value() );
       
   907             break;
       
   908 
       
   909         case EWPParameterToAppRef: // TO-APPREF
       
   910             {
       
   911             // APPLICATION/TO-APPREF
       
   912             if ( !iSetVoipUris )
       
   913                 {
       
   914                 iCurrentVoIPItem->AddToAppRefL( tmpValue->Des() );
       
   915                 }
       
   916             else
       
   917                 {
       
   918                 if ( iCurrentVoIPItem && 
       
   919                     iCurrentVoIPItem->VoipUrisToAppRef().Length() == 0 )
       
   920                     {
       
   921                     iCurrentVoIPItem->SetVoipUrisToAppRefL( tmpValue->Des() );
       
   922                     }
       
   923                 }// else if
       
   924             } //case
       
   925             break;
       
   926 
       
   927         // VOIPURIS/TO-NAPID
       
   928         case EWPParameterToNapID:
       
   929             {
       
   930             if ( iCurrentVoIPItem && iSetVoipUris 
       
   931                 && iCurrentVoIPItem->ToNapId().Length() == 0 )
       
   932                 {
       
   933                 iCurrentVoIPItem->SetToNapIdL( tmpValue->Des() );
       
   934                 }
       
   935             break;
       
   936             }
       
   937 
       
   938         default:
       
   939             break;
       
   940         }// switch
       
   941     CleanupStack::PopAndDestroy( tmpValue );
       
   942     DBG_PRINT( "CWVoIPAdapter::VisitL( parameter ) - end" );
       
   943     }
       
   944 
       
   945 // ---------------------------------------------------------------------------
       
   946 // CWPVoIPAdapter::VisitLinkL
       
   947 // ---------------------------------------------------------------------------
       
   948 //
       
   949 void CWPVoIPAdapter::VisitLinkL( CWPCharacteristic& aLink )
       
   950     {
       
   951     DBG_PRINT( "CWVoIPAdapter::VisitLinkL - begin" );
       
   952     switch( aLink.Type() )
       
   953         {
       
   954         case KWPNapDef:
       
   955             {            
       
   956             if ( !iCurrentVoIPItem->NapDef() )
       
   957                 {
       
   958                 iCurrentVoIPItem->SetNapDef( &aLink );
       
   959                 }
       
   960             break;
       
   961             }
       
   962         default:
       
   963             break;
       
   964         }
       
   965     DBG_PRINT( "CWVoIPAdapter::VisitLinkL - end" );
       
   966     }
       
   967 // ---------------------------------------------------------------------------
       
   968 // CWPVoIPAdapter::SettingsSavedL
       
   969 // ---------------------------------------------------------------------------
       
   970 //
       
   971 void CWPVoIPAdapter::SettingsSavedL ( const TDesC8& aAppIdOfSavingItem,
       
   972     const TDesC8& aAppRef, const TDesC8& aStorageIdValue )
       
   973     {
       
   974     DBG_PRINT( "CWVoIPAdapter::SettingsSavedL - begin" );
       
   975 
       
   976     if ( !aAppIdOfSavingItem.Length() || !aAppRef.Length() || 
       
   977         !aStorageIdValue.Length() )
       
   978         {
       
   979         DBG_PRINT( "CWVoIPAdapter::SettingsSavedL - end" );
       
   980         return;
       
   981         }
       
   982 
       
   983     HBufC8* tmpAppId = aAppIdOfSavingItem.AllocLC(); // CS:1
       
   984 
       
   985     TUint32 storageId( 0 );
       
   986     TLex8 lex( aStorageIdValue );
       
   987     User::LeaveIfError( lex.Val( storageId, EDecimal ) );
       
   988 
       
   989 
       
   990     const TInt itemCount = iDatas.Count();
       
   991 
       
   992     //lint -e{961} No need for else statement here
       
   993     if ( KErrNone == KSIPAppID8().CompareF( tmpAppId->Des() ) )
       
   994         {
       
   995         for ( TInt itemIndex = 0; itemIndex < itemCount; itemIndex++ )
       
   996             {
       
   997             TBool setOk = iDatas[itemIndex]->SetStorageId( CWPVoIPItem::ESIP,
       
   998                 storageId, aAppRef );
       
   999 
       
  1000             TBuf8<KTempStringlength> userAgentHeader;
       
  1001             iDatas[itemIndex]->GetUserAgentHeaderL( userAgentHeader );
       
  1002             // SIPProfileId must be bigger than 1 because otherwise
       
  1003             // cSIPManagedProfileRegistry->ProfileL will leave.
       
  1004             if ( setOk && storageId > 1 )
       
  1005                 {
       
  1006                 TUint32 itemId = iDatas[itemIndex]->ItemId();
       
  1007                 if ( TUint( KNotSaved ) != itemId )
       
  1008                     {
       
  1009                     // First update RCSE so that service will be created.
       
  1010                     DBG_PRINT( "CWVoIPAdapter::SettingsSavedL - update RCSE..." );
       
  1011                     CRCSEProfileRegistry* rcseReg = 
       
  1012                         CRCSEProfileRegistry::NewLC();
       
  1013                     CRCSEProfileEntry* rcseProf = CRCSEProfileEntry::NewLC();
       
  1014                     rcseReg->FindL( itemId, *rcseProf );
       
  1015                     TSettingIds referredIds;
       
  1016                     referredIds.iProfileType = 0; // SIP.
       
  1017                     referredIds.iProfileId = TInt( storageId );
       
  1018                     // Never reference to profile specific settings.
       
  1019                     referredIds.iProfileSpecificSettingId = KNotSet; 
       
  1020                     rcseProf->iIds.Append( referredIds );
       
  1021                     rcseReg->UpdateL( itemId, *rcseProf );
       
  1022                     CleanupStack::PopAndDestroy( 2, rcseReg );
       
  1023                     }
       
  1024                 
       
  1025 
       
  1026                 // Then set SIP user-agent header
       
  1027                 DBG_PRINT(
       
  1028                     "CWVoIPAdapter::SettingsSavedL - \
       
  1029                     create SIP User-Agent Header..." );
       
  1030                 CSIPProfileRegistryObserver* cSIPProfRegObserver = 
       
  1031                     CSIPProfileRegistryObserver::NewLC(); // CS:2
       
  1032                 CSIPManagedProfileRegistry* cSIPManagedProfileRegistry =
       
  1033                     CSIPManagedProfileRegistry::NewLC( 
       
  1034                         *cSIPProfRegObserver ); // CS:3
       
  1035                 CSIPProfile* cSIPProfile = NULL;
       
  1036                 cSIPProfile = cSIPManagedProfileRegistry->ProfileL( 
       
  1037                     storageId );
       
  1038                 CleanupStack::PushL( cSIPProfile ); // CS:4
       
  1039                 CSIPManagedProfile* cSIPManagedProfile = 
       
  1040                     static_cast<CSIPManagedProfile*>( cSIPProfile );
       
  1041                 CleanupStack::PushL( cSIPManagedProfile ); // CS:5
       
  1042                 // Create an array for setting the user agent header.
       
  1043                 // Granularity is 1 since only one item is appended into
       
  1044                 // the array.
       
  1045                 CDesC8ArrayFlat* uahArray = 
       
  1046                     new ( ELeave ) CDesC8ArrayFlat( 1 );
       
  1047                 CleanupStack::PushL( uahArray ); // CS:6
       
  1048                 uahArray->AppendL( userAgentHeader );
       
  1049                 if ( userAgentHeader.Length() > 0 )
       
  1050                     {
       
  1051                     User::LeaveIfError( cSIPManagedProfile->SetParameter( 
       
  1052                         KSIPHeaders, *uahArray ) );
       
  1053                     }
       
  1054                 
       
  1055                 cSIPManagedProfileRegistry->SaveL( *cSIPManagedProfile );
       
  1056                 uahArray->Reset();
       
  1057                 CleanupStack::PopAndDestroy( uahArray ); // CS:5
       
  1058                 CleanupStack::PopAndDestroy( cSIPManagedProfile ); // CS:4
       
  1059                 CleanupStack::Pop( cSIPProfile ); // CS:3
       
  1060                 cSIPProfile = NULL;
       
  1061                 CleanupStack::PopAndDestroy( 
       
  1062                     cSIPManagedProfileRegistry );// CS:2
       
  1063                 CleanupStack::PopAndDestroy( cSIPProfRegObserver );// CS:1
       
  1064                 DBG_PRINT(
       
  1065                     "CWVoIPAdapter::SettingsSavedL - \
       
  1066                     SIP User-Agent Header created and set." );
       
  1067                 } // if ( matches ... )
       
  1068             } // for
       
  1069         }
       
  1070 
       
  1071     else if ( KErrNone == KSCCPAppID8().CompareF( tmpAppId->Des() ) )
       
  1072         {
       
  1073         for ( TInt itemIndex = 0; itemIndex < iDatas.Count(); itemIndex++ )
       
  1074             {
       
  1075             iDatas[itemIndex]->SetStorageId( CWPVoIPItem::ESCCP, storageId, 
       
  1076                 aAppRef );
       
  1077             }
       
  1078         }
       
  1079 
       
  1080     else if ( KErrNone == KNATFWAppID8().CompareF( tmpAppId->Des() ) )
       
  1081         {
       
  1082         for ( TInt itemIndex = 0; itemIndex < iDatas.Count(); itemIndex++ )
       
  1083             {
       
  1084             iDatas[itemIndex]->SetStorageId( CWPVoIPItem::ENATFW, storageId,
       
  1085                 aAppRef );
       
  1086             }
       
  1087         }
       
  1088 
       
  1089     else if ( KErrNone == KPresenceAppId8().CompareF( tmpAppId->Des() ) )
       
  1090         {
       
  1091         for ( TInt itemIndex = 0; itemIndex < iDatas.Count(); itemIndex++ )
       
  1092             {
       
  1093             iDatas[itemIndex]->SetStorageId( CWPVoIPItem::EPresence, 
       
  1094                 storageId, aAppRef );
       
  1095             }
       
  1096         }
       
  1097 
       
  1098     else if ( KErrNone == KSNAPAppID8().CompareF( tmpAppId->Des() ) )
       
  1099         {
       
  1100         for ( TInt itemIndex = 0; itemIndex < iDatas.Count(); itemIndex++ )
       
  1101             {
       
  1102             iDatas[itemIndex]->SetStorageId( CWPVoIPItem::ESNAP, storageId, 
       
  1103                 aAppRef );
       
  1104             }
       
  1105         }
       
  1106 
       
  1107     CleanupStack::PopAndDestroy( tmpAppId ); // CS:0
       
  1108     DBG_PRINT( "CWVoIPAdapter::SettingsSavedL - end" );
       
  1109     }
       
  1110 
       
  1111 
       
  1112 // ---------------------------------------------------------------------------
       
  1113 // CWPVoIPAdapter::SavingFinalizedL()
       
  1114 // ---------------------------------------------------------------------------
       
  1115 //
       
  1116 void CWPVoIPAdapter::SavingFinalizedL()
       
  1117     {
       
  1118     DBG_PRINT( "CWVoIPAdapter::SavingFinalizedL - begin" );
       
  1119     // Prerequisites: All data received and is stored at least transiently in
       
  1120     // the data structures in VoIP items. Call SavingFinalized for everyone to
       
  1121     // make them update the APPREF/TO-APPREF linkage data.
       
  1122     for ( TInt itemIndex = 0; itemIndex < iDatas.Count(); itemIndex++ )
       
  1123         {
       
  1124         iDatas[itemIndex]->SavingFinalizedL();
       
  1125         }// for
       
  1126     DBG_PRINT( "CWVoIPAdapter::SavingFinalizedL - end" );
       
  1127     }
       
  1128 
       
  1129 // ---------------------------------------------------------------------------
       
  1130 // CWPVoIPAdapter::DescToInt()
       
  1131 // ---------------------------------------------------------------------------
       
  1132 //
       
  1133 TInt CWPVoIPAdapter::DescToInt( HBufC8* aDescValue, TInt& aIntValue ) const
       
  1134     {
       
  1135     TInt err( KErrNotFound );
       
  1136     if ( aDescValue )
       
  1137         {
       
  1138         TLex8 lex( aDescValue->Des() );
       
  1139         err = lex.Val( aIntValue );    
       
  1140         }    
       
  1141     return err;
       
  1142     }
       
  1143 
       
  1144 // ---------------------------------------------------------------------------
       
  1145 // CWPVoIPAdapter::IapIdFromWapIdL
       
  1146 // Returns IAP ID from WAP ID.
       
  1147 // ---------------------------------------------------------------------------
       
  1148 //
       
  1149 TUint32 CWPVoIPAdapter::IapIdFromWapIdL( TUint32 aWapId )
       
  1150     {
       
  1151     DBG_PRINT( "CWPVoIPAdapter::IapIdFromWapIdL - begin" );
       
  1152     RCmManagerExt cmManager;
       
  1153     cmManager.OpenLC(); // CS:1
       
  1154     RArray<TUint32> iapIds;
       
  1155     TUint32 iapId( 0 );
       
  1156 
       
  1157     // First get all free IAP ID's.
       
  1158     cmManager.ConnectionMethodL( iapIds );
       
  1159     CleanupClosePushL( iapIds ); // CS:2
       
  1160  
       
  1161     // Then get IAP ID's from all destinations.
       
  1162     RArray<TUint32> destIds;
       
  1163     cmManager.AllDestinationsL( destIds );
       
  1164     CleanupClosePushL( destIds ); // CS:3
       
  1165     
       
  1166     TInt destCount = destIds.Count();
       
  1167     
       
  1168     for ( TInt destIndex = 0; destIndex < destCount; destIndex++ )
       
  1169         {
       
  1170         RCmDestinationExt dest = cmManager.DestinationL( 
       
  1171             destIds[destIndex] );
       
  1172         CleanupClosePushL( dest ); // CS:4
       
  1173         TInt cmCount = dest.ConnectionMethodCount();
       
  1174         for ( TInt cmIndex = 0; cmIndex < cmCount; cmIndex++ )
       
  1175             {
       
  1176             TUint32 apId = dest.ConnectionMethodL( 
       
  1177                 cmIndex ).GetIntAttributeL( CMManager::ECmIapId );
       
  1178             iapIds.AppendL( apId );
       
  1179             }
       
  1180         CleanupStack::PopAndDestroy( &dest ); // CS:3
       
  1181         }
       
  1182     // Finally, go through all connection methods and find correct IAP ID.
       
  1183     const TInt cmCount = iapIds.Count();
       
  1184     for ( TInt counter = 0; counter < cmCount; counter++ )
       
  1185         {
       
  1186         TUint32 id = cmManager.GetConnectionMethodInfoIntL( 
       
  1187             iapIds[counter], CMManager::ECmWapId );
       
  1188 
       
  1189         if ( id == aWapId )
       
  1190             {
       
  1191             iapId = iapIds[counter];
       
  1192             // No need to go through rest of IAPs.
       
  1193             break;
       
  1194             }
       
  1195         }
       
  1196     
       
  1197     // PopAndDestroy destIds, iapIds, cmManager.
       
  1198     CleanupStack::PopAndDestroy( 3, &cmManager ); // CS:0
       
  1199 
       
  1200     DBG_PRINT( "CWPVoIPAdapter::IapIdFromWapIdL - end" );
       
  1201     return iapId;
       
  1202     }
       
  1203 
       
  1204 //  End of File