deviceupdatesui/omadmadapters/nsmldmalwaysonadapter/src/nsmldmalwaysonadapter.cpp
changeset 44 137912d1a556
equal deleted inserted replaced
43:88e14c3d4c4f 44:137912d1a556
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Provides handling of Always-on settings in Device management.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ecom/implementationproxy.h>
       
    20 
       
    21 #include "nsmldmalwaysonadapter.h"
       
    22 #include "logger.h"
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 
       
    27 // --------------------------------------------------------------------------
       
    28 // Maps plugin UID to its factory function (constructor)
       
    29 // --------------------------------------------------------------------------
       
    30 const TImplementationProxy ImplementationTable[] =
       
    31     {
       
    32     IMPLEMENTATION_PROXY_ENTRY(0x101f6d36, 
       
    33                                CNSmlDmAOAdapter::NewL)
       
    34     };
       
    35 
       
    36 // --------------------------------------------------------------------------
       
    37 // For ecom plugin implementation
       
    38 // -------------------------------------------------------------------------
       
    39 
       
    40 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
       
    41     {
       
    42     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
    43     return ImplementationTable;
       
    44     }
       
    45 
       
    46 // --------------------------------------------------------------------------
       
    47 // CNSmlDmAOAdapter::NewL
       
    48 // --------------------------------------------------------------------------
       
    49 CNSmlDmAOAdapter* CNSmlDmAOAdapter::NewL( MSmlDmCallback* aDmCallback )
       
    50     {
       
    51     LOGSTRING("CNSmlDmAOAdapter::NewL: Start");
       
    52     
       
    53     CNSmlDmAOAdapter* self = new (ELeave) CNSmlDmAOAdapter( aDmCallback );
       
    54     CleanupStack::PushL(self);
       
    55     self->ConstructL();
       
    56     CleanupStack::Pop( self );
       
    57     
       
    58     LOGSTRING("CNSmlDmAOAdapter::NewL: End");
       
    59     return self;
       
    60     }
       
    61 
       
    62 // --------------------------------------------------------------------------
       
    63 // CNSmlDmAOAdapter::CNSmlDmAOAdapter
       
    64 // --------------------------------------------------------------------------
       
    65 
       
    66 CNSmlDmAOAdapter::CNSmlDmAOAdapter( MSmlDmCallback* aDmCallback ) 
       
    67     : CSmlDmAdapter( aDmCallback )
       
    68     {
       
    69     }
       
    70 
       
    71 // --------------------------------------------------------------------------
       
    72 // CNSmlDmAOAdapter::ConstructL
       
    73 // --------------------------------------------------------------------------
       
    74 void CNSmlDmAOAdapter::ConstructL()
       
    75     {
       
    76     LOGSTRING( "CNSmlDmAOAdapter::CNSmlDmAOAdapter: Start" );
       
    77     
       
    78     iSettingStore = CNSmlDmAOSettingStore::NewL( this );
       
    79     
       
    80     LOGSTRING( "CNSmlDmAOAdapter::CNSmlDmAOAdapter: End" );
       
    81     }
       
    82 
       
    83 // --------------------------------------------------------------------------
       
    84 // CNSmlDmAOAdapter::~CNSmlDmAOAdapter
       
    85 // --------------------------------------------------------------------------
       
    86 CNSmlDmAOAdapter::~CNSmlDmAOAdapter()
       
    87     {
       
    88     LOGSTRING( "CNSmlDmAOAdapter::~CNSmlDmAOAdapter: Start" );    
       
    89  
       
    90     //iBuffer.ResetAndDestroy();
       
    91     //iBuffer.Close();
       
    92     delete iSettingStore;
       
    93  
       
    94     LOGSTRING( "CNSmlDmAOAdapter::~CNSmlDmAOAdapter: End" );
       
    95     }
       
    96     
       
    97 // --------------------------------------------------------------------------
       
    98 // CNSmlDmAOAdapter::DDFVersionL
       
    99 // Returns ddf version nr
       
   100 // --------------------------------------------------------------------------
       
   101 void CNSmlDmAOAdapter::DDFVersionL( CBufBase& aDDFVersion )
       
   102     {
       
   103     LOGSTRING( "CNSmlDmAOAdapter::DDFVersionL: Start" );
       
   104  
       
   105     aDDFVersion.InsertL( 0, KNSmlDmAOAdapterDDFVersion );
       
   106  
       
   107     LOGSTRING( "CNSmlDmAOAdapter::DDFVersionL:End" );
       
   108     }
       
   109    
       
   110 // --------------------------------------------------------------------------
       
   111 // CNSmlDmAOAdapter::DDFStructureL
       
   112 //  Constructs the DDF structure
       
   113 // --------------------------------------------------------------------------
       
   114 void CNSmlDmAOAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
       
   115     {
       
   116     LOGSTRING( "CNSmlDmAOAdapter::DDFStructureL: Start" );
       
   117     TSmlDmAccessTypes accessTypes;
       
   118 
       
   119     // VENDORCONFIG
       
   120     MSmlDmDDFObject& ao = aDDF.AddChildObjectL( KNSmlDmAOAdapterAO );
       
   121     
       
   122     accessTypes.SetGet();    
       
   123     
       
   124     ao.SetAccessTypesL( accessTypes );
       
   125     ao.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   126     ao.SetScopeL( MSmlDmDDFObject::EPermanent );
       
   127     ao.SetDFFormatL( MSmlDmDDFObject::ENode );
       
   128     ao.AddDFTypeMimeTypeL( KNSmlDmAOAdapterTextPlain );
       
   129     ao.SetDescriptionL( KNSmlDmAOAdapterAODescription );
       
   130     accessTypes.Reset();
       
   131 
       
   132     // VENDORCONFIG/Name
       
   133     MSmlDmDDFObject& name = ao.AddChildObjectL( KNSmlDmAOAdapterName );
       
   134     
       
   135     accessTypes.SetGet();
       
   136     accessTypes.SetReplace();
       
   137     accessTypes.SetAdd();
       
   138     
       
   139     name.SetAccessTypesL( accessTypes );
       
   140     name.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   141     name.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   142     name.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   143     name.SetDescriptionL( KNSmlDmAOAdapterNameDescription );
       
   144     accessTypes.Reset();
       
   145 
       
   146     // VENDORCONFIG/AWON-PDPC
       
   147     MSmlDmDDFObject& awonPdpc = 
       
   148                           ao.AddChildObjectL( KNSmlDmAOAdapterAwonPdpc );
       
   149     
       
   150     accessTypes.SetGet();
       
   151     accessTypes.SetReplace();
       
   152     accessTypes.SetAdd();
       
   153     
       
   154     awonPdpc.SetAccessTypesL( accessTypes );
       
   155     awonPdpc.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   156     awonPdpc.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   157     awonPdpc.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   158     awonPdpc.SetDescriptionL( KNSmlDmAOAdapterAwonPdpcDescription );
       
   159     accessTypes.Reset();
       
   160         
       
   161     // VENDORCONFIG/T-RETRY
       
   162     MSmlDmDDFObject& tRetry = 
       
   163                           ao.AddChildObjectL( KNSmlDmAOAdapterTRetry );
       
   164     
       
   165     accessTypes.SetGet();
       
   166     accessTypes.SetReplace();
       
   167     accessTypes.SetAdd();
       
   168     
       
   169     tRetry.SetAccessTypesL( accessTypes );
       
   170     tRetry.SetOccurenceL( MSmlDmDDFObject::EOne );
       
   171     tRetry.SetScopeL( MSmlDmDDFObject::EDynamic );
       
   172     tRetry.SetDFFormatL( MSmlDmDDFObject::EChr );
       
   173     tRetry.SetDescriptionL( KNSmlDmAOAdapterTRetryDescription );
       
   174     accessTypes.Reset();
       
   175     
       
   176     LOGSTRING( "CNSmlDmAOAdapter::DDFStructureL: End" );    
       
   177     }
       
   178 
       
   179 // -------------------------------------------------------------------------
       
   180 // CNSmlDmAOAdapter::UpdateLeafObjectL
       
   181 // Adds or updates leaf node value. 
       
   182 // -------------------------------------------------------------------------
       
   183 void CNSmlDmAOAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
       
   184                                           const TDesC8& aLUID, 
       
   185                                           const TDesC8& aObject, 
       
   186                                           const TDesC8& /*aType*/, 
       
   187                                           TInt aStatusRef )
       
   188     {
       
   189     LOGSTRING( "CNSmlDmAOAdapter::UpdateLeafObjectL: Start" );
       
   190     LOGSTRING4( "\tUpdateLeafObjectL  \tURI: %S, \n\tLUID: %S,\
       
   191                          \tobject: %S ", 
       
   192                         &aURI, &aLUID, &aObject );
       
   193         
       
   194 	// execute command and return status  
       
   195     CSmlDmAOCommandElement* cmd = 
       
   196     CSmlDmAOCommandElement::NewLC( ETrue, 
       
   197                                    aStatusRef,
       
   198                                    KNSmlDmAOInvalidRef, 
       
   199                                    CNSmlDmAOAdapter::EAddCmd,
       
   200                                    LastURISeg( aURI ), 
       
   201                                    aObject);
       
   202     
       
   203     TInt luid( KDefaultLuid );
       
   204     
       
   205     if ( aLUID.Length() > 0 )
       
   206         {
       
   207         luid = DesToIntL( aLUID );    
       
   208         }
       
   209                                                                                                      
       
   210     iSettingStore->ExecuteCmdL( *cmd, luid );    
       
   211     
       
   212     LOGSTRING2( "\tCmd executed with status: %d", 
       
   213                           cmd->Status() );
       
   214     Callback().SetStatusL( aStatusRef, cmd->Status() );     
       
   215     CleanupStack::PopAndDestroy( cmd );                
       
   216         
       
   217     LOGSTRING( "CNSmlDmAOAdapter::UpdateLeafObjectL: End" );    
       
   218     }
       
   219 // --------------------------------------------------------------------------
       
   220 // CNSmlDmAOAdapter::DeleteObjectL
       
   221 // Not supported
       
   222 // --------------------------------------------------------------------------
       
   223 
       
   224 void CNSmlDmAOAdapter::DeleteObjectL( const TDesC8& /*aURI*/, 
       
   225                                       const TDesC8& /*aLUID*/,
       
   226 						              TInt aStatusRef )
       
   227     {
       
   228     LOGSTRING( "CNSmlDmAOAdapter::DeleteObjectL: Start" );
       
   229     Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError); 
       
   230     LOGSTRING( "CNSmlDmAOAdapter::DeleteObjectL: End" );
       
   231     }
       
   232     
       
   233 // -------------------------------------------------------------------------
       
   234 // CNSmlDmAOAdapter::FetchLeafObjectL
       
   235 // Fetches leaf object value.
       
   236 // -------------------------------------------------------------------------
       
   237 void CNSmlDmAOAdapter::FetchLeafObjectL( const TDesC8& aURI, 
       
   238                                          const TDesC8& aLUID, 
       
   239                                          const TDesC8& /*aType*/, 
       
   240                                          const TInt aResultsRef, 
       
   241                                          const TInt aStatusRef )
       
   242     {
       
   243     LOGSTRING( "NSmlDmAOAdapter::FetchLeafObjectL: Start" );
       
   244     LOGSTRING3( "\tFetchLeafObjectL  \tURI: %S, \tLUID: %S,", 
       
   245                         &aURI, &aLUID );
       
   246     
       
   247     CSmlDmAOCommandElement* cmd = 
       
   248     CSmlDmAOCommandElement::NewLC( ETrue, 
       
   249                                    aStatusRef, 
       
   250                                    aResultsRef, 
       
   251                                    CNSmlDmAOAdapter::EGetCmd,
       
   252                                    LastURISeg( aURI ), 
       
   253                                    KNullDesC8);
       
   254 
       
   255     TInt luid( KDefaultLuid );
       
   256     
       
   257     if ( aLUID.Length() > 0 )
       
   258         {
       
   259         luid = DesToIntL( aLUID );    
       
   260         }
       
   261         
       
   262     iSettingStore->ExecuteCmdL( *cmd, luid );
       
   263     LOGSTRING2( "\tCmd executed with status: %d ", 
       
   264                           cmd->Status() );
       
   265 
       
   266     // if executed return status
       
   267     if ( cmd->Executed() ) 
       
   268         {
       
   269         Callback().SetStatusL( aStatusRef, cmd->Status() );            
       
   270         // if successful set results
       
   271         if ( cmd->Status() == CSmlDmAdapter::EOk )
       
   272             {
       
   273             LOGSTRING2( "\tCmd executed with result: %S ", 
       
   274                                   cmd->Data() );
       
   275             CBufBase* result = CBufFlat::NewL( cmd->Data()->Size() );
       
   276             CleanupStack::PushL( result );
       
   277             result->InsertL( 0, *cmd->Data() );
       
   278             Callback().SetResultsL( aResultsRef, *result, KNullDesC8 );
       
   279             CleanupStack::PopAndDestroy( result );
       
   280             }
       
   281         }
       
   282     else
       
   283         {
       
   284         // failed to execute command
       
   285         Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
   286         }
       
   287     CleanupStack::PopAndDestroy( cmd );
       
   288     
       
   289     
       
   290     LOGSTRING( "NSmlDmAOAdapter::FetchLeafObjectL: End" );
       
   291     }
       
   292 
       
   293 // --------------------------------------------------------------------------
       
   294 //  CNSmlDmAOAdapter::FetchLeafObjectSizeL
       
   295 //  Fetches leaf object size.
       
   296 // -------------------------------------------------------------------------
       
   297 void CNSmlDmAOAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, 
       
   298                                              const TDesC8& aLUID,
       
   299 									         const TDesC8& /* aType */, 
       
   300 									         TInt aResultsRef,
       
   301 									         TInt aStatusRef )
       
   302     {
       
   303     LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: Start" );
       
   304     LOGSTRING3( "\tFetchLeafObjectSizeL  \tURI: %S, \tLUID: %S,", 
       
   305                          &aURI, &aLUID );
       
   306    
       
   307     CSmlDmAOCommandElement* cmd = 
       
   308     CSmlDmAOCommandElement::NewLC( ETrue, 
       
   309                                    aStatusRef, 
       
   310                                    aResultsRef, 
       
   311                                    CNSmlDmAOAdapter::EGetSizeCmd,
       
   312                                    LastURISeg( aURI ), 
       
   313                                    KNullDesC8);
       
   314                                    
       
   315     TInt luid( KDefaultLuid );
       
   316     
       
   317     if ( aLUID.Length() > 0 )
       
   318         {
       
   319         luid = DesToIntL( aLUID );    
       
   320         }
       
   321                                        
       
   322     iSettingStore->ExecuteCmdL( *cmd, luid );
       
   323     
       
   324     LOGSTRING2( "\tCmd executed with status: %d ", 
       
   325                           cmd->Status() );
       
   326     // if executed get status
       
   327     if ( cmd->Executed() ) 
       
   328         {
       
   329         Callback().SetStatusL( aStatusRef, cmd->Status() );            
       
   330         // if successful get results
       
   331         if ( cmd->Status() == CSmlDmAdapter::EOk )
       
   332             {
       
   333             LOGSTRING2( "\tCmd executed with result: %S ", 
       
   334                                   cmd->Data() );
       
   335             CBufBase* result = CBufFlat::NewL( cmd->Data()->Size() );
       
   336             CleanupStack::PushL( result );
       
   337             result->InsertL( 0, *cmd->Data() );
       
   338             Callback().SetResultsL( aResultsRef, *result, KNullDesC8 );
       
   339             CleanupStack::PopAndDestroy( result );
       
   340             }
       
   341         }
       
   342     else
       
   343         {
       
   344         // failed to execute command
       
   345         Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
       
   346         }
       
   347     
       
   348     CleanupStack::PopAndDestroy( cmd );
       
   349         
       
   350     LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: End" );
       
   351     }
       
   352 
       
   353 // ------------------------------------------------------------------------
       
   354 //  CNSmlDmAOAdapter::ChildURIListL
       
   355 //  Fetches child nodes of a node. these may be either all VENDORCONFIG 
       
   356 //  nodes or leaf nodes under a VENDORCONFIG node. 
       
   357 // ------------------------------------------------------------------------
       
   358 void CNSmlDmAOAdapter::ChildURIListL( const TDesC8& aURI, 
       
   359                                       const TDesC8& aLUID,
       
   360 					                  const CArrayFix<TSmlDmMappingInfo>& 
       
   361 					                  /*aPreviousURISegmentList*/,
       
   362 					                  TInt aResultsRef, 
       
   363 					                  TInt aStatusRef )
       
   364     {
       
   365     LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: Start" );
       
   366     LOGSTRING3( "\tChildURIListL  URI: %S, LUID: %S ", 
       
   367                         &aURI, &aLUID );
       
   368     
       
   369     CBufBase* resultList = CBufFlat::NewL( KSmlMaxURISegLen );
       
   370     CleanupStack::PushL( resultList );
       
   371 	
       
   372 	// get all leaf nodes below VENDORCONFIG node
       
   373     if ( !aURI.Compare( KNSmlDmAOAdapterAO ) )
       
   374         {        
       
   375         CSmlDmAOCommandElement* cmd = 
       
   376         CSmlDmAOCommandElement::NewLC( EFalse, 
       
   377                                        aStatusRef,
       
   378                                        aResultsRef, 
       
   379                                        CNSmlDmAOAdapter::EGetCmd, 
       
   380                                        KNullDesC8, 
       
   381                                        KNullDesC8 );
       
   382                                        
       
   383         TInt luid( KDefaultLuid );
       
   384     
       
   385         if ( aLUID.Length() > 0 )
       
   386             {
       
   387             luid = DesToIntL( aLUID );    
       
   388             }
       
   389                                            
       
   390         iSettingStore->ExecuteCmdL( *cmd, luid );
       
   391         
       
   392         LOGSTRING2( "\tCmd executed with status: %d ", 
       
   393                               cmd->Status() );
       
   394    
       
   395         Callback().SetStatusL( aStatusRef, cmd->Status() );
       
   396         if( cmd->Status() == CSmlDmAdapter::EOk )
       
   397             {
       
   398             resultList->InsertL( 0, *cmd->Data() );
       
   399             Callback().SetResultsL( aResultsRef, 
       
   400                                     *resultList, 
       
   401                                     KNullDesC8 );
       
   402             } 
       
   403    
       
   404         CleanupStack::PopAndDestroy( cmd );               
       
   405         }        
       
   406    
       
   407     CleanupStack::PopAndDestroy( resultList );
       
   408     LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: End" );
       
   409     }
       
   410  
       
   411 // --------------------------------------------------------------------------
       
   412 //  CNSmlDmAOAdapter::AddNodeObjectL
       
   413 //  Not supported
       
   414 // --------------------------------------------------------------------------
       
   415 void CNSmlDmAOAdapter::AddNodeObjectL( const TDesC8& /*aURI*/, 
       
   416                                        const TDesC8& /*aParentLUID*/,
       
   417 								       TInt aStatusRef )
       
   418     {
       
   419     LOGSTRING( "CNSmlDmAOAdapter::AddNodeObjectL: Start" );
       
   420     Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);
       
   421     LOGSTRING( "CNSmlDmAOAdapter::AddNodeObjectL: End" );
       
   422     }
       
   423 
       
   424 // -------------------------------------------------------------------------
       
   425 //  CNSmlDmAOAdapter::UpdateLeafObjectL
       
   426 //  Not supported from stream
       
   427 // -------------------------------------------------------------------------
       
   428 void CNSmlDmAOAdapter::UpdateLeafObjectL( const TDesC8& /* aURI */, 
       
   429                                           const TDesC8& /* aLUID */, 
       
   430                                           RWriteStream*& /* aStream */, 
       
   431                                           const TDesC8& /* aType */, 
       
   432                                           TInt aStatusRef )
       
   433     {
       
   434     LOGSTRING( "CNSmlDmAOAdapter::UpdateLeafObjectL: Start" );
       
   435     Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);    
       
   436     LOGSTRING( "CNSmlDmAOAdapter::UpdateLeafObjectL: End" );
       
   437     }
       
   438 
       
   439 
       
   440 
       
   441 // -------------------------------------------------------------------------
       
   442 //  CNSmlDmAOAdapter::ExecuteCommandL
       
   443 //  Not supported
       
   444 // -------------------------------------------------------------------------
       
   445 void CNSmlDmAOAdapter::ExecuteCommandL( const TDesC8& /* aURI */, 
       
   446                                         const TDesC8& /* aLUID */, 
       
   447                                         const TDesC8& /* aArgument */, 
       
   448                                         const TDesC8& /* aType */, 
       
   449                                         TInt aStatusRef )
       
   450     {
       
   451     LOGSTRING( "CNSmlDmAOAdapter::ExecuteCommandL: Start" );
       
   452     Callback().SetStatusL(aStatusRef, CSmlDmAdapter::EError);    
       
   453     LOGSTRING( "CNSmlDmAOAdapter::ExecuteCommandL: End" );
       
   454     }
       
   455 // -------------------------------------------------------------------------
       
   456 //  CNSmlDmAOAdapter::ExecuteCommandL
       
   457 //  Not supported
       
   458 // -------------------------------------------------------------------------
       
   459 void CNSmlDmAOAdapter::ExecuteCommandL( const TDesC8& /* aURI */, 
       
   460                                         const TDesC8& /* aLUID */, 
       
   461                                         RWriteStream*& /* aStream */, 
       
   462                                         const TDesC8& /* aType */, 
       
   463                                         TInt aStatusRef )
       
   464     {
       
   465     LOGSTRING( "CNSmlDmAOAdapter::ExecuteCommandL: Start" );
       
   466     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );    
       
   467     LOGSTRING( "CNSmlDmAOAdapter::ExecuteCommandL: End" );
       
   468     }
       
   469  
       
   470 // -------------------------------------------------------------------------
       
   471 //  CNSmlDmAOAdapter::CopyCommandL
       
   472 //  Not supported
       
   473 // -------------------------------------------------------------------------
       
   474 void CNSmlDmAOAdapter::CopyCommandL( const TDesC8& /* aTargetURI */ , 
       
   475                                      const TDesC8& /* aTargetLUID */ , 
       
   476                                      const TDesC8& /* aSourceURI */ , 
       
   477                                      const TDesC8& /* aSourceLUID */, 
       
   478                                      const TDesC8& /* aType */ , 
       
   479                                      TInt aStatusRef )
       
   480     {
       
   481     //not supported
       
   482     LOGSTRING( "CNSmlDmAOAdapter::CopyCommandL: Sart" );
       
   483     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );    
       
   484     LOGSTRING( "CNSmlDmAOAdapter::CopyCommandL: End" );
       
   485     }
       
   486 // -------------------------------------------------------------------------
       
   487 //  CNSmlDmAOAdapter::StartAtomicL
       
   488 //  Not supported
       
   489 // -------------------------------------------------------------------------
       
   490 void CNSmlDmAOAdapter::StartAtomicL()
       
   491     {
       
   492     LOGSTRING( "CNSmlDmAOAdapter::StartAtomicL: Start" );
       
   493     LOGSTRING( "CNSmlDmAOAdapter::StartAtomicL: End" );
       
   494     }
       
   495 // -------------------------------------------------------------------------
       
   496 //  CNSmlDmAOAdapter::CommitAtomicL
       
   497 //  Not supported
       
   498 // -------------------------------------------------------------------------
       
   499 void CNSmlDmAOAdapter::CommitAtomicL()
       
   500     {
       
   501     LOGSTRING( "CNSmlDmAOAdapter::CommitAtomicL: Start" );
       
   502     LOGSTRING( "CNSmlDmAOAdapter::CommitAtomicL: End" );
       
   503     }
       
   504 
       
   505 // -------------------------------------------------------------------------
       
   506 //  CNSmlDmAOAdapter::RollbackAtomicL
       
   507 //  Not supported
       
   508 // -------------------------------------------------------------------------
       
   509 void CNSmlDmAOAdapter::RollbackAtomicL()
       
   510     {
       
   511     LOGSTRING( "CNSmlDmAOAdapter::RollbackAtomicL: Start" );
       
   512     LOGSTRING( "CNSmlDmAOAdapter::RollbackAtomicL: End" );
       
   513     }
       
   514 
       
   515 TBool CNSmlDmAOAdapter::StreamingSupport( TInt& /* aItemSize */ )
       
   516     {
       
   517     LOGSTRING( "CNSmlDmAOAdapter::StreamingSupport: Start" );
       
   518     LOGSTRING( "CNSmlDmAOAdapter::StreamingSupport: End" );
       
   519     return EFalse;
       
   520     }
       
   521 // -------------------------------------------------------------------------
       
   522 //  CNSmlDmAOAdapter::StreamCommittedL
       
   523 //  Not supported
       
   524 // -------------------------------------------------------------------------
       
   525 void CNSmlDmAOAdapter::StreamCommittedL()
       
   526     {
       
   527     LOGSTRING( "CNSmlDmAOAdapter::StreamCommittedL: Start" );
       
   528     LOGSTRING( "CNSmlDmAOAdapter::StreamCommittedL: End" );
       
   529     }
       
   530 
       
   531 // -------------------------------------------------------------------------
       
   532 // CNSmlDmAOAdapter::CompleteOutstandingCmdsL
       
   533 // Buffering not needed because nodes can't be added
       
   534 // -------------------------------------------------------------------------
       
   535 void CNSmlDmAOAdapter::CompleteOutstandingCmdsL()
       
   536     {
       
   537     LOGSTRING( "CNSmlDmAOAdapter::CompleteOutstandingCmdsL: Start");
       
   538     LOGSTRING( "CNSmlDmAOAdapter::CompleteOutstandingCmdsL: End" );    
       
   539     }
       
   540 
       
   541 // --------------------------------------------------------------------------
       
   542 // CNSmlDmAOAdapter::IntToDes8L
       
   543 // Converts integer to 8bit descriptor
       
   544 // --------------------------------------------------------------------------
       
   545 HBufC8* CNSmlDmAOAdapter::IntToDes8L( TInt aLuid ) const
       
   546     {
       
   547     HBufC8* buf = HBufC8::NewL( 10 ); //10 = max length of 32bit integer
       
   548     TPtr8 ptrBuf = buf->Des();
       
   549     ptrBuf.Num( aLuid );
       
   550     return buf;
       
   551     }
       
   552     
       
   553 // --------------------------------------------------------------------------
       
   554 // CNSmlDmAOAdapter::DesToIntL
       
   555 // Converts 8bit descriptor to int
       
   556 // --------------------------------------------------------------------------
       
   557 TUint CNSmlDmAOAdapter::DesToIntL( const TDesC8& aLuid ) const
       
   558     {
       
   559     TLex8 lex( aLuid );
       
   560     TUint value( 0 );
       
   561     User::LeaveIfError( lex.Val( value ) );
       
   562     return value;
       
   563     }        
       
   564 
       
   565 // --------------------------------------------------------------------------
       
   566 // CNSmlDmAOAdapter::LastURISeg
       
   567 // Returns the last uri segemnt of a uri. 
       
   568 // --------------------------------------------------------------------------
       
   569 TPtrC8 CNSmlDmAOAdapter::LastURISeg( const TDesC8& aURI ) const
       
   570     {
       
   571     TInt i;
       
   572     for ( i=aURI.Length()-1; i >= 0; i-- )
       
   573         {
       
   574         if ( aURI[i]=='/' )
       
   575             {
       
   576             break;
       
   577             }
       
   578         }
       
   579         
       
   580     if ( i==0 )
       
   581         {
       
   582         return aURI;
       
   583         }
       
   584     else
       
   585         {
       
   586         return aURI.Mid( i + 1 );
       
   587         }
       
   588     }
       
   589 
       
   590 
       
   591 //---------------------- CSmlDmAOCommandElement -------------------------//
       
   592 
       
   593 // --------------------------------------------------------------------------
       
   594 // CSmlDmAOCommandElement* CSmlDmAOCommandElement::NewLC
       
   595 // --------------------------------------------------------------------------
       
   596 
       
   597 CSmlDmAOCommandElement* CSmlDmAOCommandElement::NewLC( TBool aLeaf,
       
   598                                                        TInt aStatusRef, 
       
   599                                                        TInt aResultRef, 
       
   600                                                        CNSmlDmAOAdapter::TCommandType aCmdType,
       
   601                                                        const TDesC8& aLastUriSeg, 
       
   602                                                        const TDesC8& aData )
       
   603     {
       
   604     CSmlDmAOCommandElement* self = new (ELeave) CSmlDmAOCommandElement( aLeaf, 
       
   605                                                                         aStatusRef, 
       
   606                                                                         aResultRef, 
       
   607                                                                         aCmdType );
       
   608     CleanupStack::PushL(self);
       
   609     self->ConstructL( aLastUriSeg, aData );
       
   610     return self;
       
   611     }    
       
   612     
       
   613 // --------------------------------------------------------------------------
       
   614 // CSmlDmAOCommandElement::~CSmlDmAOCommandElement
       
   615 // --------------------------------------------------------------------------
       
   616 CSmlDmAOCommandElement::~CSmlDmAOCommandElement()
       
   617     {
       
   618     delete iLastUriSeg;
       
   619     delete iData;
       
   620     }
       
   621     
       
   622 // --------------------------------------------------------------------------
       
   623 // CSmlDmAOCommandElement::CSmlDmAOCommandElement
       
   624 // --------------------------------------------------------------------------
       
   625 CSmlDmAOCommandElement::CSmlDmAOCommandElement( TBool aLeaf,
       
   626                                                 TInt aStatusRef, 
       
   627                                                 TInt aResultRef, 
       
   628                                                 CNSmlDmAOAdapter::TCommandType  aCmdType )
       
   629                                                 : iStatus( CSmlDmAdapter::EError ),
       
   630                                                 iLeaf( aLeaf ),
       
   631                                                 iStatusRef( aStatusRef ),
       
   632                                                 iResultRef( aResultRef ),
       
   633                                                 iCmdType( aCmdType ),
       
   634                                                 iData( NULL )
       
   635                                                 
       
   636     {
       
   637     }
       
   638 
       
   639 // --------------------------------------------------------------------------
       
   640 // CSmlDmAOCommandElement::ConstructL
       
   641 // --------------------------------------------------------------------------
       
   642 void CSmlDmAOCommandElement::ConstructL( const TDesC8& aLastUriSeg, 
       
   643                                          const TDesC8& aData )
       
   644     {
       
   645     iLastUriSeg = aLastUriSeg.AllocL();    
       
   646     iData = aData.AllocL();
       
   647     }