voipplugins/voipadapters/dmgenvoipsettings/src/NSmlDmGeneralVoIPSettingsAdapter.cpp
changeset 0 a4daefaec16c
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2006 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 General VoIP Settings Adapter
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <utf.h>
       
    20 #include <implementationproxy.h> // For TImplementationProxy definition
       
    21 #include <sysutil.h>
       
    22 #include <e32property.h>
       
    23 #include <centralrepository.h>
       
    24 #include <crcseprofileentry.h>
       
    25 #include <crcseprofileregistry.h>
       
    26 #include <settingsinternalcrkeys.h>
       
    27 #include <featmgr.h>
       
    28 
       
    29 #include "NSmlDmGeneralVoIPSettingsAdapter.h"
       
    30 #include "nsmlconstants.h"
       
    31 #include "nsmldmconstants.h"
       
    32 #include "nsmldmconst.h"
       
    33 
       
    34 const TUint KNSmlDMGenVoIPAdapterImplUid = 0x10275413;
       
    35 const TInt  KNSmlGenVoIPMaxResultLength  = 256;
       
    36 const TInt  KNSmlGenVoIPMaxUriLength     = 100;
       
    37 const TInt  KDefaultResultSize           = 64;
       
    38 const TInt  KTwoSegs                     = 2;
       
    39 const TInt  KMaxUriLength                = 64;
       
    40 
       
    41 // Reference: OMA_Device_Management_DDF_for_General_VoIP_Settings
       
    42 _LIT8( KNSmlDMGenVoIPDDFVersion,            "0.1" );
       
    43 _LIT8( KNSmlDMGenVoIPNodeName,              "GenVoIP" );
       
    44 _LIT8( KNSmlDMVoIPNodeName,                 "VoIP" );
       
    45 _LIT8( KNSmlDMGenVoIPClir,                  "Clir" );
       
    46 _LIT8( KNSmlDMGenVoIPAnonCallBlockRule,     "AnonCallBlockRule" );
       
    47 _LIT8( KNSmlDMGenVoIPPreferredTelephony,    "PrefTelephony" );
       
    48 _LIT8( KNSmlDMGenVoIPDoNotDisturb,          "DoNotDisturb" );
       
    49 _LIT8( KNSmlDMGenVoIPPSCallWaiting,         "PSCallWaiting" );
       
    50 _LIT8( KNSmlDMGenVoIPProfileId,             "VoIPProfileId" );
       
    51 
       
    52 _LIT8( KNSmlDMGenVoIPNodeNameExp,           "Main node for General VoIP settings" );
       
    53 _LIT8( KNSmlDMGenVoIPClirExp,               "Calling Line Identification Restriction" );
       
    54 _LIT8( KNSmlDMGenVoIPPSCallWaitingExp,      "PS call waiting" );
       
    55 _LIT8( KNSmlDMGenVoIPAnonCallBlockRuleExp,  "Anonymous call blocking rule" );
       
    56 _LIT8( KNSmlDMGenVoIPPreferredTelephonyExp, "Preferred telephony" );
       
    57 _LIT8( KNSmlDMGenVoIPDoNotDisturbExp,       "Do not disturb" );
       
    58 _LIT8( KNSmlDMGenVoIPProfileIdExp,          "VoIP node id for linking" );
       
    59 
       
    60 // Other
       
    61 _LIT8( KNSmlDMGenVoIPTextPlain,             "text/plain" );
       
    62 _LIT8( KNSmlDMGenVoIPSeparator,             "/" );
       
    63 _LIT8( KNSmlDMGenVoIPUriDotSlash,           "./");
       
    64 _LIT8( KVoipId,                             "VoIPId" );
       
    65 
       
    66 //MACROS 
       
    67 #define KNSMLDMURISEPARATORDEF '/'
       
    68 
       
    69 // Following lines are for enabling debug prints.
       
    70 #ifdef _DEBUG
       
    71 #define _DBG_FILE(p) RDebug::Print(_L(p))
       
    72 #define _DBG_FILE2(p,a) RDebug::Print(_L(p),a)
       
    73 #else
       
    74 #define _DBG_FILE(p)
       
    75 #define _DBG_FILE2(p,a)
       
    76 #endif // _DEBUG
       
    77 
       
    78 // ======== LOCAL FUNCTIONS ========
       
    79 
       
    80 template <class T>
       
    81 inline void CleanupResetAndDestroy<T>::PushL(T& aRef)
       
    82 	{CleanupStack::PushL(TCleanupItem(&ResetAndDestroy,&aRef));}
       
    83 
       
    84 template <class T>
       
    85 void CleanupResetAndDestroy<T>::ResetAndDestroy(TAny *aPtr)
       
    86 	{(STATIC_CAST(T*,aPtr))->ResetAndDestroy();}
       
    87 
       
    88 template <class T>
       
    89 inline void CleanupResetAndDestroyL(T& aRef)
       
    90 	{CleanupResetAndDestroy<T>::PushL(aRef);}
       
    91 
       
    92 
       
    93 // ======== MEMBER FUNCTIONS ========
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CNSmlDmGeneralVoIPSettingsAdapter::ConstructL
       
    97 // Symbian 2nd phase constructor can leave.
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CNSmlDmGeneralVoIPSettingsAdapter::ConstructL()
       
   101     {
       
   102     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::ConstructL(): begin" );
       
   103     // Check VoIP support from feature manager
       
   104     FeatureManager::InitializeLibL();
       
   105     TBool support = FeatureManager::FeatureSupported( KFeatureIdCommonVoip );
       
   106     FeatureManager::UnInitializeLib();
       
   107 
       
   108     if( !support )
       
   109         {
       
   110         _DBG_FILE( 
       
   111             "CNSmlDmGeneralVoIPSettingsAdapter::ConstructL(): no support" );
       
   112         User::Leave( KErrNotSupported );
       
   113         }
       
   114     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::ConstructL(): end" );
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CNSmlDmGeneralVoIPSettingsAdapter* CNSmlDmGeneralVoIPSettingsAdapter::NewL
       
   119 // Two-phased constructor.
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 CNSmlDmGeneralVoIPSettingsAdapter* CNSmlDmGeneralVoIPSettingsAdapter::NewL( 
       
   123     MSmlDmCallback* aDmCallback )
       
   124     {
       
   125     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::NewL(): begin" );
       
   126     CNSmlDmGeneralVoIPSettingsAdapter* self = NewLC( aDmCallback );
       
   127     CleanupStack::Pop( self );
       
   128     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::NewL(): end" );
       
   129     return self;
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // CNSmlDmGeneralVoIPSettingsAdapter* CNSmlDmGeneralVoIPSettingsAdapter::NewLC
       
   134 // Two-phased constructor.
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 CNSmlDmGeneralVoIPSettingsAdapter* CNSmlDmGeneralVoIPSettingsAdapter::NewLC( 
       
   138     MSmlDmCallback* aDmCallback )
       
   139     {
       
   140     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::NewLC(): begin" );
       
   141     CNSmlDmGeneralVoIPSettingsAdapter* self = 
       
   142         new ( ELeave ) CNSmlDmGeneralVoIPSettingsAdapter( aDmCallback );
       
   143     CleanupStack::PushL( self );
       
   144 
       
   145     self->ConstructL();
       
   146     self->iDmCallback = aDmCallback;
       
   147     
       
   148     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::NewLC(): end" );
       
   149     return self;
       
   150     }
       
   151     
       
   152 // ---------------------------------------------------------------------------
       
   153 // CNSmlDmGeneralVoIPSettingsAdapter::~CNSmlDmGeneralVoIPSettingsAdapter()
       
   154 // Destructor
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 CNSmlDmGeneralVoIPSettingsAdapter::~CNSmlDmGeneralVoIPSettingsAdapter()
       
   158     {
       
   159     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::~CNSmlDmGeneralVoIPSettingsAdapter(): begin" );
       
   160     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::~CNSmlDmGeneralVoIPSettingsAdapter(): end" );
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // CNSmlDmGeneralVoIPSettingsAdapter::CNSmlDmGeneralVoIPSettingsAdapter
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 CNSmlDmGeneralVoIPSettingsAdapter::CNSmlDmGeneralVoIPSettingsAdapter(
       
   168     TAny* aEcomArguments ):CSmlDmAdapter( aEcomArguments )
       
   169     {
       
   170     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::CNSmlDmGeneralVoIPSettingsAdapter( aEcomArguments ): begin" );
       
   171     iEntry.iAreSettingsLoaded = EFalse;
       
   172     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::CNSmlDmGeneralVoIPSettingsAdapter( aEcomArguments ): end" ); 
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // CNSmlDmGeneralVoIPSettingsAdapter::FetchObjectL
       
   177 // Fetches the values of leaf objects.
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 CSmlDmAdapter::TError CNSmlDmGeneralVoIPSettingsAdapter::FetchObjectL( 
       
   181     const TDesC8& aURI, 
       
   182     CBufBase& aResult )
       
   183     {
       
   184     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::FetchObjectL(): begin" );
       
   185     CSmlDmAdapter::TError status = CSmlDmAdapter::EError;
       
   186     TBuf8< KNSmlGenVoIPMaxResultLength > segmentResult;
       
   187     TPtrC8 lastURISeg = LastURISeg( aURI );
       
   188     TPtrC8 uriTmp = RemoveLastURISeg( aURI );
       
   189     TPtrC8 secondLastURISeg = LastURISeg( uriTmp );
       
   190 
       
   191     if ( !( iEntry.iAreSettingsLoaded ) )
       
   192         {
       
   193         TInt err = LoadSettingsL();
       
   194         if ( KErrNone != err )
       
   195             {
       
   196             return status;
       
   197             }
       
   198         }
       
   199 
       
   200     if ( 0 == secondLastURISeg.Compare( KNSmlDMGenVoIPNodeName() )
       
   201         && KTwoSegs == NumOfURISegs( aURI ) )
       
   202         {
       
   203         status = CSmlDmAdapter::EOk;
       
   204         // Clir
       
   205         if ( KNSmlDMGenVoIPClir() == lastURISeg )
       
   206             {
       
   207             segmentResult.Num( iEntry.iClir );
       
   208             }
       
   209         // AnonCallBlockRule
       
   210         else if ( KNSmlDMGenVoIPAnonCallBlockRule() == lastURISeg )
       
   211             {
       
   212             segmentResult.Num( iEntry.iACBRule );
       
   213             }
       
   214         // PreferredTelephony
       
   215         else if ( KNSmlDMGenVoIPPreferredTelephony() == lastURISeg )
       
   216             {
       
   217             segmentResult.Num( iEntry.iPrefTel );
       
   218             }
       
   219         // DoNotDisturb
       
   220         else if ( KNSmlDMGenVoIPDoNotDisturb() == lastURISeg )
       
   221             {
       
   222             segmentResult.Num( iEntry.iDnd );
       
   223             }
       
   224         // PSCallWaiting
       
   225         else if ( KNSmlDMGenVoIPPSCallWaiting() == lastURISeg )
       
   226             {
       
   227             segmentResult.Num( iEntry.iPSCallWaiting );
       
   228             }
       
   229         // ProfileName
       
   230         else if ( KNSmlDMGenVoIPProfileId() == lastURISeg )
       
   231             {
       
   232             segmentResult.Copy( iEntry.iVoipProfileId );
       
   233             }
       
   234         else
       
   235             {
       
   236             status = CSmlDmAdapter::ENotFound;
       
   237             }
       
   238         }
       
   239     else
       
   240         {
       
   241         status = CSmlDmAdapter::ENotFound;
       
   242         }
       
   243 
       
   244     if ( CSmlDmAdapter::EOk == status )    
       
   245         {
       
   246         aResult.InsertL( aResult.Size(), segmentResult );
       
   247         }
       
   248     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::FetchObjectL(): end" );
       
   249     return status;
       
   250     }
       
   251 
       
   252 // ---------------------------------------------------------------------------
       
   253 // CNSmlDmGeneralVoIPSettingsAdapter::LoadSettingsL
       
   254 // Loads general VoIP settings from Central Repository.
       
   255 // ---------------------------------------------------------------------------
       
   256 //
       
   257 TInt CNSmlDmGeneralVoIPSettingsAdapter::LoadSettingsL()
       
   258     {
       
   259     _DBG_FILE( "CNSmlDmGeneralVoIPSEttingsAdapter::LoadSettingsL(): begin" );
       
   260     CRepository* cRepository = CRepository::NewLC( KCRUidRichCallSettings );
       
   261     
       
   262     TInt err( KErrNone );
       
   263     err = cRepository->Get( KRCSEClir, iEntry.iClir );
       
   264     if ( KErrNone == err )
       
   265         {
       
   266         err = cRepository->Get( KRCSEAnonymousCallBlockRule,
       
   267             iEntry.iACBRule );
       
   268         }
       
   269     if ( KErrNone == err )
       
   270         {
       
   271         err = cRepository->Get( KRCSEPreferredTelephony, iEntry.iPrefTel );
       
   272         }
       
   273     if ( KErrNone == err )
       
   274         {
       
   275         err = cRepository->Get( KRCSEDoNotDisturb, iEntry.iDnd );
       
   276         }
       
   277     if ( KErrNone == err )
       
   278         {
       
   279         err = cRepository->Get( KRCSPSCallWaiting, iEntry.iPSCallWaiting );
       
   280         }
       
   281     if ( KErrNone == err )
       
   282         {
       
   283         err = ResolvePreferredServiceNameL( *cRepository );
       
   284         }
       
   285     if ( KErrNone == err )
       
   286         {
       
   287         iEntry.iAreSettingsLoaded = ETrue;
       
   288         }
       
   289     CleanupStack::PopAndDestroy( cRepository );
       
   290     _DBG_FILE( "CNSmlDmGeneralVoIPSEttingsAdapter::LoadSettingsL(): end" );
       
   291     return err;
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // CNSmlDmGeneralVoIPSettingsAdapter::DesToInt
       
   296 // Converts a 8 bit descriptor to int.
       
   297 // ---------------------------------------------------------------------------
       
   298 //
       
   299 TInt CNSmlDmGeneralVoIPSettingsAdapter::DesToInt( 
       
   300     const TDesC8& aDes )
       
   301     {
       
   302     TLex8 lex( aDes );
       
   303     TInt value( 0 );
       
   304     lex.Val( value );
       
   305     return value;
       
   306     }
       
   307 
       
   308 // ---------------------------------------------------------------------------
       
   309 // CNSmlDmGeneralVoIPSettingsAdapter::RemoveLastURISeg
       
   310 // returns parent uri, i.e. removes last uri segment
       
   311 // ---------------------------------------------------------------------------
       
   312 //
       
   313 TPtrC8 CNSmlDmGeneralVoIPSettingsAdapter::RemoveLastURISeg( 
       
   314     const TDesC8& aURI )
       
   315     {
       
   316     TInt counter( 0 );
       
   317     
       
   318     // Check that aURI exists
       
   319     if ( 0 < aURI.Length() )
       
   320         {
       
   321         for ( counter = aURI.Length() - 1; counter >= 0; counter-- )
       
   322             {
       
   323             if ( KNSMLDMURISEPARATORDEF == aURI[ counter ] )
       
   324                 {
       
   325                 break;
       
   326                 }
       
   327             }
       
   328         }
       
   329     return aURI.Left( counter );
       
   330     }
       
   331 
       
   332 // ---------------------------------------------------------------------------
       
   333 // CNSmlDmGeneralVoIPSettingsAdapter::NumOfURISegs
       
   334 // For getting the number of uri segs
       
   335 // ---------------------------------------------------------------------------
       
   336 //
       
   337 TInt CNSmlDmGeneralVoIPSettingsAdapter::NumOfURISegs( 
       
   338     const TDesC8& aURI )
       
   339     {
       
   340     TInt numOfURISegs( 1 );
       
   341     for ( TInt counter = 0; counter < aURI.Length(); counter++ )
       
   342         {
       
   343         if ( KNSMLDMURISEPARATORDEF == aURI[ counter ] )
       
   344             {
       
   345             numOfURISegs++;
       
   346             }
       
   347         }
       
   348     return numOfURISegs;
       
   349     }
       
   350 
       
   351 // ---------------------------------------------------------------------------
       
   352 // CNSmlDmGeneralVoIPSettingsAdapter::LastURISeg
       
   353 // Returns only the last uri segment
       
   354 // ---------------------------------------------------------------------------
       
   355 //
       
   356 TPtrC8 CNSmlDmGeneralVoIPSettingsAdapter::LastURISeg( 
       
   357     const TDesC8& aURI ) const
       
   358     {
       
   359     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::LastURISeg() : begin" );
       
   360     TInt counter( 0 );
       
   361     
       
   362     // Check that aURI exists
       
   363     if ( 0 < aURI.Length() )
       
   364         {
       
   365         for ( counter = aURI.Length() - 1; counter >= 0; counter-- )
       
   366             {
       
   367             if ( KNSMLDMURISEPARATORDEF == aURI[ counter ] )
       
   368                 {
       
   369                 break;
       
   370                 }
       
   371             }
       
   372         }
       
   373     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::LastURISeg() : end" );
       
   374     if ( 0 == counter  )
       
   375         {
       
   376         return aURI;
       
   377         }
       
   378     else
       
   379         {
       
   380         return aURI.Mid( counter + 1 );
       
   381         }
       
   382     }
       
   383     
       
   384 // ---------------------------------------------------------------------------
       
   385 // CNSmlDmGeneralVoIPSettingsAdapter::RemoveDotSlash
       
   386 // return uri without dot and slash in start
       
   387 // ---------------------------------------------------------------------------
       
   388 //
       
   389 TPtrC8 CNSmlDmGeneralVoIPSettingsAdapter::RemoveDotSlash( 
       
   390     const TDesC8& aURI )
       
   391     {
       
   392     if ( 0 == aURI.Find( KNSmlDMGenVoIPUriDotSlash ) )
       
   393         {
       
   394         return aURI.Right( 
       
   395             aURI.Length() - KNSmlDMGenVoIPUriDotSlash().Length() );
       
   396         }
       
   397     else
       
   398         {
       
   399         return aURI;
       
   400         }
       
   401     }
       
   402 
       
   403 // ---------------------------------------------------------------------------
       
   404 // CNSmlDmGeneralVoIPSettingsAdapter::DDFVersionL
       
   405 // From base class CNSmlDmAdapter.
       
   406 // Inserts DDF version of the adapter to aDDFVersion
       
   407 // ---------------------------------------------------------------------------
       
   408 //
       
   409 void CNSmlDmGeneralVoIPSettingsAdapter::DDFVersionL(
       
   410     CBufBase& aDDFVersion )
       
   411     {
       
   412     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::DDFVersionL( TDes& aDDFVersion): begin" );
       
   413     aDDFVersion.InsertL( 0, KNSmlDMGenVoIPDDFVersion );
       
   414     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::DDFVersionL( TDes& aDDFVersion): end" );
       
   415     }
       
   416 
       
   417 // ---------------------------------------------------------------------------
       
   418 // CNSmlDmGeneralVoIPSettingsAdapter::DDFStructureL
       
   419 // From base class CNSmlDmAdapter.
       
   420 // Builds the DDF structure of adapter
       
   421 // ---------------------------------------------------------------------------
       
   422 //
       
   423 void CNSmlDmGeneralVoIPSettingsAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
       
   424     {
       
   425     _DBG_FILE("CNSmlDmGeneralVoIPSettingsAdapter::DDFStructureL(): begin");
       
   426 
       
   427     TSmlDmAccessTypes accessTypesGet;
       
   428     accessTypesGet.SetGet();
       
   429 
       
   430     TSmlDmAccessTypes accessTypesGetAdd;
       
   431     accessTypesGetAdd.SetGet();
       
   432     accessTypesGetAdd.SetAdd();
       
   433 
       
   434     TSmlDmAccessTypes accessTypesGetReplaceAdd;
       
   435     accessTypesGetReplaceAdd.SetGet();
       
   436     accessTypesGetReplaceAdd.SetReplace();
       
   437     accessTypesGetReplaceAdd.SetAdd();
       
   438 
       
   439     TSmlDmAccessTypes accessTypesAll;
       
   440     accessTypesAll.SetGet();
       
   441     accessTypesAll.SetDelete();
       
   442     accessTypesAll.SetAdd();
       
   443     accessTypesAll.SetReplace();
       
   444 
       
   445     // GenVoIP
       
   446     MSmlDmDDFObject& genVoIP = aDDF.AddChildObjectL( KNSmlDMGenVoIPNodeName );
       
   447     genVoIP.SetAccessTypesL( accessTypesGet );
       
   448     genVoIP.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   449     genVoIP.SetScopeL( MSmlDmDDFObject::EPermanent );
       
   450     genVoIP.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   451     genVoIP.AddDFTypeMimeTypeL( KNSmlDMGenVoIPTextPlain );
       
   452     genVoIP.SetDescriptionL( KNSmlDMGenVoIPNodeNameExp );
       
   453 
       
   454     // Clir
       
   455     MSmlDmDDFObject& clir = genVoIP.AddChildObjectL( KNSmlDMGenVoIPClir );
       
   456     clir.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   457     clir.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   458     clir.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   459     clir.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   460     clir.AddDFTypeMimeTypeL( KNSmlDMGenVoIPTextPlain );
       
   461     clir.SetDescriptionL( KNSmlDMGenVoIPClirExp );
       
   462 
       
   463     // AnonCallBlockRule
       
   464     MSmlDmDDFObject& acbRule = genVoIP.AddChildObjectL( 
       
   465         KNSmlDMGenVoIPAnonCallBlockRule );
       
   466     acbRule.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   467     acbRule.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   468     acbRule.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   469     acbRule.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   470     acbRule.AddDFTypeMimeTypeL( KNSmlDMGenVoIPTextPlain );
       
   471     acbRule.SetDescriptionL( KNSmlDMGenVoIPAnonCallBlockRuleExp );
       
   472 
       
   473     // PreferredTelephony
       
   474     MSmlDmDDFObject& prefTel = genVoIP.AddChildObjectL( 
       
   475         KNSmlDMGenVoIPPreferredTelephony );
       
   476     prefTel.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   477     prefTel.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   478     prefTel.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   479     prefTel.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   480     prefTel.AddDFTypeMimeTypeL( KNSmlDMGenVoIPTextPlain );
       
   481     prefTel.SetDescriptionL( KNSmlDMGenVoIPPreferredTelephonyExp );
       
   482 
       
   483     // DoNotDisturb
       
   484     MSmlDmDDFObject& dnd = genVoIP.AddChildObjectL( 
       
   485         KNSmlDMGenVoIPDoNotDisturb );
       
   486     dnd.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   487     dnd.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   488     dnd.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   489     dnd.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   490     dnd.AddDFTypeMimeTypeL( KNSmlDMGenVoIPTextPlain );
       
   491     dnd.SetDescriptionL( KNSmlDMGenVoIPDoNotDisturbExp );
       
   492 
       
   493     // PSCallWaiting
       
   494     MSmlDmDDFObject& psCallWaiting = genVoIP.AddChildObjectL( 
       
   495         KNSmlDMGenVoIPPSCallWaiting );
       
   496     psCallWaiting.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   497     psCallWaiting.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   498     psCallWaiting.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   499     psCallWaiting.SetDFFormatL( MSmlDmDDFObject::EInt );
       
   500     psCallWaiting.AddDFTypeMimeTypeL( KNSmlDMGenVoIPTextPlain );
       
   501     psCallWaiting.SetDescriptionL( KNSmlDMGenVoIPPSCallWaitingExp );
       
   502 
       
   503     // ProfileName
       
   504     MSmlDmDDFObject& voipProfileId = genVoIP.AddChildObjectL(
       
   505         KNSmlDMGenVoIPProfileId );
       
   506     voipProfileId.SetAccessTypesL( accessTypesGetReplaceAdd );
       
   507     voipProfileId.SetOccurenceL( MSmlDmDDFObject::EZeroOrOne );
       
   508     voipProfileId.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   509     voipProfileId.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   510     voipProfileId.AddDFTypeMimeTypeL( KNSmlDMGenVoIPTextPlain );
       
   511     voipProfileId.SetDescriptionL( KNSmlDMGenVoIPProfileIdExp );
       
   512 
       
   513     _DBG_FILE("CNSmlDmGeneralVoIPSettingsAdapter::DDFStructureL(): end");
       
   514     }
       
   515 
       
   516 // ---------------------------------------------------------------------------
       
   517 // CNSmlDmGeneralVoIPSettingsAdapter::UpdateLeafObjectL
       
   518 // From base class CNSmlDmAdapter.
       
   519 // Updates value of a leaf object
       
   520 // ---------------------------------------------------------------------------
       
   521 //
       
   522 void CNSmlDmGeneralVoIPSettingsAdapter::UpdateLeafObjectL( 
       
   523     const TDesC8& aURI, 
       
   524     const TDesC8& /*aLUID*/, 
       
   525     const TDesC8& aObject, 
       
   526     const TDesC8& /*aType*/, 
       
   527     const TInt aStatusRef )
       
   528     {
       
   529     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::UpdateLeafObjectL(): begin" );
       
   530 
       
   531     CSmlDmAdapter::TError status = EError;
       
   532 
       
   533     TPtrC8 lastURISeg = LastURISeg( aURI );
       
   534     TPtrC8 uriTmp = RemoveLastURISeg( aURI );
       
   535     TPtrC8 secondLastURISeg = LastURISeg( uriTmp );
       
   536 
       
   537     // Make sure iEntry holds values.
       
   538     if ( !( iEntry.iAreSettingsLoaded ) )
       
   539         {
       
   540         TInt err = LoadSettingsL();
       
   541         if ( KErrNone != err )
       
   542             {
       
   543             status = CSmlDmAdapter::EError;
       
   544             iDmCallback->SetStatusL( aStatusRef, status );
       
   545             return;
       
   546             }
       
   547         }
       
   548 
       
   549     if( 0 == secondLastURISeg.Compare( KNSmlDMGenVoIPNodeName() )
       
   550         && KTwoSegs == NumOfURISegs( aURI ) )
       
   551         {
       
   552         status = CSmlDmAdapter::EOk;
       
   553         iEntry.iStatusRef = aStatusRef;
       
   554 
       
   555         // Clir
       
   556         if ( KNSmlDMGenVoIPClir() == lastURISeg )
       
   557             {
       
   558             iEntry.iClir = DesToInt( aObject );
       
   559             }
       
   560         // AnonCallBlockRule
       
   561         else if ( KNSmlDMGenVoIPAnonCallBlockRule() == lastURISeg )
       
   562             {
       
   563             iEntry.iACBRule = DesToInt( aObject );
       
   564             }
       
   565         // PreferredTelephony
       
   566         else if ( KNSmlDMGenVoIPPreferredTelephony() == lastURISeg )
       
   567             {
       
   568             iEntry.iPrefTel = DesToInt( aObject );
       
   569             }
       
   570         // DoNotDisturb
       
   571         else if ( KNSmlDMGenVoIPDoNotDisturb() == lastURISeg )
       
   572             {
       
   573             iEntry.iDnd = DesToInt( aObject );
       
   574             }
       
   575         // PSCallWaiting
       
   576         else if ( KNSmlDMGenVoIPPSCallWaiting() == lastURISeg )
       
   577             {
       
   578             iEntry.iPSCallWaiting = DesToInt( aObject );
       
   579             }
       
   580         else if ( KNSmlDMGenVoIPProfileId() == lastURISeg )
       
   581             {
       
   582             iEntry.iVoipProfileId = aObject;
       
   583             }
       
   584         else
       
   585             {
       
   586             status = CSmlDmAdapter::ENotFound;
       
   587             }
       
   588         }
       
   589     else
       
   590         {
       
   591         status = CSmlDmAdapter::ENotFound;
       
   592         }
       
   593 
       
   594     iDmCallback->SetStatusL( aStatusRef, status ); 
       
   595 
       
   596     _DBG_FILE("CNSmlDmGeneralVoIPSettingsAdapter::UpdateLeafObjectL(): end");
       
   597     }
       
   598 
       
   599 // ---------------------------------------------------------------------------
       
   600 // CNSmlDmGeneralVoIPSettingsAdapter::UpdateLeafObjectL
       
   601 // From base class CNSmlDmAdapter.
       
   602 // Not supported (see smldmadapter.h).
       
   603 // ---------------------------------------------------------------------------
       
   604 //
       
   605 void CNSmlDmGeneralVoIPSettingsAdapter::UpdateLeafObjectL( 
       
   606     const TDesC8& /*aURI*/, 
       
   607     const TDesC8& /*aLUID*/, 
       
   608     RWriteStream*& /*aStream*/, 
       
   609     const TDesC8& /*aType*/, 
       
   610     const TInt aStatusRef )
       
   611     {
       
   612     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::UpdateLeafObjectL(): stream: begin" );
       
   613     iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
   614     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::UpdateLeafObjectL(): stream: end" );
       
   615     }
       
   616 
       
   617 // ---------------------------------------------------------------------------
       
   618 // CNSmlDmGeneralVoIPSettingsAdapter::DeleteObjectL
       
   619 // From base class CNSmlDmAdapter.
       
   620 // Not supported.
       
   621 // ---------------------------------------------------------------------------
       
   622 //
       
   623 void CNSmlDmGeneralVoIPSettingsAdapter::DeleteObjectL( 
       
   624     const TDesC8& /*aURI*/, 
       
   625     const TDesC8& /*aLUID*/, 
       
   626     const TInt aStatusRef )
       
   627     {
       
   628     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::DeleteObjectL(): begin" );
       
   629     iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
   630     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::DeleteObjectL(): end" );
       
   631     }
       
   632 
       
   633 // ---------------------------------------------------------------------------
       
   634 // CNSmlDmGeneralVoIPSettingsAdapter::FetchLeafObjectL
       
   635 // From base class CNSmlDmAdapter.
       
   636 // Fetches the values of leaf objects.
       
   637 // ---------------------------------------------------------------------------
       
   638 //
       
   639 void CNSmlDmGeneralVoIPSettingsAdapter::FetchLeafObjectL( 
       
   640     const TDesC8& aURI, 
       
   641     const TDesC8& /*aLUID*/, 
       
   642     const TDesC8& aType, 
       
   643     const TInt aResultsRef, 
       
   644     const TInt aStatusRef )
       
   645     {
       
   646     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::FetchLeafObjectL(): begin" );
       
   647 
       
   648     CBufBase *result = CBufFlat::NewL( KDefaultResultSize );
       
   649     CleanupStack::PushL( result );
       
   650     CSmlDmAdapter::TError status = FetchObjectL( aURI, *result );
       
   651 
       
   652     if ( CSmlDmAdapter::EOk == status )
       
   653         {
       
   654         iDmCallback->SetResultsL( aResultsRef, *result, aType );
       
   655         }
       
   656     iDmCallback->SetStatusL( aStatusRef, status );
       
   657 
       
   658     CleanupStack::PopAndDestroy( result ); 
       
   659     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::FetchLeafObjectL(): end" );
       
   660     }
       
   661 
       
   662 // ---------------------------------------------------------------------------
       
   663 // CNSmlDmGeneralVoIPSettingsAdapter::FetchLeafObjectSizeL
       
   664 // From base class CNSmlDmAdapter.
       
   665 // Fetches the size of a leaf object.
       
   666 // ---------------------------------------------------------------------------
       
   667 //
       
   668 void CNSmlDmGeneralVoIPSettingsAdapter::FetchLeafObjectSizeL( 
       
   669     const TDesC8& aURI, 
       
   670     const TDesC8& /*aLUID*/, 
       
   671     const TDesC8& aType, 
       
   672     const TInt aResultsRef, 
       
   673     const TInt aStatusRef )
       
   674     {
       
   675     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::FetchLeafObjectSizeL(): begin" );
       
   676     CBufBase *result = CBufFlat::NewL( 1 );
       
   677     CleanupStack::PushL( result );
       
   678     CSmlDmAdapter::TError status = FetchObjectL( aURI, *result );
       
   679     
       
   680     TInt objSizeInBytes = result->Size();
       
   681     TBuf8<16> stringObjSizeInBytes;
       
   682     stringObjSizeInBytes.Num( objSizeInBytes );
       
   683     result->Reset();
       
   684     result->InsertL( 0, stringObjSizeInBytes );
       
   685 
       
   686     iDmCallback->SetStatusL( aStatusRef, status );
       
   687     iDmCallback->SetResultsL( aResultsRef, *result, aType );
       
   688     CleanupStack::PopAndDestroy( result );
       
   689     _DBG_FILE("CNSmlDmGeneralVoIPSettingsAdapter::FetchLeafObjectSizeL(): end" );
       
   690     }
       
   691 
       
   692 // ---------------------------------------------------------------------------
       
   693 // CNSmlDmGeneralVoIPSettingsAdapter::ChildURIListL
       
   694 // From base class CNSmlDmAdapter.
       
   695 // Asks for the list of child objects of the node.
       
   696 // ---------------------------------------------------------------------------
       
   697 //
       
   698 void CNSmlDmGeneralVoIPSettingsAdapter::ChildURIListL( 
       
   699     const TDesC8& aURI,
       
   700     const TDesC8& /*aLUID*/, 
       
   701     const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, 
       
   702     const TInt aResultsRef, 
       
   703     const TInt aStatusRef ) 
       
   704     {
       
   705     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::ChildURIListL(): start" );
       
   706     CSmlDmAdapter::TError status = CSmlDmAdapter::EError;
       
   707 
       
   708     CBufBase *currentURISegmentList = CBufFlat::NewL( KDefaultResultSize );
       
   709     CleanupStack::PushL( currentURISegmentList );
       
   710     TBuf8<KNSmlGenVoIPMaxUriLength> mappingInfo( KNullDesC8 );
       
   711     TBuf8<KNSmlGenVoIPMaxUriLength> uri = aURI;
       
   712     TBuf8<KSmlMaxURISegLen> segmentName;
       
   713 
       
   714     if ( KNSmlDMGenVoIPNodeName() == LastURISeg( aURI ) )
       
   715         {
       
   716         // Clir
       
   717         segmentName.Copy( KNSmlDMGenVoIPClir );
       
   718         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   719             segmentName );
       
   720         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   721             KNSmlDMGenVoIPSeparator );
       
   722         // AnonCallBlockRule
       
   723         segmentName.Copy( KNSmlDMGenVoIPAnonCallBlockRule );
       
   724         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   725             segmentName );
       
   726         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   727             KNSmlDMGenVoIPSeparator );
       
   728         // PreferredTelephony
       
   729         segmentName.Copy( KNSmlDMGenVoIPPreferredTelephony );
       
   730         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   731             segmentName );
       
   732         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   733             KNSmlDMGenVoIPSeparator );
       
   734         // DoNotDisturb
       
   735         segmentName.Copy( KNSmlDMGenVoIPDoNotDisturb );
       
   736         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   737             segmentName );
       
   738         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   739             KNSmlDMGenVoIPSeparator );
       
   740         // PSCallWaiting
       
   741         segmentName.Copy( KNSmlDMGenVoIPPSCallWaiting );
       
   742         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   743             segmentName );
       
   744         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   745             KNSmlDMGenVoIPSeparator );
       
   746         // ProfileName
       
   747         segmentName.Copy( KNSmlDMGenVoIPProfileId );
       
   748         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   749             segmentName );
       
   750         currentURISegmentList->InsertL( currentURISegmentList->Size(), 
       
   751             KNSmlDMGenVoIPSeparator );
       
   752         status = CSmlDmAdapter::EOk;
       
   753         }
       
   754 
       
   755     iDmCallback->SetStatusL( aStatusRef, status );
       
   756     iDmCallback->SetResultsL( aResultsRef, 
       
   757         *currentURISegmentList, KNullDesC8 );
       
   758     CleanupStack::PopAndDestroy( currentURISegmentList );
       
   759 
       
   760     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::ChildURIListL(): end" );
       
   761     }
       
   762     
       
   763 // ---------------------------------------------------------------------------
       
   764 // CNSmlDmGeneralVoIPSettingsAdapter::AddNodeObjectL
       
   765 // From base class CNSmlDmAdapter.
       
   766 // Not supported since there can only be one general VoIP settings node.
       
   767 // ---------------------------------------------------------------------------
       
   768 //
       
   769 void CNSmlDmGeneralVoIPSettingsAdapter::AddNodeObjectL( 
       
   770     const TDesC8& /*aURI*/, 
       
   771     const TDesC8& /*aParentLUID*/, 
       
   772     const TInt aStatusRef )
       
   773     {
       
   774     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::AddNodeObjectL(): begin" );
       
   775     iDmCallback->SetStatusL( aStatusRef, EOk );
       
   776     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::AddNodeObjectL(): end" );
       
   777     }
       
   778     
       
   779 // ---------------------------------------------------------------------------
       
   780 // CNSmlDmGeneralVoIPSettingsAdapter::ExecuteCommandL
       
   781 // From base class CNSmlDmAdapter.
       
   782 // Not supported (see smldmadapter.h).
       
   783 // ---------------------------------------------------------------------------
       
   784 //
       
   785 void CNSmlDmGeneralVoIPSettingsAdapter::ExecuteCommandL( 
       
   786     const TDesC8& /*aURI*/, 
       
   787     const TDesC8& /*aLUID*/, 
       
   788     const TDesC8& /*aArgument*/, 
       
   789     const TDesC8& /*aType*/, 
       
   790     const TInt aStatusRef )
       
   791     {
       
   792     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::ExecuteCommandL(): begin" );
       
   793     iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
   794     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::ExecuteCommandL(): end" );
       
   795     }
       
   796 
       
   797 // ---------------------------------------------------------------------------
       
   798 // CNSmlDmGeneralVoIPSettingsAdapter::ExecuteCommandL
       
   799 // From base class CNSmlDmAdapter.
       
   800 // Not supported (see smldmadapter.h).
       
   801 // ---------------------------------------------------------------------------
       
   802 //
       
   803 void CNSmlDmGeneralVoIPSettingsAdapter::ExecuteCommandL( 
       
   804     const TDesC8& /*aURI*/, 
       
   805     const TDesC8& /*aParentLUID*/, 
       
   806     RWriteStream*& /*aStream*/, 
       
   807     const TDesC8& /*aType*/, 
       
   808     const TInt aStatusRef )
       
   809     {
       
   810     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::ExecuteCommandL(): stream: begin" );
       
   811     iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
   812     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::ExecuteCommandL(): stream: end" );
       
   813     }
       
   814 
       
   815 // ---------------------------------------------------------------------------
       
   816 // CNSmlDmGeneralVoIPSettingsAdapter::CopyCommandL
       
   817 // From base class CNSmlDmAdapter.
       
   818 // Not supported (see smldmadapter.h).
       
   819 // ---------------------------------------------------------------------------
       
   820 //
       
   821 void CNSmlDmGeneralVoIPSettingsAdapter::CopyCommandL( 
       
   822     const TDesC8& /*aTargetURI*/, 
       
   823     const TDesC8& /*aTargetLUID*/, 
       
   824     const TDesC8& /*aSourceURI*/, 
       
   825     const TDesC8& /*aSourceLUID*/, 
       
   826     const TDesC8& /*aType*/, 
       
   827     TInt aStatusRef )
       
   828     {
       
   829     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::CopyCommandL(): begin" );
       
   830     iDmCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
   831     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::CopyCommandL(): end" );
       
   832     }
       
   833 
       
   834 // ---------------------------------------------------------------------------
       
   835 // CNSmlDmGeneralVoIPSettingsAdapter::StartAtomicL
       
   836 // From base class CNSmlDmAdapter.
       
   837 // Not supported (see smldmadapter.h).
       
   838 // ---------------------------------------------------------------------------
       
   839 //
       
   840 void CNSmlDmGeneralVoIPSettingsAdapter::StartAtomicL()
       
   841     {
       
   842     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::StartAtomicL(): begin" );
       
   843     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::StartAtomicL(): end" );
       
   844     }
       
   845     
       
   846 // ---------------------------------------------------------------------------
       
   847 // CNSmlDmGeneralVoIPSettingsAdapter::CommitAtomicL
       
   848 // From base class CNSmlDmAdapter.
       
   849 // Not supported (see smldmadapter.h).
       
   850 // ---------------------------------------------------------------------------
       
   851 //
       
   852 void CNSmlDmGeneralVoIPSettingsAdapter::CommitAtomicL()
       
   853     {
       
   854     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::CommitAtomicL(): begin" );
       
   855     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::CommitAtomicL(): end" );
       
   856     }
       
   857 
       
   858 // ---------------------------------------------------------------------------
       
   859 // CNSmlDmGeneralVoIPSettingsAdapter::RollbackAtomicL
       
   860 // From base class CNSmlDmAdapter.
       
   861 // Not supported (see smldmadapter.h).
       
   862 // ---------------------------------------------------------------------------
       
   863 //
       
   864 void CNSmlDmGeneralVoIPSettingsAdapter::RollbackAtomicL()
       
   865     {
       
   866     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::RollbackAtomicL(): begin" );
       
   867     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::RollbackAtomicL(): end" );
       
   868     }
       
   869 
       
   870 // ---------------------------------------------------------------------------
       
   871 // CNSmlDmGeneralVoIPSettingsAdapter::StreamingSupport
       
   872 // From base class CNSmlDmAdapter.
       
   873 // Not supported (see smldmadapter.h).
       
   874 // ---------------------------------------------------------------------------
       
   875 //
       
   876 TBool CNSmlDmGeneralVoIPSettingsAdapter::StreamingSupport( TInt& /*aItemSize*/ )
       
   877     {
       
   878     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::StreamingSupport(): begin" );
       
   879     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::StreamingSupport(): end" );
       
   880     return EFalse;
       
   881     }
       
   882 
       
   883 // ---------------------------------------------------------------------------
       
   884 // CNSmlDmGeneralVoIPSettingsAdapter::StreamCommittedL
       
   885 // From base class CNSmlDmAdapter.
       
   886 // Not supported (see smldmadapter.h).
       
   887 // ---------------------------------------------------------------------------
       
   888 //
       
   889 void CNSmlDmGeneralVoIPSettingsAdapter::StreamCommittedL()
       
   890     {
       
   891     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::StreamCommittedL(): begin" );
       
   892     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::StreamCommittedL(): end" );
       
   893     }
       
   894 
       
   895 // ---------------------------------------------------------------------------
       
   896 // CNSmlDmGeneralVoIPSettingsAdapter::CompleteOutstandingCmdsL
       
   897 // From base class CNSmlDmAdapter.
       
   898 // Saves modified profiles back to permanent store.
       
   899 // ---------------------------------------------------------------------------
       
   900 //
       
   901 void CNSmlDmGeneralVoIPSettingsAdapter::CompleteOutstandingCmdsL()
       
   902     {
       
   903     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::CompleteOutstandingCmdsL(): begin" );
       
   904     // All commands received, save changes.
       
   905     if ( iEntry.iAreSettingsLoaded )
       
   906         {
       
   907         CRepository* cRepository = CRepository::NewLC( KCRUidRichCallSettings );
       
   908 
       
   909         User::LeaveIfError( cRepository->Set( KRCSEClir, iEntry.iClir ) );
       
   910         User::LeaveIfError( cRepository->Set( KRCSEAnonymousCallBlockRule,
       
   911             iEntry.iACBRule ) );
       
   912         User::LeaveIfError( cRepository->Set( KRCSEPreferredTelephony,
       
   913             iEntry.iPrefTel ) );
       
   914         User::LeaveIfError( cRepository->Set( KRCSEDoNotDisturb,
       
   915             iEntry.iDnd ) );
       
   916         User::LeaveIfError( cRepository->Set( KRCSPSCallWaiting, 
       
   917             iEntry.iPSCallWaiting ) );
       
   918 
       
   919         // If preferred telephony mode has been set to VoIP and general VoIP
       
   920         // settings "links" to a VoIP profile, set the service id stored in 
       
   921         // the profile as the preferred service id.
       
   922         if ( 1 == iEntry.iPrefTel && iEntry.iVoipProfileId.Length() )
       
   923             {
       
   924             // Get VoIP profile id.
       
   925             TInt voipId( VoIPProfileIdL( iEntry.iVoipProfileId ) );
       
   926             
       
   927             // Get service ID from RCSE.
       
   928             CRCSEProfileRegistry* registry = CRCSEProfileRegistry::NewLC();
       
   929             CRCSEProfileEntry* entry = CRCSEProfileEntry::NewLC();        
       
   930 
       
   931             registry->FindL( voipId, *entry );        
       
   932             TUint serviceId = entry->iServiceProviderId;
       
   933 
       
   934             CleanupStack::PopAndDestroy( 2, registry ); // entry, registry
       
   935 
       
   936             cRepository->Set( KRCSPSPreferredService, (TInt)serviceId );
       
   937             }
       
   938         
       
   939         CleanupStack::PopAndDestroy( cRepository );
       
   940         }
       
   941     else
       
   942         {
       
   943         User::Leave( KErrGeneral );
       
   944         }
       
   945     
       
   946     _DBG_FILE( "CNSmlDmGeneralVoIPSettingsAdapter::CompleteOutstandingCmdsL(): end" );
       
   947     }
       
   948 
       
   949 // ---------------------------------------------------------------------------
       
   950 // CNSmlDmGeneralVoIPSettingsAdapter::VoIPProfileIdL
       
   951 // Get VoIP profile ID.
       
   952 // ---------------------------------------------------------------------------
       
   953 //
       
   954 TUint32 CNSmlDmGeneralVoIPSettingsAdapter::VoIPProfileIdL(
       
   955     const TDesC8& aObject ) const
       
   956     {
       
   957     _DBG_FILE("CNSmlDmGeneralVoIPSettingsAdapter::VoIPProfileIdL : begin");
       
   958 
       
   959     __ASSERT_ALWAYS( iDmCallback != NULL, User::Leave( KErrArgument ) );
       
   960 
       
   961     HBufC8* luid = iDmCallback->GetLuidAllocL( aObject );
       
   962     CleanupStack::PushL( luid ); // CS:1
       
   963     if ( luid->Des().Length() )
       
   964         {
       
   965         TBuf8<KMaxUriLength> tmp;
       
   966         tmp.Copy( luid->Des().Mid( KVoipId().Length() ) );
       
   967         TLex8 lex( tmp );
       
   968         TUint profileId( 0 );
       
   969         User::LeaveIfError( lex.Val( profileId ) );
       
   970 
       
   971         CleanupStack::PopAndDestroy( luid ); // CS:0
       
   972         _DBG_FILE("CNSmlDmGeneralVoIPSettingsAdapter::VoIPProfileIdL : end");
       
   973         return profileId;
       
   974         }
       
   975     CleanupStack::PopAndDestroy( luid ); // CS:0
       
   976     
       
   977     _DBG_FILE("CNSmlDmGeneralVoIPSettingsAdapter::VoIPProfileIdL : end");
       
   978     return KErrNone;
       
   979     }
       
   980 
       
   981 // ---------------------------------------------------------------------------
       
   982 // CNSmlDmGeneralVoIPSettingsAdapter::ResolvePreferredServiceNameL
       
   983 // Get name of the preferred VoIP service.
       
   984 // ---------------------------------------------------------------------------
       
   985 //
       
   986 TInt CNSmlDmGeneralVoIPSettingsAdapter::ResolvePreferredServiceNameL(
       
   987     CRepository& aRepository )
       
   988     {
       
   989     _DBG_FILE("CNSmlDmGeneralVoIPSettingsAdapter::ResolvePreferredServiceNameL : begin");
       
   990 
       
   991     // Reset VoIP profile id.
       
   992     iEntry.iVoipProfileId.Zero();
       
   993     
       
   994     // No need to resolve if preferred telephony isn't set to VoIP.
       
   995     if ( 1 != iEntry.iPrefTel )
       
   996         {
       
   997         return KErrNone;
       
   998         }
       
   999     
       
  1000     // Get preferred service id from central repository.
       
  1001     TInt serviceId( KErrNotFound );
       
  1002     
       
  1003     User::LeaveIfError( aRepository.Get(
       
  1004         KRCSPSPreferredService, serviceId ) );
       
  1005     
       
  1006     // Find the VoIP profile with the given service id.
       
  1007     CRCSEProfileRegistry* registry = CRCSEProfileRegistry::NewLC();
       
  1008     RPointerArray<CRCSEProfileEntry> entries;
       
  1009     CleanupResetAndDestroyL( entries );
       
  1010 
       
  1011     registry->FindByServiceIdL( serviceId, entries );
       
  1012 
       
  1013     if ( !entries.Count() )
       
  1014         {
       
  1015         User::Leave( KErrNotFound );
       
  1016         }
       
  1017 
       
  1018     TInt voipProfileId = entries[0]->iId;
       
  1019     
       
  1020     CleanupStack::PopAndDestroy( 2, registry ); // entries, registry
       
  1021 
       
  1022     // Get URIs to all VoIP settings.
       
  1023     CBufBase* result = CBufFlat::NewL( 1 );
       
  1024     CleanupStack::PushL( result ); // CS:1
       
  1025     CSmlDmAdapter::TError status;
       
  1026 
       
  1027     iDmCallback->FetchLinkL( KNSmlDMVoIPNodeName(), *result, status );
       
  1028     
       
  1029     result->Compress();
       
  1030     
       
  1031     HBufC8* childList = HBufC8::NewLC( result->Size() ); // CS:2
       
  1032     TInt uriSegCount( 0 );
       
  1033 
       
  1034     if ( result->Size() )
       
  1035         {
       
  1036         childList->Des().Copy( result->Ptr( 0 ) );
       
  1037         uriSegCount = NumOfURISegs( childList->Des() );
       
  1038         }
       
  1039 
       
  1040     // Get LUIDs for URIs and save the correct profile name.
       
  1041     for ( TInt index = 0; index < uriSegCount; index++ )
       
  1042         {
       
  1043         HBufC8* uri = HBufC8::NewLC( KMaxUriLength ); // CS:3
       
  1044       
       
  1045         uri->Des().Copy( KNSmlDMVoIPNodeName() );
       
  1046         uri->Des().Append( KNSmlDMGenVoIPSeparator() );
       
  1047         uri->Des().Append( LastURISeg( childList->Des() ) );        
       
  1048 
       
  1049         HBufC8* luid = iDmCallback->GetLuidAllocL( uri->Des() );
       
  1050         CleanupStack::PushL( luid ); // CS:4
       
  1051 
       
  1052         if ( luid->Des().Length() && 
       
  1053             voipProfileId == DesToInt(
       
  1054                 luid->Des().Mid( KVoipId().Length() ) ) )
       
  1055             {
       
  1056             iEntry.iVoipProfileId.Copy( uri->Des() );
       
  1057             CleanupStack::PopAndDestroy( luid ); // CS:3
       
  1058             CleanupStack::PopAndDestroy( uri );  // CS:2
       
  1059             break;
       
  1060             }
       
  1061         childList->Des().Copy( RemoveLastURISeg( childList->Des() ) );
       
  1062         CleanupStack::PopAndDestroy( luid ); // CS:3
       
  1063         CleanupStack::PopAndDestroy( uri );  // CS:2
       
  1064         }
       
  1065 
       
  1066     CleanupStack::PopAndDestroy( childList );  // CS:1
       
  1067     CleanupStack::PopAndDestroy( result );     // CS:0
       
  1068 
       
  1069     _DBG_FILE("CNSmlDmGeneralVoIPSettingsAdapter::ResolvePreferredServiceNameL : end");
       
  1070     return status;
       
  1071     }
       
  1072 
       
  1073 // ---------------------------------------------------------------------------
       
  1074 // TImplementationProxy ImplementationTable[]
       
  1075 // Needed because of ECOM architecture
       
  1076 // ---------------------------------------------------------------------------
       
  1077 //
       
  1078 #ifndef IMPLEMENTATION_PROXY_ENTRY
       
  1079 #define IMPLEMENTATION_PROXY_ENTRY( aUid, aFuncPtr ) {{ aUid }, ( aFuncPtr )}
       
  1080 #endif
       
  1081 
       
  1082 const TImplementationProxy ImplementationTable[] = 
       
  1083     {
       
  1084     IMPLEMENTATION_PROXY_ENTRY( KNSmlDMGenVoIPAdapterImplUid, 
       
  1085         CNSmlDmGeneralVoIPSettingsAdapter::NewL )
       
  1086     };
       
  1087 
       
  1088 // ---------------------------------------------------------------------------
       
  1089 // ImplementationGroupProxy()
       
  1090 // Needed because of ECOM architecture
       
  1091 // ---------------------------------------------------------------------------
       
  1092 //
       
  1093 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( 
       
  1094     TInt& aTableCount )
       
  1095     {
       
  1096     _DBG_FILE( "ImplementationGroupProxy() for CNSmlDmGeneralVoIPSettingsAdapter: begin" );
       
  1097     aTableCount = sizeof( ImplementationTable ) / 
       
  1098         sizeof( TImplementationProxy );
       
  1099     _DBG_FILE( "ImplementationGroupProxy() for CNSmlDmGeneralVoIPSettingsAdapter: end" );
       
  1100     return ImplementationTable;
       
  1101     }
       
  1102