syncmlfw/dm/treedbclient/src/nsmldmtreedbclient.cpp
changeset 0 b497e44ab2fc
child 13 86979fe66c4c
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  source file for dm tree db client
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // ---------------------------------------------------------------------------
       
    20 // Includes
       
    21 // ---------------------------------------------------------------------------
       
    22 #include <eikdll.h>
       
    23 #include <apgcli.h>
       
    24 #include <s32mem.h>
       
    25 
       
    26 #include <nsmldmtreedbclient.h>
       
    27 #include <nsmldmuri.h> //tarm
       
    28 #include <SettingEnforcementInfo.h>
       
    29 #include <nsmldebug.h>
       
    30 #include "nsmldmcallbackserver.h"
       
    31 #include "nsmldmcallbackserverdefs.h"
       
    32 #include "nsmldmtreedtd.h" //tarm
       
    33 
       
    34 //tarm start
       
    35 _LIT8( KNSmlDmDefaultACLForDataWithoutServer, "Add=*&Get=*&Replace=*&Delete=*&Exec=*");
       
    36 //tarm end
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // LaunchServerL()
       
    40 // Launches the server.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 TInt LaunchServerL()
       
    44 	{	
       
    45 	TInt result = KErrNone;
       
    46 	
       
    47 	RFs fs;
       
    48 	User::LeaveIfError( fs.Connect() );
       
    49     CleanupClosePushL( fs );
       
    50 	TFindFile findFile( fs );
       
    51 		
       
    52 	RProcess server;
       
    53 	
       
    54 	User::LeaveIfError( server.Create( KNSmlDMCallbackExeName, KNullDesC ) );
       
    55 	
       
    56 	CleanupStack::PopAndDestroy(); // fs
       
    57 	
       
    58 	TRequestStatus status;
       
    59 	server.Rendezvous( status );
       
    60 
       
    61 	if ( status != KRequestPending )
       
    62 		{
       
    63 		server.Kill( 0 );	// abort startup
       
    64 		server.Close();
       
    65 		return KErrGeneral;	// status can be KErrNone: don't return status.Int()
       
    66 		}
       
    67 	else
       
    68 		{
       
    69 		server.Resume();	// logon OK - start the server
       
    70 		}
       
    71 		
       
    72 	User::WaitForRequest( status );
       
    73 	
       
    74 	result = status.Int();
       
    75 	
       
    76 	if ( status == KErrNone )
       
    77 		{
       
    78 		server.Close();
       
    79 		}
       
    80 
       
    81 	return result;
       
    82 	}
       
    83 	
       
    84 // ---------------------------------------------------------------------------
       
    85 // RNSmlDMCallbackSession::RNSmlDMCallbackSession()
       
    86 // ---------------------------------------------------------------------------
       
    87 EXPORT_C RNSmlDMCallbackSession::RNSmlDMCallbackSession()
       
    88 	{
       
    89 	iEnforceCheckdone = 0;
       
    90 	}
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // RNSmlDMCallbackSession::~RNSmlDMCallbackSession()
       
    94 // ---------------------------------------------------------------------------
       
    95 EXPORT_C RNSmlDMCallbackSession::~RNSmlDMCallbackSession()
       
    96 	{
       
    97 	iLuids.ResetAndDestroy();
       
    98 	iLuids.Close();
       
    99 	}
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // TInt RNSmlDMCallbackSession::Connect()
       
   103 // Connect to the  server
       
   104 // ---------------------------------------------------------------------------
       
   105 EXPORT_C TInt RNSmlDMCallbackSession::Connect()
       
   106 	{
       
   107 	TInt result(KErrNone);
       
   108 	
       
   109 	TVersion ver ( KNSmlDmCallbackServerVersionMajor,
       
   110 		KNSmlDmCallbackServerVersionMinor, 0  );
       
   111 		
       
   112 	result = CreateSession( KNSmlDmCallbackServerName, ver );
       
   113 	if(result!=KErrNone)
       
   114 		{
       
   115 		TRAPD(error, result = LaunchServerL());
       
   116 		if ( (error == KErrNone) && ( result == KErrNone ) )
       
   117 			{
       
   118 			result = CreateSession( KNSmlDmCallbackServerName, ver );
       
   119 			}
       
   120 		}
       
   121 	return result;
       
   122 	}
       
   123 	
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // TVersion RNSmlDMCallbackSession::Version()
       
   127 // ---------------------------------------------------------------------------
       
   128 TVersion RNSmlDMCallbackSession::Version(void) const
       
   129 	{
       
   130 	return(TVersion(KNSmlDmCallbackServerVersionMajor,
       
   131 		KNSmlDmCallbackServerVersionMinor,0));
       
   132 	}
       
   133 
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // void RNSmlDMCallbackSession::Close()
       
   137 // ---------------------------------------------------------------------------
       
   138 EXPORT_C void RNSmlDMCallbackSession::Close()
       
   139 	{
       
   140 	SendReceive(ECmdDMCallbackCloseSession,TIpcArgs());
       
   141 	RHandleBase::Close();
       
   142 	}
       
   143 
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 // TInt RNSmlDMCallbackSession::ResourceCount()
       
   147 // ---------------------------------------------------------------------------
       
   148 EXPORT_C TInt RNSmlDMCallbackSession::ResourceCount()
       
   149 	{
       
   150 	//previously not initialised
       
   151 	TInt count=0;
       
   152 	TPckgBuf<TInt> pckg(count);
       
   153 	SendReceive(ECmdDMCallbackResourceCount,TIpcArgs(&pckg));
       
   154 	return pckg();
       
   155 	}
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // void RNSmlDMCallbackSession::SetServerL()
       
   159 // ---------------------------------------------------------------------------
       
   160 EXPORT_C void RNSmlDMCallbackSession::SetServerL(const TDesC8& aServer)
       
   161 	{
       
   162 	HBufC8* serverId = aServer.AllocLC();
       
   163 	TPtr8 serverPtr = serverId->Des();
       
   164 	TIpcArgs args(0,&serverPtr);
       
   165 	
       
   166 	User::LeaveIfError(SendReceive(ECmdDMCallbackSetServer,args));
       
   167 	CleanupStack::PopAndDestroy(); //serverId
       
   168 	}
       
   169 
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // HBufC8* RNSmlDMCallbackSession::GetLuidAllocL()
       
   173 // ---------------------------------------------------------------------------
       
   174 EXPORT_C HBufC8* RNSmlDMCallbackSession::GetLuidAllocL(
       
   175 	TUint32 aAdapterId,const TDesC8& aURI)
       
   176 	{
       
   177 	HBufC8* uri = aURI.AllocLC();
       
   178 	TPtr8 uriPtr = uri->Des();
       
   179 	TPckgBuf<TUint32> len;
       
   180 	HBufC8* data=NULL;
       
   181 	TIpcArgs args(aAdapterId,&uriPtr,0,&len);
       
   182 	
       
   183 	if(SendReceive(ECmdDMCallbackGetLuidLength,args)==KErrNone)
       
   184 		{
       
   185 		if(len())
       
   186 			{
       
   187 			data = HBufC8::NewLC(len());		
       
   188 			TPtr8 dataPtr = data->Des();
       
   189 			TIpcArgs args2(0,0,0,&dataPtr);
       
   190 			
       
   191 			SendReceive(ECmdDMCallbackGetLuid,args2);
       
   192 			CleanupStack::Pop(); //data
       
   193 			}
       
   194 		else
       
   195 			{
       
   196 			data=KNullDesC8().AllocL();
       
   197 			}
       
   198 		}
       
   199 	else
       
   200 		{
       
   201 		data = KNullDesC8().AllocL();
       
   202 		}
       
   203 	CleanupStack::PopAndDestroy(); //uri
       
   204 	
       
   205 	return data;
       
   206 	}
       
   207 
       
   208 
       
   209 // ---------------------------------------------------------------------------
       
   210 // void RNSmlDMCallbackSession::GetUriSegListL()
       
   211 // ---------------------------------------------------------------------------
       
   212 EXPORT_C void RNSmlDMCallbackSession::GetUriSegListL(TUint32 aAdapterId,
       
   213 	const TDesC8& aURI, CArrayFixFlat<TSmlDmMappingInfo>& aURISegList)
       
   214 	{
       
   215 	iLuids.ResetAndDestroy();
       
   216 	HBufC8* uri = aURI.AllocLC();
       
   217 	TPtr8 uriPtr = uri->Des();
       
   218 	TPckgBuf<TUint32> len;
       
   219 	HBufC8* data=NULL;
       
   220 	TIpcArgs args(aAdapterId,&uriPtr,0,&len);
       
   221 	
       
   222 	if(SendReceive(ECmdDMCallbackGetSegmentListLength,args)==KErrNone)
       
   223 		{
       
   224 		if(len())
       
   225 			{
       
   226 			data = HBufC8::NewLC(len());
       
   227 			TPtr8 dataPtr = data->Des();
       
   228 			TIpcArgs args2(0,0,0,&dataPtr);
       
   229 			
       
   230 			SendReceive(ECmdDMCallbackGetSegmentList,args2);
       
   231 			RDesReadStream readStream(dataPtr);
       
   232 			CleanupClosePushL(readStream);
       
   233 
       
   234 			TUint16 count = readStream.ReadUint16L();
       
   235 			TUint8 length8;
       
   236 			
       
   237 			for(TInt i=0;i<count;i++)
       
   238 				{
       
   239 				length8 = readStream.ReadUint8L();
       
   240 				HBufC8 *uriSeg =HBufC8::NewLC(length8);
       
   241 				TPtr8 uriSegPtr = uriSeg->Des();
       
   242 				readStream.ReadL(uriSegPtr,length8);
       
   243 
       
   244 				length8 = readStream.ReadUint8L();
       
   245 				HBufC8 *luid =HBufC8::NewLC(length8);
       
   246 				TPtr8 luidPtr = luid->Des();
       
   247 				readStream.ReadL(luidPtr,length8);
       
   248 				iLuids.AppendL(luid);
       
   249 				CleanupStack::Pop(); //luid
       
   250 
       
   251 				TSmlDmMappingInfo mapInfo;
       
   252 				mapInfo.iURISeg = TBufC8<KSmlMaxURISegLen>(uriSegPtr);
       
   253 				mapInfo.iURISegLUID.Set(*luid);
       
   254 				aURISegList.AppendL(mapInfo);
       
   255 				CleanupStack::PopAndDestroy(); //uriSeg
       
   256 				}
       
   257 			CleanupStack::PopAndDestroy(2); //readStream,data
       
   258 			}
       
   259 		}
       
   260 	CleanupStack::PopAndDestroy(); //uri
       
   261 	}
       
   262 
       
   263 // ---------------------------------------------------------------------------
       
   264 // TInt RNSmlDMCallbackSession::AddMappingInfoL()
       
   265 // ---------------------------------------------------------------------------
       
   266 EXPORT_C TInt RNSmlDMCallbackSession::AddMappingInfoL(
       
   267 	TUint32 aAdapterId, const TDesC8& aURI, const TDesC8& aLuid )
       
   268 	{
       
   269 
       
   270 	HBufC8* uri = aURI.AllocLC();
       
   271 	TPtr8 uriPtr = uri->Des();
       
   272 	HBufC8* luid = aLuid.AllocLC();
       
   273 	TPtr8 luidPtr = luid->Des();
       
   274 
       
   275 	TIpcArgs args(aAdapterId,&uriPtr,&luidPtr);
       
   276 	
       
   277 	TInt ret = SendReceive(ECmdDMCallbackAddMappingInfo,args);
       
   278 	CleanupStack::PopAndDestroy(2); //uri, luid
       
   279     User::LeaveIfError(ret);
       
   280 	return ret;
       
   281 	}
       
   282 	
       
   283 // ---------------------------------------------------------------------------
       
   284 // TInt RNSmlDMCallbackSession::RemoveMappingInfoL()
       
   285 // ---------------------------------------------------------------------------
       
   286 EXPORT_C TInt RNSmlDMCallbackSession::RemoveMappingInfoL(
       
   287 	TUint32 aAdapterId, const TDesC8& aURI, TBool aChildAlso)
       
   288 	{
       
   289 	HBufC8* uri = aURI.AllocLC();
       
   290 	TPtr8 uriPtr = uri->Des();
       
   291 
       
   292 	TIpcArgs args(aAdapterId,&uriPtr,aChildAlso);
       
   293 	
       
   294 	TInt ret = SendReceive(ECmdDMCallbackRemoveMappingInfo,args);
       
   295 	CleanupStack::PopAndDestroy(); //uri
       
   296     User::LeaveIfError(ret);
       
   297 	return ret;
       
   298 	}
       
   299 
       
   300 // ---------------------------------------------------------------------------
       
   301 // TInt RNSmlDMCallbackSession::RenameMappingL()
       
   302 // ---------------------------------------------------------------------------
       
   303 EXPORT_C TInt RNSmlDMCallbackSession::RenameMappingL(
       
   304 	TUint32 aAdapterId, const TDesC8& aURI, const TDesC8& aObject )
       
   305 	{
       
   306 	HBufC8* uri = aURI.AllocLC();
       
   307 	TPtr8 uriPtr = uri->Des();
       
   308 	HBufC8* newName = aObject.AllocLC();
       
   309 	TPtr8 newNamePtr = newName->Des();
       
   310 
       
   311 	TIpcArgs args(aAdapterId,&uriPtr,&newNamePtr);
       
   312 	
       
   313 	TInt ret = SendReceive(ECmdDMCallbackRenameMapping,args);
       
   314 	CleanupStack::PopAndDestroy(2); //uri,newName
       
   315     User::LeaveIfError(ret);
       
   316 	return ret;
       
   317 	}
       
   318 	
       
   319 
       
   320 // ---------------------------------------------------------------------------
       
   321 // TInt RNSmlDMCallbackSession::UpdateMappingInfoL()
       
   322 // ---------------------------------------------------------------------------
       
   323 EXPORT_C void RNSmlDMCallbackSession::UpdateMappingInfoL(
       
   324 	TUint32 aAdapterId, const TDesC8& aURI, CBufBase& aCurrentList)
       
   325 	{
       
   326 	HBufC8* uri = aURI.AllocLC();
       
   327 	TPtr8 uriPtr = uri->Des();
       
   328 	TPtr8 currentListPtr = aCurrentList.Ptr(0);
       
   329 
       
   330 	TIpcArgs args(aAdapterId,&uriPtr,&currentListPtr);
       
   331 	
       
   332 	TInt ret = SendReceive(ECmdDMCallbackUpdateMapping,args);
       
   333     User::LeaveIfError(ret);
       
   334 	CleanupStack::PopAndDestroy(); //uri
       
   335 	}
       
   336 	
       
   337 	
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // TInt RNSmlDMCallbackSession::DeleteAclL()
       
   341 // ---------------------------------------------------------------------------
       
   342 EXPORT_C TInt RNSmlDMCallbackSession::DeleteAclL(const TDesC8& aURI)
       
   343 	{
       
   344 	HBufC8* uri = aURI.AllocLC();
       
   345 	TPtr8 uriPtr = uri->Des();
       
   346 
       
   347 	TIpcArgs args(0,&uriPtr);
       
   348 	
       
   349 	TInt ret = SendReceive(ECmdDMCallbackDeleteAcl,args);
       
   350 	CleanupStack::PopAndDestroy(); //uri
       
   351     User::LeaveIfError(ret);
       
   352 	return ret;
       
   353 	}
       
   354 	
       
   355 
       
   356 // ---------------------------------------------------------------------------
       
   357 // TInt RNSmlDMCallbackSession::UpdateAclL()
       
   358 // ---------------------------------------------------------------------------
       
   359 EXPORT_C TInt RNSmlDMCallbackSession::UpdateAclL(
       
   360 	const TDesC8& aURI,const TDesC8& aACL)
       
   361 	{
       
   362 	HBufC8* uri = aURI.AllocLC();
       
   363 	TPtr8 uriPtr = uri->Des();
       
   364 	HBufC8* acl = aACL.AllocLC();
       
   365 	TPtr8 aclPtr = acl->Des();
       
   366 
       
   367 	TIpcArgs args(0,&uriPtr,&aclPtr);
       
   368 	
       
   369 	TInt ret = SendReceive(ECmdDMCallbackUpdateAcl,args);
       
   370 	CleanupStack::PopAndDestroy(2); //uri,acl
       
   371     User::LeaveIfError(ret);
       
   372 	return ret;
       
   373 	}
       
   374 	
       
   375 
       
   376 // ---------------------------------------------------------------------------
       
   377 // TInt RNSmlDMCallbackSession::GetAclL()
       
   378 // ---------------------------------------------------------------------------
       
   379 EXPORT_C TInt RNSmlDMCallbackSession::GetAclL(const TDesC8& aURI,
       
   380 	CBufBase& aACL,TBool /*aInherited*/)
       
   381     {    
       
   382     //If enforced pass parent uri to server and get that ACL    
       
   383     TInt enforced=KErrNotFound;    
       
   384     //connect to policy engine
       
   385     CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
       
   386     CleanupStack::PushL(info);        
       
   387     info->EnforcementActiveL(aURI, enforced);
       
   388     DBG_FILE_CODE(enforced,_S8("GetAclL tarm enforcement is"));    
       
   389     CleanupStack::PopAndDestroy(info);
       
   390 
       
   391     //In enforced case this method will be visited by trusted server only
       
   392     if( EEnforcedServer == enforced )
       
   393         {
       
   394         TPtrC8 parent;
       
   395         TInt foundpos = aURI.Locate('/');
       
   396         if(foundpos > 0)
       
   397             {
       
   398             parent.Set(aURI.Left(foundpos));
       
   399             }
       
   400         else
       
   401             {
       
   402             parent.Set(aURI);
       
   403             }
       
   404         HBufC8* uri = parent.AllocLC();
       
   405         TPtr8 uriPtr = uri->Des();
       
   406         TPckgBuf<TUint32> len;
       
   407         TIpcArgs args(0,&uriPtr,0,&len);
       
   408         TInt ret(KErrNotFound);
       
   409         if(SendReceive(ECmdDMCallbackGetAclLength,args)==KErrNone)
       
   410             {
       
   411             HBufC8* acl = HBufC8::NewLC(len());
       
   412             TPtr8 aclPtr = acl->Des();
       
   413             TIpcArgs args2(0,&uriPtr,0,&aclPtr);
       
   414             ret = SendReceive(ECmdDMCallbackGetAcl,args2);
       
   415             aACL.InsertL(0,aclPtr);
       
   416             CleanupStack::PopAndDestroy(); //acl
       
   417             }
       
   418         CleanupStack::PopAndDestroy(); //uri
       
   419         return ret;	
       
   420         }
       
   421     else
       
   422         {
       
   423         HBufC8* uri = aURI.AllocLC();
       
   424         TPtr8 uriPtr = uri->Des();
       
   425         TPckgBuf<TUint32> len;
       
   426         TIpcArgs args(0,&uriPtr,0,&len);
       
   427         TInt ret(KErrNotFound);
       
   428         if(SendReceive(ECmdDMCallbackGetAclLength,args)==KErrNone)
       
   429             {
       
   430             HBufC8* acl = HBufC8::NewLC(len());
       
   431             TPtr8 aclPtr = acl->Des();
       
   432             TIpcArgs args2(0,&uriPtr,0,&aclPtr);
       
   433             ret = SendReceive(ECmdDMCallbackGetAcl,args2);
       
   434             aACL.InsertL(0,aclPtr);
       
   435             CleanupStack::PopAndDestroy(); //acl
       
   436             }
       
   437         CleanupStack::PopAndDestroy(); //uri
       
   438         return ret;
       
   439         }
       
   440     }
       
   441 
       
   442 	
       
   443 // ---------------------------------------------------------------------------
       
   444 // TBool RNSmlDMCallbackSession::CheckAclL()
       
   445 // ---------------------------------------------------------------------------
       
   446 EXPORT_C TBool RNSmlDMCallbackSession::CheckAclL(
       
   447 	const TDesC8& aURI, TNSmlDmCmdType aCmdType)
       
   448 	{
       
   449 	HBufC8* uri = aURI.AllocLC();
       
   450 	TPtr8 uriPtr = uri->Des();
       
   451 	TPckgBuf<TBool> retVal;
       
   452 	TBool ret(EFalse);
       
   453 
       
   454 
       
   455 	TIpcArgs args(0,&uriPtr,TInt(aCmdType),&retVal);
       
   456 	
       
   457 	if(SendReceive(ECmdDMCallbackCheckAcl,args)==KErrNone)
       
   458 		{
       
   459 		ret = retVal();
       
   460 		}
       
   461 	CleanupStack::PopAndDestroy(); //uri
       
   462 	return ret;
       
   463 	}
       
   464 
       
   465 //tarm start
       
   466 // ----------------------------------------------------------------------------
       
   467 // RNSmlDMCallbackSession::CheckDynamicAclL( const TDesC& aURI, TNSmlDmCmdType aCmdType)
       
   468 // Does the ACL checking
       
   469 // ----------------------------------------------------------------------------
       
   470 EXPORT_C TBool RNSmlDMCallbackSession::CheckDynamicAclL(
       
   471         const TDesC8& aURI,
       
   472         TNSmlDmCmdType aCmdType,
       
   473         CNSmlDmMgmtTree *aMgmtTree
       
   474         )
       
   475     {
       
   476     //Check aURI enforced
       
   477     if(iEnforceCheckdone == 0)
       
   478         {
       
   479         TInt enforced=KErrNotFound;        
       
   480         //connect to policy engine
       
   481         CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
       
   482         CleanupStack::PushL(info);        
       
   483         info->EnforcementActiveL(aURI, enforced);
       
   484         DBG_FILE_CODE(enforced,_S8("CheckDynamicAclL tarm enforcement is"));        
       
   485         CleanupStack::PopAndDestroy(info);
       
   486         if(EEnforcedServer == enforced)
       
   487             {
       
   488             return ETrue;
       
   489             }
       
   490         else if(ENonEnforcedServer == enforced)
       
   491             {
       
   492             return EFalse;
       
   493             }
       
   494         else 
       
   495             {
       
   496             //behave as no enforcement case
       
   497             }
       
   498         }
       
   499     CBufFlat *acl = CBufFlat::NewL( 128 );
       
   500     CleanupStack::PushL( acl );
       
   501     //
       
   502     // NOTE: In here we make assumption that if acl is not defined,
       
   503     // function will return empty acl and NOT derived one.
       
   504     GetAclL( aURI, *acl, EFalse );
       
   505 
       
   506     TBool emptyACL = (acl->Size() == 0);
       
   507     CleanupStack::PopAndDestroy( acl );
       
   508 
       
   509     //
       
   510     // If we don't have ACL defined for this URI, check if default is needed
       
   511     //
       
   512     if( emptyACL )
       
   513         {
       
   514         //
       
   515         // Conditions:
       
   516         // 1. We have either dynamic node or static leaf
       
   517         // 2. All the parent nodes are static (non-dynamic)
       
   518         // 3. All the parent nodes except root node must not have ACL (?)
       
   519         //
       
   520         TBool uriExists = ETrue;
       
   521         TBool checkParents = EFalse;
       
   522         TBool nonStaticParents = EFalse;
       
   523         TBool parentHasACL = EFalse;
       
   524         CNSmlDmNodeList* nodelist = NULL;
       
   525 
       
   526         TNSmlDmDDFFormat format =
       
   527             aMgmtTree->FindNameFromNodeListL(aURI,nodelist);
       
   528 
       
   529         if( ENSmlDmDDFNotFound == format )
       
   530             {
       
   531             uriExists = EFalse;
       
   532             }
       
   533         else if( NULL == nodelist )
       
   534             {
       
   535             uriExists = EFalse;
       
   536             }
       
   537         else if( NULL == nodelist->iNode )
       
   538             {
       
   539             uriExists = EFalse;            
       
   540             }
       
   541 
       
   542         if( uriExists )
       
   543             {
       
   544 
       
   545             CNSmlDmNode *node = nodelist->iNode;
       
   546 
       
   547             //
       
   548             // Check that parents are static
       
   549             //
       
   550             if( ENSmlDmDDFLeaf == format )
       
   551                 {
       
   552                 checkParents = ETrue;
       
   553                 }
       
   554 
       
   555             if( (ENSmlDmDDFNode == format) &&
       
   556                 (node->iDFProperties.iScope == MSmlDmDDFObject::EDynamic)
       
   557                 )
       
   558                 {
       
   559                 checkParents = ETrue;
       
   560                 }
       
   561 
       
   562             if( checkParents )
       
   563                 {
       
   564                 CNSmlDmNode *parentNode = node;
       
   565                 TInt ascend = 0; // Keeps track of levels we check
       
   566                 TInt highestDynamic = 0;
       
   567                 while( parentNode->iParent )
       
   568                     {
       
   569                     parentNode = parentNode->iParent;
       
   570                     ascend ++;
       
   571 
       
   572                     if( parentNode->iDFProperties.iScope == MSmlDmDDFObject::EDynamic )
       
   573                         {
       
   574                         highestDynamic = ascend;
       
   575                         nonStaticParents = ETrue;
       
   576                         // break if you use ascend in this scope
       
   577                         // instead of highestDynamic
       
   578                         //break;
       
   579                         }
       
   580                     }
       
   581 
       
   582                 if( nonStaticParents && ascend )
       
   583                     {
       
   584                     //
       
   585                     // Continue checking... finally check the dynamic node nearest to root
       
   586                     // If it has no acl, set it.
       
   587                     // ACL will then be inherited to the URI in question.
       
   588                     //
       
   589                     TPtrC8 upperURI = aURI;
       
   590                     while( highestDynamic )
       
   591                         {
       
   592                         upperURI.Set( NSmlDmURI::RemoveLastSeg( upperURI ) );
       
   593                         highestDynamic --;
       
   594                         }
       
   595 
       
   596                     // NOTE: If following recursive call will result in ACL change,
       
   597                     // it will affect the return value of the current call also.
       
   598                     // NOTE: To prevent infinite loop, do not allow same URI to be used again.
       
   599                     if( upperURI.Compare(aURI) != 0 )
       
   600                         {
       
   601                         iEnforceCheckdone++;
       
   602                         CheckDynamicAclL( upperURI, aCmdType, aMgmtTree );
       
   603                         }
       
   604                     }
       
   605                 else
       
   606                     {
       
   607                     //
       
   608                     // Check that parents have no ACL
       
   609                     //
       
   610                     TPtrC8 parentURI = NSmlDmURI::RemoveLastSeg( aURI );
       
   611                     CBufFlat *aclParent = CBufFlat::NewL( 128 );
       
   612                     CleanupStack::PushL( aclParent );
       
   613                     while( parentURI.Length() && (parentURI.Compare( _L8(".") ) != 0) )
       
   614                         {
       
   615                         // NOTE: In here we make assumption that if acl is not defined,
       
   616                         // function will return empty acl and NOT derived one.
       
   617                         GetAclL( parentURI, *aclParent, EFalse );
       
   618 
       
   619                         if( aclParent->Size() != 0 )
       
   620                             {
       
   621                             parentHasACL = ETrue;
       
   622                             break;                    
       
   623                             }
       
   624 
       
   625                         parentURI.Set( NSmlDmURI::RemoveLastSeg( parentURI ) );
       
   626                         }
       
   627                     CleanupStack::PopAndDestroy( aclParent );
       
   628 
       
   629                     if( !parentHasACL )
       
   630                         {
       
   631                         //
       
   632                         // Set ACL
       
   633                         //
       
   634                         UpdateAclL( aURI, KNSmlDmDefaultACLForDataWithoutServer() );
       
   635                         }
       
   636                     }
       
   637                 }
       
   638             }
       
   639         }
       
   640 
       
   641     // NOTE: This must be only function to use aCbSession.CheckAclL
       
   642     // If dynamically adjusted ACLs are supported
       
   643     //
       
   644     if(iEnforceCheckdone > 0)
       
   645         iEnforceCheckdone--;
       
   646     return CheckAclL( aURI, aCmdType );
       
   647     }
       
   648 //tarm end
       
   649 
       
   650 // ---------------------------------------------------------------------------
       
   651 // TInt RNSmlDMCallbackSession::DefaultACLsToServerL()
       
   652 // ---------------------------------------------------------------------------
       
   653 EXPORT_C TInt RNSmlDMCallbackSession::DefaultACLsToServerL(
       
   654 	const TDesC8& aURI)
       
   655 	{
       
   656 	HBufC8* uri = aURI.AllocLC();
       
   657 	TPtr8 uriPtr = uri->Des();
       
   658 	TIpcArgs args(0,&uriPtr);
       
   659 	
       
   660 	TInt ret = SendReceive(ECmdDMCallbackDefaultAclsToServer,args);
       
   661 	CleanupStack::PopAndDestroy(); //uri
       
   662 	return ret;
       
   663 	}
       
   664 
       
   665 // ---------------------------------------------------------------------------
       
   666 // TInt RNSmlDMCallbackSession::DefaultACLsToChildrenL()
       
   667 // ---------------------------------------------------------------------------
       
   668 EXPORT_C TInt RNSmlDMCallbackSession::DefaultACLsToChildrenL(
       
   669 	const TDesC8& aURI,CBufBase& aChildList)
       
   670 	{
       
   671 	HBufC8* uri = aURI.AllocLC();
       
   672 	TPtr8 uriPtr = uri->Des();
       
   673 	TPtr8 childListPtr = aChildList.Ptr(0);
       
   674 
       
   675 	TIpcArgs args(0,&uriPtr,&childListPtr);
       
   676 	
       
   677 	TInt ret = SendReceive(ECmdDMCallbackDefaultAclsToChildren,args);
       
   678 	CleanupStack::PopAndDestroy(); //uri
       
   679     User::LeaveIfError(ret);
       
   680 	return ret;
       
   681 	}
       
   682 
       
   683 // ---------------------------------------------------------------------------
       
   684 // TInt RNSmlDMCallbackSession::EraseServerIdL()
       
   685 // ---------------------------------------------------------------------------
       
   686 EXPORT_C TInt RNSmlDMCallbackSession::EraseServerIdL(const TDesC8& aServerId)
       
   687 	{
       
   688 	HBufC8* serverId = aServerId.AllocLC();
       
   689 	TPtr8 serverPtr = serverId->Des();
       
   690 	TIpcArgs args(0,&serverPtr);
       
   691 	
       
   692 	TInt ret = SendReceive(ECmdDMCallbackEraseServerId,args);
       
   693 	CleanupStack::PopAndDestroy(); //serverId
       
   694     User::LeaveIfError(ret);
       
   695 	return ret;
       
   696 	}
       
   697 
       
   698 // ---------------------------------------------------------------------------
       
   699 // TInt RNSmlDMCallbackSession::StartAtomic()
       
   700 // ---------------------------------------------------------------------------
       
   701 EXPORT_C TInt RNSmlDMCallbackSession::StartAtomic()
       
   702 	{
       
   703 	TIpcArgs args;
       
   704 	
       
   705 	TInt ret = SendReceive(ECmdDMCallbackStartAtomic,args);
       
   706 	return ret;
       
   707 	}
       
   708 
       
   709 // ---------------------------------------------------------------------------
       
   710 // TInt RNSmlDMCallbackSession::CommitAtomic()
       
   711 // ---------------------------------------------------------------------------
       
   712 EXPORT_C TInt RNSmlDMCallbackSession::CommitAtomic()
       
   713 	{
       
   714 	TIpcArgs args;
       
   715 	
       
   716 	TInt ret = SendReceive(ECmdDMCallbackCommitAtomic,args);
       
   717 	return ret;
       
   718 	}
       
   719 
       
   720 // ---------------------------------------------------------------------------
       
   721 // TInt RNSmlDMCallbackSession::RollbackAtomic()
       
   722 // ---------------------------------------------------------------------------
       
   723 EXPORT_C TInt RNSmlDMCallbackSession::RollbackAtomic()
       
   724 	{
       
   725 	TIpcArgs args;
       
   726 	
       
   727 	TInt ret = SendReceive(ECmdDMCallbackRollbackAtomic,args);
       
   728 	return ret;
       
   729 	}