voipplugins/voipadapters/dmvoipadapter/src/nsmldmvoipadapter.cpp
changeset 0 a4daefaec16c
child 11 bddb6d4447db
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Device Management VoIP adapter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <f32file.h>
       
    21 #include <sysutil.h>
       
    22 #include <settingsinternalcrkeys.h>
       
    23 #include <centralrepository.h>
       
    24 #include <wlaninternalpskeys.h> // For GetWlanacAddress and GetWlanTypeL.
       
    25 #include <badesca.h> // For CDesC8ArrayFlat used in CompleteOutstandingCmdsL.
       
    26 #include <coemain.h> // For GetPhoneModelL.
       
    27 #include <crcseprofileregistry.h>
       
    28 #include <crcseprofileentry.h>
       
    29 #include <crcseaudiocodecregistry.h>
       
    30 #include <crcseaudiocodecentry.h>
       
    31 #include <utf.h>
       
    32 #include <sipmanagedprofile.h> // For SIP User Agent Header.
       
    33 #include <sipprofileregistryobserver.h> // For SIP User Agent Header.
       
    34 #include <sipmanagedprofileregistry.h> // For SIP User Agent Header.
       
    35 #include <spdefinitions.h> // For Service Provider Settings.
       
    36 #include <spsettings.h>    // For Service Provider Settings.
       
    37 #include <spentry.h>       // For Service Provider Settings.
       
    38 #include <spproperty.h>    // For Service Provider Settings.
       
    39 #include <featmgr.h>
       
    40 #include <nsmldmiapmatcher.h> // For fetching IAP.
       
    41 #include <pathinfo.h> // For getting phone rom root path.
       
    42 #include <cvimpstsettingsstore.h> // For IM tone path
       
    43 
       
    44 #include "nsmldmvoipadapter.h"
       
    45 #include "cdmvoipspsettings.h"
       
    46 #include "CSIPProfileRegistryObserver.h" // For SIP User Agent Header.
       
    47 #include "cipappphoneutils.h"            // For GetPhoneModelL, GetTerminalTypeL
       
    48 #include "cipapputilsaddressresolver.h"  // For GetWlanMacAddress
       
    49 #include "smldmvoipdebug.h"
       
    50 
       
    51 // CONSTANTS
       
    52 
       
    53 const TInt   KNSmlVoIPMaxUriLength     = 256;
       
    54 const TInt   KDefaultResultSize        = 64;
       
    55 const TInt   KNSmlVoIPMaxResultLength  = 256;
       
    56 const TInt   KNSmlDMFatMinimumFileSize = 512;
       
    57 const TUint  KTempStringlength = 200;
       
    58 _LIT8( KSpaceMark,         " " );
       
    59 _LIT8( KUserAgent,         "User-Agent" );
       
    60 _LIT8( KColonMark,         ":" );
       
    61 
       
    62 _LIT8( KNSmlDMVoIPDDFVersion,                "1.0" ); 
       
    63 _LIT8( KNSmlDMVoIPNodeName,                  "VoIP" );
       
    64 _LIT8( KNSmlDMVoIPPrefix,                    "VoIPId" );
       
    65 _LIT8( KNSmlDMVoIPDynamicNode,               "" );
       
    66 _LIT8( KNSmlDMVoIPSetID,                     "VoIPId" ); 
       
    67 _LIT8( KNSmlDMVoIPProvID,                    "ProviderName" ); 
       
    68 _LIT8( KNSmlDMVoIPName,                      "SettingsName" );
       
    69 _LIT8( KNSmlDMVoIPPreferredCodecsNode,       "PreferredCodecs" );
       
    70 
       
    71 // VoIP/x/CodecSettings
       
    72 _LIT8( KNSmlDMVoIPCodecSettingsNode,         "CodecSettings" );
       
    73 _LIT8( KNSmlDMVoIPCodecSettingsId,           "CodecSettingsId" );
       
    74 _LIT8( KNSmlDMVoIPCodecId,                   "VoIPCodecId" );
       
    75 _LIT8( KNSmlDMVoIPPreferredCodecId,          "PreferredCodecId" );
       
    76 _LIT8( KNSmlDMVoIPMediaTypeName,             "MediaTypeName" );
       
    77 _LIT8( KNSmlDMVoIPMediaSubTypeName,          "MediaSubTypeName" );
       
    78 _LIT8( KNSmlDMVoIPJitterBufferSize,          "JitterBufferSize" );
       
    79 _LIT8( KNSmlDMVoIPOctetAlign,                "OctetAlign" );
       
    80 _LIT8( KNSmlDMVoIPModeSetNode,               "ModeSet" );
       
    81 _LIT8( KNSmlDMVoIPMode,                      "Mode" );
       
    82 _LIT8( KNSmlDMVoIPModeId,                    "ModeId" );
       
    83 _LIT8( KNSmlDMVoIPModeChangePeriod,          "ModeChangePeriod" );
       
    84 _LIT8( KNSmlDMVoIPModeChangeNeighbor,        "ModeChangeNeighbor" );
       
    85 _LIT8( KNSmlDMVoIPPtime,                     "Ptime" );
       
    86 _LIT8( KNSmlDMVoIPMaxPtime,                  "MaxPtime" );
       
    87 _LIT8( KNSmlDMVoIPVAD,                       "VAD" ); 
       
    88 _LIT8( KNSmlDMVoIPAnnexB,                    "AnnexB" );
       
    89 _LIT8( KNSmlDMVoIPMaxRed,                    "MaxRed" );
       
    90 
       
    91 // VoIP/x/SettingIds node
       
    92 _LIT8( KNSmlDMVoIPSettingIdsNode,            "SettingIds" );
       
    93 _LIT8( KNSmlDMVoIPSettingId,                 "SettingId" );
       
    94 _LIT8( KNSmlDMVoIPProfileType,               "ProfileType" ); 
       
    95 _LIT8( KNSmlDMVoIPProfileId,                 "ProfileId" );
       
    96 _LIT8( KNSmlDMVoIPProfileSpecificId,         "ProfileSpecificId" );
       
    97 _LIT8( KNSmlDMVoIPProfileTypeSIP,            "SIP" );
       
    98 _LIT8( KNSmlDMVoIPProfileTypeSCCP,           "SCCP" );
       
    99 
       
   100 // VoIP/x/
       
   101 _LIT8( KNSmlDMVoIPSMPort,                    "StartMediaPort" );
       
   102 _LIT8( KNSmlDMVoIPEMPort,                    "EndMediaPort" );
       
   103 _LIT8( KNSmlDMVoIPMediaQos,                  "MediaQos" );
       
   104 _LIT8( KNSmlDMVoIPDTMFIB,                    "InbandDTMF" );
       
   105 _LIT8( KNSmlDMVoIPDTMFOB,                    "OutbandDTMF" );
       
   106 _LIT8( KNSmlDMVoIPSecureCallPref,            "SecureCallPref" );
       
   107 _LIT8( KNSmlDMVoIPRTCP,                      "RTCP" );
       
   108 _LIT8( KNSmlDMVoIPUAHTerminalType,           "UAHTerminalType" );
       
   109 _LIT8( KNSmlDMVoIPUAHWLANMAC,                "UAHWLANMAC" );
       
   110 _LIT8( KNSmlDMVoIPUAHString,                 "UAHString" );
       
   111 _LIT8( KNSmlDMVoIPProfileLockedToIAP,        "ProfileLockedToIAP" );
       
   112 _LIT8( KNSmlDMVoIPPluginUID,                 "VoIPPluginUID" );
       
   113 _LIT8( KNSmlDMVoIPAllowVoIPOverWCDMA,        "AllowVoIPOverWCDMA" );
       
   114 _LIT8( KNSmlDMVoIPVoIPDigits,                "VoIPDigits" );
       
   115 _LIT8( KNSmlDMVoIPURIDomainIgnoreRule,       "URIDomainIgnoreRule" );
       
   116 _LIT8( KNSmlDMVoIPAutoAcceptBuddyRequest,    "AutoAcceptBuddyRequest" );
       
   117 _LIT8( KNSmlDMVoIPUsedVoIPRelease,           "UsedVoIPRelease" );
       
   118 _LIT8( KNSmlDMVoIPAddUserPhone,              "AddUserPhone" );
       
   119 _LIT8( KNSmlDMVoIPProviderBookmarkUri,       "ProviderBookmarkURI" );
       
   120 _LIT8( KNSmlDMVoIPSIPConnTestUri,            "SIPConnectivityTestURI" );
       
   121 _LIT8( KNSmlDMVoIPNatFwProfileId,            "NATFWProfileId" );
       
   122 _LIT8( KNSmlDMVoIPMinSessionInterval,        "MinSessionInterval" );
       
   123 _LIT8( KNSmlDMVoIPSessionExpires,            "SessionExpires" );
       
   124 _LIT8( KNSmlDMVoIPBrandingDataUri,           "BradingDataURI" );
       
   125 _LIT8( KNSmlDMVoIPPresenceSettingsId,        "PresenceSettingsId" );
       
   126 _LIT8( KNSmlDMVoIPUsedNatProtocol,           "UsedNATProtocol" );
       
   127 _LIT8( KNSmlDMVoIPAutoEnable,                "AutoEnable" );
       
   128 _LIT8( KNSmlDMVoIPSnapProfileId,             "SNAPProfileId" );
       
   129 _LIT8( KNSmlDMVoIPEnableIm,                  "EnableIM" );
       
   130 
       
   131 // VoIP/x/VoiceMailBox
       
   132 _LIT8( KNSmlDMVoIPVmbxNode,                  "VoiceMailBox" );
       
   133 _LIT8( KNSmlDMVoIPMwiUri,                    "MWI-URI" );
       
   134 _LIT8( KNSmlDMVoIPListeningUri,              "ListeningURI" );
       
   135 _LIT8( KNSmlDMVoIPUsedIAPId,                 "UsedIAPId" );
       
   136 _LIT8( KNSmlDMVoIPReSubscribeInterval,       "ReSubscribeInterval" );
       
   137 _LIT8( KNSmlDMVoIPUsedSIPProfileId,          "UsedSIPProfileId" );
       
   138 
       
   139 // Explanations of parameters
       
   140 _LIT8( KNSmlDMVoIPNodeNameExp,               "The interior object holds all VoIP objects" );
       
   141 _LIT8( KNSmlDMVoIPDynamicNodeExp,            "Placeholder for settings ID's" );
       
   142 _LIT8( KNSmlDMVoIPSetIDExp,                  "Settings ID number" );
       
   143 _LIT8( KNSmlDMVoIPProvIDExp,                 "Provider ID" ); 
       
   144 _LIT8( KNSmlDMVoIPNameExp,                   "Name of the settings" );
       
   145 
       
   146 // CodecSettings
       
   147 _LIT8( KNSmlDMVoIPCodecOrderExp,             "Codec order" );
       
   148 _LIT8( KNSmlDMVoIPCodecSettingsNodeExp,      "CodecSettings" );
       
   149 _LIT8( KNSmlDMVoIPCodecSettingsIdExp,        "CodecSettingsID" );
       
   150 _LIT8( KNSmlDMVoIPMediaTypeNameExp,          "MediaTypeName" );
       
   151 _LIT8( KNSmlDMVoIPMediaSubTypeNameExp,       "MediaSubTypeName" );
       
   152 _LIT8( KNSmlDMVoIPJitterBufferSizeExp,       "JitterBufferSize" );
       
   153 _LIT8( KNSmlDMVoIPOctetAlignExp,             "OctetAlign" );
       
   154 _LIT8( KNSmlDMVoIPModeSetNodeExp,            "ModeSet" );
       
   155 _LIT8( KNSmlDMVoIPModeSetIdExp,              "Mode Id" );
       
   156 _LIT8( KNSmlDMVoIPModeChangePeriodExp,       "ModeChangePeriod" );
       
   157 _LIT8( KNSmlDMVoIPModeChangeNeighborExp,     "ModeChangeNeighbor" );
       
   158 _LIT8( KNSmlDMVoIPPtimeExp,                  "Ptime" );
       
   159 _LIT8( KNSmlDMVoIPMaxPtimeExp,               "MaxPtime" );
       
   160 _LIT8( KNSmlDMVoIPVADExp,                    "Voice activation detection" );
       
   161 _LIT8( KNSmlDMVoIPAnnexBExp,                 "AnnexB" );
       
   162 _LIT8( KNSmlDMVoIPMaxRedExp,                 "Max-red" );
       
   163 
       
   164 // VoIP/x/
       
   165 _LIT8( KNSmlDMVoIPSMPortExp,                 "Start media port" );
       
   166 _LIT8( KNSmlDMVoIPEMPortExp,                 "End media port" );
       
   167 _LIT8( KNSmlDMVoIPMediaQosExp,               "Media QOS" );
       
   168 _LIT8( KNSmlDMVoIPDTMFIBExp,                 "DTMF in-band" );
       
   169 _LIT8( KNSmlDMVoIPDTMFOBExp,                 "DTMF out-band" );
       
   170 _LIT8( KNSmlDMVoIPSecureCallPrefExp,         "Secure call preference");
       
   171 _LIT8( KNSmlDMVoIPRTCPExp,                   "Real-Time Control Protocol reporting" );
       
   172 _LIT8( KNSmlDMVoIPUAHTerminalTypeExp,        "SIP VoIP User Agent header: terminal type display" );
       
   173 _LIT8( KNSmlDMVoIPUAHWLANMACExp,             "SIP VoIP User Agent header: WLAN MAC address display " );
       
   174 _LIT8( KNSmlDMVoIPUAHStringExp,              "SIP VoIP User Agent header: free string" );
       
   175 _LIT8( KNSmlDMVoIPProfileLockedToIAPExp,     "Profile locked to IAP" );
       
   176 _LIT8( KNSmlDMVoIPPluginUIDExp,              "VoIP plugin UID" );
       
   177 _LIT8( KNSmlDMVoIPAllowVoIPOverWCDMAExp,     "Allow VoIP over WCDMA" );
       
   178 _LIT8( KNSmlDMVoIPVoIPDigitsExp,             "Number of meaningful VoIP digits" );
       
   179 _LIT8( KNSmlDMVoIPURIDomainIgnoreRuleExp,    "Domain part of URI ignore rule" );
       
   180 _LIT8( KNSmlDMVoIPAutoAcceptBuddyRequestExp, "Auto-accept buddy request" );
       
   181 _LIT8( KNSmlDMVoIPUsedVoIPReleaseExp,        "Used VoIP release" );
       
   182 _LIT8( KNSmlDMVoIPAddUserPhoneExp,           "Add user=phone to all numbers" );
       
   183 _LIT8( KNSmlDMVoIPProviderBookmarkUriExp,    "Provider bookmark URI" );
       
   184 _LIT8( KNSmlDMVoIPSIPConnTestUriExp,         "SIP connectivity test URI" );
       
   185 _LIT8( KNSmlDMVoIPNatFwProfileIdExp,         "NATFW profile ID" );
       
   186 _LIT8( KNSmlDMVoIPMinSessionIntervalExp,     "Minimum value for session interval" );
       
   187 _LIT8( KNSmlDMVoIPSessionExpiresExp,         "Session interval for SIP session" );
       
   188 _LIT8( KNSmlDMVoIPBrandingDataUriExp,        "Brading data URI" );
       
   189 _LIT8( KNSmlDMVoIPPresenceSettingsIdExp,     "Presence settings ID" );
       
   190 _LIT8( KNSmlDMVoIPUsedNatProtocolExp,        "Used NAT Protocol" );
       
   191 _LIT8( KNSmlDMVoIPAutoEnableExp,             "Auto enable the service" );
       
   192 _LIT8( KNSmlDMVoIPSnapProfileIdExp,          "SNAP profile ID" );
       
   193 _LIT8( KNSmlDMVoIPEnableImExp,               "Enable IM" );
       
   194 
       
   195 // VoIP/x/VoiceMailBox
       
   196 _LIT8( KNSmlDMVoIPVmbxNodeExp,               "VoiceMailBox node" );
       
   197 _LIT8( KNSmlDMVoIPMwiUriExp,                 "MWI-URI" );
       
   198 _LIT8( KNSmlDMVoIPListeningUriExp,           "Listening-URI" );
       
   199 _LIT8( KNSmlDMVoIPUsedIAPIdExp,              "Used IAP ID" );
       
   200 _LIT8( KNSmlDMVoIPReSubscribeIntervalExp,    "Re-rubscribe interval" );
       
   201 _LIT8( KNSmlDMVoIPUsedSIPProfileIdExp,       "Used SIP profile ID" );
       
   202 
       
   203 // VoIP/x/SettingIds node
       
   204 _LIT8( KNSmlDMVoIPProfileTypeExp,            "ProfileType" ); 
       
   205 _LIT8( KNSmlDMVoIPProfileIdExp,              "ProfileId" );
       
   206 _LIT8( KNSmlDMVoIPProfileSpecificExp,        "ProfileSpecificId" );
       
   207 
       
   208 // Other
       
   209 _LIT8( KNSmlDMVoIPValueTrue,                 "True" );
       
   210 _LIT8( KNSmlDMVoIPValueFalse,                "False" );
       
   211 _LIT8( KNSmlDMVoIPValueNotSet,               "NotSet" );
       
   212 _LIT8( KNSmlDefDMSIP,                        "SIP" );
       
   213 _LIT8( KNSmlDefDMSCCP,                       "SCCP/SCCPAcc" );
       
   214 _LIT8( KNSmlDMVoIPTextPlain,                 "text/plain" );
       
   215 _LIT8( KNSmlDMVoIPSeparator,                 "/" );
       
   216 _LIT8( KNSmlVoIPUriDotSlash,                 "./");
       
   217 _LIT( KOpenParenthesis,                      "(" );
       
   218 _LIT( KClosedParenthesis,                    ")" );
       
   219 _LIT8( KDefaultSettingsName,                 "DMAdapterIns" );
       
   220 _LIT8( KNSmlDMSIPSipID,                      "SIPId" );
       
   221 _LIT8( KNSmlDMSCCPSccpID,                    "SCCPId" );
       
   222 _LIT8( KNSmlDMNATFWDomain,                   "NATFW/DomainSpecific" );
       
   223 _LIT8( KNSmlDMPresence,                      "OMA_PRESENCE" );
       
   224 _LIT8( KNSmlDMSnapUriPrefix,                 "BearerManagementSNAP" );
       
   225 const TInt KSixSegs   = 6;
       
   226 const TInt KFiveSegs  = 5;
       
   227 const TInt KFourSegs  = 4;
       
   228 const TInt KThreeSegs = 3;
       
   229 const TInt KTwoSegs   = 2;
       
   230 
       
   231 const TUint8 KDMVoIPSeparator = '/';
       
   232 
       
   233 // VoiceMailBox related constants.
       
   234 const TInt KDefaultReSubscribe = 600;
       
   235 // IM related constants.
       
   236 const TUint32 KIMSubServicePluginId = 0x1027545A; // KSIPConnectivityPluginImplUid
       
   237 const TUint32 KIMLaunchUid          = 0x200255D0;
       
   238 const TInt    KIMSettingsId         = 1;
       
   239 // Default IM message tone
       
   240 _LIT( KDefaultTone,       "Message 2.aac" );
       
   241 
       
   242 // ---------------------------------------------------------------------------
       
   243 // CNSmlDmVoIPAdapter::ConstructL
       
   244 // Symbian 2nd phase constructor can leave.
       
   245 // ---------------------------------------------------------------------------
       
   246 //
       
   247 void CNSmlDmVoIPAdapter::ConstructL()
       
   248     {
       
   249     DBG_PRINT( "CNSmlDmVoIPAdapter::ConstructL(): begin" );
       
   250     // Check VoIP support from feature manager
       
   251     FeatureManager::InitializeLibL();
       
   252     TBool support = FeatureManager::FeatureSupported( KFeatureIdCommonVoip );
       
   253     FeatureManager::UnInitializeLib();
       
   254 
       
   255     if ( !support )
       
   256         {
       
   257         DBG_PRINT( "CNSmlDmVoIPAdapter::ConstructL(): no support" );        
       
   258         User::Leave( KErrNotSupported );
       
   259         }
       
   260     DBG_PRINT( "CNSmlDmVoIPAdapter::ConstructL(): end" );
       
   261     }
       
   262 
       
   263 // ---------------------------------------------------------------------------
       
   264 // CNSmlDmVoIPAdapter* CNSmlDmVoIPAdapter::NewL
       
   265 // Two-phased constructor.
       
   266 // ---------------------------------------------------------------------------
       
   267 //
       
   268 CNSmlDmVoIPAdapter* CNSmlDmVoIPAdapter::NewL(
       
   269     MSmlDmCallback* aDmCallback )
       
   270     {
       
   271     DBG_PRINT("CNSmlDmVoIPAdapter::NewL(): begin");
       
   272     CNSmlDmVoIPAdapter* self = new (ELeave) CNSmlDmVoIPAdapter( aDmCallback );
       
   273     self->ConstructL();
       
   274     self->iDmCallback = aDmCallback;
       
   275     DBG_PRINT("CNSmlDmVoIPAdapter::NewL(): end");
       
   276     return self;
       
   277     }
       
   278 
       
   279 // ---------------------------------------------------------------------------
       
   280 // CNSmlDmVoIPAdapter::~CNSmlDmVoIPAdapter
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 CNSmlDmVoIPAdapter::~CNSmlDmVoIPAdapter()
       
   284     {
       
   285     DBG_PRINT("CNSmlDmVoIPAdapter::~CNSmlDmVoIPAdapter(): begin");
       
   286 
       
   287     iCodecEntries.ResetAndDestroy();
       
   288     iCodecEntries.Close();
       
   289 
       
   290     iProfileEntries.ResetAndDestroy();
       
   291     iProfileEntries.Close();
       
   292 
       
   293     if ( iCRCSEAudioCodec )
       
   294         {
       
   295         delete iCRCSEAudioCodec;
       
   296         }
       
   297 
       
   298     if ( iCRCSEProfile )
       
   299         {
       
   300         delete iCRCSEProfile; 
       
   301         }
       
   302 
       
   303     iProfileModifs.Close();
       
   304     iCodecModifs.Close();
       
   305 
       
   306     iSPSettings.ResetAndDestroy();
       
   307     iSPSettings.Close();
       
   308 
       
   309     DBG_PRINT("CNSmlDmVoIPAdapter::~CNSmlDmVoIPAdapter(): end");
       
   310     }
       
   311 
       
   312 // ---------------------------------------------------------------------------
       
   313 // CNSmlDmVoIPAdapter::LoadProfilesL
       
   314 // ---------------------------------------------------------------------------
       
   315 //
       
   316 void CNSmlDmVoIPAdapter::LoadProfilesL()
       
   317     {
       
   318     DBG_PRINT("CNSmlDmVoIPAdapter::LoadProfilesL(): begin");
       
   319 
       
   320     if ( !iCRCSEProfile )
       
   321         {
       
   322         iCRCSEProfile = CRCSEProfileRegistry::NewL();
       
   323         }
       
   324 
       
   325     if ( !iCRCSEAudioCodec )
       
   326         {
       
   327         iCRCSEAudioCodec = CRCSEAudioCodecRegistry::NewL();
       
   328         }
       
   329 
       
   330     // Load profiles to pointerarray
       
   331     RArray<TUint32> allIds;
       
   332     iCRCSEProfile->GetAllIdsL( allIds ); 
       
   333     TInt idCount = allIds.Count();
       
   334     for ( TInt counter = 0; counter < idCount; counter++ )
       
   335         {
       
   336         CRCSEProfileEntry* profile = CRCSEProfileEntry::NewLC();
       
   337         iCRCSEProfile->FindL( allIds[counter], *profile );
       
   338         // Ownership change to iProfileEntries:
       
   339         iProfileEntries.AppendL( profile );
       
   340         CleanupStack::Pop( profile );
       
   341         }
       
   342 
       
   343     allIds.Reset();
       
   344 
       
   345     // Load audio codecs information to pointerarray
       
   346     iCRCSEAudioCodec->GetAllCodecIdsL( allIds );
       
   347     idCount = allIds.Count();
       
   348     for ( TInt counter = 0; counter < idCount; counter++ )
       
   349         {
       
   350         CRCSEAudioCodecEntry* codec = CRCSEAudioCodecEntry::NewLC();
       
   351         iCRCSEAudioCodec->FindL( allIds[counter], *codec );
       
   352         // Ownership change to iCodecEntries:
       
   353         iCodecEntries.AppendL( codec );
       
   354         CleanupStack::Pop( codec );
       
   355         }
       
   356     allIds.Close();
       
   357     DBG_PRINT("CNSmlDmVoIPAdapter::LoadProfilesL(): end");
       
   358     }
       
   359 
       
   360 // ---------------------------------------------------------------------------
       
   361 // CNSmlDmVoIPAdapter::CNSmlDmVoIPAdapter
       
   362 // C++ default constructor can NOT contain any code, that
       
   363 // might leave.
       
   364 // ---------------------------------------------------------------------------
       
   365 //
       
   366 CNSmlDmVoIPAdapter::CNSmlDmVoIPAdapter( TAny* aEcomArguments ):
       
   367     CSmlDmAdapter( aEcomArguments )
       
   368     {
       
   369     DBG_PRINT("CNSmlDmVoIPAdapter::CNSmlDmVoIPAdapter(aEcomArguments): begin");
       
   370     DBG_PRINT("CNSmlDmVoIPAdapter::CNSmlDmVoIPAdapter(aEcomArguments): end");   
       
   371     }
       
   372 
       
   373 // ---------------------------------------------------------------------------
       
   374 // CNSmlDmVoIPAdapter::DDFVersionL
       
   375 // Inserts DDF version of the adapter to aDDFVersion
       
   376 // ---------------------------------------------------------------------------
       
   377 //
       
   378 void CNSmlDmVoIPAdapter::DDFVersionL( CBufBase& aDDFVersion )
       
   379     {
       
   380     DBG_PRINT("CNSmlDmVoIPAdapter::DDFVersionL(TDes& aDDFVersion): begin");
       
   381     aDDFVersion.InsertL( 0, KNSmlDMVoIPDDFVersion );
       
   382     DBG_PRINT("CNSmlDmVoIPAdapter::DDFVersionL(TDes& aDDFVersion): end");
       
   383     }
       
   384 
       
   385 // ---------------------------------------------------------------------------
       
   386 // CNSmlDmVoIPAdapter::DDFStructureL
       
   387 // Builds the DDF structure of adapter
       
   388 // ---------------------------------------------------------------------------
       
   389 //
       
   390 void CNSmlDmVoIPAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
       
   391     {
       
   392     DBG_PRINT("CNSmlDmVoIPAdapter::DDFStructureL(): begin");
       
   393 
       
   394     TSmlDmAccessTypes accessTypesGet;
       
   395     accessTypesGet.SetGet();
       
   396 
       
   397     TSmlDmAccessTypes accessTypesGetAdd;
       
   398     accessTypesGetAdd.SetGet();
       
   399     accessTypesGetAdd.SetAdd();
       
   400 
       
   401     TSmlDmAccessTypes accessTypesGetReplaceAdd;
       
   402     accessTypesGetReplaceAdd.SetGet();
       
   403     accessTypesGetReplaceAdd.SetReplace();
       
   404     accessTypesGetReplaceAdd.SetAdd();
       
   405 
       
   406     TSmlDmAccessTypes accessTypesAll;
       
   407     accessTypesAll.SetGet();
       
   408     accessTypesAll.SetDelete();
       
   409     accessTypesAll.SetAdd();
       
   410     accessTypesAll.SetReplace();
       
   411 
       
   412     // VoIP
       
   413     MSmlDmDDFObject& voip = aDDF.AddChildObjectL( KNSmlDMVoIPNodeName );
       
   414     voip.SetAccessTypesL( accessTypesGetAdd );
       
   415     voip.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   416     voip.SetScopeL( MSmlDmDDFObject::EPermanent );
       
   417     voip.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   418     voip.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   419     voip.SetDescriptionL( KNSmlDMVoIPNodeNameExp );
       
   420 
       
   421     // dynamic settings ID node
       
   422     MSmlDmDDFObject& idNode = voip.AddChildObjectGroupL();
       
   423     idNode.SetAccessTypesL( accessTypesAll );
       
   424     idNode.SetOccurenceL( MSmlDmDDFObject::EZeroOrMore );
       
   425     idNode.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   426     idNode.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   427     idNode.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   428     idNode.SetDescriptionL( KNSmlDMVoIPDynamicNode );
       
   429 
       
   430     // VoIPId
       
   431     MSmlDmDDFObject& setID = idNode.AddChildObjectL( 
       
   432         KNSmlDMVoIPSetID );
       
   433     setID.SetAccessTypesL( accessTypesGet );
       
   434     setID.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   435     setID.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   436     setID.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   437     setID.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   438     setID.SetDescriptionL( KNSmlDMVoIPSetIDExp );
       
   439 
       
   440     // ProviderName
       
   441     MSmlDmDDFObject& provID = idNode.AddChildObjectL( 
       
   442         KNSmlDMVoIPProvID );
       
   443     provID.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   444     provID.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   445     provID.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   446     provID.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   447     provID.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   448     provID.SetDescriptionL( KNSmlDMVoIPProvIDExp );
       
   449 
       
   450     // SettingsName
       
   451     MSmlDmDDFObject& name = idNode.AddChildObjectL( 
       
   452         KNSmlDMVoIPName );
       
   453     name.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   454     name.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   455     name.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   456     name.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   457     name.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   458     name.SetDescriptionL( KNSmlDMVoIPNameExp );
       
   459 
       
   460     // PreferredCodecs node
       
   461     MSmlDmDDFObject& codecOrder = idNode.AddChildObjectL( 
       
   462         KNSmlDMVoIPPreferredCodecsNode );
       
   463     codecOrder.SetAccessTypesL( accessTypesGet );
       
   464     codecOrder.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   465     codecOrder.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   466     codecOrder.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   467     codecOrder.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   468     codecOrder.SetDescriptionL( KNSmlDMVoIPCodecOrderExp );
       
   469 
       
   470     // PreferredCodecs dynamic
       
   471     MSmlDmDDFObject& codecDyn = codecOrder.AddChildObjectGroupL();
       
   472     codecDyn.SetAccessTypesL( accessTypesGet );
       
   473     codecDyn.SetOccurenceL( MSmlDmDDFObject::EZeroOrMore );
       
   474     codecDyn.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   475     codecDyn.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   476     codecDyn.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   477     codecDyn.SetDescriptionL( KNSmlDMVoIPCodecOrderExp );
       
   478 
       
   479     // PreferredCodecs/PreferredCodecId
       
   480     MSmlDmDDFObject& preferredCodecID = codecDyn.AddChildObjectL( 
       
   481         KNSmlDMVoIPPreferredCodecId );
       
   482     preferredCodecID.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   483     preferredCodecID.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   484     preferredCodecID.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   485     preferredCodecID.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   486     preferredCodecID.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   487     preferredCodecID.SetDescriptionL( KNSmlDMVoIPCodecSettingsIdExp );
       
   488 
       
   489     // CodecSettings node
       
   490     MSmlDmDDFObject& codecNode = idNode.AddChildObjectL( 
       
   491         KNSmlDMVoIPCodecSettingsNode );
       
   492     codecNode.SetAccessTypesL( accessTypesGetAdd );
       
   493     codecNode.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   494     codecNode.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   495     codecNode.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   496     codecNode.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   497     codecNode.SetDescriptionL( KNSmlDMVoIPCodecSettingsNodeExp );
       
   498 
       
   499     // CodecSettings dynamic
       
   500     MSmlDmDDFObject& codecSetDyn = codecNode.AddChildObjectGroupL();
       
   501     codecSetDyn.SetAccessTypesL( accessTypesAll );
       
   502     codecSetDyn.SetOccurenceL( MSmlDmDDFObject::EZeroOrMore );
       
   503     codecSetDyn.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   504     codecSetDyn.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   505     codecSetDyn.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   506     codecSetDyn.SetDescriptionL( KNSmlDMVoIPDynamicNodeExp );
       
   507 
       
   508     // CodecSettings/VoIPCodecId
       
   509     MSmlDmDDFObject& codecsetID = codecSetDyn.AddChildObjectL( 
       
   510         KNSmlDMVoIPCodecId );
       
   511     codecsetID.SetAccessTypesL( accessTypesGet );
       
   512     codecsetID.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   513     codecsetID.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   514     codecsetID.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   515     codecsetID.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   516     codecsetID.SetDescriptionL( KNSmlDMVoIPCodecSettingsIdExp );
       
   517 
       
   518     // CodecSettings/MediaTypeName
       
   519     MSmlDmDDFObject& mediaTypeName = codecSetDyn.AddChildObjectL( 
       
   520         KNSmlDMVoIPMediaTypeName );
       
   521     mediaTypeName.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   522     mediaTypeName.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   523     mediaTypeName.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   524     mediaTypeName.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   525     mediaTypeName.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   526     mediaTypeName.SetDescriptionL( KNSmlDMVoIPMediaTypeNameExp );
       
   527 
       
   528     // CodecSettings/MediaSubTypeName
       
   529     MSmlDmDDFObject& mediaSubTypeName = codecSetDyn.AddChildObjectL( 
       
   530         KNSmlDMVoIPMediaSubTypeName );
       
   531     mediaSubTypeName.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   532     mediaSubTypeName.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   533     mediaSubTypeName.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   534     mediaSubTypeName.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   535     mediaSubTypeName.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   536     mediaSubTypeName.SetDescriptionL( KNSmlDMVoIPMediaSubTypeNameExp );
       
   537 
       
   538      // CodecSettings/JitterBufferSize
       
   539     MSmlDmDDFObject& jitterBufferSize = codecSetDyn.AddChildObjectL( 
       
   540         KNSmlDMVoIPJitterBufferSize );
       
   541     jitterBufferSize.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   542     jitterBufferSize.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   543     jitterBufferSize.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   544     jitterBufferSize.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   545     jitterBufferSize.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   546     jitterBufferSize.SetDescriptionL( KNSmlDMVoIPJitterBufferSizeExp );
       
   547 
       
   548      // CodecSettings/OctetAlign
       
   549     MSmlDmDDFObject& octetAlign = codecSetDyn.AddChildObjectL( 
       
   550         KNSmlDMVoIPOctetAlign );
       
   551     octetAlign.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   552     octetAlign.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   553     octetAlign.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   554     octetAlign.SetDFFormatL( MSmlDmDDFObject::EBool );
       
   555     octetAlign.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   556     octetAlign.SetDescriptionL( KNSmlDMVoIPOctetAlignExp );
       
   557 
       
   558     // CodecSettings/ModeSet node
       
   559     MSmlDmDDFObject& modeSetNode = codecSetDyn.AddChildObjectL( 
       
   560         KNSmlDMVoIPModeSetNode );
       
   561     modeSetNode.SetAccessTypesL( accessTypesGetAdd );
       
   562     modeSetNode.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   563     modeSetNode.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   564     modeSetNode.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   565     modeSetNode.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   566     modeSetNode.SetDescriptionL( KNSmlDMVoIPModeSetNodeExp );
       
   567 
       
   568     // ModeSet dynamic
       
   569     MSmlDmDDFObject& modeSetDyn = modeSetNode.AddChildObjectGroupL();
       
   570     modeSetDyn.SetAccessTypesL( accessTypesAll );
       
   571     modeSetDyn.SetOccurenceL( MSmlDmDDFObject::EZeroOrMore );
       
   572     modeSetDyn.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   573     modeSetDyn.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   574     modeSetDyn.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   575     modeSetDyn.SetDescriptionL( KNSmlDMVoIPModeSetIdExp );
       
   576 
       
   577      // ModeSet/x/Mode
       
   578     MSmlDmDDFObject& modeSetId = modeSetDyn.AddChildObjectL( 
       
   579         KNSmlDMVoIPMode );
       
   580     modeSetId.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   581     modeSetId.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   582     modeSetId.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   583     modeSetId.SetDFFormatL( MSmlDmDDFObject::EInt );  // int
       
   584     modeSetId.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   585     modeSetId.SetDescriptionL( KNSmlDMVoIPModeChangePeriodExp );
       
   586 
       
   587      // CodecSettings/ModeChangePeriod
       
   588     MSmlDmDDFObject& modeChangePer = codecSetDyn.AddChildObjectL( 
       
   589         KNSmlDMVoIPModeChangePeriod );
       
   590     modeChangePer.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   591     modeChangePer.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   592     modeChangePer.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   593     modeChangePer.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   594     modeChangePer.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   595     modeChangePer.SetDescriptionL( KNSmlDMVoIPModeChangePeriodExp );
       
   596 
       
   597      // CodecSettings/ModeChangeNeighbor
       
   598     MSmlDmDDFObject& modeChange = codecSetDyn.AddChildObjectL( 
       
   599         KNSmlDMVoIPModeChangeNeighbor );
       
   600     modeChange.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   601     modeChange.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   602     modeChange.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   603     modeChange.SetDFFormatL( MSmlDmDDFObject::EBool );
       
   604     modeChange.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   605     modeChange.SetDescriptionL( KNSmlDMVoIPModeChangeNeighborExp );
       
   606 
       
   607      // CodecSettings/Ptime
       
   608     MSmlDmDDFObject& ptime = codecSetDyn.AddChildObjectL( 
       
   609         KNSmlDMVoIPPtime );
       
   610     ptime.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   611     ptime.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   612     ptime.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   613     ptime.SetDFFormatL( MSmlDmDDFObject::EInt );  // int
       
   614     ptime.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   615     ptime.SetDescriptionL( KNSmlDMVoIPPtimeExp );
       
   616 
       
   617      // CodecSettings/MaxPtime
       
   618     MSmlDmDDFObject& maxptime = codecSetDyn.AddChildObjectL( 
       
   619         KNSmlDMVoIPMaxPtime );
       
   620     maxptime.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   621     maxptime.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   622     maxptime.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   623     maxptime.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   624     maxptime.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   625     maxptime.SetDescriptionL( KNSmlDMVoIPMaxPtimeExp );
       
   626 
       
   627      // CodecSettings/VAD
       
   628     MSmlDmDDFObject& vad = codecSetDyn.AddChildObjectL( 
       
   629         KNSmlDMVoIPVAD );
       
   630     vad.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   631     vad.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   632     vad.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   633     vad.SetDFFormatL( MSmlDmDDFObject::EBool ); // bool
       
   634     vad.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   635     vad.SetDescriptionL( KNSmlDMVoIPVADExp );
       
   636 
       
   637     // CodecSettings/AnnexB
       
   638     MSmlDmDDFObject& annexB = codecSetDyn.AddChildObjectL( 
       
   639         KNSmlDMVoIPAnnexB );
       
   640     annexB.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   641     annexB.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   642     annexB.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   643     annexB.SetDFFormatL( MSmlDmDDFObject::EBool );  // bool
       
   644     annexB.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   645     annexB.SetDescriptionL( KNSmlDMVoIPAnnexBExp ); 
       
   646 
       
   647     // CodecSettings/MaxRed
       
   648     MSmlDmDDFObject& maxRed = codecSetDyn.AddChildObjectL(
       
   649         KNSmlDMVoIPMaxRed );
       
   650     maxRed.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   651     maxRed.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   652     maxRed.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   653     maxRed.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   654     maxRed.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   655     maxRed.SetDescriptionL( KNSmlDMVoIPMaxRedExp );
       
   656 
       
   657     // SettingsIds node
       
   658     MSmlDmDDFObject& settingIds = idNode.AddChildObjectL( 
       
   659         KNSmlDMVoIPSettingIdsNode );
       
   660     settingIds.SetAccessTypesL( accessTypesGetAdd );
       
   661     settingIds.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   662     settingIds.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   663     settingIds.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   664     settingIds.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   665     settingIds.SetDescriptionL( KNSmlDMVoIPDynamicNode );
       
   666 
       
   667     // settingsIds dynamic
       
   668     MSmlDmDDFObject& settingIdsDynID = settingIds.AddChildObjectGroupL();
       
   669     settingIdsDynID.SetAccessTypesL( accessTypesAll );
       
   670     settingIdsDynID.SetOccurenceL( MSmlDmDDFObject::EZeroOrMore );
       
   671     settingIdsDynID.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   672     settingIdsDynID.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   673     settingIdsDynID.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   674     settingIdsDynID.SetDescriptionL( KNSmlDMVoIPDynamicNodeExp );
       
   675 
       
   676     // SettingIds/ProfileType
       
   677     MSmlDmDDFObject& profileType = settingIdsDynID.AddChildObjectL( 
       
   678         KNSmlDMVoIPProfileType );
       
   679     profileType.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   680     profileType.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   681     profileType.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   682     profileType.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   683     profileType.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   684     profileType.SetDescriptionL( KNSmlDMVoIPProfileTypeExp ); 
       
   685 
       
   686     // SettingIds/ProfileId
       
   687     MSmlDmDDFObject& profileId = settingIdsDynID.AddChildObjectL( 
       
   688         KNSmlDMVoIPProfileId );
       
   689     profileId.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   690     profileId.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   691     profileId.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   692     profileId.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   693     profileId.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   694     profileId.SetDescriptionL( KNSmlDMVoIPProfileIdExp );
       
   695 
       
   696     // SettingIds/ProfileSpecificId
       
   697     MSmlDmDDFObject& profileSpecific = settingIdsDynID.AddChildObjectL( 
       
   698         KNSmlDMVoIPProfileSpecificId );
       
   699     profileSpecific.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   700     profileSpecific.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   701     profileSpecific.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   702     profileSpecific.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   703     profileSpecific.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   704     profileSpecific.SetDescriptionL( KNSmlDMVoIPProfileSpecificExp );
       
   705 
       
   706     // VoIP/<x>/VoiceMailBox
       
   707     MSmlDmDDFObject& vmbx = idNode.AddChildObjectL( 
       
   708         KNSmlDMVoIPVmbxNode );
       
   709     vmbx.SetAccessTypesL( accessTypesGetAdd );
       
   710     vmbx.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   711     vmbx.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   712     vmbx.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   713     vmbx.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   714     vmbx.SetDescriptionL( KNSmlDMVoIPVmbxNodeExp );
       
   715 
       
   716     // VoIP/<x>/VoiceMailBox/MWI-URI
       
   717     MSmlDmDDFObject& mwiUri = vmbx.AddChildObjectL( 
       
   718         KNSmlDMVoIPMwiUri );
       
   719     mwiUri.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   720     mwiUri.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   721     mwiUri.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   722     mwiUri.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   723     mwiUri.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   724     mwiUri.SetDescriptionL( KNSmlDMVoIPMwiUriExp );
       
   725 
       
   726     // VoIP/<x>/VoiceMailBox/ListeningURI
       
   727     MSmlDmDDFObject& listenUri = vmbx.AddChildObjectL( 
       
   728         KNSmlDMVoIPListeningUri );
       
   729     listenUri.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   730     listenUri.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   731     listenUri.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   732     listenUri.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   733     listenUri.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   734     listenUri.SetDescriptionL( KNSmlDMVoIPListeningUriExp );
       
   735 
       
   736     // VoIP/<x>/VoiceMailBox/UsedIAPId
       
   737     MSmlDmDDFObject& usedIapId = vmbx.AddChildObjectL( 
       
   738         KNSmlDMVoIPUsedIAPId );
       
   739     usedIapId.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   740     usedIapId.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   741     usedIapId.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   742     usedIapId.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   743     usedIapId.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   744     usedIapId.SetDescriptionL( KNSmlDMVoIPUsedIAPIdExp );
       
   745 
       
   746     // VoIP/<x>/VoiceMailBox/ReSubscribeInterval
       
   747     MSmlDmDDFObject& reSubscribe = vmbx.AddChildObjectL( 
       
   748         KNSmlDMVoIPReSubscribeInterval );
       
   749     reSubscribe.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   750     reSubscribe.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   751     reSubscribe.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   752     reSubscribe.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   753     reSubscribe.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   754     reSubscribe.SetDescriptionL( KNSmlDMVoIPReSubscribeIntervalExp );
       
   755 
       
   756     // VoIP/<x>/VoiceMailBox/UsedSIPProfileId
       
   757     MSmlDmDDFObject& sipId = vmbx.AddChildObjectL( 
       
   758         KNSmlDMVoIPUsedSIPProfileId );
       
   759     sipId.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   760     sipId.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   761     sipId.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   762     sipId.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   763     sipId.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   764     sipId.SetDescriptionL( KNSmlDMVoIPUsedSIPProfileIdExp );
       
   765 
       
   766     // StartMediaPort
       
   767     MSmlDmDDFObject& smport = idNode.AddChildObjectL( 
       
   768         KNSmlDMVoIPSMPort );
       
   769     smport.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   770     smport.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   771     smport.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   772     smport.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   773     smport.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   774     smport.SetDescriptionL( KNSmlDMVoIPSMPortExp );
       
   775 
       
   776     // EndMediaPort
       
   777     MSmlDmDDFObject& emport = idNode.AddChildObjectL( 
       
   778         KNSmlDMVoIPEMPort );
       
   779     emport.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   780     emport.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   781     emport.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   782     emport.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   783     emport.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   784     emport.SetDescriptionL( KNSmlDMVoIPEMPortExp );
       
   785 
       
   786     // MediaQos
       
   787     MSmlDmDDFObject& mediaQos = idNode.AddChildObjectL( 
       
   788         KNSmlDMVoIPMediaQos );
       
   789     mediaQos.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   790     mediaQos.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   791     mediaQos.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   792     mediaQos.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   793     mediaQos.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   794     mediaQos.SetDescriptionL( KNSmlDMVoIPMediaQosExp );
       
   795 
       
   796     // DTMFIB
       
   797     MSmlDmDDFObject& dtmfbib = idNode.AddChildObjectL( 
       
   798         KNSmlDMVoIPDTMFIB );
       
   799     dtmfbib.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   800     dtmfbib.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   801     dtmfbib.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   802     dtmfbib.SetDFFormatL( MSmlDmDDFObject::EBool );
       
   803     dtmfbib.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   804     dtmfbib.SetDescriptionL( KNSmlDMVoIPDTMFIBExp );
       
   805 
       
   806     // DTMFOB
       
   807     MSmlDmDDFObject& dtmfob = idNode.AddChildObjectL( 
       
   808         KNSmlDMVoIPDTMFOB );
       
   809     dtmfob.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   810     dtmfob.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   811     dtmfob.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   812     dtmfob.SetDFFormatL( MSmlDmDDFObject::EBool );
       
   813     dtmfob.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   814     dtmfob.SetDescriptionL( KNSmlDMVoIPDTMFOBExp );
       
   815 
       
   816     // SecureCallPref
       
   817     MSmlDmDDFObject& secureCallPref = idNode.AddChildObjectL(
       
   818         KNSmlDMVoIPSecureCallPref );
       
   819     secureCallPref.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   820     secureCallPref.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   821     secureCallPref.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   822     secureCallPref.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   823     secureCallPref.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   824     secureCallPref.SetDescriptionL( KNSmlDMVoIPSecureCallPrefExp );
       
   825 
       
   826     // RTCP
       
   827     MSmlDmDDFObject& rtcp = idNode.AddChildObjectL(
       
   828         KNSmlDMVoIPRTCP );
       
   829     rtcp.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   830     rtcp.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   831     rtcp.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   832     rtcp.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   833     rtcp.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   834     rtcp.SetDescriptionL( KNSmlDMVoIPRTCPExp );
       
   835 
       
   836     // UAHTerminalType
       
   837     MSmlDmDDFObject& uahTerminalType = idNode.AddChildObjectL(
       
   838         KNSmlDMVoIPUAHTerminalType );
       
   839     uahTerminalType.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   840     uahTerminalType.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   841     uahTerminalType.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   842     uahTerminalType.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   843     uahTerminalType.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   844     uahTerminalType.SetDescriptionL( KNSmlDMVoIPUAHTerminalTypeExp );
       
   845 
       
   846     // UAHWLANMAC
       
   847     MSmlDmDDFObject& uahWLANMAC = idNode.AddChildObjectL(
       
   848         KNSmlDMVoIPUAHWLANMAC );
       
   849     uahWLANMAC.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   850     uahWLANMAC.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   851     uahWLANMAC.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   852     uahWLANMAC.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   853     uahWLANMAC.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   854     uahWLANMAC.SetDescriptionL( KNSmlDMVoIPUAHWLANMACExp );
       
   855 
       
   856     // UAHString
       
   857     MSmlDmDDFObject& uahString = idNode.AddChildObjectL(
       
   858         KNSmlDMVoIPUAHString );
       
   859     uahString.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   860     uahString.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   861     uahString.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   862     uahString.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   863     uahString.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   864     uahString.SetDescriptionL( KNSmlDMVoIPUAHStringExp );
       
   865 
       
   866     // ProfileLockedToIAP
       
   867     MSmlDmDDFObject& profileLockedToIAP = idNode.AddChildObjectL(
       
   868         KNSmlDMVoIPProfileLockedToIAP );
       
   869     profileLockedToIAP.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   870     profileLockedToIAP.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   871     profileLockedToIAP.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   872     profileLockedToIAP.SetDFFormatL( MSmlDmDDFObject::EBool );
       
   873     profileLockedToIAP.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   874     profileLockedToIAP.SetDescriptionL( KNSmlDMVoIPProfileLockedToIAPExp );
       
   875 
       
   876     // VoIPPluginUID
       
   877     MSmlDmDDFObject& voipPluginUID = idNode.AddChildObjectL(
       
   878         KNSmlDMVoIPPluginUID );
       
   879     voipPluginUID.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   880     voipPluginUID.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   881     voipPluginUID.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   882     voipPluginUID.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   883     voipPluginUID.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   884     voipPluginUID.SetDescriptionL( KNSmlDMVoIPPluginUIDExp );
       
   885 
       
   886     // AllowVoIPOverWCDMA
       
   887     MSmlDmDDFObject& voipOverWCDMA = idNode.AddChildObjectL(
       
   888         KNSmlDMVoIPAllowVoIPOverWCDMA );
       
   889     voipOverWCDMA.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   890     voipOverWCDMA.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   891     voipOverWCDMA.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   892     voipOverWCDMA.SetDFFormatL( MSmlDmDDFObject::EBool );
       
   893     voipOverWCDMA.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   894     voipOverWCDMA.SetDescriptionL( KNSmlDMVoIPAllowVoIPOverWCDMAExp );
       
   895 
       
   896     // VoIPDigits
       
   897     MSmlDmDDFObject& voipDigits = idNode.AddChildObjectL(
       
   898         KNSmlDMVoIPVoIPDigits );
       
   899     voipDigits.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   900     voipDigits.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   901     voipDigits.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   902     voipDigits.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   903     voipDigits.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   904     voipDigits.SetDescriptionL( KNSmlDMVoIPVoIPDigitsExp );
       
   905 
       
   906     // URIDomainIgnoreRule
       
   907     MSmlDmDDFObject& uriDomainIgn = idNode.AddChildObjectL(
       
   908         KNSmlDMVoIPURIDomainIgnoreRule );
       
   909     uriDomainIgn.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   910     uriDomainIgn.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   911     uriDomainIgn.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   912     uriDomainIgn.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   913     uriDomainIgn.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   914     uriDomainIgn.SetDescriptionL( KNSmlDMVoIPURIDomainIgnoreRuleExp );
       
   915 
       
   916     // AutoAcceptBuddyRequest
       
   917     MSmlDmDDFObject& aaBuddyReq = idNode.AddChildObjectL(
       
   918         KNSmlDMVoIPAutoAcceptBuddyRequest );
       
   919     aaBuddyReq.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   920     aaBuddyReq.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   921     aaBuddyReq.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   922     aaBuddyReq.SetDFFormatL( MSmlDmDDFObject::EBool );
       
   923     aaBuddyReq.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   924     aaBuddyReq.SetDescriptionL( KNSmlDMVoIPAutoAcceptBuddyRequestExp );
       
   925 
       
   926     // UsedVoIPRelease
       
   927     MSmlDmDDFObject& voipRel = idNode.AddChildObjectL(
       
   928         KNSmlDMVoIPUsedVoIPRelease );
       
   929     voipRel.SetAccessTypesL( accessTypesGet );
       
   930     voipRel.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   931     voipRel.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   932     voipRel.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   933     voipRel.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   934     voipRel.SetDescriptionL( KNSmlDMVoIPUsedVoIPReleaseExp );
       
   935 
       
   936     // AddUserPhone
       
   937     MSmlDmDDFObject& addUserPhone = idNode.AddChildObjectL(
       
   938         KNSmlDMVoIPAddUserPhone );
       
   939     addUserPhone.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   940     addUserPhone.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   941     addUserPhone.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   942     addUserPhone.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   943     addUserPhone.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   944     addUserPhone.SetDescriptionL( KNSmlDMVoIPAddUserPhoneExp );
       
   945 
       
   946     // ProviderBookmarkURI
       
   947     MSmlDmDDFObject& providerBkmarkUri = idNode.AddChildObjectL(
       
   948         KNSmlDMVoIPProviderBookmarkUri );
       
   949     providerBkmarkUri.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   950     providerBkmarkUri.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   951     providerBkmarkUri.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   952     providerBkmarkUri.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   953     providerBkmarkUri.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   954     providerBkmarkUri.SetDescriptionL( KNSmlDMVoIPProviderBookmarkUriExp );
       
   955 
       
   956     // SIPConnectivityTestURI
       
   957     MSmlDmDDFObject& sipConnTestUri = idNode.AddChildObjectL( 
       
   958         KNSmlDMVoIPSIPConnTestUri );
       
   959     sipConnTestUri.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   960     sipConnTestUri.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   961     sipConnTestUri.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   962     sipConnTestUri.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   963     sipConnTestUri.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   964     sipConnTestUri.SetDescriptionL( KNSmlDMVoIPSIPConnTestUriExp );
       
   965 
       
   966     // NATFWProfileId
       
   967     MSmlDmDDFObject& natfwId = idNode.AddChildObjectL(
       
   968         KNSmlDMVoIPNatFwProfileId );
       
   969     natfwId.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   970     natfwId.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   971     natfwId.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   972     natfwId.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   973     natfwId.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   974     natfwId.SetDescriptionL( KNSmlDMVoIPNatFwProfileIdExp );
       
   975 
       
   976     // MinSessionInterval
       
   977     MSmlDmDDFObject& minSe = idNode.AddChildObjectL(
       
   978         KNSmlDMVoIPMinSessionInterval );
       
   979     minSe.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   980     minSe.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   981     minSe.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   982     minSe.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   983     minSe.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   984     minSe.SetDescriptionL( KNSmlDMVoIPMinSessionIntervalExp );
       
   985 
       
   986     // SessionExpires
       
   987     MSmlDmDDFObject& sessionExpires = idNode.AddChildObjectL(
       
   988         KNSmlDMVoIPSessionExpires );
       
   989     sessionExpires.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   990     sessionExpires.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   991     sessionExpires.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   992     sessionExpires.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   993     sessionExpires.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
   994     sessionExpires.SetDescriptionL( KNSmlDMVoIPSessionExpiresExp );
       
   995 
       
   996     // BradingDataURI
       
   997     MSmlDmDDFObject& brandingUri = idNode.AddChildObjectL(
       
   998         KNSmlDMVoIPBrandingDataUri );
       
   999     brandingUri.SetAccessTypesL( accessTypesGetReplaceAdd );
       
  1000     brandingUri.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
  1001     brandingUri.SetScopeL( MSmlDmDDFObject::EDynamic );
       
  1002     brandingUri.SetDFFormatL( MSmlDmDDFObject::EInt );
       
  1003     brandingUri.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
  1004     brandingUri.SetDescriptionL( KNSmlDMVoIPBrandingDataUriExp );
       
  1005 
       
  1006     // PresenceSettingsID
       
  1007     MSmlDmDDFObject& presenceId = idNode.AddChildObjectL(
       
  1008         KNSmlDMVoIPPresenceSettingsId );
       
  1009     presenceId.SetAccessTypesL( accessTypesGetReplaceAdd );
       
  1010     presenceId.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
  1011     presenceId.SetScopeL( MSmlDmDDFObject::EDynamic );
       
  1012     presenceId.SetDFFormatL( MSmlDmDDFObject::EInt );
       
  1013     presenceId.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
  1014     presenceId.SetDescriptionL( KNSmlDMVoIPPresenceSettingsIdExp );
       
  1015 
       
  1016     // UsedNatProtocol
       
  1017     MSmlDmDDFObject& natProtocol = idNode.AddChildObjectL(
       
  1018         KNSmlDMVoIPUsedNatProtocol );
       
  1019     natProtocol.SetAccessTypesL( accessTypesGetReplaceAdd );
       
  1020     natProtocol.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
  1021     natProtocol.SetScopeL( MSmlDmDDFObject::EDynamic );
       
  1022     natProtocol.SetDFFormatL( MSmlDmDDFObject::EInt );
       
  1023     natProtocol.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
  1024     natProtocol.SetDescriptionL( KNSmlDMVoIPUsedNatProtocolExp );
       
  1025 
       
  1026     // AutoEnableService
       
  1027     MSmlDmDDFObject& autoEnable = idNode.AddChildObjectL(
       
  1028         KNSmlDMVoIPAutoEnable );
       
  1029     autoEnable.SetAccessTypesL( accessTypesGetReplaceAdd );
       
  1030     autoEnable.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
  1031     autoEnable.SetScopeL( MSmlDmDDFObject::EDynamic );
       
  1032     autoEnable.SetDFFormatL( MSmlDmDDFObject::EBool );
       
  1033     autoEnable.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
  1034     autoEnable.SetDescriptionL( KNSmlDMVoIPAutoEnableExp );
       
  1035     
       
  1036     // SNAPProfileId
       
  1037     MSmlDmDDFObject& snapId = idNode.AddChildObjectL(
       
  1038         KNSmlDMVoIPSnapProfileId );
       
  1039     snapId.SetAccessTypesL( accessTypesGetReplaceAdd );
       
  1040     snapId.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
  1041     snapId.SetScopeL( MSmlDmDDFObject::EDynamic );
       
  1042     snapId.SetDFFormatL( MSmlDmDDFObject::EChr );
       
  1043     snapId.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
  1044     snapId.SetDescriptionL( KNSmlDMVoIPSnapProfileIdExp );
       
  1045 
       
  1046     // EnableIM
       
  1047     MSmlDmDDFObject& enableIm = idNode.AddChildObjectL(
       
  1048         KNSmlDMVoIPEnableIm );
       
  1049     enableIm.SetAccessTypesL( accessTypesGetReplaceAdd );
       
  1050     enableIm.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
  1051     enableIm.SetScopeL( MSmlDmDDFObject::EDynamic );
       
  1052     enableIm.SetDFFormatL( MSmlDmDDFObject::EBool );
       
  1053     enableIm.AddDFTypeMimeTypeL( KNSmlDMVoIPTextPlain );
       
  1054     enableIm.SetDescriptionL( KNSmlDMVoIPEnableImExp );
       
  1055     
       
  1056     DBG_PRINT("CNSmlDmVoIPAdapter::DDFStructureL(): end");
       
  1057     }
       
  1058 
       
  1059 // ---------------------------------------------------------------------------
       
  1060 // CNSmlDmVoIPAdapter::UpdateLeafObjectL
       
  1061 // Updates value of leaf object
       
  1062 // ---------------------------------------------------------------------------
       
  1063 //
       
  1064 void CNSmlDmVoIPAdapter::UpdateLeafObjectL( 
       
  1065     const TDesC8& aURI, 
       
  1066     const TDesC8& aLUID, 
       
  1067     const TDesC8& aObject, 
       
  1068     const TDesC8& /*aType*/, 
       
  1069     const TInt aStatusRef )
       
  1070     {
       
  1071     DBG_PRINT("CNSmlDmVoIPAdapter::UpdateLeafObjectL(): begin");
       
  1072 
       
  1073     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  1074 
       
  1075     // Load VoIP profile information if not loaded yet
       
  1076     if ( !iProfileEntries.Count() )
       
  1077         {
       
  1078         LoadProfilesL();
       
  1079         }
       
  1080 
       
  1081     CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
       
  1082     TPtrC8 uriSeg = LastURISeg( aURI );
       
  1083     TPtrC8 uriTmp = RemoveLastURISeg( aURI );
       
  1084     TPtrC8 secondLastUriSeg = LastURISeg( uriTmp );
       
  1085 
       
  1086     // Check that luid mapping exist 
       
  1087     if ( !aLUID.Length() )
       
  1088         {
       
  1089         iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  1090         DBG_PRINT("CNSmlDmVoIPAdapter::UpdateLeafObjectL(): no LUID end");
       
  1091         return;
       
  1092         }
       
  1093 
       
  1094      // Find profile and get settings
       
  1095     iProfileID = FindProfileLocation( aLUID );
       
  1096 
       
  1097     // If profile is not found return error.
       
  1098     if ( KErrNotFound == iProfileID )
       
  1099         {
       
  1100         retValue = CSmlDmAdapter::ENotFound;
       
  1101         iDmCallback->SetStatusL( aStatusRef, retValue );
       
  1102         DBG_PRINT("CNSmlDmVoIPAdapter::UpdateLeafObjectL(): not found end");
       
  1103         return;
       
  1104         }
       
  1105 
       
  1106     CDMVoIPSPSettings* spSettings = CDMVoIPSPSettings::NewLC(); // CS:1
       
  1107     spSettings->iRcseProfileId = iProfileEntries[iProfileID]->iId;
       
  1108     TInt spSettingsId( KErrNotFound );
       
  1109     // Check if service provider settings for this VoIP profile are already
       
  1110     // updated to be stored.
       
  1111     for ( TInt counter = 0; counter < iSPSettings.Count(); counter++ )
       
  1112         {
       
  1113         if ( iProfileEntries[iProfileID]->iId == 
       
  1114             iSPSettings[counter]->iRcseProfileId )
       
  1115             {
       
  1116             spSettingsId = counter;
       
  1117             }
       
  1118         }
       
  1119     TBool addSpSettings( EFalse );
       
  1120 
       
  1121     // Check that profile is not already to be saved.
       
  1122     if ( KErrNotFound == iProfileModifs.Find( iProfileID ) )
       
  1123         {
       
  1124         iProfileModifs.Insert( iProfileID, iProfileModifs.Count() );
       
  1125         }
       
  1126 
       
  1127     // VoIP/x/ProviderName
       
  1128     if ( KNSmlDMVoIPProvID() == uriSeg )
       
  1129         {
       
  1130         CRCSEProfileEntry* tmpEntryForProvider = CRCSEProfileEntry::NewLC();
       
  1131         tmpEntryForProvider->iProviderName.Copy( aObject );
       
  1132         CheckDuplicateProviderL( *tmpEntryForProvider );
       
  1133         iProfileEntries[iProfileID]->iProviderName.Copy( 
       
  1134             tmpEntryForProvider->iProviderName );
       
  1135         CleanupStack::PopAndDestroy( tmpEntryForProvider );
       
  1136         }
       
  1137     // VoIP/x/SettingsName
       
  1138     else if ( KNSmlDMVoIPName() == uriSeg )
       
  1139         {
       
  1140         CRCSEProfileEntry* tmpEntryForName = CRCSEProfileEntry::NewLC();
       
  1141         tmpEntryForName->iSettingsName.Copy( aObject );
       
  1142         CheckDuplicateNameL( *tmpEntryForName );
       
  1143         iProfileEntries[iProfileID]->iSettingsName.Copy( 
       
  1144             tmpEntryForName->iSettingsName );
       
  1145         CleanupStack::PopAndDestroy( tmpEntryForName ); 
       
  1146         }
       
  1147     // VoIP/x/SMPort
       
  1148     else if ( KNSmlDMVoIPSMPort() == uriSeg )
       
  1149         {
       
  1150         iProfileEntries[iProfileID]->iStartMediaPort = 
       
  1151             DesToInt( aObject );
       
  1152         }
       
  1153     // VoIP/x/EMPort
       
  1154     else if ( KNSmlDMVoIPEMPort() == uriSeg )
       
  1155         {
       
  1156         iProfileEntries[iProfileID]->iEndMediaPort = DesToInt( aObject );
       
  1157         }
       
  1158     // VoIP/x/MediaQos
       
  1159     else if ( KNSmlDMVoIPMediaQos() == uriSeg )
       
  1160         {
       
  1161         iProfileEntries[iProfileID]->iMediaQOS = DesToInt( aObject );
       
  1162         }
       
  1163     // VoIP/x/DTMFIB
       
  1164     else if ( KNSmlDMVoIPDTMFIB() == uriSeg )
       
  1165         {
       
  1166         if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1167             {
       
  1168             iProfileEntries[iProfileID]->iInbandDTMF = CRCSEProfileEntry::EOn;
       
  1169             }
       
  1170         else if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1171             {
       
  1172             iProfileEntries[iProfileID]->iInbandDTMF = 
       
  1173                 CRCSEProfileEntry::EOff;
       
  1174             }
       
  1175         else
       
  1176             {
       
  1177             retValue = CSmlDmAdapter::EInvalidObject;   
       
  1178             }
       
  1179         }
       
  1180     // VoIP/x/DTMFOB
       
  1181     else if ( KNSmlDMVoIPDTMFOB() == uriSeg )
       
  1182         {
       
  1183         if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1184             {
       
  1185             iProfileEntries[iProfileID]->iOutbandDTMF = 
       
  1186                 CRCSEProfileEntry::EOn;
       
  1187             }
       
  1188         else if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1189             {
       
  1190             iProfileEntries[iProfileID]->iOutbandDTMF = 
       
  1191                 CRCSEProfileEntry::EOff;
       
  1192             }
       
  1193         else
       
  1194             {
       
  1195             retValue = CSmlDmAdapter::EInvalidObject;   
       
  1196             }
       
  1197         }
       
  1198     // VoIP/x/SecureCallPref
       
  1199     else if ( KNSmlDMVoIPSecureCallPref() == uriSeg )
       
  1200         {
       
  1201         iProfileEntries[iProfileID]->
       
  1202             iSecureCallPreference = DesToInt( aObject );
       
  1203         }
       
  1204     // VoIP/x/RTCP
       
  1205     else if ( KNSmlDMVoIPRTCP() == uriSeg )
       
  1206         {
       
  1207         iProfileEntries[iProfileID]->iRTCP = DesToInt( aObject );
       
  1208         }
       
  1209     // VoIP/x/UAHTerminalType
       
  1210     else if ( KNSmlDMVoIPUAHTerminalType() == uriSeg )
       
  1211         {
       
  1212         iProfileEntries[iProfileID]->
       
  1213             iSIPVoIPUAHTerminalType = DesToInt( aObject );
       
  1214         }
       
  1215     // VoIP/x/UAHWLANMAC
       
  1216     else if ( KNSmlDMVoIPUAHWLANMAC() == uriSeg )
       
  1217         {
       
  1218         iProfileEntries[iProfileID]->
       
  1219             iSIPVoIPUAHeaderWLANMAC = DesToInt( aObject );
       
  1220         }
       
  1221     // VoIP/x/UAHString
       
  1222     else if ( KNSmlDMVoIPUAHString() == uriSeg )
       
  1223         {
       
  1224         iProfileEntries[iProfileID]->
       
  1225             iSIPVoIPUAHeaderString.Copy( aObject );
       
  1226         }
       
  1227     // VoIP/x/ProfileLockedToIAP
       
  1228     else if ( KNSmlDMVoIPProfileLockedToIAP() == uriSeg )
       
  1229         {
       
  1230         if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1231             {
       
  1232             iProfileEntries[iProfileID]->
       
  1233                 iProfileLockedToIAP = CRCSEProfileEntry::EOn;
       
  1234             }
       
  1235         else if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1236             {
       
  1237             iProfileEntries[iProfileID]->
       
  1238                 iProfileLockedToIAP = CRCSEProfileEntry::EOff;
       
  1239             }
       
  1240         else
       
  1241             {
       
  1242             retValue = CSmlDmAdapter::EInvalidObject;   
       
  1243             }
       
  1244         }
       
  1245     // VoIP/x/VoIPPluginUID
       
  1246     else if ( KNSmlDMVoIPPluginUID() == uriSeg )
       
  1247         {
       
  1248         iProfileEntries[iProfileID]->iVoIPPluginUID = 
       
  1249             DesToTUint( aObject );
       
  1250         }
       
  1251     // VoIP/x/AllowVoIPOverWCDMA
       
  1252     else if ( KNSmlDMVoIPAllowVoIPOverWCDMA() == uriSeg )
       
  1253         {
       
  1254         if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1255             {
       
  1256             iProfileEntries[iProfileID]->
       
  1257                 iAllowVoIPoverWCDMA = CRCSEProfileEntry::EOn;
       
  1258             }
       
  1259         else if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1260             {
       
  1261             iProfileEntries[iProfileID]->
       
  1262                 iAllowVoIPoverWCDMA = CRCSEProfileEntry::EOff;
       
  1263             }
       
  1264         else
       
  1265             {
       
  1266             retValue = CSmlDmAdapter::EInvalidObject;   
       
  1267             }
       
  1268         }
       
  1269     // VoIP/x/VoIPDigits
       
  1270     else if ( KNSmlDMVoIPVoIPDigits() == uriSeg )
       
  1271         {
       
  1272         iProfileEntries[iProfileID]->iMeanCountOfVoIPDigits = 
       
  1273             DesToInt( aObject );
       
  1274         }
       
  1275     // VoIP/x/URIDomainIgnoreRule
       
  1276     else if ( KNSmlDMVoIPURIDomainIgnoreRule() == uriSeg )
       
  1277         {
       
  1278         iProfileEntries[iProfileID]->iIgnoreAddrDomainPart = 
       
  1279             DesToInt( aObject );
       
  1280         }
       
  1281     // VoIP/x/AddUserPhone
       
  1282     else if ( KNSmlDMVoIPAddUserPhone() == uriSeg )
       
  1283         {
       
  1284         if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1285             {
       
  1286             iProfileEntries[iProfileID]->iUserPhoneUriParameter =
       
  1287             CRCSEProfileEntry::EOff;
       
  1288             }
       
  1289         else if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1290             {
       
  1291             iProfileEntries[iProfileID]->iUserPhoneUriParameter =
       
  1292             CRCSEProfileEntry::EOn;
       
  1293             }
       
  1294         else
       
  1295             {
       
  1296             retValue = CSmlDmAdapter::EInvalidObject;
       
  1297             }
       
  1298         }
       
  1299     // VoIP/x/ProviderBookmarkURI
       
  1300     else if ( KNSmlDMVoIPProviderBookmarkUri() == uriSeg )
       
  1301         {
       
  1302         if ( KErrNotFound == spSettingsId )
       
  1303             {
       
  1304             delete spSettings->iServiceProviderBookmark;
       
  1305             spSettings->iServiceProviderBookmark = NULL;
       
  1306             spSettings->iServiceProviderBookmark = HBufC::NewL( 
       
  1307                 aObject.Length() );
       
  1308             spSettings->iServiceProviderBookmark->Des().Copy( aObject );
       
  1309             addSpSettings = ETrue;
       
  1310             }
       
  1311         else
       
  1312             {
       
  1313             delete iSPSettings[spSettingsId]->iServiceProviderBookmark;
       
  1314             iSPSettings[spSettingsId]->iServiceProviderBookmark = NULL;
       
  1315             iSPSettings[spSettingsId]->iServiceProviderBookmark = HBufC::NewL(
       
  1316                 aObject.Length() );
       
  1317             iSPSettings[spSettingsId]->iServiceProviderBookmark->Des().Copy( 
       
  1318                 aObject );
       
  1319             }
       
  1320         }
       
  1321     // VoIP/x/SIPConnectivityTestURI
       
  1322     else if ( KNSmlDMVoIPSIPConnTestUri() == uriSeg )
       
  1323         {
       
  1324         iProfileEntries[iProfileID]->iSIPConnTestAddress.Copy( 
       
  1325             aObject );
       
  1326         }
       
  1327     // VoIP/x/NATFWProfileId
       
  1328     else if ( KNSmlDMVoIPNatFwProfileId() == uriSeg )
       
  1329         {
       
  1330         TUint32 natId = NatFwIdL( aObject );
       
  1331         if ( KErrNone == natId )
       
  1332             {
       
  1333             retValue = CSmlDmAdapter::EInvalidObject;
       
  1334             }
       
  1335         else
       
  1336             {
       
  1337             iProfileEntries[iProfileID]->iNATSettingsStorageId = natId;
       
  1338             }
       
  1339         }
       
  1340     // VoIP/x/MinSessionInterval
       
  1341     else if ( KNSmlDMVoIPMinSessionInterval() == uriSeg )
       
  1342         {
       
  1343         iProfileEntries[iProfileID]->iSIPMinSE = DesToInt( aObject );
       
  1344         }
       
  1345     // VoIP/x/SessionExpires
       
  1346     else if ( KNSmlDMVoIPSessionExpires() == uriSeg )
       
  1347         {
       
  1348         iProfileEntries[iProfileID]->iSIPSessionExpires = 
       
  1349             DesToInt( aObject );
       
  1350         }
       
  1351     // VoIP/x/BradingDataURI
       
  1352     else if ( KNSmlDMVoIPBrandingDataUri() == uriSeg )
       
  1353         {
       
  1354         if ( KErrNotFound == spSettingsId )
       
  1355             {
       
  1356             delete spSettings->iBrandingDataUri;
       
  1357             spSettings->iBrandingDataUri = NULL;
       
  1358             spSettings->iBrandingDataUri = HBufC::NewL( aObject.Length() );
       
  1359             spSettings->iBrandingDataUri->Des().Copy( aObject );
       
  1360             addSpSettings = ETrue;
       
  1361             }
       
  1362         else
       
  1363             {
       
  1364             delete iSPSettings[spSettingsId]->iBrandingDataUri;
       
  1365             iSPSettings[spSettingsId]->iBrandingDataUri = NULL;
       
  1366             iSPSettings[spSettingsId]->iBrandingDataUri = 
       
  1367                 HBufC::NewL( aObject.Length() );
       
  1368             iSPSettings[spSettingsId]->iBrandingDataUri->Des().Copy( 
       
  1369                 aObject );
       
  1370             }
       
  1371         }
       
  1372     // VoIP/x/PresenceSettingsID
       
  1373     else if ( KNSmlDMVoIPPresenceSettingsId() == uriSeg )
       
  1374         {
       
  1375         if ( KErrNotFound == spSettingsId )
       
  1376             {
       
  1377             spSettings->iPresenceId = PresenceIdL( aObject );
       
  1378             addSpSettings = ETrue;
       
  1379             }
       
  1380         else
       
  1381             {
       
  1382             iSPSettings[spSettingsId]->iPresenceId = PresenceIdL( aObject );
       
  1383             }
       
  1384         }
       
  1385     // VoIP/x/UsedNATProtocol
       
  1386     else if ( KNSmlDMVoIPUsedNatProtocol() == uriSeg )
       
  1387         {
       
  1388         iProfileEntries[iProfileID]->iNATProtocol = DesToInt( aObject );
       
  1389         }
       
  1390     // VoIP/x/AutoEnable
       
  1391     else if ( KNSmlDMVoIPAutoEnable() == uriSeg )
       
  1392         {
       
  1393         if ( KErrNotFound == spSettingsId )
       
  1394             {
       
  1395             spSettings->iAutoEnableService = DesToInt( aObject );
       
  1396             addSpSettings = ETrue;
       
  1397             }
       
  1398         else
       
  1399             {
       
  1400             iSPSettings[spSettingsId]->iAutoEnableService =  
       
  1401                 DesToInt( aObject );
       
  1402             }
       
  1403         }
       
  1404     // VoIP/x/SNAPProfileId
       
  1405     else if ( KNSmlDMVoIPSnapProfileId() == uriSeg )
       
  1406         {
       
  1407         if ( KErrNotFound == spSettingsId )
       
  1408             {
       
  1409             spSettings->iSnapId = SnapIdL( aObject );
       
  1410             addSpSettings = ETrue;
       
  1411             }
       
  1412         else
       
  1413             {
       
  1414             iSPSettings[spSettingsId]->iSnapId = SnapIdL( aObject );
       
  1415             }
       
  1416         }
       
  1417     // VoIP/x/EnableIM
       
  1418     else if ( KNSmlDMVoIPEnableIm() == uriSeg )
       
  1419         {
       
  1420         if ( KErrNotFound == spSettingsId )
       
  1421             {
       
  1422             if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1423                 {
       
  1424                 spSettings->iImEnabled = EFalse;
       
  1425                 addSpSettings = ETrue;
       
  1426                 }
       
  1427             else if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1428                 {
       
  1429                 spSettings->iImEnabled = ETrue;
       
  1430                 addSpSettings = ETrue;
       
  1431                 }
       
  1432             else
       
  1433                 {
       
  1434                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1435                 }
       
  1436             }
       
  1437         else
       
  1438             {
       
  1439             if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1440                 {
       
  1441                 iSPSettings[spSettingsId]->iImEnabled = EFalse;
       
  1442                 }
       
  1443             else if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1444                 {
       
  1445                 iSPSettings[spSettingsId]->iImEnabled = ETrue;
       
  1446                 }
       
  1447             else
       
  1448                 {
       
  1449                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1450                 }
       
  1451             }
       
  1452         }
       
  1453 
       
  1454     // ==============================
       
  1455     // SettingIds node (update)
       
  1456     // ==============================
       
  1457     //
       
  1458 
       
  1459     // VoIP/x/SettingIds
       
  1460     if ( KNSmlDMVoIPSettingId() == LastURISeg( aLUID ).Left( 
       
  1461         KNSmlDMVoIPSettingId().Length() ) 
       
  1462         && KFiveSegs == NumOfURISegs( aURI ) )
       
  1463         {
       
  1464         retValue = UpdateSettingIdsSpecificObjectL( aLUID, uriSeg, aObject );
       
  1465         }
       
  1466 
       
  1467     // ==============================
       
  1468     // PreferredCodecs node (update)
       
  1469     // ==============================
       
  1470     //
       
  1471 
       
  1472     // VoIP/x/PreferredCodecs node
       
  1473     if ( KNSmlDMVoIPPreferredCodecId() == uriSeg
       
  1474         && KFiveSegs == NumOfURISegs( aURI ) ) 
       
  1475         {
       
  1476         // Check that codec ID is found from codec entries before setting it.
       
  1477         // Preferred codec ID setting is only for knowing and changing an
       
  1478         // already existing codec priority.
       
  1479         if ( FindCodecLocation( DesToInt( aObject ) ) != KErrNotFound &&
       
  1480             DesToInt( aLUID.Right( 10 ) ) <= iProfileEntries[iProfileID]->
       
  1481             iPreferredCodecs.Count() )
       
  1482             {
       
  1483             iProfileEntries[iProfileID]->iPreferredCodecs[ 
       
  1484                 DesToInt( aLUID.Right( 10 ))] = DesToInt( aObject );
       
  1485             }
       
  1486         else
       
  1487             {
       
  1488             // Codec is not found from codecsettings or
       
  1489             // invalid LUID is passed to the adapter.
       
  1490             retValue = CSmlDmAdapter::EInvalidObject;
       
  1491             }
       
  1492 
       
  1493         }
       
  1494 
       
  1495     // ==============================
       
  1496     // CodecSettings node (update)
       
  1497     // ==============================
       
  1498     //
       
  1499     if ( KNSmlDMVoIPCodecSettingsId() == LastURISeg( aLUID ).
       
  1500         Left( KNSmlDMVoIPCodecSettingsId().Length() )
       
  1501         && KFiveSegs == NumOfURISegs( aURI ) )
       
  1502         {
       
  1503         retValue = UpdateCodecSpecificObject( aLUID, uriSeg, aObject );
       
  1504         }
       
  1505 
       
  1506     // ==============================
       
  1507     // VoiceMailBox node (update)
       
  1508     // ==============================
       
  1509     //
       
  1510     if ( KNSmlDMVoIPVmbxNode() == secondLastUriSeg && 
       
  1511         KFourSegs == NumOfURISegs( aURI ) )
       
  1512         {
       
  1513         if ( KNSmlDMVoIPMwiUri() == uriSeg )
       
  1514             {
       
  1515             if ( KErrNotFound == spSettingsId )
       
  1516                 {
       
  1517                 delete spSettings->iVmbxMwiUri;
       
  1518                 spSettings->iVmbxMwiUri = NULL;
       
  1519                 spSettings->iVmbxMwiUri = HBufC::NewL( aObject.Length() );
       
  1520                 spSettings->iVmbxMwiUri->Des().Copy( aObject );
       
  1521                 addSpSettings = ETrue;
       
  1522                 }
       
  1523             else
       
  1524                 {
       
  1525                 delete iSPSettings[spSettingsId]->iVmbxMwiUri;
       
  1526                 iSPSettings[spSettingsId]->iVmbxMwiUri = NULL;
       
  1527                 iSPSettings[spSettingsId]->iVmbxMwiUri = HBufC::NewL( 
       
  1528                     aObject.Length() );
       
  1529                 iSPSettings[spSettingsId]->iVmbxMwiUri->Des().Copy( aObject );
       
  1530                 }
       
  1531             }
       
  1532         else if ( KNSmlDMVoIPListeningUri() == uriSeg )
       
  1533             {
       
  1534             if ( KErrNotFound == spSettingsId )
       
  1535                 {
       
  1536                 delete spSettings->iVmbxListenUri;
       
  1537                 spSettings->iVmbxListenUri = NULL;
       
  1538                 spSettings->iVmbxListenUri = HBufC::NewL( aObject.Length() );
       
  1539                 spSettings->iVmbxListenUri->Des().Copy( aObject );
       
  1540                 addSpSettings = ETrue;
       
  1541                 }
       
  1542             else
       
  1543                 {
       
  1544                 delete iSPSettings[spSettingsId]->iVmbxListenUri;
       
  1545                 iSPSettings[spSettingsId]->iVmbxListenUri = NULL;
       
  1546                 iSPSettings[spSettingsId]->iVmbxListenUri = HBufC::NewL( 
       
  1547                     aObject.Length() );
       
  1548                 iSPSettings[spSettingsId]->iVmbxListenUri->Des().Copy( 
       
  1549                     aObject );
       
  1550                 }
       
  1551             }
       
  1552         else if ( KNSmlDMVoIPUsedIAPId() == uriSeg )
       
  1553             {
       
  1554             TInt iapId = ConRefL( aObject );
       
  1555             if ( KErrNotFound == iapId )
       
  1556                 {
       
  1557                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1558                 }
       
  1559             else
       
  1560                 {
       
  1561                 if ( KErrNotFound == spSettingsId )
       
  1562                     {
       
  1563                     spSettings->iVmbxIapId = iapId;
       
  1564                     addSpSettings = ETrue;
       
  1565                     }
       
  1566                 else
       
  1567                     {
       
  1568                     iSPSettings[spSettingsId]->iVmbxIapId = iapId;
       
  1569                     }
       
  1570                 }
       
  1571             }
       
  1572         else if ( KNSmlDMVoIPReSubscribeInterval() == uriSeg )
       
  1573             {
       
  1574             if ( KErrNotFound == spSettingsId )
       
  1575                 {
       
  1576                 spSettings->iReSubscribeInterval = DesToInt( aObject );
       
  1577                 addSpSettings = ETrue;
       
  1578                 }
       
  1579             else
       
  1580                 {
       
  1581                 iSPSettings[spSettingsId]->iReSubscribeInterval = 
       
  1582                     DesToInt( aObject );
       
  1583                 }
       
  1584             }
       
  1585         else if ( KNSmlDMVoIPUsedSIPProfileId() == uriSeg )
       
  1586             {
       
  1587             TUint32 profileId = SetSipRefL( aObject ); 
       
  1588             // SIP profile ID's start from 2.
       
  1589             if ( profileId > 1 )
       
  1590                 {
       
  1591                 if ( KErrNotFound == spSettingsId )
       
  1592                     {
       
  1593                     spSettings->iVmbxSipId = profileId;
       
  1594                     addSpSettings = ETrue;
       
  1595                     }
       
  1596                 else
       
  1597                     {
       
  1598                     iSPSettings[spSettingsId]->iVmbxSipId = profileId;
       
  1599                     }
       
  1600                 }
       
  1601             else
       
  1602                 {
       
  1603                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1604                 }
       
  1605             }
       
  1606         else if ( KNSmlDMVoIPAutoAcceptBuddyRequest() == uriSeg )
       
  1607             {
       
  1608             if ( KErrNotFound == spSettingsId )
       
  1609                 {
       
  1610                 spSettings->iAutoAcceptBuddy = DesToInt( aObject );
       
  1611                 addSpSettings = ETrue;
       
  1612                 }
       
  1613             else
       
  1614                 {
       
  1615                 iSPSettings[spSettingsId]->iAutoAcceptBuddy = 
       
  1616                     DesToInt( aObject );
       
  1617                 }
       
  1618             }
       
  1619         else
       
  1620             {
       
  1621             retValue = CSmlDmAdapter::EInvalidObject;
       
  1622             }
       
  1623         }
       
  1624 
       
  1625     if ( addSpSettings )
       
  1626         {
       
  1627         // Append Service Provider Settings to array for saving them later.
       
  1628         // iSPSettings array will own the object now. 
       
  1629         iSPSettings.AppendL( spSettings );
       
  1630         CleanupStack::Pop( spSettings ); // CS:0
       
  1631         }
       
  1632     else
       
  1633         {
       
  1634         // Local Service Provider Settings not needed.
       
  1635         CleanupStack::PopAndDestroy( spSettings ); // CS:0
       
  1636         }
       
  1637 
       
  1638     iDmCallback->SetStatusL( aStatusRef, retValue );
       
  1639 
       
  1640     DBG_PRINT("CNSmlDmVoIPAdapter::UpdateLeafObjectL(): end");
       
  1641     }
       
  1642     
       
  1643 // ---------------------------------------------------------------------------
       
  1644 // CNSmlDmVoIPAdapter::UpdateCodecSpecificObject
       
  1645 // Updates Codec specific object.
       
  1646 // ---------------------------------------------------------------------------
       
  1647 //
       
  1648 CSmlDmAdapter::TError CNSmlDmVoIPAdapter::UpdateCodecSpecificObject(
       
  1649     const TDesC8& aLUID, const TDesC8& aUriSeg, const TDesC8& aObject )
       
  1650     {
       
  1651     DBG_PRINT("CNSmlDmVoIPAdapter::UpdateCodecSpecificObject(): begin");
       
  1652 
       
  1653     CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
       
  1654 
       
  1655     // Get codec ID used by these settings.
       
  1656     TUint32 codecId = DesToInt( aLUID.Right( 10 ) );
       
  1657     TInt codecPos = FindCodecLocation( codecId );
       
  1658     if ( KErrNotFound != codecPos )
       
  1659         {
       
  1660         // Add profile to be saved if not done already.
       
  1661         if ( KErrNotFound == iCodecModifs.Find( codecPos ) )
       
  1662             {
       
  1663             iCodecModifs.Insert( codecPos, iCodecModifs.Count() );
       
  1664             }
       
  1665         //CodecId
       
  1666         if ( KNSmlDMVoIPCodecId() == aUriSeg ) 
       
  1667             {
       
  1668             iCodecEntries[codecPos]->iCodecId = DesToInt( aObject );
       
  1669             }
       
  1670         //MediaTypeName
       
  1671         if ( KNSmlDMVoIPMediaTypeName() == aUriSeg ) 
       
  1672             {
       
  1673             iCodecEntries[codecPos]->iMediaTypeName.Copy( aObject );
       
  1674             }
       
  1675         //MediaSubTypeName
       
  1676         if ( KNSmlDMVoIPMediaSubTypeName() == aUriSeg ) 
       
  1677             {
       
  1678             iCodecEntries[codecPos]->
       
  1679                 iMediaSubTypeName.Copy( aObject );
       
  1680             }
       
  1681         //JitterBufferSize
       
  1682         if ( KNSmlDMVoIPJitterBufferSize() == aUriSeg ) 
       
  1683             {
       
  1684             iCodecEntries[codecPos]->iJitterBufferSize = 
       
  1685                 DesToInt( aObject );
       
  1686             }
       
  1687         //OctetAlign
       
  1688         if ( KNSmlDMVoIPOctetAlign() == aUriSeg ) 
       
  1689             {
       
  1690             if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1691                 {
       
  1692                 iCodecEntries[codecPos]->iOctetAlign = 
       
  1693                     CRCSEAudioCodecEntry::EOn;
       
  1694                 }
       
  1695             else if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1696                 {
       
  1697                 iCodecEntries[codecPos]->iOctetAlign = 
       
  1698                     CRCSEAudioCodecEntry::EOff;
       
  1699                 }
       
  1700             else
       
  1701                 {
       
  1702                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1703                 }
       
  1704             }
       
  1705         //ModeChangePeriod
       
  1706         if ( KNSmlDMVoIPModeChangePeriod() == aUriSeg ) 
       
  1707             {
       
  1708             iCodecEntries[codecPos]->iModeChangePeriod = 
       
  1709                 DesToInt( aObject );
       
  1710             }
       
  1711         //ModeChangeNeighbor                
       
  1712         if ( KNSmlDMVoIPModeChangeNeighbor() == aUriSeg ) 
       
  1713             {
       
  1714             if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1715                 {
       
  1716                 iCodecEntries[codecPos]->iModeChangeNeighbor = 
       
  1717                     CRCSEAudioCodecEntry::EOn;
       
  1718                 }
       
  1719             else if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1720                 {
       
  1721                 iCodecEntries[codecPos]->iModeChangeNeighbor = 
       
  1722                     CRCSEAudioCodecEntry::EOff;
       
  1723                 }
       
  1724             else
       
  1725                 {
       
  1726                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1727                 }
       
  1728             }
       
  1729         //Ptime
       
  1730         if ( KNSmlDMVoIPPtime() == aUriSeg ) 
       
  1731             {
       
  1732             iCodecEntries[codecPos]->iPtime = DesToInt( aObject );
       
  1733             }
       
  1734         //Maxptime
       
  1735         if ( KNSmlDMVoIPMaxPtime() == aUriSeg ) 
       
  1736             {
       
  1737             iCodecEntries[codecPos]->iMaxptime = DesToInt( aObject );
       
  1738             }
       
  1739         //VAD                
       
  1740         if ( KNSmlDMVoIPVAD() == aUriSeg ) 
       
  1741             {
       
  1742             if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1743                 {
       
  1744                 iCodecEntries[codecPos]->iVAD = 
       
  1745                     CRCSEAudioCodecEntry::EOn;
       
  1746                 }
       
  1747             else if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1748                 {
       
  1749                 iCodecEntries[codecPos]->iVAD = 
       
  1750                     CRCSEAudioCodecEntry::EOff;
       
  1751                 }
       
  1752             else
       
  1753                 {
       
  1754                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1755                 }
       
  1756             }
       
  1757         //AnnexB                
       
  1758         if ( KNSmlDMVoIPAnnexB() == aUriSeg ) 
       
  1759             {
       
  1760             if ( KNSmlDMVoIPValueTrue() == aObject )
       
  1761                 {
       
  1762                 iCodecEntries[codecPos]->iAnnexb =
       
  1763                     CRCSEAudioCodecEntry::EOn;
       
  1764                 }
       
  1765             else if ( KNSmlDMVoIPValueFalse() == aObject )
       
  1766                 {
       
  1767                 iCodecEntries[codecPos]->iAnnexb =
       
  1768                     CRCSEAudioCodecEntry::EOff;
       
  1769                 }
       
  1770             else
       
  1771                 {
       
  1772                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1773                 }
       
  1774             }
       
  1775         // MaxRed
       
  1776         if ( KNSmlDMVoIPMaxRed() == aUriSeg )
       
  1777             {
       
  1778             iCodecEntries[codecPos]->iMaxRed = DesToInt( aObject );
       
  1779             }
       
  1780 
       
  1781         // ==============================
       
  1782         // ModeSet node ( update )
       
  1783         // ==============================
       
  1784         //
       
  1785         if ( KNSmlDMVoIPMode() == aUriSeg )  
       
  1786             {
       
  1787             // Add profile to be saved if not done already.
       
  1788             if ( KErrNotFound == iCodecModifs.Find( codecPos ) )
       
  1789                 {
       
  1790                 iCodecModifs.Insert( codecPos, iCodecModifs.Count() );
       
  1791                 }
       
  1792             iCodecEntries[codecPos]->iModeSet[ 
       
  1793                 DesToInt( aLUID.Right( 10 ))] = DesToInt( aObject );
       
  1794             }
       
  1795         }
       
  1796     else
       
  1797         {
       
  1798         // codecsetting not found even in luid exists
       
  1799         retValue = CSmlDmAdapter::EError;
       
  1800         }
       
  1801     DBG_PRINT("CNSmlDmVoIPAdapter::UpdateCodecSpecificObject(): end");
       
  1802 
       
  1803     return retValue;
       
  1804     }
       
  1805 
       
  1806 // ---------------------------------------------------------------------------
       
  1807 // CNSmlDmVoIPAdapter::UpdateSettingIdsSpecificObjectL
       
  1808 // Updates SettingIds specific object.
       
  1809 // ---------------------------------------------------------------------------
       
  1810 //
       
  1811 CSmlDmAdapter::TError CNSmlDmVoIPAdapter::UpdateSettingIdsSpecificObjectL(
       
  1812     const TDesC8& aLUID, const TDesC8& aUriSeg, const TDesC8& aObject )
       
  1813     {
       
  1814     DBG_PRINT("CNSmlDmVoIPAdapter::UpdateSettingIdsSpecificObjectL(): start");
       
  1815 
       
  1816     CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
       
  1817 
       
  1818     // Get SIP Specific ID used by these settings.
       
  1819 
       
  1820     // Add profile to be saved if not done already.
       
  1821     if ( KErrNotFound == iProfileModifs.Find( iProfileID ) )
       
  1822         {
       
  1823         iProfileModifs.Insert( iProfileID, iProfileModifs.Count() );
       
  1824         }
       
  1825     //ProfileType
       
  1826     if ( KNSmlDMVoIPProfileType() == aUriSeg )
       
  1827         {
       
  1828         if ( KNSmlDMVoIPProfileTypeSIP() == aObject )
       
  1829             {
       
  1830             iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  1831                 LastURISeg( aLUID ).Right( 10 ))].iProfileType = 0;
       
  1832             }
       
  1833         else if ( KNSmlDMVoIPProfileTypeSCCP() == aObject )
       
  1834             {
       
  1835             iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  1836                 LastURISeg( aLUID ).Right( 10 ))].iProfileType = 1;
       
  1837             }
       
  1838         else
       
  1839             {
       
  1840             retValue = CSmlDmAdapter::EInvalidObject;   
       
  1841             }
       
  1842         }
       
  1843     // ProfileId
       
  1844     if ( KNSmlDMVoIPProfileId() == aUriSeg )
       
  1845         {
       
  1846         // Handle SIP type.
       
  1847         if ( 0 == iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  1848             LastURISeg( aLUID ).Right( 10 ))].iProfileType )
       
  1849             {
       
  1850             TUint32 profileId = SetSipRefL( aObject ); 
       
  1851             if ( profileId > 0 )
       
  1852                 {
       
  1853                 // Set profileId to settingsids.
       
  1854                 iProfileEntries[iProfileID]->
       
  1855                     iIds[DesToInt( LastURISeg( aLUID ).Right( 10 ))].
       
  1856                     iProfileId = profileId;
       
  1857                 retValue = CSmlDmAdapter::EOk;
       
  1858                 }
       
  1859             else
       
  1860                 {
       
  1861                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1862                 }
       
  1863             }  
       
  1864         // Handle SCCP type
       
  1865         else if ( 1 == iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  1866             LastURISeg( aLUID ).Right( 10 ))].iProfileType )
       
  1867             {
       
  1868             TUint32 profileId = SetSccpRefL( aObject ); 
       
  1869 
       
  1870             // profileId can be zero
       
  1871             if ( profileId > 0 || 0 == profileId )
       
  1872                 {
       
  1873                 // set profileId to settingsids
       
  1874                 iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  1875                     LastURISeg( aLUID ).Right( 10 ))].
       
  1876                     iProfileId = profileId;
       
  1877                 retValue = CSmlDmAdapter::EOk;
       
  1878                 }
       
  1879             else
       
  1880                 {
       
  1881                 retValue = CSmlDmAdapter::EInvalidObject;
       
  1882                 }
       
  1883             }
       
  1884         else
       
  1885             {
       
  1886             // no SCCP or SIP type found
       
  1887             retValue = CSmlDmAdapter::EError;
       
  1888             }
       
  1889         }
       
  1890     // ProfileSpecificId
       
  1891     if ( KNSmlDMVoIPProfileSpecificId() == aUriSeg )
       
  1892         {
       
  1893         // SIPSpecific settings have been removed so set
       
  1894         // SIPSpecific ID as not found.
       
  1895         iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  1896             LastURISeg( aLUID ).Right( 10 ))].
       
  1897             iProfileSpecificSettingId = KErrNotFound;
       
  1898 
       
  1899         // Set status to OK so we won't break backwards compatibility.
       
  1900         // Some DM servers may react to receiving other status than OK
       
  1901         // when sending settings they think are supported.
       
  1902         retValue = CSmlDmAdapter::EOk;
       
  1903         }
       
  1904 
       
  1905     DBG_PRINT("CNSmlDmVoIPAdapter::UpdateSettingIdsSpecificObjectL(): end");
       
  1906 
       
  1907     return retValue;
       
  1908     }
       
  1909 // ---------------------------------------------------------------------------
       
  1910 // CNSmlDmVoIPAdapter::DeleteObjectL
       
  1911 // This deletes VoIP profiles
       
  1912 // ---------------------------------------------------------------------------
       
  1913 //
       
  1914 void CNSmlDmVoIPAdapter::DeleteObjectL( 
       
  1915     const TDesC8& aURI, 
       
  1916     const TDesC8& aLUID, 
       
  1917     const TInt aStatusRef )
       
  1918     {
       
  1919     DBG_PRINT("CNSmlDmVoIPAdapter::DeleteObjectL( ): begin");
       
  1920 
       
  1921     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  1922 
       
  1923     // Load VoIP profile information if not loaded yet
       
  1924     if ( !iProfileEntries.Count() )
       
  1925         {
       
  1926         LoadProfilesL();
       
  1927         }
       
  1928 
       
  1929     CSmlDmAdapter::TError retValue = CSmlDmAdapter::EError;
       
  1930 
       
  1931     // Get URI parameters.
       
  1932     TBuf8<KNSmlVoIPMaxUriLength> uri = aURI;
       
  1933     TPtrC8 uriSeg = LastURISeg( aURI );
       
  1934     TPtrC8 uriTmp = RemoveLastURISeg( aURI );
       
  1935     TPtrC8 secondLastUriSeg = LastURISeg( uriTmp );
       
  1936 
       
  1937     // Copy LUID as last segment if exists.
       
  1938     if ( 0 < aLUID.Length() )
       
  1939         {
       
  1940         uri.Copy ( aLUID );
       
  1941         }
       
  1942     iProfileID = FindProfileLocation( uri );
       
  1943     if ( KErrNotFound == iProfileID )
       
  1944         {
       
  1945         iProfileID = FindProfileLocation( aURI );
       
  1946         if ( KErrNotFound == iProfileID )
       
  1947             {
       
  1948             retValue = CSmlDmAdapter::ENotFound;
       
  1949             iDmCallback->SetStatusL( aStatusRef, retValue );
       
  1950             DBG_PRINT("CNSmlDmVoIPAdapter::DeleteObjectL( ): ENotFound end");
       
  1951             return;
       
  1952             }
       
  1953         } 
       
  1954 
       
  1955     // ==============================
       
  1956     // VoIP/x (delete)
       
  1957     // ==============================
       
  1958     //
       
  1959     if ( secondLastUriSeg == KNSmlDMVoIPNodeName
       
  1960         && aLUID.Find( KNSmlDMVoIPPrefix ) != KErrNotFound )
       
  1961         {
       
  1962         // Delete profile from RCSE.
       
  1963         iCRCSEProfile->DeleteL( iProfileEntries[iProfileID]->iId );
       
  1964 
       
  1965         // Delete profile also from memory and compress array.
       
  1966         delete iProfileEntries[iProfileID];
       
  1967         iProfileEntries[iProfileID] = NULL;
       
  1968         iProfileEntries.Remove( iProfileID );
       
  1969         iProfileEntries.Compress();
       
  1970         iDmCallback->SetMappingL( aURI, KNullDesC8 ); 
       
  1971         retValue = CSmlDmAdapter::EOk;
       
  1972 
       
  1973         // Fall back to CS preferred when no more VoIP profiles
       
  1974         TInt profileCount = iProfileEntries.Count();
       
  1975         if ( KErrNone == profileCount )
       
  1976             {
       
  1977             SetTelephonyPreferenceL( ECSPreferred );
       
  1978             }
       
  1979         }
       
  1980 
       
  1981     // ==============================
       
  1982     // CodecSettings node ( delete ) 
       
  1983     // ==============================
       
  1984     //
       
  1985     else if ( KNSmlDMVoIPCodecSettingsNode() == secondLastUriSeg  
       
  1986         && KFourSegs == NumOfURISegs( aURI ) 
       
  1987         && aLUID.Find( KNSmlDMVoIPCodecSettingsId ) != KErrNotFound )
       
  1988         {
       
  1989         // Get codec ID used by this setting.
       
  1990         TUint32 codecId = DesToInt( aLUID.Right(10) );
       
  1991         TInt codecPos = FindCodecLocation( codecId );    
       
  1992         if ( KErrNotFound != codecPos )
       
  1993             {
       
  1994             // Delete codec settings from RCSE.
       
  1995             iCRCSEAudioCodec->DeleteL( codecId );
       
  1996             TInt preferredPos = iProfileEntries[iProfileID]->
       
  1997                 iPreferredCodecs.Find( codecId );
       
  1998 
       
  1999             // Remove codec settings ID from profiles iPreferredCodecs.
       
  2000             iProfileEntries[iProfileID]->iPreferredCodecs.Remove(
       
  2001                 preferredPos );
       
  2002             iProfileEntries[iProfileID]->iPreferredCodecs.Compress();
       
  2003 
       
  2004             // Remove codec settings from iCodecEntries and update
       
  2005             // Profile back to RCSE. 
       
  2006             delete iCodecEntries[codecPos];
       
  2007             iCodecEntries[codecPos] = NULL;
       
  2008             iCodecEntries.Remove( codecPos );
       
  2009             iCodecEntries.Compress();
       
  2010             iCRCSEProfile->UpdateL( iProfileEntries[iProfileID]->
       
  2011                 iId, *iProfileEntries[iProfileID] );
       
  2012             retValue = CSmlDmAdapter::EOk;
       
  2013             }
       
  2014         else
       
  2015             {
       
  2016             retValue = CSmlDmAdapter::EError;    
       
  2017             }
       
  2018         }
       
  2019 
       
  2020     // ==============================
       
  2021     // VoIP/x/SettingIds ( delete ) 
       
  2022     // ==============================,
       
  2023     //
       
  2024     else if ( KNSmlDMVoIPSettingIdsNode() == secondLastUriSeg  
       
  2025         && KFourSegs == NumOfURISegs( aURI ) 
       
  2026         && aLUID.Find( KNSmlDMVoIPSettingId ) != KErrNotFound )
       
  2027         {
       
  2028         iProfileEntries[iProfileID]->iIds.Remove( 
       
  2029             DesToInt( aLUID.Right( 10 ) ) );
       
  2030         iProfileEntries[iProfileID]->iIds.Compress();
       
  2031         iCRCSEProfile->UpdateL( iProfileEntries[iProfileID]->
       
  2032             iId, *iProfileEntries[iProfileID] );
       
  2033         retValue = CSmlDmAdapter::EOk;
       
  2034         }
       
  2035 
       
  2036     // ==============================
       
  2037     // VoIP/x/CodecSettings/x/ModeSet Node ( delete ) 
       
  2038     // ==============================
       
  2039     //
       
  2040     else if ( KNSmlDMVoIPModeSetNode() == secondLastUriSeg 
       
  2041         && KSixSegs == NumOfURISegs( aURI )  
       
  2042         && aLUID.Find( KNSmlDMVoIPModeId ) != KErrNotFound )
       
  2043         {
       
  2044         // get codecid used by this setting
       
  2045         TUint32 codecId = DesToInt( RemoveLastURISeg( aLUID ).Right( 10 ) );
       
  2046         TInt codecPos = FindCodecLocation( codecId );
       
  2047         if ( KErrNotFound != codecPos )
       
  2048             {
       
  2049             // remove modeset from iCodecEntries    
       
  2050             iCodecEntries[codecPos]->
       
  2051                 iModeSet.Remove( DesToInt( aLUID.Right( 10 ) ) );
       
  2052             iCodecEntries[codecPos]->
       
  2053                 iModeSet.Compress();
       
  2054 
       
  2055             // update changes also to rcse    
       
  2056             iCRCSEAudioCodec->UpdateL( codecId, *iCodecEntries[codecPos] );
       
  2057             iDmCallback->SetMappingL( aURI, KNullDesC8 );     
       
  2058             retValue = CSmlDmAdapter::EOk;
       
  2059             }
       
  2060         else
       
  2061             {
       
  2062             retValue = CSmlDmAdapter::EError;   
       
  2063             }
       
  2064         }
       
  2065     else
       
  2066         {
       
  2067         retValue = CSmlDmAdapter::EInvalidObject;
       
  2068         }
       
  2069     iDmCallback->SetStatusL( aStatusRef, retValue ); 
       
  2070     DBG_PRINT("CNSmlDmVoIPAdapter::DeleteObjectL( ): end");
       
  2071     }
       
  2072 
       
  2073 // ---------------------------------------------------------------------------
       
  2074 // CNSmlDmVoIPAdapter::FetchLeafObjectL
       
  2075 // Fetches the values of leaf objects.
       
  2076 // ---------------------------------------------------------------------------
       
  2077 //
       
  2078 void CNSmlDmVoIPAdapter::FetchLeafObjectL( 
       
  2079     const TDesC8& aURI, 
       
  2080     const TDesC8& aLUID, 
       
  2081     const TDesC8& aType, 
       
  2082     const TInt aResultsRef, 
       
  2083     const TInt aStatusRef )
       
  2084     {
       
  2085     DBG_PRINT("CNSmlDmVoIPAdapter::FetchLeafObjectL(): begin");
       
  2086 
       
  2087     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  2088 
       
  2089     // Load VoIP profile information if not loaded yet
       
  2090     if ( !iProfileEntries.Count() )
       
  2091         {
       
  2092         LoadProfilesL();
       
  2093         }  
       
  2094 
       
  2095     CBufBase *result = CBufFlat::NewL( KDefaultResultSize );
       
  2096     CleanupStack::PushL( result );
       
  2097     CSmlDmAdapter::TError status = FetchObjectL( aURI, aLUID, *result );
       
  2098 
       
  2099     if ( CSmlDmAdapter::EOk == status )
       
  2100         {
       
  2101         iDmCallback->SetResultsL( aResultsRef, *result, aType );
       
  2102         }
       
  2103     iDmCallback->SetStatusL( aStatusRef, status );
       
  2104 
       
  2105     CleanupStack::PopAndDestroy( result ); //result
       
  2106     result = NULL;
       
  2107     DBG_PRINT("CNSmlDmVoIPAdapter::FetchLeafObjectL(): end");
       
  2108     }
       
  2109 
       
  2110 // ---------------------------------------------------------------------------
       
  2111 // CNSmlDmVoIPAdapter::FetchObjectL()
       
  2112 // Fetches the values of leaf objects.
       
  2113 // ---------------------------------------------------------------------------
       
  2114 //
       
  2115 CSmlDmAdapter::TError CNSmlDmVoIPAdapter::FetchObjectL( 
       
  2116     const TDesC8& aURI, const TDesC8& aLUID,
       
  2117     CBufBase& result )
       
  2118     {
       
  2119     DBG_PRINT("CNSmlDmVoIPAdapter::FetchObjectL(): start");
       
  2120     CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
       
  2121     typedef CRCSEProfileEntry Entry;
       
  2122 
       
  2123     // Check that LUID mapping exists.
       
  2124     if ( !aLUID.Length() > 0 )
       
  2125         {
       
  2126         DBG_PRINT("CNSmlDmVoIPAdapter::FetchLeafObjectL(internal)()():ENotFound end");
       
  2127         return CSmlDmAdapter::ENotFound;
       
  2128         }
       
  2129 
       
  2130     TBuf8<KNSmlVoIPMaxResultLength> segmentResult;
       
  2131     TPtrC8 uriSeg = LastURISeg( aURI );
       
  2132 
       
  2133     TPtrC8 uriTmp = RemoveLastURISeg( aURI );
       
  2134     TPtrC8 secondLastUriSeg = LastURISeg( uriTmp );
       
  2135 
       
  2136     // Find profile and get its settings.
       
  2137     iProfileID = FindProfileLocation( aLUID );
       
  2138 
       
  2139     // If profile is not found return error.
       
  2140     if ( KErrNotFound == iProfileID )
       
  2141         {
       
  2142         DBG_PRINT( "CNSmlDmVoIPAdapter::FetchObjectL(): ENotFound end" );
       
  2143         return CSmlDmAdapter::ENotFound;
       
  2144         }
       
  2145 
       
  2146     // Set SPS ready for getting values.
       
  2147     CSPSettings* spSettings = CSPSettings::NewLC(); // CS:1
       
  2148     TUint32 serviceId = iProfileEntries[iProfileID]->iServiceProviderId;
       
  2149 
       
  2150     //VoIP/x/VoIPId
       
  2151     if ( KNSmlDMVoIPSetID() == uriSeg )
       
  2152         {
       
  2153         segmentResult.AppendNumFixedWidthUC( 
       
  2154             iProfileEntries[iProfileID]->iId, EDecimal, 10 );
       
  2155         }
       
  2156     //VoIP/x/ProviderName
       
  2157     else if ( KNSmlDMVoIPProvID() == uriSeg )
       
  2158         {
       
  2159         segmentResult.Copy( iProfileEntries[iProfileID]->
       
  2160             iProviderName );
       
  2161         }
       
  2162     //VoIP/x/SettingsName
       
  2163     else if ( KNSmlDMVoIPName() == uriSeg )
       
  2164         {
       
  2165         segmentResult.Copy( iProfileEntries[iProfileID]->
       
  2166             iSettingsName );
       
  2167         }
       
  2168     //VoIP/x/SMPort
       
  2169     else if ( KNSmlDMVoIPSMPort() == uriSeg )
       
  2170         {
       
  2171         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2172             iStartMediaPort );
       
  2173         }
       
  2174     //VoIP/x/EMPort
       
  2175     else if ( KNSmlDMVoIPEMPort() == uriSeg )
       
  2176         {
       
  2177         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2178             iEndMediaPort );
       
  2179         }
       
  2180     //VoIP/x/MediaQos
       
  2181     else if ( KNSmlDMVoIPMediaQos() == uriSeg )
       
  2182         {
       
  2183         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2184             iMediaQOS );
       
  2185         }
       
  2186     //VoIP/x/DTMFIB
       
  2187     else if ( KNSmlDMVoIPDTMFIB() == uriSeg )
       
  2188         {
       
  2189         if ( Entry::EOONotSet == iProfileEntries[iProfileID]->
       
  2190             iInbandDTMF )
       
  2191             {
       
  2192             segmentResult.Copy( KNSmlDMVoIPValueNotSet );
       
  2193             }
       
  2194         if ( Entry::EOn == iProfileEntries[iProfileID]->iInbandDTMF )
       
  2195             {
       
  2196             segmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2197             }
       
  2198         if ( Entry::EOff == iProfileEntries[iProfileID]->iInbandDTMF )
       
  2199             {
       
  2200             segmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2201             }
       
  2202         }
       
  2203     //VoIP/x/DTMFOB
       
  2204     else if ( KNSmlDMVoIPDTMFOB() == uriSeg )
       
  2205         {
       
  2206         if ( Entry::EOONotSet == iProfileEntries[iProfileID]->
       
  2207             iOutbandDTMF )
       
  2208             {
       
  2209             segmentResult.Copy( KNSmlDMVoIPValueNotSet );
       
  2210             }
       
  2211         if ( Entry::EOff == iProfileEntries[iProfileID]->iOutbandDTMF )
       
  2212             {
       
  2213             segmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2214             }
       
  2215         if ( Entry::EOn == iProfileEntries[iProfileID]->iOutbandDTMF )
       
  2216             {
       
  2217             segmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2218             }
       
  2219         }
       
  2220     // VoIP/x/SecureCallPref
       
  2221     else if ( KNSmlDMVoIPSecureCallPref() == uriSeg )
       
  2222         {
       
  2223         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2224             iSecureCallPreference );
       
  2225         }
       
  2226     // VoIP/x/RTCP
       
  2227     else if ( KNSmlDMVoIPRTCP() == uriSeg )
       
  2228         {
       
  2229         segmentResult.Num( iProfileEntries[iProfileID]->iRTCP );
       
  2230         }
       
  2231    // VoIP/x/UAHTerminalType
       
  2232     else if ( KNSmlDMVoIPUAHTerminalType() == uriSeg )
       
  2233         {
       
  2234         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2235             iSIPVoIPUAHTerminalType );
       
  2236         }
       
  2237     // VoIP/x/UAHWLANMAC
       
  2238     else if ( KNSmlDMVoIPUAHWLANMAC() == uriSeg )
       
  2239         {
       
  2240         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2241             iSIPVoIPUAHeaderWLANMAC );
       
  2242         }
       
  2243     // VoIP/x/UAHString
       
  2244     else if ( KNSmlDMVoIPUAHString() == uriSeg )
       
  2245         {
       
  2246         segmentResult.Copy( iProfileEntries[iProfileID]->
       
  2247             iSIPVoIPUAHeaderString );
       
  2248         }
       
  2249     // VoIP/x/ProfileLockedToIAP
       
  2250     else if ( KNSmlDMVoIPProfileLockedToIAP() == uriSeg )
       
  2251         {
       
  2252         if ( Entry::EOONotSet == iProfileEntries[iProfileID]->
       
  2253             iProfileLockedToIAP )
       
  2254             {
       
  2255             segmentResult.Copy( KNSmlDMVoIPValueNotSet );
       
  2256             }
       
  2257         if ( Entry::EOn == iProfileEntries[iProfileID]->
       
  2258             iProfileLockedToIAP )
       
  2259             {
       
  2260             segmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2261             }
       
  2262         if ( Entry::EOff == iProfileEntries[iProfileID]->
       
  2263             iProfileLockedToIAP )
       
  2264             {
       
  2265             segmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2266             }
       
  2267         }
       
  2268     // VoIP/x/VoIPPluginUID
       
  2269     else if ( KNSmlDMVoIPPluginUID() == uriSeg )
       
  2270         {
       
  2271         segmentResult.Num( iProfileEntries[iProfileID]->iVoIPPluginUID );
       
  2272         }
       
  2273     // VoIP/x/AllowVoIPOverWCDMA
       
  2274     else if ( KNSmlDMVoIPAllowVoIPOverWCDMA() == uriSeg )
       
  2275         {
       
  2276         if ( Entry::EOONotSet == iProfileEntries[iProfileID]->
       
  2277             iAllowVoIPoverWCDMA )
       
  2278             {
       
  2279             segmentResult.Copy( KNSmlDMVoIPValueNotSet );
       
  2280             }
       
  2281         if ( Entry::EOn == iProfileEntries[iProfileID]->
       
  2282             iAllowVoIPoverWCDMA )
       
  2283             {
       
  2284             segmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2285             }
       
  2286         if ( Entry::EOff == iProfileEntries[iProfileID]->
       
  2287             iAllowVoIPoverWCDMA )
       
  2288             {
       
  2289             segmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2290             }
       
  2291         }
       
  2292     // VoIP/x/VoIPDigits
       
  2293     else if ( KNSmlDMVoIPVoIPDigits() == uriSeg )
       
  2294         {
       
  2295         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2296             iMeanCountOfVoIPDigits );
       
  2297         }
       
  2298     // VoIP/x/URIDomainIgnoreRule
       
  2299     else if ( KNSmlDMVoIPURIDomainIgnoreRule() == uriSeg )
       
  2300         {
       
  2301         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2302             iIgnoreAddrDomainPart );
       
  2303         }
       
  2304     // VoIP/x/AutoAcceptBuddyRequest
       
  2305     else if ( KNSmlDMVoIPAutoAcceptBuddyRequest() == uriSeg )
       
  2306         {
       
  2307         CSPProperty* autoAcceptBuddy = CSPProperty::NewLC();
       
  2308         TInt err = spSettings->FindPropertyL( serviceId, 
       
  2309             ESubPropertyPresenceRequestPreference, *autoAcceptBuddy );
       
  2310         if ( KErrNone != err )
       
  2311             {
       
  2312             retValue = CSmlDmAdapter::EError;
       
  2313             }
       
  2314         else
       
  2315             {
       
  2316             TInt autoAccept;
       
  2317             err = autoAcceptBuddy->GetValue( autoAccept );
       
  2318             if ( KErrNone == err )
       
  2319                 {
       
  2320                 segmentResult.Num( autoAccept );
       
  2321                 }
       
  2322             else
       
  2323                 {
       
  2324                 retValue = CSmlDmAdapter::EError;
       
  2325                 }
       
  2326             }
       
  2327         CleanupStack::PopAndDestroy( autoAcceptBuddy );
       
  2328         }
       
  2329     // VoIP/x/UsedVoIPRelease
       
  2330     else if ( KNSmlDMVoIPUsedVoIPRelease() == uriSeg )
       
  2331         {
       
  2332         TBuf16<KMaxUriLength> voipRelease( KNullDesC16 );
       
  2333         voipRelease.Copy( spSettings->GetSIPVoIPSWVersion() );
       
  2334         if ( !voipRelease.Length() )
       
  2335             {
       
  2336             retValue = CSmlDmAdapter::EError;
       
  2337             }
       
  2338         else
       
  2339             {
       
  2340             segmentResult.Copy( voipRelease );
       
  2341             }
       
  2342         }
       
  2343     // VoIP/x/AddUserPhone
       
  2344     else if ( KNSmlDMVoIPAddUserPhone() == uriSeg )
       
  2345         {
       
  2346         if ( Entry::EOONotSet == iProfileEntries[iProfileID]->
       
  2347             iUserPhoneUriParameter )
       
  2348             {
       
  2349             segmentResult.Copy( KNSmlDMVoIPValueNotSet );
       
  2350             }
       
  2351         else if ( Entry::EOn == iProfileEntries[iProfileID]->
       
  2352             iUserPhoneUriParameter )
       
  2353             {
       
  2354             segmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2355             }
       
  2356         else if ( Entry::EOff == iProfileEntries[iProfileID]->
       
  2357             iUserPhoneUriParameter )
       
  2358             {
       
  2359             segmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2360             }
       
  2361         }
       
  2362     // VoIP/x/ProviderBookmarkURI
       
  2363     else if ( KNSmlDMVoIPProviderBookmarkUri() == uriSeg )
       
  2364         {
       
  2365         CSPProperty* providerBkmark = CSPProperty::NewLC();
       
  2366         TInt err = spSettings->FindPropertyL( serviceId, 
       
  2367             EPropertyServiceBookmarkUri, *providerBkmark );
       
  2368         if ( KErrNone != err )
       
  2369             {
       
  2370             retValue = CSmlDmAdapter::EError;
       
  2371             }
       
  2372         else
       
  2373             {
       
  2374             TBuf16<KNSmlVoIPMaxUriLength> bkmark;
       
  2375             err = providerBkmark->GetValue( bkmark );
       
  2376             if ( KErrNone == err )
       
  2377                 {
       
  2378                 segmentResult.Copy( bkmark );
       
  2379                 }
       
  2380             else
       
  2381                 {
       
  2382                 retValue = CSmlDmAdapter::EError;
       
  2383                 }
       
  2384             }
       
  2385         CleanupStack::PopAndDestroy( providerBkmark );
       
  2386         }
       
  2387     // VoIP/x/SIPConnectivityTestURI
       
  2388     else if ( KNSmlDMVoIPSIPConnTestUri() == uriSeg )
       
  2389         {
       
  2390         segmentResult.Copy( iProfileEntries[iProfileID]->
       
  2391             iSIPConnTestAddress );
       
  2392         }
       
  2393     // VoIP/x/NATFWProfileId
       
  2394     else if ( KNSmlDMVoIPNatFwProfileId() == uriSeg )
       
  2395         {
       
  2396         TBuf16<KMaxUriLength> natfwProfile;
       
  2397         retValue = GetNatFwUriL( natfwProfile, 
       
  2398             iProfileEntries[iProfileID]->iNATSettingsStorageId );
       
  2399         if ( CSmlDmAdapter::EOk == retValue )
       
  2400             {
       
  2401             segmentResult.Copy( natfwProfile );
       
  2402             }
       
  2403         }
       
  2404     // VoIP/x/MinSessionInterval
       
  2405     else if ( KNSmlDMVoIPMinSessionInterval() == uriSeg )
       
  2406         {
       
  2407         segmentResult.Num( iProfileEntries[iProfileID]->iSIPMinSE );
       
  2408         }
       
  2409     // VoIP/x/SessionExpires
       
  2410     else if ( KNSmlDMVoIPSessionExpires() == uriSeg )
       
  2411         {
       
  2412         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2413             iSIPSessionExpires );
       
  2414         }
       
  2415     // VoIP/x/BradingDataURI
       
  2416     else if ( KNSmlDMVoIPBrandingDataUri() == uriSeg )
       
  2417         {
       
  2418         CSPProperty* brandingUri = CSPProperty::NewLC();
       
  2419         TInt err = spSettings->FindPropertyL( serviceId, 
       
  2420             ESubPropertyVoIPBrandDataUri, *brandingUri );
       
  2421         if ( KErrNone != err )
       
  2422             {
       
  2423             retValue = CSmlDmAdapter::EError;
       
  2424             }
       
  2425         else
       
  2426             {
       
  2427             TBuf16<KNSmlVoIPMaxUriLength> brandUri;
       
  2428             err = brandingUri->GetValue( brandUri );
       
  2429             if ( KErrNone == err )
       
  2430                 {
       
  2431                 segmentResult.Copy( brandUri );
       
  2432                 }
       
  2433             else
       
  2434                 {
       
  2435                 retValue = CSmlDmAdapter::EError;
       
  2436                 }
       
  2437             }
       
  2438         CleanupStack::PopAndDestroy( brandingUri );
       
  2439         }
       
  2440     // VoIP/x/PresenceSettingsId
       
  2441     else if ( KNSmlDMVoIPPresenceSettingsId() == uriSeg )
       
  2442         {
       
  2443         CSPProperty* presenceId = CSPProperty::NewLC();
       
  2444         TInt err = spSettings->FindPropertyL( serviceId, 
       
  2445             ESubPropertyPresenceSettingsId, *presenceId );
       
  2446         if ( KErrNone != err )
       
  2447             {
       
  2448             retValue = CSmlDmAdapter::EError;
       
  2449             }
       
  2450         else
       
  2451             {
       
  2452             TInt presId;
       
  2453             err = presenceId->GetValue( presId );
       
  2454             if ( KErrNone == err )
       
  2455                 {
       
  2456                 TBuf16<KMaxUriLength> presenceUri;
       
  2457                 retValue = GetPresenceUriL( presenceUri, (TUint32)presId );
       
  2458                 if ( EOk == retValue )
       
  2459                     {
       
  2460                     segmentResult.Copy( presenceUri );
       
  2461                     }
       
  2462                 }
       
  2463             else
       
  2464                 {
       
  2465                 retValue = CSmlDmAdapter::EError;
       
  2466                 }
       
  2467             }
       
  2468         CleanupStack::PopAndDestroy( presenceId );
       
  2469         }
       
  2470     // VoIP/x/UsedNATProtocol
       
  2471     else if ( KNSmlDMVoIPUsedNatProtocol() == uriSeg )
       
  2472         {
       
  2473         segmentResult.Num( iProfileEntries[iProfileID]->iNATProtocol );
       
  2474         }
       
  2475     // VoIP/x/AutoEnable
       
  2476     else if ( KNSmlDMVoIPAutoEnable() == uriSeg )
       
  2477         {
       
  2478         CSPProperty* autoEnableService = CSPProperty::NewLC();
       
  2479         TInt err = spSettings->FindPropertyL( serviceId, 
       
  2480             ESubPropertyVoIPEnabled, *autoEnableService );
       
  2481         if ( KErrNone != err )
       
  2482             {
       
  2483             retValue = CSmlDmAdapter::EError;
       
  2484             }
       
  2485         else
       
  2486             {
       
  2487             TInt autoEnable;
       
  2488             err = autoEnableService->GetValue( autoEnable );
       
  2489             if ( KErrNone == err )
       
  2490                 {
       
  2491                 segmentResult.Num( autoEnable );
       
  2492                 }
       
  2493             else
       
  2494                 {
       
  2495                 retValue = CSmlDmAdapter::EError;
       
  2496                 }
       
  2497             }
       
  2498         CleanupStack::PopAndDestroy( autoEnableService );
       
  2499         }
       
  2500     // VoIP/x/SnapProfileId
       
  2501     else if ( KNSmlDMVoIPSnapProfileId() == uriSeg )
       
  2502         {
       
  2503         CSPProperty* snapProfileId = CSPProperty::NewLC();
       
  2504         TInt err = spSettings->FindPropertyL( serviceId, 
       
  2505             ESubPropertyVoIPPreferredSNAPId, *snapProfileId );
       
  2506         if ( KErrNone != err )
       
  2507             {
       
  2508             retValue = CSmlDmAdapter::EError;
       
  2509             }
       
  2510         else
       
  2511             {
       
  2512             TInt snapId;
       
  2513             err = snapProfileId->GetValue( snapId );
       
  2514             if ( KErrNone == err )
       
  2515                 {
       
  2516                 TBuf8<KMaxUriLength> snapUri;
       
  2517                 retValue = GetSnapUriL( snapUri, (TUint32)snapId );
       
  2518                 if ( EOk == retValue )
       
  2519                     {
       
  2520                     segmentResult.Copy( snapUri );
       
  2521                     }
       
  2522                 }
       
  2523             else
       
  2524                 {
       
  2525                 retValue = CSmlDmAdapter::EError;
       
  2526                 }
       
  2527             }
       
  2528         CleanupStack::PopAndDestroy( snapProfileId );
       
  2529         }
       
  2530     // VoIP/x/EnableIM
       
  2531     else if ( KNSmlDMVoIPEnableIm() == uriSeg )
       
  2532         {
       
  2533         CSPProperty* enableIm = CSPProperty::NewLC();
       
  2534         TInt err = spSettings->FindPropertyL( serviceId, 
       
  2535             ESubPropertyIMEnabled, *enableIm );
       
  2536         if ( KErrNotFound == err )
       
  2537             {
       
  2538             segmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2539             }
       
  2540         else if ( KErrNone != err )
       
  2541             {
       
  2542             retValue = CSmlDmAdapter::EError;
       
  2543             }
       
  2544         else
       
  2545             {
       
  2546             TInt enableValue;
       
  2547             err = enableIm->GetValue( enableValue );
       
  2548             if ( KErrNone == err && 0 < enableValue )
       
  2549                 {
       
  2550                 segmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2551                 }
       
  2552             else if ( KErrNone == err && !enableValue )
       
  2553                 {
       
  2554                 segmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2555                 }
       
  2556             else
       
  2557                 {
       
  2558                 retValue = CSmlDmAdapter::EError;
       
  2559                 }
       
  2560             }
       
  2561         CleanupStack::PopAndDestroy( enableIm );
       
  2562         }
       
  2563 
       
  2564     // ==============================
       
  2565     // CodecSettings node ( fetch )
       
  2566     // ==============================
       
  2567     //
       
  2568     // VoIP/x/PreferredCodecs node
       
  2569     if ( KNSmlDMVoIPPreferredCodecId() == uriSeg.Left(
       
  2570         KNSmlDMVoIPPreferredCodecId().Length() ) ) 
       
  2571         {
       
  2572         TInt preferredPos = DesToInt( LastURISeg( aLUID ).Right( 10 ) );
       
  2573         segmentResult.Num( iProfileEntries[iProfileID]->
       
  2574             iPreferredCodecs[preferredPos]);
       
  2575         }
       
  2576 
       
  2577     // VoIP/x/CodecSettings node    
       
  2578     if ( KNSmlDMVoIPCodecSettingsId() == LastURISeg( aLUID ).
       
  2579         Left( KNSmlDMVoIPCodecSettingsId().Length() )
       
  2580         && KFiveSegs == NumOfURISegs( aURI ) )
       
  2581         {
       
  2582         retValue = FetchCodecObject( aLUID, uriSeg, segmentResult );
       
  2583         }
       
  2584 
       
  2585     // ==============================
       
  2586     // SettingIds node ( fetch )
       
  2587     // ==============================
       
  2588     //
       
  2589     if ( KNSmlDMVoIPSettingId() == LastURISeg( aLUID ).
       
  2590         Left( KNSmlDMVoIPSettingId().Length() ) 
       
  2591         && KFiveSegs == NumOfURISegs( aURI ) )
       
  2592         {
       
  2593 
       
  2594         //ProfileType
       
  2595         if ( KNSmlDMVoIPProfileType() == uriSeg )
       
  2596             {
       
  2597             if ( 0 == iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  2598                 LastURISeg( aLUID ).Right( 10 ))].iProfileType )
       
  2599                 {
       
  2600                 segmentResult.Copy( KNSmlDMVoIPProfileTypeSIP );
       
  2601                 }
       
  2602             if ( 1 == iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  2603                 LastURISeg( aLUID ).Right( 10 ))].iProfileType )
       
  2604                 {
       
  2605                 segmentResult.Copy( KNSmlDMVoIPProfileTypeSCCP );
       
  2606                 }
       
  2607             }
       
  2608 
       
  2609         // ProfileId
       
  2610         if ( KNSmlDMVoIPProfileId() == uriSeg )
       
  2611             {
       
  2612             if ( 0 == iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  2613                 LastURISeg( aLUID ).Right( 10 ))].iProfileType )
       
  2614                 {
       
  2615                 retValue = GetSipIdL( result, iProfileEntries[iProfileID]->
       
  2616                     iIds[DesToInt( LastURISeg( aLUID ).Right( 10 ))].
       
  2617                     iProfileId );
       
  2618                 }
       
  2619             if ( 1 == iProfileEntries[iProfileID]->iIds[DesToInt( 
       
  2620                 LastURISeg( aLUID ).Right( 10 ))].iProfileType )
       
  2621                 {
       
  2622                 // Get SCCP ID from sccp adapter if exists
       
  2623                 retValue = GetSccpIdL( result, iProfileEntries[iProfileID]->
       
  2624                     iIds[DesToInt( LastURISeg( aLUID ).Right( 10 ))].
       
  2625                     iProfileId );
       
  2626                 }
       
  2627             }
       
  2628 
       
  2629         // ProfileSpecificId
       
  2630         if ( KNSmlDMVoIPProfileSpecificId() == uriSeg )
       
  2631             {
       
  2632             segmentResult.Num( iProfileEntries[iProfileID]->iIds[
       
  2633                 DesToInt( LastURISeg( aLUID ).Right( 10 ) ) ].
       
  2634                 iProfileSpecificSettingId );
       
  2635             }
       
  2636         }
       
  2637 
       
  2638     // ==============================
       
  2639     // VoiceMailBox node (fetch)
       
  2640     // ==============================
       
  2641     //
       
  2642     if ( KNSmlDMVoIPVmbxNode() == secondLastUriSeg &&
       
  2643         KFourSegs == NumOfURISegs( aURI ) )
       
  2644         {
       
  2645         // VoIP/x/VoiceMailBox/MWI-URI
       
  2646         if ( KNSmlDMVoIPMwiUri() == uriSeg )
       
  2647             {
       
  2648             CSPProperty* mwiUri = CSPProperty::NewLC();
       
  2649             TInt err = spSettings->FindPropertyL( serviceId, 
       
  2650                 ESubPropertyVMBXMWIAddress, *mwiUri );
       
  2651             if ( KErrNone != err )
       
  2652                 {
       
  2653                 retValue = CSmlDmAdapter::EError;
       
  2654                 }
       
  2655             else
       
  2656                 {
       
  2657                 TBuf16<KNSmlVoIPMaxUriLength> mwiAddr;
       
  2658                 err = mwiUri->GetValue( mwiAddr );
       
  2659                 if ( KErrNone == err )
       
  2660                     {
       
  2661                     segmentResult.Copy( mwiAddr );
       
  2662                     }
       
  2663                 else
       
  2664                     {
       
  2665                     retValue = CSmlDmAdapter::EError;
       
  2666                     }
       
  2667                 }
       
  2668             CleanupStack::PopAndDestroy( mwiUri );
       
  2669             }
       
  2670 
       
  2671         // VoIP/x/VoiceMailBox/ListeningURI
       
  2672         if ( KNSmlDMVoIPListeningUri() == uriSeg )
       
  2673             {
       
  2674             CSPProperty* listeningUri = CSPProperty::NewLC();
       
  2675             TInt err = spSettings->FindPropertyL( serviceId, 
       
  2676                 ESubPropertyVMBXListenAddress, *listeningUri );
       
  2677             if ( KErrNone != err )
       
  2678                 {
       
  2679                 retValue = CSmlDmAdapter::EError;
       
  2680                 }
       
  2681             else
       
  2682                 {
       
  2683                 TBuf16<KNSmlVoIPMaxUriLength> listenUri;
       
  2684                 err = listeningUri->GetValue( listenUri );
       
  2685                 if ( KErrNone == err )
       
  2686                     {
       
  2687                     segmentResult.Copy( listenUri );
       
  2688                     }
       
  2689                 else
       
  2690                     {
       
  2691                     retValue = CSmlDmAdapter::EError;
       
  2692                     }
       
  2693                 }
       
  2694             CleanupStack::PopAndDestroy( listeningUri );
       
  2695             }
       
  2696 
       
  2697         // VoIP/x/VoiceMailBox/UsedIAPId
       
  2698         if ( KNSmlDMVoIPUsedIAPId() == uriSeg )
       
  2699             {
       
  2700             CSPProperty* iapId = CSPProperty::NewLC();
       
  2701             TInt err = spSettings->FindPropertyL( serviceId, 
       
  2702                 ESubPropertyVMBXPreferredIAPId, *iapId );
       
  2703             if ( KErrNone != err )
       
  2704                 {
       
  2705                 retValue = CSmlDmAdapter::EError;
       
  2706                 }
       
  2707             else
       
  2708                 {
       
  2709                 TInt iap;
       
  2710                 err = iapId->GetValue( iap );
       
  2711                 if ( KErrNone == err )
       
  2712                     {
       
  2713                     retValue = GetConRefL( result, iap );
       
  2714                     if ( CSmlDmAdapter::EOk != retValue )
       
  2715                         {
       
  2716                         result.Reset();
       
  2717                         }
       
  2718                     }
       
  2719                 else
       
  2720                     {
       
  2721                     retValue = CSmlDmAdapter::EError;
       
  2722                     }
       
  2723                 
       
  2724                 }
       
  2725             CleanupStack::PopAndDestroy( iapId );
       
  2726             }
       
  2727 
       
  2728         // VoIP/x/VoiceMailBox/ReSubscribeInterval
       
  2729         if ( KNSmlDMVoIPReSubscribeInterval() == uriSeg )
       
  2730             {
       
  2731             CSPProperty* reSubscrInterval = CSPProperty::NewLC();
       
  2732             TInt err = spSettings->FindPropertyL( serviceId, 
       
  2733                 ESubPropertyVMBXMWISubscribeInterval, *reSubscrInterval );
       
  2734             if ( KErrNone != err )
       
  2735                 {
       
  2736                 retValue = CSmlDmAdapter::EError;
       
  2737                 }
       
  2738             else
       
  2739                 {
       
  2740                 TInt reSubscribe;
       
  2741                 err = reSubscrInterval->GetValue( reSubscribe );
       
  2742                 if ( KErrNone == err )
       
  2743                     {
       
  2744                     segmentResult.Num( reSubscribe );
       
  2745                     }
       
  2746                 else
       
  2747                     {
       
  2748                     retValue = CSmlDmAdapter::EError;
       
  2749                     }
       
  2750                 }
       
  2751             CleanupStack::PopAndDestroy( reSubscrInterval );
       
  2752             }
       
  2753 
       
  2754         // VoIP/x/VoiceMailBox/UsedSIPProfileId
       
  2755         if ( KNSmlDMVoIPUsedSIPProfileId() == uriSeg )
       
  2756             {
       
  2757             CSPProperty* sipProfileId = CSPProperty::NewLC();
       
  2758             TInt err = spSettings->FindPropertyL( serviceId, 
       
  2759                 ESubPropertyVMBXSettingsId, *sipProfileId );
       
  2760             if ( KErrNone != err )
       
  2761                 {
       
  2762                 retValue = CSmlDmAdapter::EError;
       
  2763                 }
       
  2764             else
       
  2765                 {
       
  2766                 TInt sipId;
       
  2767                 err = sipProfileId->GetValue( sipId );
       
  2768                 if ( KErrNone == err )
       
  2769                     {
       
  2770                     retValue = GetSipIdL( result, sipId );
       
  2771                     if ( CSmlDmAdapter::EOk != retValue )
       
  2772                         {
       
  2773                         result.Reset();
       
  2774                         }
       
  2775                     }
       
  2776                 else
       
  2777                     {
       
  2778                     retValue = CSmlDmAdapter::EError;
       
  2779                     }
       
  2780                 }
       
  2781             CleanupStack::PopAndDestroy( sipProfileId );
       
  2782             }
       
  2783         }
       
  2784 
       
  2785     result.InsertL( result.Size(), segmentResult );       
       
  2786     CleanupStack::PopAndDestroy( spSettings );
       
  2787 
       
  2788     DBG_PRINT("CNSmlDmVoIPAdapter::FetchObjectL(): end");
       
  2789     return retValue;
       
  2790     }
       
  2791 
       
  2792 // ---------------------------------------------------------------------------
       
  2793 // CNSmlDmVoIPAdapter::FetchCodecObject
       
  2794 // Fetches the values of Codec specific leaf objects.
       
  2795 // ---------------------------------------------------------------------------
       
  2796 //
       
  2797 CSmlDmAdapter::TError CNSmlDmVoIPAdapter::FetchCodecObject( 
       
  2798     const TDesC8& aLUID, const TDesC8& aUriSeg, TDes8& aSegmentResult )
       
  2799     {
       
  2800     DBG_PRINT("CNSmlDmVoIPAdapter::FetchCodecObject(): begin");
       
  2801     
       
  2802     CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
       
  2803 
       
  2804     TUint32 codecId = DesToInt( aLUID.Right( 10 ) );
       
  2805     TInt codecPos = FindCodecLocation( codecId );
       
  2806     if ( KErrNotFound != codecPos )
       
  2807         {
       
  2808         //CodecId
       
  2809         if ( KNSmlDMVoIPCodecId() == aUriSeg ) 
       
  2810             {
       
  2811             aSegmentResult.Num ( iCodecEntries[codecPos]->iCodecId );
       
  2812             }
       
  2813         //MediaTypeName
       
  2814         if ( KNSmlDMVoIPMediaTypeName() == aUriSeg ) 
       
  2815             {
       
  2816             aSegmentResult.Copy ( iCodecEntries[codecPos]->
       
  2817                 iMediaTypeName );
       
  2818             }
       
  2819         //MediaSubTypeName
       
  2820         if ( KNSmlDMVoIPMediaSubTypeName() == aUriSeg ) 
       
  2821             {
       
  2822             aSegmentResult.Copy ( iCodecEntries[codecPos]->
       
  2823                 iMediaSubTypeName );
       
  2824             }
       
  2825         //JitterBufferSize
       
  2826         if ( KNSmlDMVoIPJitterBufferSize() == aUriSeg ) 
       
  2827             {
       
  2828             if ( KNotSet < iCodecEntries[codecPos]->iJitterBufferSize )
       
  2829                 {
       
  2830                 aSegmentResult.Num ( iCodecEntries[codecPos]->
       
  2831                     iJitterBufferSize );
       
  2832                 }
       
  2833             }
       
  2834         //OctetAlign            
       
  2835         if ( KNSmlDMVoIPOctetAlign() == aUriSeg ) 
       
  2836             {
       
  2837             if ( CRCSEAudioCodecEntry::EOn == 
       
  2838                 iCodecEntries[codecPos]->iOctetAlign )
       
  2839                 {
       
  2840                 aSegmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2841                 }
       
  2842             if ( CRCSEAudioCodecEntry::EOff == 
       
  2843                 iCodecEntries[codecPos]->iOctetAlign )
       
  2844                 {
       
  2845                 aSegmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2846                 }
       
  2847             }
       
  2848         //ModeChangePeriod
       
  2849         if ( KNSmlDMVoIPModeChangePeriod() == aUriSeg ) 
       
  2850             {
       
  2851             if ( KNotSet < iCodecEntries[codecPos]->
       
  2852                 iModeChangePeriod )
       
  2853                 {
       
  2854                 aSegmentResult.Num( iCodecEntries[codecPos]->
       
  2855                     iModeChangePeriod );
       
  2856                 }
       
  2857             }
       
  2858         //ModeChangeNeighbor          
       
  2859         if ( KNSmlDMVoIPModeChangeNeighbor() == aUriSeg ) 
       
  2860             {
       
  2861             if ( CRCSEAudioCodecEntry::EOn == 
       
  2862                 iCodecEntries[codecPos]->iModeChangeNeighbor )
       
  2863                 {
       
  2864                 aSegmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2865                 }
       
  2866             if ( CRCSEAudioCodecEntry::EOff == 
       
  2867                 iCodecEntries[codecPos]->iModeChangeNeighbor )
       
  2868                 {
       
  2869                 aSegmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2870                 }
       
  2871             }
       
  2872         //Ptime
       
  2873         if ( KNSmlDMVoIPPtime() == aUriSeg )  
       
  2874             {
       
  2875             if ( KNotSet < iCodecEntries[codecPos]->iPtime )
       
  2876                 {
       
  2877                 aSegmentResult.Num( iCodecEntries[codecPos]->iPtime );
       
  2878                 }
       
  2879             }
       
  2880         //Maxptime
       
  2881         if ( KNSmlDMVoIPMaxPtime() == aUriSeg ) 
       
  2882             {
       
  2883             if ( KNotSet < iCodecEntries[codecPos]->iMaxptime )
       
  2884                 {
       
  2885                 aSegmentResult.Num( 
       
  2886                     iCodecEntries[codecPos]->iMaxptime );
       
  2887                 }
       
  2888             }
       
  2889         //VAD                
       
  2890         if ( KNSmlDMVoIPVAD() == aUriSeg ) 
       
  2891             {
       
  2892             if ( CRCSEAudioCodecEntry::EOn ==
       
  2893                 iCodecEntries[codecPos]->iVAD )
       
  2894                 {
       
  2895                 aSegmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2896                 }
       
  2897             if ( CRCSEAudioCodecEntry::EOff == 
       
  2898                 iCodecEntries[codecPos]->iVAD )
       
  2899                 {
       
  2900                 aSegmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2901                 }
       
  2902             }
       
  2903         //AnnexB                
       
  2904         if ( KNSmlDMVoIPAnnexB() == aUriSeg ) 
       
  2905             {
       
  2906             if ( CRCSEAudioCodecEntry::EOn == 
       
  2907                 iCodecEntries[codecPos]->iAnnexb )
       
  2908                 {
       
  2909                 aSegmentResult.Copy( KNSmlDMVoIPValueTrue );
       
  2910                 }
       
  2911             if ( CRCSEAudioCodecEntry::EOff == 
       
  2912                 iCodecEntries[codecPos]->iAnnexb )
       
  2913                 {
       
  2914                 aSegmentResult.Copy( KNSmlDMVoIPValueFalse );
       
  2915                 }
       
  2916             }
       
  2917         // MaxRed
       
  2918         if ( KNSmlDMVoIPMaxRed() == aUriSeg )
       
  2919             {
       
  2920             if ( CRCSEAudioCodecEntry::EOONotSet < 
       
  2921                 iCodecEntries[codecPos]->iMaxRed )                
       
  2922                 {
       
  2923                 aSegmentResult.Num( iCodecEntries[codecPos]->iMaxRed );
       
  2924                 }
       
  2925             }
       
  2926 
       
  2927         // ==============================
       
  2928         // ModeSet node ( fetch )
       
  2929         // ==============================
       
  2930         //
       
  2931         if ( KNSmlDMVoIPMode() == aUriSeg )  
       
  2932             {
       
  2933             aSegmentResult.Num ( iCodecEntries[codecPos]->
       
  2934                 iModeSet[DesToInt( aLUID.Right( 10 ))] );
       
  2935             }
       
  2936         }
       
  2937     else
       
  2938         {
       
  2939         // Codec not found even if LUID exists.
       
  2940         retValue = CSmlDmAdapter::EError;    
       
  2941         }   
       
  2942 
       
  2943     DBG_PRINT("CNSmlDmVoIPAdapter::FetchCodecObject(): begin");
       
  2944 
       
  2945     return retValue;
       
  2946     }
       
  2947 
       
  2948 // ---------------------------------------------------------------------------
       
  2949 // CNSmlDmVoIPAdapter::ChildURIListL
       
  2950 // Inserts the list of children objects of the node to dm-module
       
  2951 // ---------------------------------------------------------------------------
       
  2952 //
       
  2953 void  CNSmlDmVoIPAdapter::ChildURIListL( 
       
  2954     const TDesC8& aURI,
       
  2955     const TDesC8& aLUID, 
       
  2956     const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, 
       
  2957     const TInt aResultsRef, 
       
  2958     const TInt aStatusRef )
       
  2959     {
       
  2960     DBG_PRINT( "CNSmlDmVoIPAdapter::ChildURIListL(): start" );
       
  2961 
       
  2962     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  2963 
       
  2964     // Load VoIP profile information if not loaded yet
       
  2965     if ( !iProfileEntries.Count() )
       
  2966         {
       
  2967         LoadProfilesL();
       
  2968         }
       
  2969 
       
  2970     CSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
       
  2971 
       
  2972     CBufBase *currentURISegmentList = CBufFlat::NewL( 1 );
       
  2973     CleanupStack::PushL( currentURISegmentList );
       
  2974 
       
  2975     // get URI parameters
       
  2976     TBuf8<KNSmlVoIPMaxUriLength> uri( KNullDesC8 );
       
  2977     TBuf8<KNSmlVoIPMaxUriLength> mappingInfo( KNullDesC8 );
       
  2978     TPtrC8 uriTmp = RemoveLastURISeg( aURI );
       
  2979     TPtrC8 secondLastUriSeg = LastURISeg( uriTmp );
       
  2980     TBuf8<KSmlMaxURISegLen> segmentName;
       
  2981     TInt howManyObjects = iProfileEntries.Count();
       
  2982 
       
  2983     iProfileID = FindProfileLocation( aLUID );
       
  2984 
       
  2985     // VoIP
       
  2986     if ( KNSmlDMVoIPNodeName() == LastURISeg( aURI ) )   
       
  2987         {
       
  2988         for ( TInt counter = 0; counter < howManyObjects ; counter++ )
       
  2989             {
       
  2990             TBool notInList = ETrue;
       
  2991             TInt currentline = 0;
       
  2992             TUint ddId ( iProfileEntries[counter]->iId );
       
  2993             while ( notInList && currentline < aPreviousURISegmentList.Count() )
       
  2994                 {
       
  2995                 TInt profileLocation = FindProfileLocation(
       
  2996                     aPreviousURISegmentList.At( currentline ).iURISegLUID );
       
  2997                 if ( profileLocation != KErrNotFound )
       
  2998                     {
       
  2999                     TUint32 profileID( 
       
  3000                         iProfileEntries[profileLocation]->iId );   
       
  3001                     if ( profileID == ddId ) 
       
  3002                         {
       
  3003                         notInList = EFalse;
       
  3004                         break;
       
  3005                         }
       
  3006                     }
       
  3007                 currentline++;
       
  3008                 }
       
  3009             if ( notInList )
       
  3010                 {
       
  3011                 // VoIP/x
       
  3012                 segmentName.Copy( KNSmlDMVoIPPrefix );
       
  3013 
       
  3014                 // Add profileID number to identify profile
       
  3015                 segmentName.AppendNumFixedWidthUC( 
       
  3016                     iProfileEntries[counter]->iId, EDecimal, 10 );
       
  3017                 currentURISegmentList->InsertL( currentURISegmentList->
       
  3018                     Size(), segmentName );
       
  3019                 currentURISegmentList->InsertL( currentURISegmentList->
       
  3020                     Size(), KNSmlDMVoIPSeparator );
       
  3021 
       
  3022                 // set luid mapping to dm-module
       
  3023                 mappingInfo.Copy ( KNSmlDMVoIPPrefix );
       
  3024                 TUint val ( iProfileEntries[counter]->iId );
       
  3025                 mappingInfo.AppendNumFixedWidthUC( val, EDecimal, 10 );
       
  3026                 uri.Copy( KNSmlDMVoIPNodeName );
       
  3027                 uri.Append ( KNSmlDMVoIPSeparator );
       
  3028                 uri.Append ( KNSmlDMVoIPPrefix );
       
  3029                 uri.AppendNumFixedWidthUC( val, EDecimal, 10 );
       
  3030                 iDmCallback->SetMappingL( uri, mappingInfo ); 
       
  3031                 }
       
  3032             else
       
  3033                 { // Add those in PreviousList which are on database
       
  3034                 currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3035                     aPreviousURISegmentList.At(currentline).iURISeg );
       
  3036                 currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3037                      KNSmlDMVoIPSeparator );
       
  3038                 }
       
  3039             }
       
  3040         retValue = CSmlDmAdapter::EOk;
       
  3041         iDmCallback->SetStatusL( aStatusRef, retValue );
       
  3042         iDmCallback->SetResultsL( aResultsRef, *currentURISegmentList,
       
  3043             KNullDesC8 );
       
  3044         CleanupStack::PopAndDestroy( currentURISegmentList ); 
       
  3045         currentURISegmentList = NULL;
       
  3046         return;
       
  3047         }
       
  3048 
       
  3049     if ( KErrNotFound == iProfileID )
       
  3050         {
       
  3051         retValue = CSmlDmAdapter::ENotFound;
       
  3052         iDmCallback->SetStatusL( aStatusRef, retValue );
       
  3053         CleanupStack::PopAndDestroy( currentURISegmentList ); 
       
  3054         currentURISegmentList = NULL;
       
  3055         return;
       
  3056         }
       
  3057 
       
  3058     // VoIP/x/PreferredCodecs
       
  3059     if ( KNSmlDMVoIPPreferredCodecsNode() == LastURISeg( aURI ) )   
       
  3060         {
       
  3061         TInt preferredCount = iProfileEntries[iProfileID]->
       
  3062             iPreferredCodecs.Count();
       
  3063         for ( TInt counter = 0; counter < preferredCount ; counter++ )
       
  3064             { 
       
  3065             TBool inList = EFalse;
       
  3066             
       
  3067             // We need to rebuild LUID mapping if someone other has added or
       
  3068             // deleted codecs, because there is no usable link to each codec.
       
  3069             if ( aPreviousURISegmentList.Count() == preferredCount )
       
  3070                 {
       
  3071                 inList = ETrue;    
       
  3072                 }
       
  3073             if ( !inList )
       
  3074                 {
       
  3075                 segmentName.Copy( KNSmlDMVoIPPreferredCodecId );
       
  3076                 segmentName.AppendNumFixedWidthUC( counter + 1, EDecimal, 3 );
       
  3077                 currentURISegmentList->InsertL( currentURISegmentList->
       
  3078                     Size(), segmentName );
       
  3079                 currentURISegmentList->InsertL( currentURISegmentList->
       
  3080                     Size(), KNSmlDMVoIPSeparator );
       
  3081 
       
  3082                 // Set LUID mapping to dm-module.
       
  3083                 mappingInfo.Copy ( aLUID ); 
       
  3084                 mappingInfo.Append ( KNSmlDMVoIPSeparator );
       
  3085                 mappingInfo.Append ( KNSmlDMVoIPPreferredCodecId );
       
  3086                 mappingInfo.AppendNumFixedWidthUC( counter, EDecimal, 10 );
       
  3087                 uri.Copy( aURI );
       
  3088                 uri.Append ( KNSmlDMVoIPSeparator );
       
  3089                 uri.Append ( KNSmlDMVoIPPreferredCodecId );
       
  3090                 uri.AppendNumFixedWidthUC( counter + 1, EDecimal, 3 );
       
  3091                 iDmCallback->SetMappingL( uri, mappingInfo ); 
       
  3092                 }
       
  3093             else
       
  3094                 { // Add those in PreviousList which are on database
       
  3095                 currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3096                     aPreviousURISegmentList.At( counter ).iURISeg );
       
  3097                 currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3098                      KNSmlDMVoIPSeparator );
       
  3099                 }
       
  3100             }
       
  3101         }
       
  3102 
       
  3103     // VoIP/x/PreferredCodecs/x/
       
  3104     else if ( KNSmlDMVoIPPreferredCodecsNode() == secondLastUriSeg
       
  3105         && KFourSegs == NumOfURISegs( aURI ) )
       
  3106         {
       
  3107         segmentName.Copy( KNSmlDMVoIPPreferredCodecId );
       
  3108         currentURISegmentList->InsertL( currentURISegmentList->
       
  3109                 Size(), segmentName );
       
  3110         currentURISegmentList->InsertL( currentURISegmentList->
       
  3111                 Size(), KNSmlDMVoIPSeparator );        
       
  3112         }
       
  3113 
       
  3114     // VoIP/x/
       
  3115     else if ( KNSmlDMVoIPCodecSettingsNode() == LastURISeg( aURI ) )   
       
  3116         {
       
  3117         for ( TInt counter = 0; 
       
  3118             counter < iProfileEntries[iProfileID]->iPreferredCodecs.Count(); 
       
  3119             counter++ ) 
       
  3120             { 
       
  3121             TBool notInList = ETrue;
       
  3122             TInt currentline = 0;
       
  3123             TUint32 ddId = iProfileEntries[iProfileID]->
       
  3124                 iPreferredCodecs[counter];
       
  3125             while ( notInList && currentline < 
       
  3126                 aPreviousURISegmentList.Count() )
       
  3127                 {
       
  3128                 if ( DesToInt( aPreviousURISegmentList.At( currentline ).
       
  3129                     iURISegLUID.Right( 10 ) ) == ddId ) 
       
  3130                     {
       
  3131                     notInList = EFalse;
       
  3132                     break;
       
  3133                     }
       
  3134                 currentline++;
       
  3135                 }
       
  3136             if ( notInList )
       
  3137                 {
       
  3138                 segmentName.Copy( KNSmlDMVoIPCodecSettingsId );
       
  3139                 segmentName.AppendNumFixedWidthUC( counter + 1, EDecimal, 3 );
       
  3140                 currentURISegmentList->InsertL( currentURISegmentList->
       
  3141                     Size(), segmentName );
       
  3142                 currentURISegmentList->InsertL( currentURISegmentList->
       
  3143                     Size(), KNSmlDMVoIPSeparator );
       
  3144 
       
  3145                 // Set LUID mapping to dm-module.
       
  3146                 mappingInfo.Copy ( aLUID ); 
       
  3147                 mappingInfo.Append ( KNSmlDMVoIPSeparator );
       
  3148                 mappingInfo.Append ( KNSmlDMVoIPCodecSettingsId );
       
  3149                 mappingInfo.AppendNumFixedWidthUC( ddId, EDecimal, 10 );
       
  3150                 uri.Copy( aURI );
       
  3151                 uri.Append ( KNSmlDMVoIPSeparator );
       
  3152                 uri.Append ( KNSmlDMVoIPCodecSettingsId );
       
  3153                 uri.AppendNumFixedWidthUC( counter + 1, EDecimal, 3 );
       
  3154                 iDmCallback->SetMappingL( uri, mappingInfo ); 
       
  3155                 }
       
  3156             else
       
  3157                 { // Add those from PreviousList which are on database
       
  3158                 currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3159                     aPreviousURISegmentList.At(currentline).iURISeg );
       
  3160                 currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3161                      KNSmlDMVoIPSeparator );
       
  3162                 }
       
  3163             }
       
  3164         }
       
  3165 
       
  3166     // ==============================
       
  3167     // CodecSettings node
       
  3168     // ==============================
       
  3169     //
       
  3170     else if ( KNSmlDMVoIPCodecSettingsNode() == secondLastUriSeg 
       
  3171         && KFourSegs == NumOfURISegs( aURI ) )
       
  3172         {
       
  3173         CodecChildListL( currentURISegmentList );
       
  3174         }
       
  3175 
       
  3176     // ==============================
       
  3177     // ModeSet node
       
  3178     // ==============================
       
  3179     //
       
  3180     else if ( KNSmlDMVoIPModeSetNode() == LastURISeg( aURI ) )   
       
  3181         {
       
  3182         TUint32 codecId;
       
  3183         codecId = DesToInt( aLUID.Right( 10 ) );
       
  3184         TInt codecPos = FindCodecLocation( codecId );    
       
  3185         if ( KErrNotFound != codecPos )
       
  3186             {
       
  3187             TInt modesetCount = iCodecEntries[codecPos]->iModeSet.Count();
       
  3188             for ( TInt counter = 0; counter < modesetCount; counter++ )
       
  3189                 { 
       
  3190                 TBool inList = EFalse;
       
  3191 
       
  3192                 // We need to rebuild LUID mapping if someone other has added
       
  3193                 // or deleted, because there is no usable link to each ModeSet.
       
  3194                 if ( aPreviousURISegmentList.Count() == modesetCount )
       
  3195                     {
       
  3196                     inList = ETrue;    
       
  3197                     }
       
  3198                 if ( !inList )
       
  3199                     {
       
  3200                     segmentName.Copy( KNSmlDMVoIPModeId );
       
  3201                     segmentName.AppendNumFixedWidthUC( counter + 1, EDecimal,
       
  3202                         3 );
       
  3203                     currentURISegmentList->InsertL( currentURISegmentList->
       
  3204                         Size(), segmentName );
       
  3205                     currentURISegmentList->InsertL( currentURISegmentList->
       
  3206                         Size(), KNSmlDMVoIPSeparator );
       
  3207 
       
  3208                     // Set LUID mapping to DM module.
       
  3209                     mappingInfo.Copy ( aLUID );
       
  3210                     mappingInfo.Append ( KNSmlDMVoIPSeparator );
       
  3211                     mappingInfo.Append ( KNSmlDMVoIPModeId );
       
  3212                     mappingInfo.AppendNumFixedWidthUC( counter, EDecimal, 10 );
       
  3213                     uri.Copy( aURI );
       
  3214                     uri.Append ( KNSmlDMVoIPSeparator );
       
  3215                     uri.Append ( KNSmlDMVoIPModeId );
       
  3216                     uri.AppendNumFixedWidthUC( counter + 1, EDecimal, 3 );
       
  3217                     iDmCallback->SetMappingL( uri, mappingInfo ); 
       
  3218                     }
       
  3219                 else
       
  3220                     { // Add those in PreviousList which are on database.
       
  3221                     currentURISegmentList->InsertL( currentURISegmentList->
       
  3222                         Size(), aPreviousURISegmentList.At( counter ).iURISeg );
       
  3223                     currentURISegmentList->InsertL( currentURISegmentList->
       
  3224                         Size(), KNSmlDMVoIPSeparator );
       
  3225                     }
       
  3226                 }
       
  3227             }
       
  3228         else
       
  3229             {
       
  3230             retValue = CSmlDmAdapter::EError;    
       
  3231             }    
       
  3232         
       
  3233         }       
       
  3234 
       
  3235     else if ( KNSmlDMVoIPModeSetNode() == secondLastUriSeg 
       
  3236         && KSixSegs == NumOfURISegs( aURI ) )
       
  3237         {
       
  3238         segmentName.Copy( KNSmlDMVoIPMode );
       
  3239         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3240             segmentName );
       
  3241         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3242             KNSmlDMVoIPSeparator );
       
  3243         }       
       
  3244 
       
  3245     // ==============================
       
  3246     // SettingIds node
       
  3247     // ==============================
       
  3248     //
       
  3249     // VoIP/x/SettingIds
       
  3250     else if ( KNSmlDMVoIPSettingIdsNode() == LastURISeg( aURI ) )    
       
  3251         {
       
  3252         for ( TInt counter = 0; counter < 
       
  3253             iProfileEntries[iProfileID]->iIds.Count(); counter++ )
       
  3254             { 
       
  3255             TBool inList = EFalse;
       
  3256 
       
  3257             // We need to rebuild luid mapping if someone other has made
       
  3258             // some changes because there is no usable link to settingids.
       
  3259             if ( aPreviousURISegmentList.Count() == 
       
  3260                 iProfileEntries[iProfileID]->iIds.Count() )
       
  3261                 {
       
  3262                 inList = ETrue;    
       
  3263                 }
       
  3264             if ( !inList )
       
  3265                 {
       
  3266                 segmentName.Copy( KNSmlDMVoIPSettingId );
       
  3267                 segmentName.AppendNumFixedWidthUC( counter + 1, EDecimal, 3 );
       
  3268                 currentURISegmentList->InsertL( currentURISegmentList->
       
  3269                     Size(), segmentName );
       
  3270                 currentURISegmentList->InsertL( currentURISegmentList->
       
  3271                     Size(), KNSmlDMVoIPSeparator );
       
  3272 
       
  3273                 // set luid mapping to dm-module
       
  3274                 mappingInfo.Copy ( aLUID );     
       
  3275                 mappingInfo.Append ( KNSmlDMVoIPSeparator );
       
  3276                 mappingInfo.Append ( KNSmlDMVoIPSettingId );
       
  3277                 mappingInfo.AppendNumFixedWidthUC( counter, EDecimal, 10 );
       
  3278                 uri.Copy( aURI );
       
  3279                 uri.Append ( KNSmlDMVoIPSeparator );
       
  3280                 uri.Append ( KNSmlDMVoIPSettingId );
       
  3281                 uri.AppendNumFixedWidthUC( counter + 1, EDecimal, 3 );
       
  3282                 iDmCallback->SetMappingL( uri, mappingInfo ); 
       
  3283                 }
       
  3284             else
       
  3285                 { // Add those in PreviousList which are on database
       
  3286                 currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3287                     aPreviousURISegmentList.At( counter ).iURISeg );
       
  3288                 currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3289                      KNSmlDMVoIPSeparator );
       
  3290                 }
       
  3291             }
       
  3292         }  
       
  3293 
       
  3294     // ==============================
       
  3295     // SettingId leaf
       
  3296     // ==============================
       
  3297     //
       
  3298     else if ( KNSmlDMVoIPSettingIdsNode() == secondLastUriSeg
       
  3299         && KFourSegs == NumOfURISegs( aURI ) )
       
  3300         {
       
  3301         // ProfileType
       
  3302         segmentName.Copy( KNSmlDMVoIPProfileType );
       
  3303         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3304             segmentName );
       
  3305         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3306             KNSmlDMVoIPSeparator );
       
  3307 
       
  3308         // ProfileId
       
  3309         segmentName.Copy( KNSmlDMVoIPProfileId );
       
  3310         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3311             segmentName );
       
  3312         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3313             KNSmlDMVoIPSeparator );
       
  3314 
       
  3315         // ProfileSpecific
       
  3316         segmentName.Copy( KNSmlDMVoIPProfileSpecificId );
       
  3317         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3318             segmentName );
       
  3319         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3320             KNSmlDMVoIPSeparator );
       
  3321         }  
       
  3322 
       
  3323     // ==============================
       
  3324     // VoIP/x/VoiceMailBox node
       
  3325     // ==============================
       
  3326     //
       
  3327     else if ( KNSmlDMVoIPVmbxNode() == LastURISeg( aURI ) && 
       
  3328         KThreeSegs == NumOfURISegs( aURI ) )
       
  3329         {
       
  3330         // VoIP/x/VoiceMailBox/MWI-URI
       
  3331         segmentName.Copy( KNSmlDMVoIPMwiUri );
       
  3332         currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3333             segmentName );
       
  3334         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3335             KNSmlDMVoIPSeparator );
       
  3336         // VoIP/x/VoiceMailBox/ListeningURI
       
  3337         segmentName.Copy( KNSmlDMVoIPListeningUri );
       
  3338         currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3339             segmentName );
       
  3340         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3341             KNSmlDMVoIPSeparator );
       
  3342         // VoIP/x/VoiceMailBox/UsedIAPId
       
  3343         segmentName.Copy( KNSmlDMVoIPUsedIAPId );
       
  3344         currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3345             segmentName );
       
  3346         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3347             KNSmlDMVoIPSeparator );
       
  3348         // VoIP/x/VoiceMailBox/ReSubscribeInterval
       
  3349         segmentName.Copy( KNSmlDMVoIPReSubscribeInterval );
       
  3350         currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3351             segmentName );
       
  3352         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3353             KNSmlDMVoIPSeparator );
       
  3354         // VoIP/x/VoiceMailBox/UsedSIPProfileId
       
  3355         segmentName.Copy( KNSmlDMVoIPUsedSIPProfileId );
       
  3356         currentURISegmentList->InsertL( currentURISegmentList->Size(),
       
  3357             segmentName );
       
  3358         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
  3359             KNSmlDMVoIPSeparator );
       
  3360         }
       
  3361 
       
  3362     // ==============================
       
  3363     // VoIP/x/ node
       
  3364     // ==============================
       
  3365     //
       
  3366     else if ( KNSmlDMVoIPNodeName() == secondLastUriSeg 
       
  3367         && KTwoSegs == NumOfURISegs( aURI ) )
       
  3368         {
       
  3369         VoipChildListL( currentURISegmentList );
       
  3370         }
       
  3371     else 
       
  3372         {
       
  3373         // if none of asked nodes found return error.
       
  3374         retValue = CSmlDmAdapter::ENotFound;
       
  3375         }
       
  3376     iDmCallback->SetStatusL( aStatusRef, retValue );
       
  3377     if ( CSmlDmAdapter::EOk == retValue )
       
  3378         {
       
  3379         iDmCallback->SetResultsL( aResultsRef, *currentURISegmentList, 
       
  3380             KNullDesC8 );
       
  3381         }
       
  3382     CleanupStack::PopAndDestroy( currentURISegmentList ); 
       
  3383     currentURISegmentList = NULL;
       
  3384     DBG_PRINT("CNSmlDmVoIPAdapter::ChildURIListL(): end");
       
  3385     }
       
  3386 
       
  3387 // ---------------------------------------------------------------------------
       
  3388 // CNSmlDmVoIPAdapter::CodecChildListL
       
  3389 // Inserts Codec specific leaf objects.
       
  3390 // ---------------------------------------------------------------------------
       
  3391 //
       
  3392 void CNSmlDmVoIPAdapter::CodecChildListL(
       
  3393     CBufBase* const aCurrentURISegmentList )
       
  3394     {
       
  3395     DBG_PRINT("CNSmlDmVoIPAdapter::CodecChildListL(): start");
       
  3396 
       
  3397     TBuf8<KSmlMaxURISegLen> segmentName;
       
  3398 
       
  3399     // VoIP/x/CodecSettings/CodecSettingsIdXXX/VoIPCodecId
       
  3400     segmentName.Copy( KNSmlDMVoIPCodecId );
       
  3401     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3402         segmentName );
       
  3403     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3404         KNSmlDMVoIPSeparator );
       
  3405 
       
  3406     // VoIP/x/CodecSettings/CodecSettingsIdXXX/MediaTypeName
       
  3407     segmentName.Copy( KNSmlDMVoIPMediaTypeName );
       
  3408     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3409         segmentName );
       
  3410     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3411         KNSmlDMVoIPSeparator );
       
  3412 
       
  3413     // VoIP/x/CodecSettings/CodecSettingsIdXXX/MediaSubTypeName
       
  3414     segmentName.Copy( KNSmlDMVoIPMediaSubTypeName );
       
  3415     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3416         segmentName );
       
  3417     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3418         KNSmlDMVoIPSeparator );
       
  3419 
       
  3420     // VoIP/x/CodecSettings/CodecSettingsIdXXX/JitterBufferSize
       
  3421     segmentName.Copy( KNSmlDMVoIPJitterBufferSize );
       
  3422     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3423         segmentName );
       
  3424     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3425         KNSmlDMVoIPSeparator );
       
  3426 
       
  3427     // VoIP/x/CodecSettings/CodecSettingsIdXXX/OctetAlign
       
  3428     segmentName.Copy( KNSmlDMVoIPOctetAlign );
       
  3429     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3430         segmentName );
       
  3431     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3432         KNSmlDMVoIPSeparator );
       
  3433 
       
  3434     // VoIP/x/CodecSettings/CodecSettingsIdXXX/ModeSet
       
  3435     segmentName.Copy( KNSmlDMVoIPModeSetNode );
       
  3436     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3437         segmentName );
       
  3438     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3439         KNSmlDMVoIPSeparator );
       
  3440 
       
  3441     // VoIP/x/CodecSettings/CodecSettingsIdXXX/ModeChangePeriod
       
  3442     segmentName.Copy( KNSmlDMVoIPModeChangePeriod );
       
  3443     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3444         segmentName );
       
  3445     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3446         KNSmlDMVoIPSeparator );
       
  3447 
       
  3448     // VoIP/x/CodecSettings/CodecSettingsIdXXX/ModeChangeNeighbor
       
  3449     segmentName.Copy( KNSmlDMVoIPModeChangeNeighbor );
       
  3450     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3451         segmentName );
       
  3452     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3453         KNSmlDMVoIPSeparator );
       
  3454 
       
  3455     // VoIP/x/CodecSettings/CodecSettingsIdXXX/Ptime
       
  3456     segmentName.Copy( KNSmlDMVoIPPtime );
       
  3457     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3458         segmentName );
       
  3459     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3460         KNSmlDMVoIPSeparator );
       
  3461 
       
  3462     // VoIP/x/CodecSettings/CodecSettingsIdXXX/MaxPtime
       
  3463     segmentName.Copy( KNSmlDMVoIPMaxPtime );
       
  3464     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3465         segmentName );
       
  3466     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3467         KNSmlDMVoIPSeparator );
       
  3468 
       
  3469     // VoIP/x/CodecSettings/CodecSettingsIdXXX/VAD
       
  3470     segmentName.Copy( KNSmlDMVoIPVAD );
       
  3471     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3472         segmentName );
       
  3473     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3474         KNSmlDMVoIPSeparator );
       
  3475 
       
  3476     // VoIP/x/CodecSettings/CodecSettingsIdXXX/AnnexB
       
  3477     segmentName.Copy( KNSmlDMVoIPAnnexB );
       
  3478     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3479         segmentName );
       
  3480     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3481         KNSmlDMVoIPSeparator );
       
  3482 
       
  3483     // VoIP/x/CodecSettings/CodecSettingsIdXXX/MaxRed
       
  3484     segmentName.Copy( KNSmlDMVoIPMaxRed );
       
  3485     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3486         segmentName );
       
  3487     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3488         KNSmlDMVoIPSeparator );
       
  3489 
       
  3490     DBG_PRINT("CNSmlDmVoIPAdapter::CodecChildListL(): end");
       
  3491     }
       
  3492 
       
  3493 // ---------------------------------------------------------------------------
       
  3494 // CNSmlDmVoIPAdapter::VoipChildListL
       
  3495 // Inserts VoIP leaf objects.
       
  3496 // ---------------------------------------------------------------------------
       
  3497 //
       
  3498 void CNSmlDmVoIPAdapter::VoipChildListL(
       
  3499     CBufBase* const aCurrentURISegmentList )
       
  3500     {
       
  3501     DBG_PRINT("CNSmlDmVoIPAdapter::VoipChildListL(): start");
       
  3502 
       
  3503     TBuf8<KSmlMaxURISegLen> segmentName;
       
  3504 
       
  3505     // VoIP/x/VoIPID
       
  3506     segmentName.Copy( KNSmlDMVoIPSetID );
       
  3507     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3508         segmentName );
       
  3509     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3510         KNSmlDMVoIPSeparator );
       
  3511 
       
  3512     // VoIP/x/ProviderName
       
  3513     segmentName.Copy( KNSmlDMVoIPProvID );
       
  3514     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3515         segmentName );
       
  3516     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3517         KNSmlDMVoIPSeparator );
       
  3518 
       
  3519     // VoIP/x/SettingsName
       
  3520     segmentName.Copy( KNSmlDMVoIPName );
       
  3521     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3522         segmentName );
       
  3523     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3524         KNSmlDMVoIPSeparator );
       
  3525 
       
  3526     // VoIP/x/PreferredCodecs
       
  3527     segmentName.Copy( KNSmlDMVoIPPreferredCodecsNode );
       
  3528     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3529         segmentName ); 
       
  3530     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3531         KNSmlDMVoIPSeparator ); 
       
  3532 
       
  3533     // VoIP/x/CodecSettings
       
  3534     segmentName.Copy( KNSmlDMVoIPCodecSettingsNode );
       
  3535     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3536         segmentName ); 
       
  3537     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3538         KNSmlDMVoIPSeparator ); 
       
  3539 
       
  3540     // VoIP/x/SettingIds
       
  3541     segmentName.Copy( KNSmlDMVoIPSettingIdsNode );
       
  3542     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3543         segmentName ); 
       
  3544     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3545         KNSmlDMVoIPSeparator );
       
  3546 
       
  3547     // VoIP/x/StartMediaPort
       
  3548     segmentName.Copy( KNSmlDMVoIPSMPort );
       
  3549     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3550         segmentName ); 
       
  3551     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3552         KNSmlDMVoIPSeparator );
       
  3553 
       
  3554     // VoIP/x/EndMediaPort
       
  3555     segmentName.Copy( KNSmlDMVoIPEMPort );
       
  3556     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3557         segmentName ); 
       
  3558     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3559         KNSmlDMVoIPSeparator );
       
  3560 
       
  3561     // VoIP/x/VoiceMailBox
       
  3562     segmentName.Copy( KNSmlDMVoIPVmbxNode );
       
  3563     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3564         segmentName ); 
       
  3565     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3566         KNSmlDMVoIPSeparator );
       
  3567 
       
  3568     // VoIP/x/MegiaQos
       
  3569     segmentName.Copy( KNSmlDMVoIPMediaQos );
       
  3570     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3571         segmentName ); 
       
  3572     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3573         KNSmlDMVoIPSeparator );
       
  3574 
       
  3575     // VoIP/x/InbandDTMF
       
  3576     segmentName.Copy( KNSmlDMVoIPDTMFIB );
       
  3577     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3578         segmentName ); 
       
  3579     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3580         KNSmlDMVoIPSeparator );
       
  3581 
       
  3582     // VoIP/x/OutbandDTMF
       
  3583     segmentName.Copy( KNSmlDMVoIPDTMFOB );
       
  3584     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3585         segmentName ); 
       
  3586     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3587         KNSmlDMVoIPSeparator );
       
  3588 
       
  3589     // VoIP/x/SecureCallPref
       
  3590     segmentName.Copy( KNSmlDMVoIPSecureCallPref );
       
  3591     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3592         segmentName );
       
  3593     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3594         KNSmlDMVoIPSeparator );
       
  3595 
       
  3596     // VoIP/x/RTCP
       
  3597     segmentName.Copy( KNSmlDMVoIPRTCP );
       
  3598     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3599         segmentName );
       
  3600     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3601         KNSmlDMVoIPSeparator );
       
  3602 
       
  3603     // VoIP/x/UAHTerminalType
       
  3604     segmentName.Copy( KNSmlDMVoIPUAHTerminalType );
       
  3605     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3606         segmentName );
       
  3607     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3608         KNSmlDMVoIPSeparator );
       
  3609 
       
  3610     // VoIP/x/UAHWLANMAC
       
  3611     segmentName.Copy( KNSmlDMVoIPUAHWLANMAC );
       
  3612     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3613         segmentName );
       
  3614     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3615         KNSmlDMVoIPSeparator );
       
  3616 
       
  3617     // VoIP/x/UAHString
       
  3618     segmentName.Copy( KNSmlDMVoIPUAHString );
       
  3619     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3620         segmentName );
       
  3621     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3622         KNSmlDMVoIPSeparator );
       
  3623 
       
  3624     // VoIP/x/ProfileLockedToIAP
       
  3625     segmentName.Copy( KNSmlDMVoIPProfileLockedToIAP );
       
  3626     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3627         segmentName );
       
  3628     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3629         KNSmlDMVoIPSeparator );
       
  3630 
       
  3631     // VoIP/x/VoIPPluginUID
       
  3632     segmentName.Copy( KNSmlDMVoIPPluginUID );
       
  3633     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3634         segmentName );
       
  3635     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3636         KNSmlDMVoIPSeparator );
       
  3637 
       
  3638     // VoIP/x/AllowVoIPoverWCDMA
       
  3639     segmentName.Copy( KNSmlDMVoIPAllowVoIPOverWCDMA );
       
  3640     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3641         segmentName );
       
  3642     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(), 
       
  3643         KNSmlDMVoIPSeparator );
       
  3644 
       
  3645     // VoIP/x/VoIPDigits
       
  3646     segmentName.Copy( KNSmlDMVoIPVoIPDigits );
       
  3647     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3648         segmentName );
       
  3649     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3650         KNSmlDMVoIPSeparator );
       
  3651 
       
  3652     // VoIP/x/URIDomainIgnoreRule
       
  3653     segmentName.Copy( KNSmlDMVoIPURIDomainIgnoreRule );
       
  3654     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3655         segmentName );
       
  3656     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3657         KNSmlDMVoIPSeparator );
       
  3658 
       
  3659     // VoIP/x/AutoAcceptBuddyRequest
       
  3660     segmentName.Copy( KNSmlDMVoIPAutoAcceptBuddyRequest );
       
  3661     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3662         segmentName );
       
  3663     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3664         KNSmlDMVoIPSeparator );
       
  3665 
       
  3666     // VoIP/x/UsedVoIPRelease
       
  3667     segmentName.Copy( KNSmlDMVoIPUsedVoIPRelease );
       
  3668     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3669         segmentName );
       
  3670     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3671         KNSmlDMVoIPSeparator );
       
  3672 
       
  3673     // VoIP/x/AddUserPhone
       
  3674     segmentName.Copy( KNSmlDMVoIPAddUserPhone );
       
  3675     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3676         segmentName );
       
  3677     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3678         KNSmlDMVoIPSeparator );
       
  3679 
       
  3680     // VoIP/x/ProviderBookmarkURI
       
  3681     segmentName.Copy( KNSmlDMVoIPProviderBookmarkUri );
       
  3682     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3683         segmentName );
       
  3684     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3685         KNSmlDMVoIPSeparator );
       
  3686 
       
  3687     // VoIP/x/SIPConnectivityTestURI
       
  3688     segmentName.Copy( KNSmlDMVoIPSIPConnTestUri );
       
  3689     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3690         segmentName );
       
  3691     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3692         KNSmlDMVoIPSeparator );
       
  3693 
       
  3694     // VoIP/x/NATFWProfileId
       
  3695     segmentName.Copy( KNSmlDMVoIPNatFwProfileId );
       
  3696     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3697         segmentName );
       
  3698     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3699         KNSmlDMVoIPSeparator );
       
  3700 
       
  3701     // VoIP/x/MinSessionInterval
       
  3702     segmentName.Copy( KNSmlDMVoIPMinSessionInterval );
       
  3703     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3704         segmentName );
       
  3705     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3706         KNSmlDMVoIPSeparator );
       
  3707 
       
  3708     // VoIP/x/SessionExpires
       
  3709     segmentName.Copy( KNSmlDMVoIPSessionExpires );
       
  3710     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3711         segmentName );
       
  3712     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3713         KNSmlDMVoIPSeparator );
       
  3714 
       
  3715     // VoIP/x/BradingDataURI
       
  3716     segmentName.Copy( KNSmlDMVoIPBrandingDataUri );
       
  3717     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3718         segmentName );
       
  3719     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3720         KNSmlDMVoIPSeparator );
       
  3721 
       
  3722     // VoIP/x/PresenceSettingsId
       
  3723     segmentName.Copy( KNSmlDMVoIPPresenceSettingsId );
       
  3724     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3725         segmentName );
       
  3726     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3727         KNSmlDMVoIPSeparator );
       
  3728 
       
  3729     // VoIP/x/UsedNATProtocol
       
  3730     segmentName.Copy( KNSmlDMVoIPUsedNatProtocol );
       
  3731     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3732         segmentName );
       
  3733     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3734         KNSmlDMVoIPSeparator );
       
  3735 
       
  3736     // VoIP/x/AutoEnable
       
  3737     segmentName.Copy( KNSmlDMVoIPAutoEnable );
       
  3738     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3739         segmentName );
       
  3740     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3741         KNSmlDMVoIPSeparator );
       
  3742 
       
  3743     // VoIP/x/SnapProfileId
       
  3744     segmentName.Copy( KNSmlDMVoIPSnapProfileId );
       
  3745     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3746         segmentName );
       
  3747     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3748         KNSmlDMVoIPSeparator );
       
  3749 
       
  3750     // VoIP/x/EnableIM
       
  3751     segmentName.Copy( KNSmlDMVoIPEnableIm );
       
  3752     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3753         segmentName );
       
  3754     aCurrentURISegmentList->InsertL( aCurrentURISegmentList->Size(),
       
  3755         KNSmlDMVoIPSeparator );
       
  3756 
       
  3757     DBG_PRINT("CNSmlDmVoIPAdapter::VoipChildListL(): end");
       
  3758     }
       
  3759 
       
  3760 // ---------------------------------------------------------------------------
       
  3761 // CNSmlDmVoIPAdapter::AddNodeObjectL
       
  3762 // Adds a new node.
       
  3763 // ---------------------------------------------------------------------------
       
  3764 //
       
  3765 void CNSmlDmVoIPAdapter::AddNodeObjectL( 
       
  3766     const TDesC8& aURI, 
       
  3767     const TDesC8& aParentLUID, 
       
  3768     const TInt aStatusRef )
       
  3769     {
       
  3770     DBG_PRINT("CNSmlDmVoIPAdapter::AddNodeObjectL(): begin");
       
  3771 
       
  3772     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  3773 
       
  3774     CSmlDmAdapter::TError retValue = EOk;
       
  3775 
       
  3776     // Load VoIP profile information if not loaded yet
       
  3777     if ( !iProfileEntries.Count() )
       
  3778         {
       
  3779         LoadProfilesL();
       
  3780         }
       
  3781     // Find profile from array, profile deleted from elsewhere if not found
       
  3782     if ( aParentLUID.Length() > 0 )
       
  3783         {
       
  3784         TInt profileID = FindProfileLocation ( aParentLUID );
       
  3785         if ( KErrNotFound == profileID )
       
  3786             {
       
  3787             retValue = CSmlDmAdapter::ENotFound;
       
  3788             }
       
  3789         else
       
  3790             {
       
  3791             retValue = CSmlDmAdapter::EAlreadyExists;
       
  3792             }
       
  3793         }
       
  3794 
       
  3795     // Get last URI segment. 
       
  3796     TBuf8<KNSmlVoIPMaxUriLength> uri = aURI;
       
  3797     TBuf8<KNSmlVoIPMaxUriLength> mappingInfo ( KNullDesC8 );
       
  3798     TPtrC8 uriSeg = LastURISeg( aURI );
       
  3799     TPtrC8 uriTmp = RemoveLastURISeg( aURI );
       
  3800     TPtrC8 secondLastUriSeg = LastURISeg( uriTmp );
       
  3801 
       
  3802      // Find profile
       
  3803     iProfileID = FindProfileLocation( aParentLUID );
       
  3804 
       
  3805     // ==============================
       
  3806     // VoIP node ( add )
       
  3807     // ==============================
       
  3808     //
       
  3809     // VoIP/x/VoIP
       
  3810     if ( KNSmlDMVoIPNodeName() == secondLastUriSeg 
       
  3811         && ( EOk == retValue || ENotFound == retValue ) )
       
  3812         {
       
  3813         // Check OOD before saving new profile.
       
  3814         RFs fs;
       
  3815         User::LeaveIfError( fs.Connect() );
       
  3816         CleanupClosePushL( fs ); // CS:1
       
  3817 
       
  3818         // VoIP settings are stored in three files.
       
  3819         if ( SysUtil::FFSSpaceBelowCriticalLevelL( 
       
  3820             &fs, KNSmlDMFatMinimumFileSize * 3 ) )
       
  3821             {
       
  3822             // Prevent writing in OOD.
       
  3823             CleanupStack::PopAndDestroy( &fs ); // CS:0
       
  3824             iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EDiskFull );
       
  3825             DBG_PRINT("CNSmlDmVoIPAdapter::AddNodeObjectL(): DISK FULL end");
       
  3826             return;
       
  3827             }
       
  3828         CleanupStack::PopAndDestroy( &fs ); // CS:0
       
  3829         CRCSEProfileEntry* newProfileEntry = CRCSEProfileEntry::NewLC();
       
  3830         iCRCSEProfile->GetDefaultProfile( *newProfileEntry );
       
  3831         if ( uriSeg.Length() < KMaxSettingsNameLength )
       
  3832             {
       
  3833             newProfileEntry->iSettingsName.Copy( uriSeg );
       
  3834             }
       
  3835         newProfileEntry->iProviderName.Copy( KDefaultSettingsName );
       
  3836         CheckDuplicateNameL( *newProfileEntry );
       
  3837         CheckDuplicateProviderL( *newProfileEntry );
       
  3838 
       
  3839         CRCSEAudioCodecEntry* newAudioCodecEntry1 = 
       
  3840             CRCSEAudioCodecEntry::NewLC();
       
  3841         newAudioCodecEntry1->SetDefaultCodecValueSet( KAudioCodecAMRWB() );
       
  3842         newAudioCodecEntry1->iMediaSubTypeName = KAudioCodecAMRWB;
       
  3843         TUint32 codecId = iCRCSEAudioCodec->AddL( *newAudioCodecEntry1 );
       
  3844         newProfileEntry->iPreferredCodecs.Append( codecId );
       
  3845         newAudioCodecEntry1->iCodecId = codecId;
       
  3846         iCodecEntries.AppendL( newAudioCodecEntry1 );
       
  3847         CleanupStack::Pop( newAudioCodecEntry1 );
       
  3848 
       
  3849         CRCSEAudioCodecEntry* newAudioCodecEntry2 = 
       
  3850             CRCSEAudioCodecEntry::NewLC();
       
  3851         newAudioCodecEntry2->SetDefaultCodecValueSet( KAudioCodecAMR() );
       
  3852         newAudioCodecEntry2->iMediaSubTypeName = KAudioCodecAMR;        
       
  3853         codecId = iCRCSEAudioCodec->AddL( *newAudioCodecEntry2 );
       
  3854         newProfileEntry->iPreferredCodecs.Append( codecId );
       
  3855         newAudioCodecEntry2->iCodecId = codecId; 
       
  3856         iCodecEntries.AppendL( newAudioCodecEntry2 );
       
  3857         CleanupStack::Pop( newAudioCodecEntry2 );
       
  3858 
       
  3859         CRCSEAudioCodecEntry* newAudioCodecEntry3 = 
       
  3860             CRCSEAudioCodecEntry::NewLC();
       
  3861         newAudioCodecEntry3->SetDefaultCodecValueSet( KAudioCodecPCMU() );
       
  3862         newAudioCodecEntry3->iMediaSubTypeName = KAudioCodecPCMU;
       
  3863         codecId = iCRCSEAudioCodec->AddL( *newAudioCodecEntry3 );
       
  3864         newProfileEntry->iPreferredCodecs.Append( codecId );
       
  3865         newAudioCodecEntry3->iCodecId = codecId;
       
  3866         iCodecEntries.AppendL( newAudioCodecEntry3 );
       
  3867         CleanupStack::Pop( newAudioCodecEntry3 );
       
  3868 
       
  3869         CRCSEAudioCodecEntry* newAudioCodecEntry4 = 
       
  3870             CRCSEAudioCodecEntry::NewLC();
       
  3871         newAudioCodecEntry4->SetDefaultCodecValueSet( KAudioCodecPCMA() );
       
  3872         newAudioCodecEntry4->iMediaSubTypeName = KAudioCodecPCMA;
       
  3873         codecId = iCRCSEAudioCodec->AddL( *newAudioCodecEntry4 );
       
  3874         newProfileEntry->iPreferredCodecs.Append( codecId );
       
  3875         newAudioCodecEntry4->iCodecId = codecId; 
       
  3876         iCodecEntries.AppendL( newAudioCodecEntry4 );
       
  3877         CleanupStack::Pop( newAudioCodecEntry4 );
       
  3878 
       
  3879         CRCSEAudioCodecEntry* newAudioCodecEntry5 = 
       
  3880             CRCSEAudioCodecEntry::NewLC();
       
  3881         newAudioCodecEntry5->SetDefaultCodecValueSet( KAudioCodeciLBC() );
       
  3882         newAudioCodecEntry5->iMediaSubTypeName = KAudioCodeciLBC;
       
  3883         codecId = iCRCSEAudioCodec->AddL( *newAudioCodecEntry5 );
       
  3884         newProfileEntry->iPreferredCodecs.Append( codecId );
       
  3885         newAudioCodecEntry5->iCodecId = codecId; 
       
  3886         iCodecEntries.AppendL( newAudioCodecEntry5 );
       
  3887         CleanupStack::Pop( newAudioCodecEntry5 );
       
  3888 
       
  3889         CRCSEAudioCodecEntry* newAudioCodecEntry6 = 
       
  3890             CRCSEAudioCodecEntry::NewLC();
       
  3891         newAudioCodecEntry6->SetDefaultCodecValueSet( KAudioCodecG729() );
       
  3892         newAudioCodecEntry6->iMediaSubTypeName = KAudioCodecG729;
       
  3893         codecId = iCRCSEAudioCodec->AddL( *newAudioCodecEntry6 );
       
  3894         newProfileEntry->iPreferredCodecs.Append( codecId );
       
  3895         newAudioCodecEntry6->iCodecId = codecId;
       
  3896         iCodecEntries.AppendL( newAudioCodecEntry6 );
       
  3897         CleanupStack::Pop( newAudioCodecEntry6 );
       
  3898 
       
  3899         CRCSEAudioCodecEntry* newAudioCodecEntry7 = 
       
  3900             CRCSEAudioCodecEntry::NewLC();
       
  3901         newAudioCodecEntry7->SetDefaultCodecValueSet( KAudioCodecCN() );
       
  3902         newAudioCodecEntry7->iMediaSubTypeName = KAudioCodecCN;
       
  3903         codecId = iCRCSEAudioCodec->AddL( *newAudioCodecEntry7 );
       
  3904         newProfileEntry->iPreferredCodecs.Append( codecId );
       
  3905         newAudioCodecEntry7->iCodecId = codecId;
       
  3906         iCodecEntries.AppendL( newAudioCodecEntry7 );
       
  3907         CleanupStack::Pop( newAudioCodecEntry7 );
       
  3908 
       
  3909         // Add SettingIds entry.
       
  3910         TSettingIds idEntry;
       
  3911         idEntry.iProfileType = -1;
       
  3912         // SIPSpecific not supported => ID not found.
       
  3913         idEntry.iProfileSpecificSettingId = KErrNotFound;
       
  3914         idEntry.iProfileId = -1;
       
  3915         newProfileEntry->iIds.Append( idEntry ); 
       
  3916 
       
  3917         // Add new VoIP profile.
       
  3918         TUint32 profileID = iCRCSEProfile->AddL( *newProfileEntry );
       
  3919         newProfileEntry->iId = profileID;
       
  3920         iProfileEntries.AppendL( newProfileEntry );
       
  3921 
       
  3922         // Add LUID mapping to first SettingIds of profile.
       
  3923         uri.Copy( aURI );
       
  3924         uri.Append( KNSmlDMVoIPSeparator );
       
  3925         uri.Append( KNSmlDMVoIPSettingIdsNode );
       
  3926         uri.Append( KNSmlDMVoIPSeparator );
       
  3927         uri.Append( KNSmlDMVoIPSettingId );
       
  3928         uri.AppendNumFixedWidthUC( 1, EDecimal, 3 );
       
  3929         mappingInfo.Copy( KNSmlDMVoIPPrefix );
       
  3930         mappingInfo.AppendNumFixedWidthUC( profileID, EDecimal, 10 );
       
  3931         mappingInfo.Append( KNSmlDMVoIPSeparator );
       
  3932         mappingInfo.Append( KNSmlDMVoIPSettingId );
       
  3933         mappingInfo.AppendNumFixedWidthUC( 0, EDecimal, 10 );
       
  3934         iDmCallback->SetMappingL( uri, mappingInfo ); 
       
  3935 
       
  3936         // Add LUID mapping for CodecSettings and preferredCodecs.
       
  3937         for ( TInt counter = 0; counter < newProfileEntry->
       
  3938             iPreferredCodecs.Count(); counter++ )
       
  3939             {
       
  3940             uri.Copy( aURI );
       
  3941             uri.Append( KNSmlDMVoIPSeparator );
       
  3942             uri.Append( KNSmlDMVoIPCodecSettingsNode );
       
  3943             uri.Append( KNSmlDMVoIPSeparator );
       
  3944             uri.Append( KNSmlDMVoIPCodecSettingsId );
       
  3945             uri.AppendNumFixedWidthUC( counter + 1, EDecimal, 3 );
       
  3946             mappingInfo.Copy( KNSmlDMVoIPPrefix );
       
  3947             mappingInfo.AppendNumFixedWidthUC( profileID, EDecimal, 10 );
       
  3948             mappingInfo.Append( KNSmlDMVoIPSeparator );
       
  3949             mappingInfo.Append( KNSmlDMVoIPCodecSettingsId );
       
  3950             mappingInfo.AppendNumFixedWidthUC( newProfileEntry->
       
  3951                 iPreferredCodecs[counter], EDecimal, 10 );
       
  3952             iDmCallback->SetMappingL( uri, mappingInfo ); 
       
  3953 
       
  3954             uri.Copy( aURI );
       
  3955             uri.Append( KNSmlDMVoIPSeparator );
       
  3956             uri.Append( KNSmlDMVoIPPreferredCodecsNode );
       
  3957             uri.Append( KNSmlDMVoIPSeparator );
       
  3958             uri.Append( KNSmlDMVoIPPreferredCodecId );
       
  3959             uri.AppendNumFixedWidthUC( counter + 1, EDecimal, 3 );
       
  3960             mappingInfo.Copy( KNSmlDMVoIPPrefix );
       
  3961             mappingInfo.AppendNumFixedWidthUC( profileID, EDecimal, 10 );
       
  3962             mappingInfo.Append( KNSmlDMVoIPSeparator );
       
  3963             mappingInfo.Append( KNSmlDMVoIPPreferredCodecId );
       
  3964             mappingInfo.AppendNumFixedWidthUC( counter, EDecimal, 10 );
       
  3965             iDmCallback->SetMappingL( uri, mappingInfo ); 
       
  3966             }
       
  3967 
       
  3968         // Set LUID mapping to DM module.
       
  3969         mappingInfo.Copy ( KNSmlDMVoIPPrefix );
       
  3970         mappingInfo.AppendNumFixedWidthUC( profileID, EDecimal, 10 );
       
  3971         iDmCallback->SetMappingL( aURI, mappingInfo ); 
       
  3972 
       
  3973         CleanupStack::Pop( newProfileEntry );
       
  3974 
       
  3975         retValue = CSmlDmAdapter::EOk;
       
  3976         }
       
  3977 
       
  3978     if ( KErrNotFound != iProfileID )
       
  3979         {
       
  3980         // ==============================
       
  3981         // CodecSettings node (add)
       
  3982         // ==============================
       
  3983         //
       
  3984         if ( KNSmlDMVoIPCodecSettingsNode() == secondLastUriSeg &&
       
  3985             KErrNotFound == aParentLUID.Find( KNSmlDMVoIPCodecSettingsId ) )
       
  3986             {
       
  3987             CRCSEAudioCodecEntry *newAudioCodecEntry = 
       
  3988                 CRCSEAudioCodecEntry::NewLC();
       
  3989             iCRCSEAudioCodec->GetDefaultCodec( *newAudioCodecEntry );
       
  3990             TUint32 codecId = iCRCSEAudioCodec->AddL( *newAudioCodecEntry );
       
  3991             newAudioCodecEntry->iCodecId = codecId;
       
  3992             iCodecEntries.AppendL( newAudioCodecEntry );
       
  3993 
       
  3994             // Add new codec ID to iPreferredCodecs of current VoIP profile.
       
  3995             iProfileEntries[iProfileID]->
       
  3996                 iPreferredCodecs.Append( codecId );
       
  3997 
       
  3998             // Update VoIP profile back to permanent store.    
       
  3999             iCRCSEProfile->UpdateL( iProfileEntries[iProfileID]->
       
  4000                 iId, *iProfileEntries[iProfileID] );
       
  4001             CleanupStack::Pop( newAudioCodecEntry );
       
  4002 
       
  4003             // Add LUID mapping to new codecsettings entry.
       
  4004             mappingInfo.Copy( KNSmlDMVoIPPrefix );
       
  4005             TUint val( iProfileEntries[iProfileID]->iId );
       
  4006             mappingInfo.AppendNumFixedWidthUC( val, EDecimal, 10 );
       
  4007             mappingInfo.Append( KNSmlDMVoIPSeparator );
       
  4008             mappingInfo.Append( KNSmlDMVoIPCodecSettingsId );
       
  4009             mappingInfo.AppendNumFixedWidthUC( codecId, EDecimal, 10 );
       
  4010             iDmCallback->SetMappingL( aURI, mappingInfo );
       
  4011 
       
  4012             // Add LUID mapping to new preferredcodecs entry.
       
  4013             uri.Copy( RemoveLastURISeg( RemoveLastURISeg( aURI ) ) );
       
  4014             uri.Append( KNSmlDMVoIPSeparator );
       
  4015             uri.Append( KNSmlDMVoIPPreferredCodecsNode );
       
  4016             uri.Append( KNSmlDMVoIPSeparator );
       
  4017             uri.Append( KNSmlDMVoIPPreferredCodecId );
       
  4018             uri.AppendNumFixedWidthUC( 
       
  4019                 iProfileEntries[iProfileID]->iPreferredCodecs.Count(),
       
  4020                 EDecimal, 3 );
       
  4021             mappingInfo.Copy( KNSmlDMVoIPPrefix );
       
  4022             mappingInfo.AppendNumFixedWidthUC( iProfileID, EDecimal, 10 );
       
  4023             mappingInfo.Append( KNSmlDMVoIPSeparator );
       
  4024             mappingInfo.Append( KNSmlDMVoIPPreferredCodecId );
       
  4025             mappingInfo.AppendNumFixedWidthUC( 
       
  4026                 iProfileEntries[iProfileID]->iPreferredCodecs.Count() - 1,
       
  4027                 EDecimal, 10 );
       
  4028             iDmCallback->SetMappingL( uri, mappingInfo );    
       
  4029             retValue = CSmlDmAdapter::EOk;
       
  4030             }
       
  4031 
       
  4032         // ==============================
       
  4033         // ModeSet node (add)
       
  4034         // ==============================
       
  4035         //
       
  4036         if ( KNSmlDMVoIPModeSetNode() == secondLastUriSeg
       
  4037             && KErrNotFound == aParentLUID.Find( KNSmlDMVoIPModeId ) )
       
  4038             {
       
  4039             // Get codec ID used by these settings.
       
  4040             TUint32 codecId = DesToInt( aParentLUID.Right( 10 ) );
       
  4041             TInt codecPos = FindCodecLocation( codecId );
       
  4042             if ( KErrNotFound != codecPos )
       
  4043                 {
       
  4044                 iCodecEntries[codecPos]->iModeSet.Append( 1 );
       
  4045                 iCRCSEAudioCodec->UpdateL( codecId,
       
  4046                     *iCodecEntries[codecPos] );
       
  4047 
       
  4048                 // All LUID mapping to new mode-set item.
       
  4049                 mappingInfo.Copy( aParentLUID );
       
  4050                 mappingInfo.Append( KNSmlDMVoIPSeparator );
       
  4051                 mappingInfo.Append( KNSmlDMVoIPModeId );
       
  4052                 mappingInfo.AppendNumFixedWidthUC( 
       
  4053                     iCodecEntries[codecPos]->iModeSet.Count() - 1,
       
  4054                     EDecimal, 10 );
       
  4055                 iDmCallback->SetMappingL( aURI, mappingInfo ); 
       
  4056                 retValue = CSmlDmAdapter::EOk;    
       
  4057                 }
       
  4058             else
       
  4059                 {
       
  4060                 retValue = CSmlDmAdapter::EError;    
       
  4061                 }
       
  4062             }
       
  4063 
       
  4064         // ==============================
       
  4065         // SettingIds node (add)  
       
  4066         // ==============================
       
  4067         //
       
  4068         if ( KNSmlDMVoIPSettingIdsNode() == secondLastUriSeg &&
       
  4069             KErrNotFound == aParentLUID.Find( KNSmlDMVoIPSettingId ) )
       
  4070             {
       
  4071             TSettingIds idEntry;
       
  4072             idEntry.iProfileType = 0;
       
  4073             idEntry.iProfileSpecificSettingId = -1;
       
  4074             idEntry.iProfileId = 0;
       
  4075             iProfileEntries[iProfileID]->iIds.Append( idEntry ); 
       
  4076             iCRCSEProfile->UpdateL( iProfileEntries[iProfileID]->iId, 
       
  4077                 *iProfileEntries[iProfileID] );
       
  4078             mappingInfo.Copy( KNSmlDMVoIPPrefix );
       
  4079             TUint val( iProfileEntries[iProfileID]->iId );
       
  4080             mappingInfo.AppendNumFixedWidthUC( val, EDecimal, 10 );
       
  4081             mappingInfo.Append( KNSmlDMVoIPSeparator );
       
  4082             mappingInfo.Append( KNSmlDMVoIPSettingId );
       
  4083             mappingInfo.AppendNumFixedWidthUC( 
       
  4084                 iProfileEntries[iProfileID]->iIds.Count() - 1, EDecimal, 10 );
       
  4085             iDmCallback->SetMappingL( aURI, mappingInfo );       
       
  4086             retValue = CSmlDmAdapter::EOk;
       
  4087             }
       
  4088         }
       
  4089 
       
  4090     // Return status ok for existing leaf nodes that do not need
       
  4091     // to be added separately.    
       
  4092     if ( aParentLUID.Length() > 0 && 
       
  4093         retValue != CSmlDmAdapter::ENotFound &&
       
  4094         ( KNSmlDMVoIPCodecSettingsNode() == uriSeg
       
  4095         || KNSmlDMVoIPModeSetNode() == uriSeg
       
  4096         || KNSmlDMVoIPSettingIdsNode() == uriSeg
       
  4097         || KNSmlDMVoIPSettingIdsNode() == uriSeg
       
  4098         || KNSmlDMVoIPVmbxNode() == uriSeg
       
  4099         ) )
       
  4100         {
       
  4101         retValue = CSmlDmAdapter::EOk;   
       
  4102         }
       
  4103     iDmCallback->SetStatusL( aStatusRef, retValue );
       
  4104 
       
  4105     DBG_PRINT("CNSmlDmVoIPAdapter::AddNodeObjectL(): end");
       
  4106     }
       
  4107 
       
  4108 // ---------------------------------------------------------------------------
       
  4109 // CNSmlDmVoIPAdapter::UpdateLeafObjectL 
       
  4110 // For streaming large object data.
       
  4111 // ---------------------------------------------------------------------------
       
  4112 //
       
  4113 void CNSmlDmVoIPAdapter::UpdateLeafObjectL( 
       
  4114     const TDesC8& /*aURI*/, 
       
  4115     const TDesC8& /*aLUID*/, 
       
  4116     RWriteStream*& /*aStream*/, 
       
  4117     const TDesC8& /*aType*/, 
       
  4118     const TInt aStatusRef )
       
  4119     {
       
  4120     DBG_PRINT("CNSmlDmVoIPAdapter::UpdateLeafObjectL(): stream: begin");
       
  4121     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  4122     iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  4123     DBG_PRINT("CNSmlDmVoIPAdapter::UpdateLeafObjectL(): stream: end");
       
  4124     }
       
  4125 
       
  4126 // ---------------------------------------------------------------------------
       
  4127 // CNSmlDmVoIPAdapter::FetchLeafObjectSizeL
       
  4128 // Fetches leaf object size of aURI.
       
  4129 // ---------------------------------------------------------------------------
       
  4130 //
       
  4131 void CNSmlDmVoIPAdapter::FetchLeafObjectSizeL( 
       
  4132     const TDesC8& aURI, 
       
  4133     const TDesC8& aLUID, 
       
  4134     const TDesC8& aType, 
       
  4135     const TInt aResultsRef, 
       
  4136     const TInt aStatusRef )
       
  4137     {
       
  4138     DBG_PRINT("CNSmlDmVoIPAdapter::FetchLeafObjectSizeL(): begin");
       
  4139 
       
  4140     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  4141 
       
  4142     CBufBase *object = CBufFlat::NewL( 1 );
       
  4143     CleanupStack::PushL( object );
       
  4144     CSmlDmAdapter::TError retValue = FetchObjectL( aURI, aLUID, *object );
       
  4145 
       
  4146     TInt objSizeInBytes = object->Size();
       
  4147     TBuf8<16> stringObjSizeInBytes;
       
  4148     stringObjSizeInBytes.Num( objSizeInBytes );
       
  4149     object->Reset();
       
  4150     object->InsertL( 0, stringObjSizeInBytes );
       
  4151 
       
  4152     iDmCallback->SetStatusL( aStatusRef, retValue );
       
  4153     iDmCallback->SetResultsL( aResultsRef, *object, aType );
       
  4154     CleanupStack::PopAndDestroy( object ); 
       
  4155     object = NULL;
       
  4156     DBG_PRINT("CNSmlDmVoIPAdapter::FetchLeafObjectSizeL(): end");
       
  4157     }
       
  4158 
       
  4159 // ---------------------------------------------------------------------------
       
  4160 // CNSmlDmVoIPAdapter::ExecuteCommandL  
       
  4161 // ---------------------------------------------------------------------------
       
  4162 //
       
  4163 void CNSmlDmVoIPAdapter::ExecuteCommandL( 
       
  4164     const TDesC8& /*aURI*/, 
       
  4165     const TDesC8& /*aLUID*/, 
       
  4166     const TDesC8& /*aArgument*/, 
       
  4167     const TDesC8& /*aType*/, 
       
  4168     const TInt aStatusRef )
       
  4169     {
       
  4170     DBG_PRINT("CNSmlDmVoIPAdapter::ExecuteCommandL(): begin");
       
  4171     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  4172     iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  4173     DBG_PRINT("CNSmlDmVoIPAdapter::ExecuteCommandL(): end");
       
  4174     }
       
  4175 
       
  4176 // ---------------------------------------------------------------------------
       
  4177 // CNSmlDmVoIPAdapter::ExecuteCommandL  
       
  4178 // ---------------------------------------------------------------------------
       
  4179 //
       
  4180 void CNSmlDmVoIPAdapter::ExecuteCommandL( 
       
  4181     const TDesC8& /*aURI*/, 
       
  4182     const TDesC8& /*aParentLUID*/, 
       
  4183     RWriteStream*& /*aStream*/, 
       
  4184     const TDesC8& /*aType*/, 
       
  4185     const TInt aStatusRef )
       
  4186     {
       
  4187     DBG_PRINT("CNSmlDmVoIPAdapter::ExecuteCommandL(): stream: begin");
       
  4188     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  4189     iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  4190     DBG_PRINT("CNSmlDmVoIPAdapter::ExecuteCommandL(): stream: end");
       
  4191     }
       
  4192 
       
  4193 // ---------------------------------------------------------------------------
       
  4194 // CNSmlDmVoIPAdapter::CopyCommandL  
       
  4195 // ---------------------------------------------------------------------------
       
  4196 //
       
  4197 void CNSmlDmVoIPAdapter::CopyCommandL( 
       
  4198     const TDesC8& /*aTargetURI*/, 
       
  4199     const TDesC8& /*aTargetLUID*/, 
       
  4200     const TDesC8& /*aSourceURI*/, 
       
  4201     const TDesC8& /*aSourceLUID*/, 
       
  4202     const TDesC8& /*aType*/, 
       
  4203     TInt aStatusRef )
       
  4204     {
       
  4205     DBG_PRINT("CNSmlDmVoIPAdapter::CopyCommandL(): begin");
       
  4206     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  4207     iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
  4208     DBG_PRINT("CNSmlDmVoIPAdapter::CopyCommandL(): end");
       
  4209     }
       
  4210 
       
  4211 // ---------------------------------------------------------------------------
       
  4212 // CNSmlDmVoIPAdapter::StartAtomicL
       
  4213 // For signaling adapter of beginning of the atomic section
       
  4214 // ---------------------------------------------------------------------------
       
  4215 //
       
  4216 void CNSmlDmVoIPAdapter::StartAtomicL()
       
  4217     {
       
  4218     DBG_PRINT("CNSmlDmVoIPAdapter::StartAtomicL(): begin");
       
  4219     DBG_PRINT("CNSmlDmVoIPAdapter::StartAtomicL(): end");
       
  4220     }
       
  4221 
       
  4222 // ---------------------------------------------------------------------------
       
  4223 // CNSmlDmVoIPAdapter::CommitAtomicL
       
  4224 // The CommitAtomicL call is issued only if all the commands in the Atomic were successful 
       
  4225 // ---------------------------------------------------------------------------
       
  4226 //
       
  4227 void CNSmlDmVoIPAdapter::CommitAtomicL()
       
  4228     {
       
  4229     DBG_PRINT("CNSmlDmVoIPAdapter::CommitAtomicL(): begin");
       
  4230     DBG_PRINT("CNSmlDmVoIPAdapter::CommitAtomicL(): end");
       
  4231     }
       
  4232 
       
  4233 // ---------------------------------------------------------------------------
       
  4234 // CNSmlDmVoIPAdapter::RollbackAtomicL
       
  4235 // For signaling adapter to roll back all atomic commands
       
  4236 // ---------------------------------------------------------------------------
       
  4237 //
       
  4238 void CNSmlDmVoIPAdapter::RollbackAtomicL()
       
  4239     {
       
  4240     DBG_PRINT("CNSmlDmVoIPAdapter::RollbackAtomicL(): begin");
       
  4241     DBG_PRINT("CNSmlDmVoIPAdapter::RollbackAtomicL(): end");
       
  4242     }
       
  4243 
       
  4244 // ---------------------------------------------------------------------------
       
  4245 // CNSmlDmVoIPAdapter::StreamingSupport
       
  4246 // For telling framework whether streaming large object data is supported
       
  4247 // ---------------------------------------------------------------------------
       
  4248 //
       
  4249 TBool CNSmlDmVoIPAdapter::StreamingSupport( TInt& /*aItemSize*/ )
       
  4250     {
       
  4251     DBG_PRINT("CNSmlDmVoIPAdapter::StreamingSupport(): begin");
       
  4252     DBG_PRINT("CNSmlDmVoIPAdapter::StreamingSupport(): end");
       
  4253     return EFalse;
       
  4254     }
       
  4255 
       
  4256 // ---------------------------------------------------------------------------
       
  4257 // CNSmlDmVoIPAdapter::StreamCommittedL()
       
  4258 // For telling adapter when streaming large object is finished.
       
  4259 // ---------------------------------------------------------------------------
       
  4260 //
       
  4261 void CNSmlDmVoIPAdapter::StreamCommittedL()
       
  4262     {
       
  4263     DBG_PRINT("CNSmlDmVoIPAdapter::StreamCommittedL(): begin");
       
  4264     DBG_PRINT("CNSmlDmVoIPAdapter::StreamCommittedL(): end");
       
  4265     }
       
  4266 
       
  4267 // ---------------------------------------------------------------------------
       
  4268 // CNSmlDmVoIPAdapter::CompleteOutstandingCmdsL()
       
  4269 // When all buffered dm commands are sent to adapter, set SIP User Agent 
       
  4270 // Header into SIPManagedProfile, and save all changes.
       
  4271 // ---------------------------------------------------------------------------
       
  4272 //
       
  4273 void CNSmlDmVoIPAdapter::CompleteOutstandingCmdsL()
       
  4274     {
       
  4275     DBG_PRINT("CNSmlDmVoIPAdapter::CompleteOutstandingCmdsL(): begin");
       
  4276 
       
  4277     // Save only profiles that have changed. If there are such profiles,
       
  4278     // save changed profiles back to permanent store
       
  4279     if ( iProfileEntries.Count() )
       
  4280         {
       
  4281         for ( TInt counter = 0; counter < iProfileModifs.Count(); counter++ )
       
  4282             {
       
  4283             for ( TInt index = 0; index < iProfileEntries[counter]->
       
  4284                 iIds.Count(); index++ )
       
  4285                 {
       
  4286                 if ( ( 0 == iProfileEntries[counter]->
       
  4287                     iIds[index].iProfileType ) 
       
  4288                     && iProfileEntries[counter]->
       
  4289                         iIds[index].iProfileId > 1
       
  4290                     && ( iProfileEntries[counter]->
       
  4291                         iSIPVoIPUAHTerminalType ||
       
  4292                         iProfileEntries[counter]->
       
  4293                         iSIPVoIPUAHeaderWLANMAC ||
       
  4294                         iProfileEntries[counter]->
       
  4295                         iSIPVoIPUAHeaderString.Length() > 0 ) )
       
  4296                     {
       
  4297                     // Create objects that allow the creation of
       
  4298                     // CSIPManagedProfile object.
       
  4299                     CSIPProfile* sipProf = NULL;
       
  4300                     CSIPProfileRegistryObserver* sipRegObs =
       
  4301                         CSIPProfileRegistryObserver::NewLC(); // CS:1
       
  4302                     CSIPManagedProfileRegistry* sipProfReg = 
       
  4303                         CSIPManagedProfileRegistry::NewLC( 
       
  4304                             *sipRegObs ); // CS:2
       
  4305                     TRAPD( err, ( sipProf = sipProfReg->ProfileL( 
       
  4306                         iProfileEntries[counter]->
       
  4307                         iIds[index].iProfileId ) ) );
       
  4308                     if ( KErrNone == err )
       
  4309                         {
       
  4310                         CSIPManagedProfile* sipManProf = 
       
  4311                             static_cast<CSIPManagedProfile*>( sipProf );
       
  4312                         CleanupStack::PushL( sipManProf ); // CS:3
       
  4313                         // Compile the User Agent Header into a TBuf string.
       
  4314                         TBuf8<KTempStringlength> userAgentHeader;
       
  4315                         TBuf<KMaxTerminalTypeLength> tempTerminalType;
       
  4316                         TBuf<KWlanMacAddressLength> tempWlanMac;
       
  4317                         TBuf<KMaxSettingsLength32> tempFreeString;
       
  4318                         tempFreeString = iProfileEntries[counter]->
       
  4319                             iSIPVoIPUAHeaderString;
       
  4320 
       
  4321                         userAgentHeader.Append( KUserAgent );
       
  4322                         userAgentHeader.Append( KColonMark );
       
  4323                         userAgentHeader.Append( KSpaceMark );
       
  4324 
       
  4325                         if ( iProfileEntries[counter]->
       
  4326                             iSIPVoIPUAHTerminalType )
       
  4327                             {
       
  4328                             GetTerminalTypeL( tempTerminalType );
       
  4329                             userAgentHeader.Append( tempTerminalType );
       
  4330                             userAgentHeader.Append( KSpaceMark );
       
  4331                             }
       
  4332                         if ( iProfileEntries[counter]->
       
  4333                             iSIPVoIPUAHeaderWLANMAC )
       
  4334                             {
       
  4335                             GetWlanMacAddressL( tempWlanMac );
       
  4336                             userAgentHeader.Append( tempWlanMac );
       
  4337                             userAgentHeader.Append( KSpaceMark );
       
  4338                             }
       
  4339                         if ( tempFreeString.Length() > 0 )
       
  4340                             {
       
  4341                             userAgentHeader.Append( tempFreeString );
       
  4342                             }
       
  4343 
       
  4344                         // Create an array for setting the user agent header.
       
  4345                         // Granularity is 1 since only one item is appended
       
  4346                         // into the array.
       
  4347                         CDesC8ArrayFlat* uahArray = new ( ELeave ) 
       
  4348                             CDesC8ArrayFlat( 1 );
       
  4349         	            CleanupStack::PushL( uahArray ); // CS:4
       
  4350         	            uahArray->AppendL( userAgentHeader );
       
  4351                         if ( userAgentHeader.Length() > 0 )
       
  4352                             {
       
  4353                             User::LeaveIfError( 
       
  4354                                 sipManProf->SetParameter( 
       
  4355                                 KSIPHeaders, *uahArray ) );
       
  4356                             }
       
  4357 
       
  4358                         sipProfReg->SaveL( *sipManProf );
       
  4359                         uahArray->Reset();
       
  4360                         // uahArray, sipManProf 
       
  4361                         CleanupStack::PopAndDestroy( 2, sipManProf ); // CS:2
       
  4362                         }// if
       
  4363                     // sipProfReg, sipRegObs
       
  4364                     CleanupStack::PopAndDestroy( 2, sipRegObs ); // CS:0
       
  4365                     sipProf = NULL;
       
  4366                     }// if
       
  4367                 }// for
       
  4368             iCRCSEProfile->UpdateL( 
       
  4369                 iProfileEntries[iProfileModifs[counter]]->iId,
       
  4370                 *iProfileEntries[iProfileModifs[counter]] );
       
  4371             }
       
  4372         iProfileModifs.Reset();
       
  4373         }
       
  4374 
       
  4375     if ( iCodecEntries.Count() )
       
  4376         {
       
  4377         for ( TInt counter = 0; counter < iCodecModifs.Count(); counter++ )
       
  4378             {
       
  4379             iCRCSEAudioCodec->UpdateL( iCodecEntries[iCodecModifs[counter]]->
       
  4380                 iCodecId, *iCodecEntries[iCodecModifs[counter]] );
       
  4381             }
       
  4382         iCodecModifs.Reset();
       
  4383         }  
       
  4384 
       
  4385     // Since CRCSEProfileRegistry::UpdateL takes CRCSEProfileEntry as const,
       
  4386     // the service ID'S in iProfileEntries array items have not changed.
       
  4387     // Hence load all profiles again from CRCSEProfileRegistry.
       
  4388     iCodecEntries.ResetAndDestroy();
       
  4389     iProfileEntries.ResetAndDestroy();
       
  4390     LoadProfilesL();
       
  4391 
       
  4392 
       
  4393     const TInt spSettingsCount = iSPSettings.Count();
       
  4394     if ( spSettingsCount )
       
  4395         {
       
  4396         // Set SPS ready for setting values.
       
  4397         CSPSettings* spSettings = CSPSettings::NewLC(); // CS:1
       
  4398 
       
  4399         for ( TInt counter = 0; counter < spSettingsCount; counter++ )
       
  4400             {
       
  4401             TUint32 serviceId = 
       
  4402                 iProfileEntries[iProfileID]->iServiceProviderId;
       
  4403 
       
  4404             TInt err( KErrNone );
       
  4405             CSPEntry* spEntry = CSPEntry::NewLC(); // CS:2
       
  4406             err = spSettings->FindEntryL( serviceId, *spEntry );
       
  4407             User::LeaveIfError( err );
       
  4408 
       
  4409             CSPProperty* property = CSPProperty::NewLC(); // CS:3
       
  4410 
       
  4411             // VMBX MWI-URI.
       
  4412             if ( iSPSettings[counter]->iVmbxMwiUri->Des().Length() )
       
  4413                 {
       
  4414                 err = property->SetName( ESubPropertyVMBXMWIAddress );
       
  4415                 property->SetValue( 
       
  4416                     iSPSettings[counter]->iVmbxMwiUri->Des() );
       
  4417                 if ( KErrNone == err )
       
  4418                     {
       
  4419                     err = spEntry->AddPropertyL( *property );
       
  4420                     if ( KErrAlreadyExists == err )
       
  4421                         {
       
  4422                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4423                             ESubPropertyVMBXMWIAddress, 
       
  4424                             iSPSettings[counter]->iVmbxMwiUri->Des() ) );
       
  4425                         }
       
  4426                     else
       
  4427                         {
       
  4428                         User::LeaveIfError( err );
       
  4429                         }
       
  4430                     }
       
  4431 
       
  4432                 // Let's check if listening URI has been or is about
       
  4433                 // to be set. If not, set same as in MWI address.
       
  4434                 CSPProperty* listeningUri = CSPProperty::NewLC();
       
  4435                 err = spSettings->FindPropertyL( serviceId, 
       
  4436                     ESubPropertyVMBXListenAddress, *listeningUri );
       
  4437                 if ( KErrNone != err && 
       
  4438                     !iSPSettings[counter]->iVmbxListenUri->Des().Length() )
       
  4439                     {
       
  4440                     delete iSPSettings[counter]->iVmbxListenUri;
       
  4441                     iSPSettings[counter]->iVmbxListenUri = NULL;
       
  4442                     iSPSettings[counter]->iVmbxListenUri = 
       
  4443                         iSPSettings[counter]->iVmbxMwiUri->Des().AllocL();
       
  4444                     }
       
  4445                 CleanupStack::PopAndDestroy( listeningUri );
       
  4446 
       
  4447                 // Let's check if re-subscribe interval has been or is
       
  4448                 // about to be set. If not, set default value.
       
  4449                 CSPProperty* reSubscrInterval = CSPProperty::NewLC();
       
  4450                 err = spSettings->FindPropertyL( serviceId, 
       
  4451                     ESubPropertyVMBXMWISubscribeInterval, *reSubscrInterval );
       
  4452                 if ( KErrNone != err && 
       
  4453                     iSPSettings[counter]->iReSubscribeInterval == KErrNotFound )
       
  4454                     {
       
  4455                     iSPSettings[counter]->iReSubscribeInterval = 
       
  4456                         KDefaultReSubscribe;
       
  4457                     }
       
  4458                 CleanupStack::PopAndDestroy( reSubscrInterval );
       
  4459                 }
       
  4460 
       
  4461             // VMBX ListeningURI.
       
  4462             if ( iSPSettings[counter]->iVmbxListenUri->Des().Length() )
       
  4463                 {
       
  4464                 err = property->SetName( ESubPropertyVMBXListenAddress );
       
  4465                 property->SetValue( 
       
  4466                     iSPSettings[counter]->iVmbxListenUri->Des() );
       
  4467                 if ( KErrNone == err )
       
  4468                     {
       
  4469                     err = spEntry->AddPropertyL( *property );
       
  4470                     if ( KErrAlreadyExists == err )
       
  4471                         {
       
  4472                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4473                             ESubPropertyVMBXListenAddress, 
       
  4474                             iSPSettings[counter]->iVmbxListenUri->Des() ) );
       
  4475                         }
       
  4476                     else
       
  4477                         {
       
  4478                         User::LeaveIfError( err );
       
  4479                         }
       
  4480                     }
       
  4481                 }
       
  4482 
       
  4483             // VMBX IAP ID.
       
  4484             if ( KErrNone != iSPSettings[counter]->iVmbxIapId )
       
  4485                 {
       
  4486                 err = property->SetName( ESubPropertyVMBXPreferredIAPId );
       
  4487                 property->SetValue( iSPSettings[counter]->iVmbxIapId );
       
  4488                 if ( KErrNone == err )
       
  4489                     {
       
  4490                     err = spEntry->AddPropertyL( *property );
       
  4491                     if ( KErrAlreadyExists == err )
       
  4492                         {
       
  4493                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4494                             ESubPropertyVMBXPreferredIAPId, 
       
  4495                             iSPSettings[counter]->iVmbxIapId ) );
       
  4496                         }
       
  4497                     else
       
  4498                         {
       
  4499                         User::LeaveIfError( err );
       
  4500                         }
       
  4501                     }
       
  4502                 }
       
  4503 
       
  4504             // VMBX re-SUBSCRIBE interval.
       
  4505             if ( KErrNotFound != iSPSettings[counter]->iReSubscribeInterval )
       
  4506                 {
       
  4507                 err = property->SetName( 
       
  4508                     ESubPropertyVMBXMWISubscribeInterval );
       
  4509                 property->SetValue( 
       
  4510                     iSPSettings[counter]->iReSubscribeInterval );
       
  4511                 if ( KErrNone == err )
       
  4512                     {
       
  4513                     err = spEntry->AddPropertyL( *property );
       
  4514                     if ( KErrAlreadyExists == err )
       
  4515                         {
       
  4516                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4517                             ESubPropertyVMBXMWISubscribeInterval, 
       
  4518                             iSPSettings[counter]->iReSubscribeInterval ) );
       
  4519                         }
       
  4520                     else
       
  4521                         {
       
  4522                         User::LeaveIfError( err );
       
  4523                         }
       
  4524                     }
       
  4525                 }
       
  4526 
       
  4527             // VMBX SIP ID.
       
  4528             if ( KErrNone != iSPSettings[counter]->iVmbxSipId )
       
  4529                 {
       
  4530                 err = property->SetName( ESubPropertyVMBXSettingsId );
       
  4531                 property->SetValue( iSPSettings[counter]->iVmbxSipId );
       
  4532                 if ( KErrNone == err )
       
  4533                     {
       
  4534                     err = spEntry->AddPropertyL( *property );
       
  4535                     if ( KErrAlreadyExists == err )
       
  4536                         {
       
  4537                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4538                             ESubPropertyVMBXSettingsId, 
       
  4539                             iSPSettings[counter]->iVmbxSipId ) );
       
  4540                         }
       
  4541                     else
       
  4542                         {
       
  4543                         User::LeaveIfError( err );
       
  4544                         }
       
  4545                     }
       
  4546                 }
       
  4547 
       
  4548             // Service provider bookmark URI.
       
  4549             if ( iSPSettings[counter]->iServiceProviderBookmark->
       
  4550                 Des().Length() )
       
  4551                 {
       
  4552                 err = property->SetName( EPropertyServiceBookmarkUri );
       
  4553                 property->SetValue( 
       
  4554                     iSPSettings[counter]->iServiceProviderBookmark->Des() );
       
  4555                 if ( KErrNone == err )
       
  4556                     {
       
  4557                     err = spEntry->AddPropertyL( *property );
       
  4558                     if ( KErrAlreadyExists == err )
       
  4559                         {
       
  4560                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4561                             EPropertyServiceBookmarkUri, 
       
  4562                             iSPSettings[counter]->
       
  4563                             iServiceProviderBookmark->Des() ) );
       
  4564                         }
       
  4565                     else
       
  4566                         {
       
  4567                         User::LeaveIfError( err );
       
  4568                         }
       
  4569                     }
       
  4570                 }
       
  4571 
       
  4572             // Branding data URI.
       
  4573             if ( iSPSettings[counter]->iBrandingDataUri->Des().Length() )
       
  4574                 {
       
  4575                 err = property->SetName( ESubPropertyVoIPBrandDataUri );
       
  4576                 property->SetValue( 
       
  4577                     iSPSettings[counter]->iBrandingDataUri->Des() );
       
  4578                 if ( KErrNone == err )
       
  4579                     {
       
  4580                     err = spEntry->AddPropertyL( *property );
       
  4581                     if ( KErrAlreadyExists == err )
       
  4582                         {
       
  4583                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4584                             ESubPropertyVoIPBrandDataUri, 
       
  4585                             iSPSettings[counter]->iBrandingDataUri->Des() ) );
       
  4586                         }
       
  4587                     else
       
  4588                         {
       
  4589                         User::LeaveIfError( err );
       
  4590                         }
       
  4591                     }
       
  4592                 }
       
  4593 
       
  4594             // Presence settings ID.
       
  4595             if ( KErrNone != iSPSettings[counter]->iPresenceId )
       
  4596                 {
       
  4597                 err = property->SetName( ESubPropertyPresenceSettingsId );
       
  4598                 property->SetValue( 
       
  4599                     iSPSettings[counter]->iPresenceId );
       
  4600                 if ( KErrNone == err )
       
  4601                     {
       
  4602                     err = spEntry->AddPropertyL( *property );
       
  4603                     if ( KErrAlreadyExists == err )
       
  4604                         {
       
  4605                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4606                             ESubPropertyPresenceSettingsId, 
       
  4607                             iSPSettings[counter]->iPresenceId ) );
       
  4608                         }
       
  4609                     else
       
  4610                         {
       
  4611                         User::LeaveIfError( err );
       
  4612                         }
       
  4613                     }
       
  4614                 }
       
  4615 
       
  4616             // Presence auto accept buddy request.
       
  4617             if ( KErrNotFound != iSPSettings[counter]->iAutoAcceptBuddy )
       
  4618                 {
       
  4619                 TOnOff value( static_cast<TOnOff>( 
       
  4620                     iSPSettings[counter]->iAutoAcceptBuddy ) );
       
  4621                 err = property->SetName( 
       
  4622                     ESubPropertyPresenceRequestPreference );
       
  4623                 property->SetValue( value );
       
  4624                 if ( KErrNone == err )
       
  4625                     {
       
  4626                     err = spEntry->AddPropertyL( *property );
       
  4627                     if ( KErrAlreadyExists == err )
       
  4628                         {
       
  4629                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4630                             ESubPropertyPresenceRequestPreference, value ) );
       
  4631                         }
       
  4632                     else
       
  4633                         {
       
  4634                         User::LeaveIfError( err );
       
  4635                         }
       
  4636                     }
       
  4637                 }
       
  4638 
       
  4639             // Auto enable service.
       
  4640             if ( KErrNotFound != iSPSettings[counter]->iAutoEnableService )
       
  4641                 {
       
  4642                 TOnOff value( static_cast<TOnOff>( 
       
  4643                     iSPSettings[counter]->iAutoEnableService ) );
       
  4644                 err = property->SetName( ESubPropertyVoIPEnabled );
       
  4645                 err = property->SetValue( value );
       
  4646                 if ( KErrNone == err )
       
  4647                     {
       
  4648                     err = spEntry->AddPropertyL( *property );
       
  4649                     if ( KErrAlreadyExists == err )
       
  4650                         {
       
  4651                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4652                             ESubPropertyVoIPEnabled, value ) ) ;
       
  4653                         }
       
  4654                     else
       
  4655                         {
       
  4656                         User::LeaveIfError( err );
       
  4657                         }
       
  4658                     }
       
  4659                 // enable presence
       
  4660                 if ( KErrNone != iSPSettings[counter]->iPresenceId )
       
  4661                     {
       
  4662                     err = property->SetName( ESubPropertyPresenceEnabled );
       
  4663                     property->SetValue( value );
       
  4664                     if ( KErrNone == err )
       
  4665                         {
       
  4666                         err = spEntry->AddPropertyL( *property );
       
  4667                         if ( KErrAlreadyExists == err )
       
  4668                             {
       
  4669                             User::LeaveIfError( spEntry->UpdateProperty( 
       
  4670                                 ESubPropertyPresenceEnabled, value ) );
       
  4671                             }
       
  4672                         else
       
  4673                             {
       
  4674                             User::LeaveIfError( err );
       
  4675                             }
       
  4676                         }
       
  4677                     }
       
  4678                 // enable voicemailbox
       
  4679                 if ( KErrNone != iSPSettings[counter]->iVmbxIapId )
       
  4680                     {
       
  4681                     err = property->SetName( ESubPropertyVMBXEnabled );
       
  4682                     property->SetValue( value );
       
  4683                     if ( KErrNone == err )
       
  4684                         {
       
  4685                         err = spEntry->AddPropertyL( *property );
       
  4686                         if ( KErrAlreadyExists == err )
       
  4687                             {
       
  4688                             User::LeaveIfError( spEntry->UpdateProperty( 
       
  4689                                 ESubPropertyVMBXEnabled, value ) );
       
  4690                             }
       
  4691                         else
       
  4692                             {
       
  4693                             User::LeaveIfError( err );
       
  4694                             }
       
  4695                         }
       
  4696                     }
       
  4697                 }
       
  4698 
       
  4699             // SNAP Profile ID.
       
  4700             if ( KErrNone != iSPSettings[counter]->iSnapId )
       
  4701                 {
       
  4702                 err = property->SetName( ESubPropertyVoIPPreferredSNAPId );
       
  4703                 property->SetValue( iSPSettings[counter]->iSnapId );
       
  4704                 if ( KErrNone == err )
       
  4705                     {
       
  4706                     err = spEntry->AddPropertyL( *property );
       
  4707                     if ( KErrAlreadyExists == err )
       
  4708                         {
       
  4709                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4710                             ESubPropertyVoIPPreferredSNAPId, 
       
  4711                             iSPSettings[counter]->iSnapId ) );
       
  4712                         }
       
  4713                     else
       
  4714                         {
       
  4715                         User::LeaveIfError( err );
       
  4716                         }
       
  4717                     }
       
  4718                 }
       
  4719 
       
  4720             // Enable IM
       
  4721             if ( KErrNotFound != iSPSettings[counter]->iImEnabled )
       
  4722                 {
       
  4723                 // IM is enabled => add or set IM properties.
       
  4724                 if ( iSPSettings[counter]->iImEnabled )
       
  4725                     {
       
  4726                     // IM enabled.
       
  4727                     property->SetName( ESubPropertyIMEnabled );
       
  4728                     property->SetValue( EOn );
       
  4729                     err = spEntry->AddPropertyL( *property );
       
  4730                     if ( KErrAlreadyExists == err )
       
  4731                         {
       
  4732                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4733                             ESubPropertyIMEnabled, EOn ) );
       
  4734                         }
       
  4735 
       
  4736                     // IM launch UID.
       
  4737                     property->SetName( ESubPropertyIMLaunchUid );
       
  4738                     property->SetValue( KIMLaunchUid );
       
  4739                     err = spEntry->AddPropertyL( *property );
       
  4740                     if ( KErrAlreadyExists == err )
       
  4741                         {
       
  4742                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4743                             ESubPropertyIMLaunchUid, KIMLaunchUid ) );
       
  4744                         }
       
  4745 
       
  4746                     // IM settings ID.
       
  4747                     property->SetName( ESubPropertyIMSettingsId );
       
  4748                     // The value only needs to be different from 0,
       
  4749                     // no-one actually uses it.
       
  4750                     property->SetValue( KIMSettingsId );
       
  4751                     err = spEntry->AddPropertyL( *property );
       
  4752                     if ( KErrAlreadyExists == err )
       
  4753                         {
       
  4754                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4755                             ESubPropertyIMSettingsId, KIMSettingsId ) );
       
  4756                         }
       
  4757 
       
  4758                     // IM sub-service plugin UID.
       
  4759                     property->SetName( EPropertyIMSubServicePluginId );
       
  4760                     property->SetValue( KIMSubServicePluginId );
       
  4761                     err = spEntry->AddPropertyL( *property );
       
  4762                     if ( KErrAlreadyExists == err )
       
  4763                         {
       
  4764                         User::LeaveIfError( spEntry->UpdateProperty( 
       
  4765                             EPropertyIMSubServicePluginId, 
       
  4766                             KIMSubServicePluginId ) );
       
  4767                         }
       
  4768 
       
  4769                     // IM preferred SNAP ID.
       
  4770                     const CSPProperty* snap;
       
  4771                     spEntry->GetProperty( snap, 
       
  4772                         ESubPropertyVoIPPreferredSNAPId );
       
  4773                     TInt snapId( KErrNone );
       
  4774                     err = snap->GetValue( snapId );
       
  4775                     if ( KErrNone == err )
       
  4776                         {
       
  4777                         property->SetName( ESubPropertyIMPreferredSNAPId );
       
  4778                         err = property->SetValue( snapId );
       
  4779                         if ( KErrNone == err )
       
  4780                             {
       
  4781                             err = spEntry->AddPropertyL( *property );
       
  4782                            if ( KErrAlreadyExists == err )
       
  4783                                 {
       
  4784                                 User::LeaveIfError( spEntry->UpdateProperty( 
       
  4785                                     ESubPropertyIMPreferredSNAPId, 
       
  4786                                     snapId ) );
       
  4787                                 }
       
  4788                             }
       
  4789                         }
       
  4790 
       
  4791                     // IM default tone.
       
  4792                     TFileName toneFile;
       
  4793                     toneFile.Copy( PathInfo::RomRootPath() );
       
  4794                     toneFile.Append( PathInfo::DigitalSoundsPath() );
       
  4795                     toneFile.Append( KDefaultTone );
       
  4796                     MVIMPSTSettingsStore* vimpStSettings =
       
  4797                         CVIMPSTSettingsStore::NewLC(); // CS:4
       
  4798                     User::LeaveIfError( vimpStSettings->SetL( serviceId,
       
  4799                         EServiceToneFileName, toneFile ) );
       
  4800                     // Pop vimpStSettings (can't use M object as argument).
       
  4801                     CleanupStack::PopAndDestroy(); // CS:3
       
  4802                     }
       
  4803                 // IM enabled is set to false => delete IM properties.
       
  4804                 else
       
  4805                     {
       
  4806                     spEntry->DeleteProperty( ESubPropertyIMEnabled );
       
  4807                     spEntry->DeleteProperty( ESubPropertyIMLaunchUid );
       
  4808                     spEntry->DeleteProperty( ESubPropertyIMSettingsId );
       
  4809                     spEntry->DeleteProperty( EPropertyIMSubServicePluginId );
       
  4810                     spEntry->DeleteProperty( ESubPropertyIMPreferredSNAPId );
       
  4811                     }
       
  4812                 }
       
  4813 
       
  4814             err = spSettings->UpdateEntryL( *spEntry );
       
  4815             // property, spEntry
       
  4816             CleanupStack::PopAndDestroy( 2, spEntry ); // CS:1
       
  4817             } // for
       
  4818         CleanupStack::PopAndDestroy( spSettings ); // CS:0
       
  4819         iSPSettings.ResetAndDestroy();
       
  4820         }
       
  4821 
       
  4822     DBG_PRINT("CNSmlDmVoIPAdapter::CompleteOutstandingCmdsL(): end");   
       
  4823     }
       
  4824 
       
  4825 // ---------------------------------------------------------------------------
       
  4826 // CNSmlDmVoIPAdapter::FindProfileLocation
       
  4827 // Finds profileID from aURI and returns profile location in array.
       
  4828 // ---------------------------------------------------------------------------
       
  4829 //
       
  4830 TInt CNSmlDmVoIPAdapter::FindProfileLocation( const TDesC8& aURI ) const
       
  4831     {
       
  4832     TInt id( 0 );
       
  4833     id = aURI.Find( KNSmlDMVoIPPrefix );
       
  4834     if ( id != KErrNotFound )
       
  4835         {
       
  4836         id = DesToInt( aURI.Mid( id + KNSmlDMVoIPPrefix().Length(), 10 ) ); 
       
  4837         for ( TInt counter = 0; counter < iProfileEntries.Count(); counter++ )
       
  4838             {
       
  4839             if ( iProfileEntries[counter]->iId == id )
       
  4840                 {
       
  4841                 return counter;
       
  4842                 }
       
  4843             }
       
  4844         }
       
  4845     return KErrNotFound;
       
  4846     }
       
  4847 
       
  4848 // ---------------------------------------------------------------------------
       
  4849 // CNSmlDmVoIPAdapter::DesToInt
       
  4850 // Converts a 8 bit descriptor to int.
       
  4851 // ---------------------------------------------------------------------------
       
  4852 //
       
  4853 TInt CNSmlDmVoIPAdapter::DesToInt( const TDesC8& aDes ) const
       
  4854     {
       
  4855     TLex8 lex( aDes );
       
  4856     TInt value = 0;
       
  4857     lex.Val( value );
       
  4858     return value;
       
  4859     }
       
  4860 
       
  4861 // ---------------------------------------------------------------------------
       
  4862 // CNSmlDmVoIPAdapter::DesToTUint
       
  4863 // Converts a 8bit descriptor to TUint.
       
  4864 // ---------------------------------------------------------------------------
       
  4865 //
       
  4866 TUint CNSmlDmVoIPAdapter::DesToTUint( const TDesC8& aDes ) const
       
  4867     {
       
  4868     TLex8 lex( aDes );
       
  4869     TUint value = 0;
       
  4870     lex.Val( value );
       
  4871     return value;
       
  4872     }
       
  4873 
       
  4874 // ---------------------------------------------------------------------------
       
  4875 // TPtrC8 CNSmlDmVoIPAdapter::RemoveLastURISeg
       
  4876 // returns parent uri, i.e. removes last uri segment
       
  4877 // ---------------------------------------------------------------------------
       
  4878 //
       
  4879 const TPtrC8 CNSmlDmVoIPAdapter::RemoveLastURISeg( const TDesC8& aURI ) const
       
  4880     {
       
  4881     TInt i ( 0 );
       
  4882     if ( KErrNotFound != aURI.Find( KNSmlDMVoIPSeparator ) )
       
  4883         {
       
  4884         for ( i = aURI.Length() - 1; i >= 0; i-- )
       
  4885             {
       
  4886             if ( KDMVoIPSeparator == aURI[i]  )
       
  4887                 {
       
  4888                 break;
       
  4889                 }
       
  4890             }
       
  4891         }
       
  4892     return aURI.Left( i );
       
  4893     }
       
  4894 
       
  4895 // ---------------------------------------------------------------------------
       
  4896 // TInt CNSmlDmVoIPAdapter::NumOfURISegs
       
  4897 // For getting the number of uri segs
       
  4898 // ---------------------------------------------------------------------------
       
  4899 //
       
  4900 TInt CNSmlDmVoIPAdapter::NumOfURISegs( const TDesC8& aURI ) const
       
  4901     {
       
  4902     TInt numOfURISegs = 1;
       
  4903     for ( TInt i = 0; i < aURI.Length(); i++ )
       
  4904         {
       
  4905         if ( KDMVoIPSeparator == aURI[i]  )
       
  4906             {
       
  4907             numOfURISegs++;
       
  4908             }
       
  4909         }
       
  4910     return numOfURISegs;
       
  4911     }
       
  4912 
       
  4913 // ---------------------------------------------------------------------------
       
  4914 // TPtrC8 CNSmlDmVoIPAdapter::LastURISeg
       
  4915 // Returns only the last uri segment
       
  4916 // ---------------------------------------------------------------------------
       
  4917 //
       
  4918 const TPtrC8 CNSmlDmVoIPAdapter::LastURISeg( const TDesC8& aURI ) const
       
  4919     {
       
  4920     TInt i( 0 );
       
  4921     if ( KErrNotFound != aURI.Find( KNSmlDMVoIPSeparator ) )
       
  4922         {
       
  4923         for ( i = aURI.Length() - 1; i >= 0; i-- )
       
  4924             {
       
  4925             if ( KDMVoIPSeparator == aURI[i] )
       
  4926                 {
       
  4927                 break;
       
  4928                 }
       
  4929             }
       
  4930         }
       
  4931     if ( 0 == i )
       
  4932         {
       
  4933         return aURI;
       
  4934         }
       
  4935     else
       
  4936         {
       
  4937         return aURI.Mid( i + 1 );
       
  4938         }
       
  4939     }
       
  4940 
       
  4941 // ---------------------------------------------------------------------------
       
  4942 // TPtrC8 CNSmlDmVoIPAdapter::RemoveDotSlash
       
  4943 // return uri without dot and slash in start
       
  4944 // ---------------------------------------------------------------------------
       
  4945 //
       
  4946 const TPtrC8 CNSmlDmVoIPAdapter::RemoveDotSlash( const TDesC8& aURI ) const
       
  4947     {
       
  4948     if ( 0 == aURI.Find( KNSmlVoIPUriDotSlash ) )
       
  4949         {
       
  4950         return aURI.Right( aURI.Length() - KNSmlVoIPUriDotSlash().Length() );
       
  4951         }
       
  4952     else
       
  4953         {
       
  4954         return aURI;
       
  4955         }
       
  4956     }
       
  4957 
       
  4958 // ---------------------------------------------------------------------------
       
  4959 // CNSmlDmVoIPAdapter::SetSipRefL
       
  4960 // Set sip reference value.
       
  4961 // ---------------------------------------------------------------------------
       
  4962 //
       
  4963 TUint32 CNSmlDmVoIPAdapter::SetSipRefL( const TDesC8& aObject ) const
       
  4964     {
       
  4965     DBG_PRINT("CNSmlDmVoIPAdapter::SetSipRef() : begin");
       
  4966     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  4967 
       
  4968     CBufBase* fetchResult = CBufFlat::NewL( 1 );
       
  4969     CleanupStack::PushL( fetchResult );
       
  4970 
       
  4971     // Make all SIP profiles known
       
  4972     CSmlDmAdapter::TError errorStatus;
       
  4973     iDmCallback->FetchLinkL( KNSmlDefDMSIP, *fetchResult, errorStatus );
       
  4974 
       
  4975     // Fetch SIP profile ID.
       
  4976     TBuf8<KNSmlVoIPMaxResultLength> object; 
       
  4977     object.Copy( aObject );
       
  4978     object.Append( KNSmlDMVoIPSeparator );
       
  4979     object.Append( KNSmlDMSIPSipID );
       
  4980     iDmCallback->FetchLinkL( object, *fetchResult, errorStatus );
       
  4981     TUint32 profileId = DesToInt( fetchResult->Ptr( 0 ) );    
       
  4982     CleanupStack::PopAndDestroy( fetchResult );
       
  4983     fetchResult = NULL;
       
  4984     DBG_PRINT("CNSmlDmVoIPAdapter::SetSipRef() : end");
       
  4985     return profileId;
       
  4986     }
       
  4987 
       
  4988 // ---------------------------------------------------------------------------
       
  4989 // CNSmlDmVoIPAdapter::GetSipIdL
       
  4990 // Get URI for given sip profile ID.
       
  4991 // ---------------------------------------------------------------------------
       
  4992 //
       
  4993 MSmlDmAdapter::TError CNSmlDmVoIPAdapter::GetSipIdL( CBufBase& aObject,
       
  4994     TUint32 aID ) const
       
  4995     {
       
  4996     DBG_PRINT("CNSmlDmVoIPAdapter::GetSipIdL() : begin");
       
  4997 
       
  4998     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  4999 
       
  5000     CBufBase* result = CBufFlat::NewL( 1 );
       
  5001     CleanupStack::PushL( result ); 
       
  5002     CSmlDmAdapter::TError errorStatus;
       
  5003     TBuf8<KNSmlVoIPMaxResultLength> object;
       
  5004     iDmCallback->FetchLinkL( KNSmlDefDMSIP, *result, errorStatus );
       
  5005     result->Compress();
       
  5006     HBufC8* childList = HBufC8::NewLC( result->Size() );
       
  5007     TInt uriSegCount( 0 );
       
  5008     if ( result->Size() > 0 )
       
  5009         {
       
  5010         childList->Des().Copy( result->Ptr(0) );
       
  5011 
       
  5012         // Delete last / mark
       
  5013         childList->Des().Delete( childList->Length() - 1, 1 );    
       
  5014         uriSegCount = NumOfURISegs( childList->Des() );
       
  5015         }
       
  5016 
       
  5017     for ( TInt counter = 0; counter < uriSegCount; counter++ )
       
  5018         {
       
  5019         result->Reset();
       
  5020         object.Copy( KNSmlDefDMSIP );
       
  5021         object.Append( KNSmlDMVoIPSeparator );
       
  5022         object.Append( LastURISeg( childList->Des() ) );
       
  5023 
       
  5024         // Make SIP profile settings known
       
  5025         iDmCallback->FetchLinkL( object, *result, errorStatus );
       
  5026         result->Compress();
       
  5027         result->Reset();
       
  5028 
       
  5029         // Get SIP id
       
  5030         object.Append( KNSmlDMVoIPSeparator );
       
  5031         object.Append( KNSmlDMSIPSipID );
       
  5032         iDmCallback->FetchLinkL( object, *result, errorStatus );
       
  5033         if ( aID == DesToInt( result->Ptr( 0 ) ) )
       
  5034             {
       
  5035             aObject.InsertL( aObject.Size(), RemoveLastURISeg( object ) );
       
  5036             break; 
       
  5037             }
       
  5038         childList->Des().Copy( RemoveLastURISeg ( childList->Des() ) );    
       
  5039         }
       
  5040     // childList, result 
       
  5041     CleanupStack::PopAndDestroy( 2, result ); //childList
       
  5042     result = NULL;
       
  5043     childList = NULL;
       
  5044     DBG_PRINT("CNSmlDmVoIPAdapter::GetSipIdL() : end");
       
  5045     return errorStatus;
       
  5046     }
       
  5047 
       
  5048 // ---------------------------------------------------------------------------
       
  5049 // CNSmlDmVoIPAdapter::SetSccpRefL
       
  5050 // Set SCCP reference value. 
       
  5051 // ---------------------------------------------------------------------------
       
  5052 //
       
  5053 TUint CNSmlDmVoIPAdapter::SetSccpRefL( const TDesC8& aObject ) const
       
  5054     {
       
  5055     DBG_PRINT("CNSmlDmVoIPAdapter::SetSccpRef() : begin");
       
  5056 
       
  5057     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  5058 
       
  5059     CBufBase* fetchResult = CBufFlat::NewL( 1 );
       
  5060     CleanupStack::PushL( fetchResult );
       
  5061 
       
  5062     // Make all SCCP profiles known
       
  5063     CSmlDmAdapter::TError errorStatus;
       
  5064     iDmCallback->FetchLinkL( KNSmlDefDMSCCP, *fetchResult, errorStatus );
       
  5065 
       
  5066     // Find profile asked
       
  5067     iDmCallback->FetchLinkL( aObject, *fetchResult, errorStatus );
       
  5068 
       
  5069     // Fetch SCCP profile ID.
       
  5070     TBuf8<KNSmlVoIPMaxResultLength> object; 
       
  5071     object.Copy( aObject );
       
  5072     object.Append( KNSmlDMVoIPSeparator );
       
  5073     object.Append( KNSmlDMSCCPSccpID ); 
       
  5074     iDmCallback->FetchLinkL( object, *fetchResult, errorStatus );
       
  5075     TUint32 profileId = DesToInt( fetchResult->Ptr( 0 ) );    
       
  5076     CleanupStack::PopAndDestroy( fetchResult );
       
  5077     fetchResult = NULL;
       
  5078     DBG_PRINT("CNSmlDmVoIPAdapter::SetSccpRef() : end");
       
  5079     return profileId;
       
  5080     }
       
  5081 
       
  5082 // ---------------------------------------------------------------------------
       
  5083 // CNSmlDmVoIPAdapter::GetSccpIdL
       
  5084 // Get URI for given sccp profile ID.
       
  5085 // ---------------------------------------------------------------------------
       
  5086 //
       
  5087 MSmlDmAdapter::TError CNSmlDmVoIPAdapter::GetSccpIdL( CBufBase& aObject,
       
  5088     TUint32 aID ) const
       
  5089     {
       
  5090     DBG_PRINT("CNSmlDmVoIPAdapter::GetSccpIdL() : begin");
       
  5091 
       
  5092     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  5093 
       
  5094     CBufBase* result = CBufFlat::NewL( 1 );
       
  5095     CleanupStack::PushL( result ); 
       
  5096     CSmlDmAdapter::TError errorStatus;
       
  5097     TBuf8<KNSmlVoIPMaxResultLength> object;
       
  5098     iDmCallback->FetchLinkL( KNSmlDefDMSCCP, *result, errorStatus );
       
  5099     result->Compress();
       
  5100     HBufC8* childList = HBufC8::NewLC( result->Size() );
       
  5101     TInt uriSegCount ( 0 );
       
  5102     if ( result->Size() > 0 )
       
  5103         {
       
  5104         childList->Des().Copy( result->Ptr(0) );
       
  5105 
       
  5106         // Delete last / mark
       
  5107         childList->Des().Delete( childList->Length() - 1, 1 );    
       
  5108         uriSegCount = NumOfURISegs( childList->Des() );
       
  5109         }
       
  5110 
       
  5111     for ( TInt counter = 0; counter < uriSegCount; counter++ )
       
  5112         {
       
  5113         result->Reset();
       
  5114 
       
  5115         // Make SCCP profile settings known
       
  5116         object.Copy( KNSmlDefDMSCCP );
       
  5117         object.Append( KNSmlDMVoIPSeparator );
       
  5118         object.Append( LastURISeg( childList->Des() ) );
       
  5119         iDmCallback->FetchLinkL( object, *result, errorStatus );
       
  5120         result->Compress();
       
  5121         result->Reset();
       
  5122 
       
  5123         // Get SCCPId
       
  5124         object.Append( KNSmlDMVoIPSeparator );
       
  5125         object.Append( KNSmlDMSCCPSccpID );
       
  5126         iDmCallback->FetchLinkL( object, *result, errorStatus );
       
  5127         if ( aID == DesToInt ( result->Ptr( 0 ) ) )
       
  5128             {
       
  5129             aObject.InsertL( aObject.Size(), RemoveLastURISeg( object ) );
       
  5130             break; 
       
  5131             }
       
  5132         childList->Des().Copy( RemoveLastURISeg ( childList->Des() ) );    
       
  5133         }
       
  5134     // childList, result 
       
  5135     CleanupStack::PopAndDestroy( 2, result ); //childList
       
  5136     result = NULL;
       
  5137     childList = NULL;
       
  5138     DBG_PRINT("CNSmlDmVoIPAdapter::GetSccpIdL() : end");
       
  5139     return errorStatus;
       
  5140     }
       
  5141 
       
  5142 // ---------------------------------------------------------------------------
       
  5143 // CNSmlDmVoIPAdapter::CheckDuplicateNameL
       
  5144 // Checks if duplicate named sip profiles. Renames if same.
       
  5145 // ---------------------------------------------------------------------------
       
  5146 //
       
  5147 TBool CNSmlDmVoIPAdapter::CheckDuplicateNameL( CRCSEProfileEntry& aEntry )
       
  5148     {
       
  5149     TBool isValid( EFalse );
       
  5150     HBufC* newName = HBufC::NewLC( KMaxSettingsNameLength * 2 );
       
  5151     newName->Des().Copy( aEntry.iSettingsName );
       
  5152 
       
  5153     TInt count( iProfileEntries.Count() );
       
  5154 
       
  5155     for ( TInt n = 0; n < count; n++ )
       
  5156         {
       
  5157         const TDesC& existingName = iProfileEntries[n]->iSettingsName;
       
  5158         if ( 0 == existingName.Compare( aEntry.iSettingsName )
       
  5159             && iProfileID != n ) // Skip the current profile.
       
  5160             {
       
  5161             TBool isUnique( EFalse );
       
  5162 
       
  5163             for ( TInt i = 1; !isUnique; i++ )
       
  5164                 {
       
  5165                 TBool found( EFalse );
       
  5166 
       
  5167                 newName->Des().Copy( aEntry.iSettingsName );
       
  5168                 newName->Des().Append( KOpenParenthesis() );
       
  5169                 newName->Des().AppendNum( i );
       
  5170                 newName->Des().Append( KClosedParenthesis() );
       
  5171                 for ( TInt m = 0; m < count; m++ )
       
  5172                     {
       
  5173                     if ( 0 == iProfileEntries[m]->iSettingsName.Compare( 
       
  5174                         newName->Des() ) )
       
  5175                         {
       
  5176                         found = ETrue;
       
  5177                         }
       
  5178                     } // for
       
  5179                 if ( !found )
       
  5180                     {
       
  5181                     isUnique = ETrue;
       
  5182                     }
       
  5183                 } // for
       
  5184             } // if
       
  5185         } // for
       
  5186 
       
  5187     // Change setting only if length is smaller than max length.
       
  5188     if ( newName->Length() < KMaxSettingsNameLength )
       
  5189         {
       
  5190         aEntry.iSettingsName.Copy( newName->Des() );
       
  5191         isValid = ETrue;
       
  5192         }
       
  5193     CleanupStack::PopAndDestroy( newName );  
       
  5194     return isValid;  
       
  5195     }
       
  5196 
       
  5197 // ---------------------------------------------------------------------------
       
  5198 // CNSmlDmVoIPAdapter::CheckDuplicateProviderL
       
  5199 // Checks if duplicate provider name. Renames if same.
       
  5200 // ---------------------------------------------------------------------------
       
  5201 //
       
  5202 TBool CNSmlDmVoIPAdapter::CheckDuplicateProviderL( CRCSEProfileEntry& aEntry )
       
  5203     {
       
  5204     TBool isValid( EFalse );
       
  5205     HBufC* newName = HBufC::NewLC( KMaxProviderNameLength * 2 );
       
  5206     newName->Des().Copy( aEntry.iProviderName );
       
  5207 
       
  5208     TInt count( iProfileEntries.Count() );
       
  5209 
       
  5210     for ( TInt n = 0; n < count; n++ )
       
  5211         {
       
  5212         const TDesC& existingName = iProfileEntries[n]->iProviderName;
       
  5213         if ( 0 == existingName.Compare( aEntry.iProviderName )
       
  5214             && iProfileID != n ) // Skip the current profile.
       
  5215             {
       
  5216             TBool isUnique( EFalse );
       
  5217 
       
  5218             for ( TInt i = 1; !isUnique; i++ )
       
  5219                 {
       
  5220                 TBool found( EFalse );
       
  5221 
       
  5222                 newName->Des().Copy( aEntry.iProviderName );
       
  5223                 newName->Des().Append( KOpenParenthesis() );
       
  5224                 newName->Des().AppendNum( i );
       
  5225                 newName->Des().Append( KClosedParenthesis() );
       
  5226                 for ( TInt m = 0; m < count; m++ )
       
  5227                     {
       
  5228                     if ( 0 == iProfileEntries[m]->iProviderName.Compare( 
       
  5229                         newName->Des() ) )
       
  5230                         {
       
  5231                         found = ETrue;
       
  5232                         }
       
  5233                     }
       
  5234                 if ( !found )
       
  5235                     {
       
  5236                     isUnique = ETrue;
       
  5237                     }
       
  5238                 }
       
  5239             }
       
  5240         }
       
  5241 
       
  5242     // Change setting only if length is smaller than max length.
       
  5243     if ( newName->Length() < KMaxProviderNameLength )
       
  5244         {
       
  5245         aEntry.iProviderName.Copy( newName->Des() );
       
  5246         isValid = ETrue;
       
  5247         }
       
  5248 
       
  5249     CleanupStack::PopAndDestroy( newName ); 
       
  5250     return isValid;  
       
  5251     }
       
  5252 
       
  5253 // ---------------------------------------------------------------------------
       
  5254 // TInt CNSmlDmVoIPAdapter::FindCodecLocation
       
  5255 // For getting codec position.
       
  5256 // ---------------------------------------------------------------------------
       
  5257 //
       
  5258 TInt CNSmlDmVoIPAdapter::FindCodecLocation( TUint32 aID ) const
       
  5259     {
       
  5260     for ( TInt i = 0; i < iCodecEntries.Count(); i++ )
       
  5261         {
       
  5262         if ( iCodecEntries[i]->iCodecId == aID )
       
  5263             {
       
  5264             return i;   
       
  5265             }
       
  5266         }
       
  5267     return KErrNotFound;
       
  5268     }
       
  5269 
       
  5270 // ---------------------------------------------------------------------------
       
  5271 // void CNSmlDmVoIPAdapter::SetTelephonyPreferenceL
       
  5272 // For setting telephony preference.
       
  5273 // ---------------------------------------------------------------------------
       
  5274 //
       
  5275 void CNSmlDmVoIPAdapter::SetTelephonyPreferenceL ( const TTelephonyPreference& 
       
  5276     aTelephonyPreference )
       
  5277     {
       
  5278     // Central Repository for richcall settings
       
  5279     CRepository* rep = CRepository::NewLC( KCRUidRichCallSettings );
       
  5280     if ( EPSPreferred == aTelephonyPreference )
       
  5281         {
       
  5282         rep->Set( KRCSEPreferredTelephony, EPSPreferred );
       
  5283         }
       
  5284     else if ( ECSPreferred == aTelephonyPreference )
       
  5285         {
       
  5286         rep->Set( KRCSEPreferredTelephony, ECSPreferred );
       
  5287         }
       
  5288     CleanupStack::PopAndDestroy( rep );
       
  5289     }
       
  5290 
       
  5291 // ---------------------------------------------------------------------------
       
  5292 // CNSmlDmVoIPAdapter::GetTerminalTypeL
       
  5293 // Collect terminal type used in SIP User Agent Header.
       
  5294 // ---------------------------------------------------------------------------
       
  5295 //
       
  5296 void CNSmlDmVoIPAdapter::GetTerminalTypeL(
       
  5297     TBuf<KMaxTerminalTypeLength>& aTerminalType ) const
       
  5298     {
       
  5299     aTerminalType.Zero(); // Reset before use
       
  5300 
       
  5301     CIpAppPhoneUtils* phoneUtils = CIpAppPhoneUtils::NewLC();
       
  5302     phoneUtils->GetTerminalTypeL( aTerminalType ); // Gets phone model + type
       
  5303     CleanupStack::PopAndDestroy( phoneUtils );
       
  5304     }
       
  5305 
       
  5306 // ---------------------------------------------------------------------------
       
  5307 // CNSmlDmVoIPAdapter::GetWlanMacAddressL
       
  5308 // Gets WLAN MAC address used in SIP User Agent Header (same as *#62209526#).
       
  5309 // ---------------------------------------------------------------------------
       
  5310 //
       
  5311 void CNSmlDmVoIPAdapter::GetWlanMacAddressL( TBuf<KWlanMacAddressLength>& 
       
  5312     aMac ) const
       
  5313     {
       
  5314     aMac.Zero(); // Reset before use
       
  5315 
       
  5316     CIPAppUtilsAddressResolver* resolver = CIPAppUtilsAddressResolver::NewLC();
       
  5317 
       
  5318     TBuf8<KWlanMacAddressLength> wlanmac;
       
  5319     _LIT8( KFormat, "-");
       
  5320     resolver->GetWlanMACAddress( wlanmac, KFormat );
       
  5321     //wlanmac buffer contains now the wlan mac address like 00-15-a0-99-10-ec
       
  5322     CleanupStack::PopAndDestroy( resolver );
       
  5323     aMac.Copy( wlanmac );
       
  5324 
       
  5325     }
       
  5326 
       
  5327 // ---------------------------------------------------------------------------
       
  5328 // CNSmlDmVoIPAdapter::GetNatFwUriL
       
  5329 // Get NAT/FW profile URI.
       
  5330 // ---------------------------------------------------------------------------
       
  5331 //
       
  5332 MSmlDmAdapter::TError CNSmlDmVoIPAdapter::GetNatFwUriL( 
       
  5333     TBuf16<KMaxUriLength>& aObject, TInt aProfileId ) const
       
  5334     {
       
  5335     DBG_PRINT("CNSmlDmVoIPAdapter::GetNatFwUriL : begin");
       
  5336 
       
  5337     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  5338 
       
  5339     CBufBase* result = CBufFlat::NewL( 1 ); // CS:1
       
  5340     CleanupStack::PushL( result );
       
  5341     CSmlDmAdapter::TError errorStatus;
       
  5342 
       
  5343     // Get URIs to all DomainSpecific NAT/FW settings.
       
  5344     iDmCallback->FetchLinkL( KNSmlDMNATFWDomain(), *result, errorStatus );
       
  5345 
       
  5346     if ( CSmlDmAdapter::EOk != errorStatus )
       
  5347         {
       
  5348         CleanupStack::PopAndDestroy( result );
       
  5349         return errorStatus;
       
  5350         }
       
  5351 
       
  5352     result->Compress();
       
  5353     HBufC8* childList = HBufC8::NewLC( result->Size() ); // CS:2
       
  5354     TInt uriSegCount( 0 );
       
  5355 
       
  5356     if ( result->Size() )
       
  5357         {
       
  5358         childList->Des().Copy( result->Ptr(0) );
       
  5359         uriSegCount = NumOfURISegs( childList->Des() );
       
  5360         }
       
  5361 
       
  5362     for ( TInt index = 0; index < uriSegCount; index++ )
       
  5363         {
       
  5364         HBufC8* uri = HBufC8::NewLC( ( KMaxUriLength * KTwoSegs ) );// CS:3
       
  5365         uri->Des().Copy( KNSmlDMNATFWDomain );
       
  5366         uri->Des().Append( KNSmlDMVoIPSeparator() );
       
  5367         uri->Des().Append( LastURISeg( childList->Des() ) );
       
  5368         HBufC8* luid = HBufC8::NewLC( KMaxUriLength ); // CS:4
       
  5369         luid->Des().Copy( iDmCallback->GetLuidAllocL( uri->Des() )->Des() );
       
  5370         if ( luid->Des().Length() && 
       
  5371             aProfileId == DesToTUint( LastURISeg( luid->Des() ) ) )
       
  5372             {
       
  5373             aObject.Copy( uri->Des() );
       
  5374             // luid, uri
       
  5375             CleanupStack::PopAndDestroy( 2, uri ); // CS:2
       
  5376             break;
       
  5377             }
       
  5378         // luid, uri
       
  5379         CleanupStack::PopAndDestroy( 2, uri ); // CS:2
       
  5380         childList->Des().Copy( RemoveLastURISeg( childList->Des() ) );
       
  5381         }
       
  5382 
       
  5383     // childList, result
       
  5384     CleanupStack::PopAndDestroy( 2, result ); // CS:0
       
  5385     DBG_PRINT("CNSmlDmVoIPAdapter::GetNatFwUriL : end");
       
  5386     return errorStatus;
       
  5387     }
       
  5388 
       
  5389 // ---------------------------------------------------------------------------
       
  5390 // CNSmlDmVoIPAdapter::NatFwIdL
       
  5391 // Get NAT/FW profile ID.
       
  5392 // ---------------------------------------------------------------------------
       
  5393 //
       
  5394 TUint32 CNSmlDmVoIPAdapter::NatFwIdL( const TDesC8& aObject ) const
       
  5395     {
       
  5396     DBG_PRINT("CNSmlDmVoIPAdapter::NatFwIdL : begin");
       
  5397 
       
  5398     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  5399 
       
  5400     TUint32 profileId( KErrNone );
       
  5401     HBufC8* luid = HBufC8::NewLC( KMaxUriLength ); // CS:1
       
  5402     luid->Des().Copy( iDmCallback->GetLuidAllocL( aObject )->Des() );
       
  5403     if ( luid->Des().Length() )
       
  5404         {
       
  5405         profileId = DesToTUint( LastURISeg( luid->Des() ) );
       
  5406         }
       
  5407     CleanupStack::PopAndDestroy( luid ); // CS:0
       
  5408     DBG_PRINT("CNSmlDmVoIPAdapter::NatFwIdL : end");
       
  5409     return profileId;
       
  5410     }
       
  5411 
       
  5412 // ---------------------------------------------------------------------------
       
  5413 // CNSmlDmVoIPAdapter::GetConRefL
       
  5414 // Get DM URI for IAP.
       
  5415 // ---------------------------------------------------------------------------
       
  5416 //
       
  5417 MSmlDmAdapter::TError CNSmlDmVoIPAdapter::GetConRefL( CBufBase& aObject, 
       
  5418     TInt aIapId ) const
       
  5419     {
       
  5420     DBG_PRINT("CNSmlDmVoIPAdapter::GetConRefL() : begin");
       
  5421 
       
  5422     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  5423 
       
  5424     TBool found = EFalse;
       
  5425     CNSmlDMIAPMatcher* iapMatch = CNSmlDMIAPMatcher::NewL( iDmCallback );
       
  5426     CleanupStack::PushL( iapMatch ); // CS:1
       
  5427     HBufC8* uri8 = iapMatch->URIFromIAPIdL( aIapId );
       
  5428     CleanupStack::PushL( uri8 ); // CS:2
       
  5429     if ( uri8 )
       
  5430         {
       
  5431         aObject.InsertL( aObject.Size(), uri8->Des() );
       
  5432         found = ETrue;
       
  5433         }
       
  5434     // uri8, iapMatch
       
  5435     CleanupStack::PopAndDestroy( 2, iapMatch ); // CS:0
       
  5436     DBG_PRINT("CNSmlDmVoIPAdapter::GetConRefL() : end");
       
  5437     if ( !found )
       
  5438         {
       
  5439         return CSmlDmAdapter::ENotFound;
       
  5440         }
       
  5441     return CSmlDmAdapter::EOk;
       
  5442     }
       
  5443 
       
  5444 // ---------------------------------------------------------------------------
       
  5445 // CNSmlDmVoIPAdapter::ConRefL
       
  5446 // Get IAP ID (connection reference value) from given URI.
       
  5447 // ---------------------------------------------------------------------------
       
  5448 //
       
  5449 TInt CNSmlDmVoIPAdapter::ConRefL( const TDesC8& aObject ) const
       
  5450     {
       
  5451     DBG_PRINT("CNSmlDmVoIPAdapter::ConRefL() : begin");
       
  5452 
       
  5453     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  5454 
       
  5455     CNSmlDMIAPMatcher* iapMatch = CNSmlDMIAPMatcher::NewL( iDmCallback );
       
  5456     CleanupStack::PushL( iapMatch );
       
  5457     TInt iapId = iapMatch->IAPIdFromURIL( aObject );
       
  5458     CleanupStack::PopAndDestroy( iapMatch ); 
       
  5459     DBG_PRINT("CNSmlDmVoIPAdapter::ConRefL() : end");
       
  5460     return iapId;
       
  5461     }
       
  5462 
       
  5463 // ---------------------------------------------------------------------------
       
  5464 // CNSmlDmVoIPAdapter::GetPresenceUriL
       
  5465 // Get Presence profile DM URI.
       
  5466 // ---------------------------------------------------------------------------
       
  5467 //
       
  5468 MSmlDmAdapter::TError CNSmlDmVoIPAdapter::GetPresenceUriL( 
       
  5469     TBuf16<KMaxUriLength>& aObject, TUint32 aProfileId ) const
       
  5470     {
       
  5471     DBG_PRINT("CNSmlDmVoIPAdapter::GetPresenceUriL : begin");
       
  5472 
       
  5473     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  5474 
       
  5475     CBufBase* result = CBufFlat::NewL( 1 );
       
  5476     CleanupStack::PushL( result ); // CS:1
       
  5477     CSmlDmAdapter::TError errorStatus;
       
  5478 
       
  5479     // Get URIs to all Presence settings.
       
  5480     iDmCallback->FetchLinkL( KNSmlDMPresence(), *result, errorStatus );
       
  5481 
       
  5482     if ( CSmlDmAdapter::EOk != errorStatus )
       
  5483         {
       
  5484         CleanupStack::PopAndDestroy( result );
       
  5485         return errorStatus;
       
  5486         }
       
  5487 
       
  5488     result->Compress();
       
  5489     HBufC8* childList = HBufC8::NewLC( result->Size() ); // CS:2
       
  5490     TInt uriSegCount( 0 );
       
  5491 
       
  5492     if ( result->Size() )
       
  5493         {
       
  5494         childList->Des().Copy( result->Ptr( 0 ) );
       
  5495         uriSegCount = NumOfURISegs( childList->Des() );
       
  5496         }
       
  5497 
       
  5498     // Get LUIDs for URIs.
       
  5499     for ( TInt index = 0; index < uriSegCount; index++ )
       
  5500         {
       
  5501         HBufC8* uri = HBufC8::NewLC( KMaxUriLength ); // CS:3
       
  5502         HBufC8* luid = HBufC8::NewLC( KMaxUriLength ); // CS:4
       
  5503 
       
  5504         uri->Des().Copy( KNSmlDMPresence() );
       
  5505         uri->Des().Append( KNSmlDMVoIPSeparator() );
       
  5506         uri->Des().Append( LastURISeg( childList->Des() ) );
       
  5507         luid->Des().Copy( iDmCallback->GetLuidAllocL( uri->Des() )->Des() );
       
  5508         if ( luid->Des().Length() && 
       
  5509             aProfileId == DesToTUint( LastURISeg( luid->Des() ) ) )
       
  5510             {
       
  5511             aObject.Copy( uri->Des() );
       
  5512             // luid, uri
       
  5513             CleanupStack::PopAndDestroy( 2, uri );  // CS:2
       
  5514             break;
       
  5515             }
       
  5516         childList->Des().Copy( RemoveLastURISeg( childList->Des() ) );
       
  5517         // luid, uri
       
  5518         CleanupStack::PopAndDestroy( 2, uri );  // CS:2
       
  5519         }
       
  5520     // childList, result
       
  5521     CleanupStack::PopAndDestroy( 2, result );     // CS:0
       
  5522     DBG_PRINT("CNSmlDmVoIPAdapter::GetPresenceUriL : end");
       
  5523     return errorStatus;
       
  5524     }
       
  5525 
       
  5526 // ---------------------------------------------------------------------------
       
  5527 // CNSmlDmVoIPAdapter::PresenceIdL
       
  5528 // Get Presence profile ID.
       
  5529 // ---------------------------------------------------------------------------
       
  5530 //
       
  5531 TUint32 CNSmlDmVoIPAdapter::PresenceIdL( const TDesC8& aObject ) const
       
  5532     {
       
  5533     DBG_PRINT("CNSmlDmVoIPAdapter::PresenceIdL : begin");
       
  5534 
       
  5535     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  5536 
       
  5537     HBufC8* luid = HBufC8::NewLC( KMaxUriLength ); // CS:1
       
  5538     luid->Des().Copy( iDmCallback->GetLuidAllocL( aObject )->Des() );
       
  5539     if ( luid->Des().Length() )
       
  5540         {
       
  5541         TUint32 profileId = DesToTUint( LastURISeg( luid->Des() ) );
       
  5542         CleanupStack::PopAndDestroy( luid ); // CS:0
       
  5543         DBG_PRINT("CNSmlDmVoIPAdapter::PresenceIdL : end");
       
  5544         return profileId;
       
  5545         }
       
  5546     CleanupStack::PopAndDestroy( luid ); // CS:0
       
  5547     DBG_PRINT("CNSmlDmVoIPAdapter::PresenceIdL : end");
       
  5548     return KErrNone;
       
  5549     }
       
  5550 
       
  5551 // ---------------------------------------------------------------------------
       
  5552 // CNSmlDmVoIPAdapter::SnapIdL
       
  5553 // Gets SNAP ID based on URI.
       
  5554 // ---------------------------------------------------------------------------
       
  5555 //
       
  5556 TInt CNSmlDmVoIPAdapter::SnapIdL( const TDesC8& aUri )
       
  5557     {
       
  5558     DBG_PRINT( "CNSmlDmVoIPAdapter::SnapIdL - begin" );
       
  5559     TInt snapId( KErrNotFound );
       
  5560 
       
  5561     HBufC8* luid = HBufC8::NewLC( KNSmlVoIPMaxUriLength ); // CS:1
       
  5562     luid->Des().Copy( iDmCallback->GetLuidAllocL( aUri )->Des() );
       
  5563 
       
  5564     if ( luid->Des().Length() )
       
  5565         {
       
  5566         snapId = DesToInt( LastURISeg( luid->Des() ) );
       
  5567         }
       
  5568     CleanupStack::PopAndDestroy( luid ); // CS:0
       
  5569     DBG_PRINT( "CNSmlDmVoIPAdapter::SnapIdL - end" );
       
  5570     return snapId;
       
  5571     }
       
  5572 
       
  5573 // ---------------------------------------------------------------------------
       
  5574 // CNSmlDmVoIPAdapter::GetSnapUriL
       
  5575 // Set SNAP URI based on SNAP ID.
       
  5576 // ---------------------------------------------------------------------------
       
  5577 //
       
  5578 MSmlDmAdapter::TError CNSmlDmVoIPAdapter::GetSnapUriL( TDes8& aObject, 
       
  5579     TInt aSnapId )
       
  5580     {
       
  5581     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
  5582 
       
  5583     DBG_PRINT( "CNSmlDmSIPAdapter::GetSnapUriL - begin" );
       
  5584 
       
  5585     CBufBase* result = CBufFlat::NewL( 1 );
       
  5586     CleanupStack::PushL( result ); // CS:1
       
  5587     CSmlDmAdapter::TError status;
       
  5588 
       
  5589     // Get URIs to all SNAP settings.
       
  5590     iDmCallback->FetchLinkL( KNSmlDMSnapUriPrefix(), *result, status );
       
  5591 
       
  5592     if ( CSmlDmAdapter::EOk != status )
       
  5593         {
       
  5594         CleanupStack::PopAndDestroy( result );
       
  5595         DBG_PRINT( "CNSmlDmVoIPAdapter::GetSnapUriL - Fetch SNAP error end" );
       
  5596         return status;
       
  5597         }
       
  5598 
       
  5599     result->Compress();
       
  5600     HBufC8* childList = HBufC8::NewLC( result->Size() ); // CS:2
       
  5601     TInt uriSegCount( 0 );
       
  5602 
       
  5603     if ( result->Size() )
       
  5604         {
       
  5605         childList->Des().Copy( result->Ptr( 0 ) );
       
  5606         uriSegCount = NumOfURISegs( childList->Des() );
       
  5607         }
       
  5608 
       
  5609     // Get LUIDs for URIs.
       
  5610     for ( TInt index = 0; index < uriSegCount; index++ )
       
  5611         {
       
  5612         HBufC8* uri = HBufC8::NewLC( KNSmlVoIPMaxUriLength ); // CS:3
       
  5613         HBufC8* luid = HBufC8::NewLC( KNSmlVoIPMaxUriLength ); // CS:4
       
  5614 
       
  5615         uri->Des().Copy( KNSmlDMSnapUriPrefix() );
       
  5616         uri->Des().Append( KNSmlDMVoIPSeparator() );
       
  5617         uri->Des().Append( LastURISeg( childList->Des() ) );
       
  5618         luid->Des().Copy( iDmCallback->GetLuidAllocL( uri->Des() )->Des() );
       
  5619         if ( luid->Des().Length() && 
       
  5620             aSnapId == DesToInt( LastURISeg( luid->Des() ) ) )
       
  5621             {
       
  5622             aObject.Copy( uri->Des() );
       
  5623             // luid, uri
       
  5624             CleanupStack::PopAndDestroy( 2, uri );  // CS:2
       
  5625             break;
       
  5626             }
       
  5627         childList->Des().Copy( RemoveLastURISeg( childList->Des() ) );
       
  5628         // luid, uri
       
  5629         CleanupStack::PopAndDestroy( 2, uri );  // CS:2
       
  5630         }
       
  5631     // childList, result
       
  5632     CleanupStack::PopAndDestroy( 2, result );     // CS:0
       
  5633     DBG_PRINT( "CNSmlDmVoIPAdapter::GetSnapUriL - end" );
       
  5634     return status;
       
  5635     }
       
  5636 
       
  5637 // End of file.