accessoryservices/remotecontrolfw/server/src/bearermanager.cpp
changeset 0 4e1aa6a622a0
child 23 66ecddbca914
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Bearer manager.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #include <bluetooth/logger.h>
       
    24 #ifdef __FLOG_ACTIVE
       
    25 _LIT8(KLogComponent, LOG_COMPONENT_REMCON_SERVER);
       
    26 #endif
       
    27 
       
    28 #include <remcon/remconbearerplugin.h>
       
    29 #include <remcon/remconbearerinterface.h>
       
    30 #include <remcon/remconbearerbulkinterface.h>
       
    31 #include <remcon/bearerparams.h>
       
    32 #include <remcon/bearersecurity.h>
       
    33 #include <remcon/remconconverterinterface.h>
       
    34 #include "bearermanager.h"
       
    35 #include "utils.h"
       
    36 #include "server.h"
       
    37 #include "session.h"
       
    38 #include "remconmessage.h"
       
    39 #include "connections.h"
       
    40 
       
    41 PANICCATEGORY("bearerman");
       
    42 
       
    43 #ifdef __FLOG_ACTIVE
       
    44 #define LOGBEARERS	LogBearers()
       
    45 #else
       
    46 #define LOGBEARERS
       
    47 #endif
       
    48  
       
    49 static TBool RemConAddrsMatch(const TRemConAddress& aFirstAddr, const TRemConAddress& aSecondAddr)
       
    50 	{
       
    51 	return aFirstAddr == aSecondAddr;
       
    52 	}
       
    53 
       
    54 CBearerManager* CBearerManager::NewL(CRemConServer& aServer)
       
    55 	{
       
    56 	LOG_STATIC_FUNC
       
    57 	CBearerManager* self = new(ELeave) CBearerManager(aServer);
       
    58 	CleanupStack::PushL(self);
       
    59 	self->ConstructL();
       
    60 	CLEANUPSTACK_POP1(self);
       
    61 	return self;
       
    62 	}
       
    63 
       
    64 CBearerManager::~CBearerManager()
       
    65 	{
       
    66 	LOG_FUNC;
       
    67 
       
    68 	// We do not check these are empty before cleaning them up. There are no 
       
    69 	// cancel methods for connect/disconnect in the bearer API.
       
    70 	iCurrentlyBeingConnected.Close();
       
    71 	iCurrentlyBeingDisconnected.Close();
       
    72 	
       
    73 	LOGBEARERS;
       
    74 	// Destroy all bearer instances.
       
    75 	iBearers.ResetAndDestroy();
       
    76 	LOGBEARERS;
       
    77 
       
    78 	iBearerIfs.Close();
       
    79 
       
    80 	// Clean up the security policy collection.
       
    81 	TSglQueIter<TBearerSecurity> iter(iBearerSecurityPolicies);
       
    82 	TBearerSecurity* sec;
       
    83 	while ( ( sec = iter++ ) != NULL )
       
    84 		{
       
    85 		iBearerSecurityPolicies.Remove(*sec);
       
    86 		delete sec;
       
    87 		}
       
    88 	}
       
    89 
       
    90 CBearerManager::CBearerManager(CRemConServer& aServer)
       
    91 :	iBearerSecurityPolicies(_FOFF(TBearerSecurity, iLink)),
       
    92 	iServer(aServer)
       
    93 	{
       
    94 	LOG_FUNC
       
    95 	}
       
    96 
       
    97 void CBearerManager::ConstructL()
       
    98 	{
       
    99 	LOG_FUNC;
       
   100 
       
   101 	// Instantiate all bearers at construction time.
       
   102 	LoadAllBearersL();
       
   103 
       
   104 	LOGBEARERS;
       
   105 	}
       
   106 
       
   107 MRemConBearerInterface* CBearerManager::BearerIf(TUid aBearerUid) const
       
   108 	{
       
   109 	LOG_FUNC;
       
   110 	LOG1(_L("\taBearerUid = 0x%08x"), aBearerUid);
       
   111 
       
   112 	MRemConBearerInterface* bearerIf = NULL;
       
   113 
       
   114 	const TUint numBearerIfs = iBearerIfs.Count();
       
   115 	for ( TUint ii = 0 ; ii < numBearerIfs ; ++ii )
       
   116 		{
       
   117 		if ( iBearerIfs[ii].iBearerUid == aBearerUid )
       
   118 			{
       
   119 			// In the current implementation we only have three bearer interface 
       
   120 			// UIDs. This UID is tied to the version of MRemConBearerInterface.
       
   121 			ASSERT_DEBUG(iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface1) || 
       
   122 						 iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface2) ||
       
   123 						 iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface3));
       
   124 			bearerIf = iBearerIfs[ii].iIf;
       
   125 			break;
       
   126 			}
       
   127 		}
       
   128 
       
   129 	LOG1(_L("\tbearerIf = 0x%08x"), bearerIf);
       
   130 	return bearerIf;
       
   131 	}
       
   132 
       
   133 MRemConBearerInterfaceV2* CBearerManager::BearerIfV2(TUid aBearerUid) const
       
   134 	{
       
   135 	LOG_FUNC;
       
   136 	LOG1(_L("\taBearerUid = 0x%08x"), aBearerUid);
       
   137 	
       
   138 	MRemConBearerInterfaceV2* bearerIfV2 = NULL;
       
   139 	
       
   140 	const TUint numBearerIfs = iBearerIfs.Count();
       
   141 	for ( TUint ii = 0 ; ii < numBearerIfs ; ++ii )
       
   142 		{
       
   143 		if ( iBearerIfs[ii].iBearerUid == aBearerUid )
       
   144 			{
       
   145 			// In the current implementation we only have two bearer interface 
       
   146 			// UIDs. This UID is tied to the version of MRemConBearerInterface.
       
   147 			ASSERT_DEBUG(iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface1) || 
       
   148 						 iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface2) ||
       
   149 						 iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface3));
       
   150 			
       
   151 			if((iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface2)) ||
       
   152 			   (iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface3)))
       
   153 				{
       
   154 				bearerIfV2 = iBearerIfs[ii].iIfV2;
       
   155 				}
       
   156 			
       
   157 			break;
       
   158 			}
       
   159 		}
       
   160 	
       
   161 	LOG1(_L("\tbearerIfV2 = 0x%08x"), bearerIfV2);
       
   162 	return bearerIfV2;
       
   163 	}
       
   164 
       
   165 MRemConBearerInterfaceV3* CBearerManager::BearerIfV3(TUid aBearerUid) const
       
   166 	{
       
   167 	LOG_FUNC;
       
   168 	LOG1(_L("\taBearerUid = 0x%08x"), aBearerUid);
       
   169 	
       
   170 	MRemConBearerInterfaceV3* bearerIfV3 = NULL;
       
   171 	
       
   172 	const TUint numBearerIfs = iBearerIfs.Count();
       
   173 	for ( TUint ii = 0 ; ii < numBearerIfs ; ++ii )
       
   174 		{
       
   175 		if ( iBearerIfs[ii].iBearerUid == aBearerUid )
       
   176 			{
       
   177 			// In the current implementation we only have three bearer interface 
       
   178 			// UIDs. This UID is tied to the version of MRemConBearerInterfaceV3.
       
   179 			ASSERT_DEBUG(iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface1) || 
       
   180 						 iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface2) ||
       
   181 						 iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface3));
       
   182 			
       
   183 			if(iBearerIfs[ii].iIfUid == TUid::Uid(KRemConBearerInterface3))
       
   184 				{
       
   185 				bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   186 				}
       
   187 			
       
   188 			break;
       
   189 			}
       
   190 		}
       
   191 	
       
   192 	LOG1(_L("\tbearerIfV3 = 0x%08x"), bearerIfV3);
       
   193 	return bearerIfV3;
       
   194 	}
       
   195 
       
   196 void CBearerManager::LoadAllBearersL()
       
   197 	{
       
   198 	LOG_FUNC;
       
   199 
       
   200 	// Use ECOM to instantiate each implementation of the bearer plugin 
       
   201 	// interface.
       
   202 	const TUid KUidRemoteControlBearerPluginInterface = TUid::Uid(KRemConBearerInterfaceUid);
       
   203 	RImplInfoPtrArray implementations;
       
   204 	const TEComResolverParams noResolverParams;
       
   205 	REComSession::ListImplementationsL(KUidRemoteControlBearerPluginInterface, 
       
   206 		noResolverParams, 
       
   207 		KRomOnlyResolverUid, 
       
   208 		implementations);
       
   209 	CleanupResetAndDestroyPushL(implementations);
       
   210 	const TUint count = implementations.Count();
       
   211 	LOG1(_L("\tnumber of implementations of bearer plugin interface: %d"), count);
       
   212 	// There should be at least one bearer present. If there are no bearers in 
       
   213 	// the ROM, then there shouldn't be RemCon server present either due to 
       
   214 	// the waste of ROM. This is why the client-side is a separate DLL, so it 
       
   215 	// can be included to satisfy any static linkages, without bringing the 
       
   216 	// unnecessary bulk of the server with it.
       
   217 	ASSERT_ALWAYS(count != 0);
       
   218 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   219 		{
       
   220 		CImplementationInformation* impl = implementations[ii];
       
   221 		ASSERT_DEBUG(impl);
       
   222 		LOG(_L("\tloading bearer with:"));
       
   223 		LOG1(_L("\t\timplementation uid 0x%08x"), impl->ImplementationUid());
       
   224 		LOG1(_L("\t\tversion number %d"), impl->Version());
       
   225 		TBuf8<KMaxName> buf8;
       
   226 		buf8.Copy(impl->DisplayName());
       
   227 		LOG1(_L8("\t\tdisplay name \"%S\""), &buf8);
       
   228 		LOG1(_L("\t\tROM only %d"), impl->RomOnly());
       
   229 		LOG1(_L("\t\tROM based %d"), impl->RomBased());
       
   230 
       
   231 		TBearerParams params(impl->ImplementationUid(), *this);
       
   232 		CRemConBearerPlugin* bearer = CRemConBearerPlugin::NewL(params);
       
   233 		CleanupStack::PushL(bearer);
       
   234 		LEAVEIFERRORL(iBearers.Append(bearer));
       
   235 		CLEANUPSTACK_POP1(bearer);
       
   236 
       
   237 		// Also get information about the interface the bearer presents.
       
   238 		// Look for latest interface first
       
   239 		TInterfaceInfo ifInfo;
       
   240 		ifInfo.iIfUid = TUid::Uid(0);
       
   241 		
       
   242 		// Control interfaces
       
   243 		ifInfo.iIfV3 = reinterpret_cast<MRemConBearerInterfaceV3*>(bearer->GetInterface(TUid::Uid(KRemConBearerInterface3)));
       
   244 		ifInfo.iIfV2 = reinterpret_cast<MRemConBearerInterfaceV2*>(bearer->GetInterface(TUid::Uid(KRemConBearerInterface2)));
       
   245 		ifInfo.iIf = reinterpret_cast<MRemConBearerInterface*>(bearer->GetInterface(TUid::Uid(KRemConBearerInterface1)));
       
   246 		if(ifInfo.iIfV3)
       
   247 			{
       
   248 			ifInfo.iIfUid = TUid::Uid(KRemConBearerInterface3);
       
   249 			}
       
   250 		else if(ifInfo.iIfV2)
       
   251 			{
       
   252 			ifInfo.iIfUid = TUid::Uid(KRemConBearerInterface2);
       
   253 			}
       
   254 		else if(ifInfo.iIf)
       
   255 			{
       
   256 			ifInfo.iIfUid = TUid::Uid(KRemConBearerInterface1);
       
   257 			}
       
   258 
       
   259 		LOG1(_L8("\t\tcontrol interface (V1) = [0x%08x]"), ifInfo.iIf);
       
   260 		LOG1(_L8("\t\tcontrol interface (V2) = [0x%08x]"), ifInfo.iIfV2);
       
   261 		LOG1(_L8("\t\tcontrol interface (V3) = [0x%08x]"), ifInfo.iIfV3);
       
   262 		// If the bearer doesn't support the basic bearer API, panic server 
       
   263 		// startup.
       
   264 		ASSERT_ALWAYS(ifInfo.iIf);
       
   265 
       
   266 		ifInfo.iBearerUid = impl->ImplementationUid();
       
   267 		ifInfo.iControllerCount = 0;
       
   268 		ifInfo.iTargetCount = 0;
       
   269 		LEAVEIFERRORL(iBearerIfs.Append(ifInfo));
       
   270 
       
   271 		TBearerSecurity* sec = new(ELeave) TBearerSecurity(bearer->Uid(), ifInfo.iIf->SecurityPolicy());
       
   272 		iBearerSecurityPolicies.AddLast(*sec);
       
   273 		}
       
   274 
       
   275 	CleanupStack::PopAndDestroy(&implementations);
       
   276 	}
       
   277 
       
   278 #ifdef __FLOG_ACTIVE
       
   279 void CBearerManager::LogBearers() const
       
   280 	{
       
   281 	const TUint count = iBearers.Count();
       
   282 	LOG1(_L("\tNumber of bearers = %d"), count);
       
   283 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   284 		{
       
   285 		const CRemConBearerPlugin* const bearer = iBearers[ii];
       
   286 		ASSERT_DEBUG(bearer);
       
   287 		LOG3(_L("\t\tbearer %d [0x%08x], Uid = 0x%08x"), 
       
   288 			ii, 
       
   289 			bearer,
       
   290 			bearer->Uid()
       
   291 			);
       
   292 		}
       
   293 	}
       
   294 #endif // __FLOG_ACTIVE
       
   295 
       
   296 TInt CBearerManager::Send(CRemConMessage& aMsg)
       
   297 	{
       
   298 	LOG_FUNC;
       
   299 	LOG4(_L("\taMsg.Addr.BearerUid = 0x%08x, aMsg.InterfaceUid = 0x%08x, aMsg.MsgType = %d, aMsg.OperationId = 0x%02x"), 
       
   300 		aMsg.Addr().BearerUid(), aMsg.InterfaceUid(), aMsg.MsgType(), aMsg.OperationId());
       
   301 
       
   302 	MRemConBearerInterface* const bearerIf = BearerIf(aMsg.Addr().BearerUid());
       
   303 	MRemConBearerInterfaceV2* const bearerIfV2 = BearerIfV2(aMsg.Addr().BearerUid());
       
   304 	MRemConBearerInterfaceV3* const bearerIfV3 = BearerIfV3(aMsg.Addr().BearerUid());
       
   305 	// For connection-oriented sends, the session protects against trying to 
       
   306 	// connect to a non-existent bearer. For connectionless sends, the TSP can 
       
   307 	// indicate whatever connections it like, but if it indicates one 
       
   308 	// belonging to a non-existent bearer, that's panicked.
       
   309 	ASSERT_DEBUG(bearerIf); 
       
   310 
       
   311 	TInt ret = KErrNone;
       
   312 
       
   313 	switch ( aMsg.MsgType() )
       
   314 		{
       
   315 	case ERemConNotifyCommand:
       
   316 	    // We originate a transaction identifier as it's a new outgoing 
       
   317 	    // notify message.
       
   318 		aMsg.TransactionId() = MrcboDoNewTransactionId();
       
   319 		ASSERT_DEBUG(bearerIfV3);
       
   320 		ret = bearerIfV3->SendNotifyCommand(aMsg.InterfaceUid(), 
       
   321 			aMsg.OperationId(), 
       
   322 			aMsg.TransactionId(),
       
   323 			aMsg.OperationData(),
       
   324 			aMsg.Addr());
       
   325 		if ( ret == KErrNone )
       
   326 			{
       
   327 			// On success, the bearer takes ownership of the message data.
       
   328 			aMsg.OperationData().Assign(NULL);
       
   329 			}
       
   330 	    break;
       
   331 	case ERemConCommand:
       
   332 		// We originate a transaction identifier as it's a new outgoing 
       
   333 		// message.
       
   334 		aMsg.TransactionId() = MrcboDoNewTransactionId();
       
   335 		ret = bearerIf->SendCommand(aMsg.InterfaceUid(), 
       
   336 			aMsg.OperationId(), 
       
   337 			aMsg.TransactionId(),
       
   338 			aMsg.OperationData(),
       
   339 			aMsg.Addr());
       
   340 		if ( ret == KErrNone )
       
   341 			{
       
   342 			// On success, the bearer takes ownership of the message data.
       
   343 			aMsg.OperationData().Assign(NULL);
       
   344 			}
       
   345 		break;
       
   346 
       
   347 	case ERemConResponse:
       
   348 		ret = bearerIf->SendResponse(aMsg.InterfaceUid(), 
       
   349 			aMsg.OperationId(), 
       
   350 			aMsg.TransactionId(),
       
   351 			aMsg.OperationData(), 
       
   352 			aMsg.Addr());
       
   353 		if ( ret == KErrNone )
       
   354 			{
       
   355 			// On success, the bearer takes ownership of the message data.
       
   356 			aMsg.OperationData().Assign(NULL);
       
   357 			}
       
   358 		break;
       
   359 	case ERemConReject:
       
   360 		{
       
   361 		ASSERT_DEBUG(aMsg.OperationData().Length() == 0);
       
   362 		if (bearerIfV2)
       
   363 			{
       
   364 			bearerIfV2->SendReject(aMsg.InterfaceUid(), 
       
   365 					aMsg.OperationId(), 
       
   366 					aMsg.TransactionId(),
       
   367 					aMsg.Addr());
       
   368 			}
       
   369 		break;
       
   370 		}
       
   371 	default:
       
   372 		DEBUG_PANIC_LINENUM; // the session protects us against this
       
   373 		break;
       
   374 		}
       
   375 
       
   376 	LOG1(_L("\tret = %d"), ret);
       
   377 	return ret;
       
   378 	}
       
   379 
       
   380 
       
   381 TInt CBearerManager::Connect(const TRemConAddress& aAddr)
       
   382 	{
       
   383 	LOG_FUNC;
       
   384 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   385 
       
   386 	TInt ret = KErrNone;
       
   387 	if ( iCurrentlyBeingConnected.Find(aAddr, RemConAddrsMatch) == KErrNotFound )
       
   388 		{
       
   389 		MRemConBearerInterface* const bearerIf = BearerIf(aAddr.BearerUid());
       
   390 		// The caller should have checked that the interface existed before 
       
   391 		// calling this.
       
   392 		ASSERT_DEBUG(bearerIf);
       
   393 		// Make a note of the address. If we can't do this then fail the connect.
       
   394 		ret = iCurrentlyBeingConnected.Append(aAddr);
       
   395 		if ( ret == KErrNone )
       
   396 			{
       
   397 			bearerIf->ConnectRequest(aAddr);
       
   398 			}
       
   399 		}
       
   400 	
       
   401 	LOG1(_L("\tret = %d"), ret);
       
   402 	return ret;
       
   403 	}
       
   404 
       
   405 TInt CBearerManager::Disconnect(const TRemConAddress& aAddr)
       
   406 	{
       
   407 	LOG_FUNC;
       
   408 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   409 
       
   410 	TInt ret = KErrNone;
       
   411 	if ( iCurrentlyBeingDisconnected.Find(aAddr, RemConAddrsMatch) == KErrNotFound )
       
   412 		{
       
   413 		MRemConBearerInterface* const bearerIf = BearerIf(aAddr.BearerUid());
       
   414 		// The caller should have checked that the interface existed before 
       
   415 		// calling this.
       
   416 		ASSERT_DEBUG(bearerIf);
       
   417 		// Make a note of the address. If we can't do this then fail the 
       
   418 		// disconnect.
       
   419 		ret = iCurrentlyBeingDisconnected.Append(aAddr);
       
   420 		if ( ret == KErrNone )
       
   421 			{
       
   422 			bearerIf->DisconnectRequest(aAddr);
       
   423 			}
       
   424 		}
       
   425 
       
   426 	LOG1(_L("\tret = %d"), ret);
       
   427 	return ret;
       
   428 	}
       
   429 
       
   430 TBool CBearerManager::BearerExists(TUid aBearerUid) const
       
   431 	{
       
   432 	LOG_FUNC;
       
   433 	LOG1(_L("\taBearerUid = 0x%08x"), aBearerUid);
       
   434 
       
   435 	TBool ret = EFalse;
       
   436 	if ( BearerIf(aBearerUid) != NULL )
       
   437 		{
       
   438 		ret = ETrue;
       
   439 		}
       
   440 
       
   441 	LOG1(_L("\tret = %d"), ret);
       
   442 	return ret;
       
   443 	}
       
   444 
       
   445 TBool CBearerManager::CheckPolicy(TUid aBearerUid, const RMessage2& aMessage)
       
   446 	{
       
   447 	LOG_FUNC;
       
   448 	LOG1(_L("\taBearerUid = 0x%08x"), aBearerUid);
       
   449 
       
   450 	MRemConBearerInterface* bearerIf = BearerIf(aBearerUid);
       
   451 	// The caller should have checked that the interface existed before 
       
   452 	// calling this.
       
   453 	ASSERT_DEBUG(bearerIf);
       
   454 	TBool ret = bearerIf->SecurityPolicy().CheckPolicy(aMessage);
       
   455 
       
   456 	LOG1(_L("\tret = %d"), ret);
       
   457 	return ret;
       
   458 	}
       
   459 
       
   460 void CBearerManager::ClientTypeSet(TBool aController)
       
   461 	{
       
   462 	LOG_FUNC;
       
   463 	LOG1(_L("\taController = %x"), aController);
       
   464 		
       
   465 	/* When a client (session) has its type set (controller or target) then 
       
   466 	   it will still have a bearer uid of NullUid. In this case we want to 
       
   467 	   update any bearers which now have a controller or target count moving to 1 */
       
   468 	const TUint count = iBearerIfs.Count();
       
   469 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   470 		{
       
   471 		MRemConBearerInterface* const bearerIf = iBearerIfs[ii].iIf;
       
   472 		MRemConBearerInterfaceV3* const bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   473 
       
   474 		ASSERT_DEBUG(bearerIf);
       
   475 		/* maintain the controller and target count for each bearer 
       
   476 		   tell the bearer if the count has increased to 1
       
   477 		   by doing this in this loop we are sure we only 
       
   478 		   tell the bearer when we need to */
       
   479 		if (aController)
       
   480 			{
       
   481 			iBearerIfs[ii].iControllerCount++;
       
   482 			if (1 == iBearerIfs[ii].iControllerCount)
       
   483 				{
       
   484 				bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   485 				}
       
   486 			}
       
   487 		else
       
   488 			{
       
   489 			iBearerIfs[ii].iTargetCount++;
       
   490 			if (1 == iBearerIfs[ii].iTargetCount)
       
   491 				{
       
   492 				bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   493 				}
       
   494 			}
       
   495 		}
       
   496 	}
       
   497 
       
   498 void CBearerManager::TargetClientAvailable(TRemConClientId aId, const TPlayerType& aClientType, const TPlayerSubType& aClientSubType, const TDesC8& aName)
       
   499 	{
       
   500 	LOG_FUNC;
       
   501 		
       
   502 	const TUint count = iBearerIfs.Count();
       
   503 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   504 		{
       
   505 		MRemConBearerInterfaceV3* const bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   506 
       
   507 		if(bearerIfV3)
       
   508 			{
       
   509 			bearerIfV3->ClientAvailable(aId, aClientType, aClientSubType, aName);
       
   510 			}
       
   511 		}
       
   512 	}
       
   513 
       
   514 void CBearerManager::ControllerClientAvailable()
       
   515 	{
       
   516 	LOG_FUNC;
       
   517 	
       
   518 	RArray<TUid> supportedInterfaces;
       
   519 	TInt err = iServer.ControllerSupportedInterfaces(supportedInterfaces);
       
   520 	LOG2(_L("\tGot %d supported interfaces with result %d"), supportedInterfaces.Count(), err);
       
   521 	
       
   522 	if(!err)
       
   523 		{
       
   524 		const TUint count = iBearerIfs.Count();
       
   525 		for ( TUint ii = 0 ; ii < count ; ++ii )
       
   526 			{
       
   527 			MRemConBearerInterfaceV3* const bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   528 
       
   529 			if(bearerIfV3)
       
   530 				{
       
   531 				bearerIfV3->ControllerFeaturesUpdated(supportedInterfaces);
       
   532 				}
       
   533 			}
       
   534 		
       
   535 		supportedInterfaces.Close();
       
   536 		}
       
   537 	}
       
   538 
       
   539 void CBearerManager::ClientConnectionOriented(TUid aUid)
       
   540 	{
       
   541 	LOG_FUNC;
       
   542 
       
   543 	const TUint count = iBearerIfs.Count();
       
   544 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   545 		{
       
   546 		MRemConBearerInterface* const bearerIf = iBearerIfs[ii].iIf;
       
   547 		ASSERT_DEBUG(bearerIf);
       
   548 		/* maintain the controller and target count for each bearer 
       
   549 		   target count won't change for this
       
   550 		   Controller won't change if we are the bearer being targetted by the controller
       
   551 		   it will go down if we're not.
       
   552 		   Tell the bearer if the controller count has decreased to zero
       
   553 		*/
       
   554 		if (aUid != iBearerIfs[ii].iBearerUid)
       
   555 			{
       
   556 			iBearerIfs[ii].iControllerCount--;
       
   557 			if (0 == iBearerIfs[ii].iControllerCount)
       
   558 				{
       
   559 				bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   560 				}
       
   561 			}
       
   562 		}
       
   563 	}
       
   564 
       
   565 void CBearerManager::ClientConnectionless(TUid aUid)
       
   566 	{
       
   567 	LOG_FUNC;
       
   568 	
       
   569 	RArray<TUid> supportedInterfaces;
       
   570 	TInt err = iServer.ControllerSupportedInterfaces(supportedInterfaces);
       
   571 	LOG2(_L("\tGot %d supported interfaces with result %d"), supportedInterfaces.Count(), err);
       
   572 
       
   573 	const TUint count = iBearerIfs.Count();
       
   574 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   575 		{
       
   576 		MRemConBearerInterface* const bearerIf = iBearerIfs[ii].iIf;
       
   577 		MRemConBearerInterfaceV3* const bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   578 		ASSERT_DEBUG(bearerIf);
       
   579 
       
   580 		/* maintain the controller and target count for each bearer 
       
   581 		   target count won't change for this
       
   582 		   Controller won't change if we were the bearer being targetted by the controller
       
   583 		   it will go up if we're not.
       
   584 		   tell the bearer if the controller count has increased to 1 and provide
       
   585 		   it with the current feature list.	   
       
   586 		*/
       
   587 		if (aUid != iBearerIfs[ii].iBearerUid)
       
   588 			{
       
   589 			iBearerIfs[ii].iControllerCount++;
       
   590 			if (1 == iBearerIfs[ii].iControllerCount)
       
   591 				{
       
   592 				bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   593 
       
   594 				if(!err && bearerIfV3)
       
   595 					{
       
   596 					bearerIfV3->ControllerFeaturesUpdated(supportedInterfaces);
       
   597 					}
       
   598 				}
       
   599 			}
       
   600 		}
       
   601 	
       
   602 	supportedInterfaces.Close();
       
   603 	}
       
   604 
       
   605 void CBearerManager::ClientClosed(TBool aController, TUid aUid, TRemConClientId aClientId)
       
   606 	{
       
   607 	LOG_FUNC;
       
   608 	LOG1(_L("\taController = %x"), aController);
       
   609 	
       
   610 	RArray<TUid> supportedInterfaces;
       
   611 	TInt err = KErrNone;
       
   612 	if(aController)
       
   613 		{
       
   614 		err = iServer.ControllerSupportedInterfaces(supportedInterfaces);
       
   615 		LOG2(_L("\tGot %d supported interfaces with result %d"), supportedInterfaces.Count(), err);
       
   616 		}
       
   617 
       
   618 	const TUint count = iBearerIfs.Count();
       
   619 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   620 		{
       
   621 		MRemConBearerInterface* const bearerIf = iBearerIfs[ii].iIf;
       
   622 		MRemConBearerInterfaceV3* const bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   623 		ASSERT_DEBUG(bearerIf);
       
   624 		/* maintain the controller and target count for each bearer 
       
   625 		   the target count may change for this
       
   626 		   Controller won't change if we were the bearer being targetted by the controller
       
   627 		   it will go up if we're not.
       
   628 		   
       
   629 		*/
       
   630 		if (aController)
       
   631 			{
       
   632 			/* so if the aUid is not null then the closed session affects only
       
   633 			   the bearer it was pointing at. If the uid is NULL then its affecting
       
   634 			   all bearers
       
   635 			   tell the bearer if controller or target count has reached zero.
       
   636 			   If there are controllers left then let the bearer know the current
       
   637 			   feature set.
       
   638 			 */
       
   639 			if ((aUid == iBearerIfs[ii].iBearerUid) || (KNullUid == aUid))
       
   640 				{
       
   641 				iBearerIfs[ii].iControllerCount--;
       
   642 				if (0 == iBearerIfs[ii].iControllerCount)
       
   643 					{
       
   644 					bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   645 					}
       
   646 				else if(!err && bearerIfV3)
       
   647 					{
       
   648 					bearerIfV3->ControllerFeaturesUpdated(supportedInterfaces);
       
   649 					}
       
   650 				}
       
   651 			}
       
   652 		else
       
   653 			{
       
   654 			iBearerIfs[ii].iTargetCount--;
       
   655 			if (0 == iBearerIfs[ii].iTargetCount)
       
   656 				{
       
   657 				bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   658 				}
       
   659 			if(bearerIfV3)
       
   660 				{
       
   661 				bearerIfV3->ClientNotAvailable(aClientId);
       
   662 				}
       
   663 			}
       
   664 		}
       
   665 	
       
   666 	supportedInterfaces.Close();
       
   667 	}
       
   668 
       
   669 TInt CBearerManager::MrcboDoNewResponse(const TRemConAddress& aAddr)
       
   670 	{
       
   671 	LOG(KNullDesC8());
       
   672 	LOG_FUNC;
       
   673 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   674 	
       
   675 	TRAPD(err, NewResponseL(aAddr));
       
   676 
       
   677 	LOG1(_L("\terr = %d"), err);
       
   678 	return err;
       
   679 	}
       
   680 TInt CBearerManager::MrcboDoNewNotifyResponse(const TRemConAddress& aAddr)
       
   681 	{
       
   682 	LOG(KNullDesC8());
       
   683 	LOG_FUNC;
       
   684 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   685 	
       
   686 	TRAPD(err, NewNotifyResponseL(aAddr));
       
   687 
       
   688 	LOG1(_L("\terr = %d"), err);
       
   689 	return err;
       
   690 	}
       
   691 
       
   692 void CBearerManager::NewResponseL(const TRemConAddress& aAddr)
       
   693 	{
       
   694 	LOG(KNullDesC8());
       
   695 	LOG_FUNC;
       
   696 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   697 
       
   698 	// Get the calling bearer from aAddr, call GetResponse on it, parse the 
       
   699 	// new message and find the originating command in the 'sent commands' 
       
   700 	// log. Give the new message to the session which sent that command. 
       
   701 	MRemConBearerInterface* bearerIf = BearerIf(aAddr.BearerUid());
       
   702 	ASSERT_DEBUG(bearerIf);
       
   703 	TUid interfaceUid;
       
   704 	TUint transactionId;
       
   705 	TUint operationId;
       
   706 	RBuf8 data;
       
   707 	TRemConAddress addr;
       
   708 	LEAVEIFERRORL(bearerIf->GetResponse(interfaceUid,
       
   709 		transactionId,
       
   710 		operationId, 
       
   711 		data, 
       
   712 		addr));
       
   713 	LOG4(_L("\treceived response with interfaceUid [0x%08x], operationId 0x%02x, transactionId %d, data.Length = %d"), 
       
   714 		interfaceUid, operationId, transactionId, data.Length());
       
   715 	// We now own what's pointed to by 'data'.
       
   716 	CleanupClosePushL(data);
       
   717 
       
   718 	CRemConMessage* msg = CRemConMessage::NewL(
       
   719 		aAddr,
       
   720 		KNullClientId,
       
   721 		ERemConResponse,
       
   722 		ERemConMessageDefault,
       
   723 		interfaceUid,
       
   724 		operationId,
       
   725 		data,
       
   726 		0, // session ID as yet unknown
       
   727 		transactionId);
       
   728 	CLEANUPSTACK_POP1(&data); // owned by msg
       
   729 	// Give the new response to the server to find the corresponding outgoing 
       
   730 	// command we sent, then use that to route the new response to a client 
       
   731 	// session.
       
   732 	iServer.NewResponse(*msg); // ownership of msg is always taken by NewResponse
       
   733 	}
       
   734 
       
   735 void CBearerManager::NewNotifyResponseL(const TRemConAddress& aAddr)
       
   736 	{
       
   737 	LOG(KNullDesC8());
       
   738 	LOG_FUNC;
       
   739 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   740 
       
   741 	// Get the calling bearer from aAddr, call GetResponse on it, parse the 
       
   742 	// new message and find the originating command in the 'sent commands' 
       
   743 	// log. Give the new message to the session which sent that command. 
       
   744 	MRemConBearerInterfaceV3* bearerIfV3 = BearerIfV3(aAddr.BearerUid());
       
   745 	ASSERT_DEBUG(bearerIfV3);
       
   746 	TUid interfaceUid;
       
   747 	TUint transactionId;
       
   748 	TUint operationId;
       
   749 	RBuf8 data;
       
   750 	TRemConAddress addr;
       
   751 	TRemConMessageSubType subMessageType;
       
   752 	LEAVEIFERRORL(bearerIfV3->GetNotifyResponse(interfaceUid,
       
   753 		transactionId,
       
   754 		operationId, 
       
   755 		data, 
       
   756 		addr,
       
   757 		subMessageType));
       
   758 	LOG4(_L("\treceived response with interfaceUid [0x%08x], operationId 0x%02x, transactionId %d, data.Length = %d"), 
       
   759 		interfaceUid, operationId, transactionId, data.Length());
       
   760 	// We now own what's pointed to by 'data'.
       
   761 	CleanupClosePushL(data);
       
   762 
       
   763 	CRemConMessage* msg = CRemConMessage::NewL(
       
   764 		aAddr,
       
   765 		KNullClientId,
       
   766 		ERemConResponse,
       
   767 		subMessageType,
       
   768 		interfaceUid,
       
   769 		operationId,
       
   770 		data,
       
   771 		0, // session ID as yet unknown
       
   772 		transactionId);
       
   773 	CLEANUPSTACK_POP1(&data); // owned by msg
       
   774 	// Give the new response to the server to find the corresponding outgoing 
       
   775 	// command we sent, then use that to route the new response to a client 
       
   776 	// session.
       
   777 	iServer.NewNotifyResponse(*msg); // ownership of msg is always taken by NewResponse
       
   778 	}
       
   779 
       
   780 TInt CBearerManager::MrcboDoNewCommand(const TRemConAddress& aAddr)
       
   781 	{
       
   782 	LOG(KNullDesC8());
       
   783 	LOG_FUNC;
       
   784 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   785 
       
   786 	TRAPD(err, NewCommandL(aAddr, KNullClientId));
       
   787 
       
   788 	LOG1(_L("\terr = %d"), err);
       
   789 	return err;
       
   790 	}
       
   791 
       
   792 TInt CBearerManager::MrcboDoNewCommand(const TRemConAddress& aAddr, const TRemConClientId& aClient)
       
   793 	{
       
   794 	LOG(KNullDesC8());
       
   795 	LOG_FUNC;
       
   796 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   797 
       
   798 	TRAPD(err, NewCommandL(aAddr, aClient));
       
   799 
       
   800 	LOG1(_L("\terr = %d"), err);
       
   801 	return err;
       
   802 	}
       
   803 
       
   804 void CBearerManager::NewCommandL(const TRemConAddress& aAddr, const TRemConClientId& aClient)
       
   805 	{
       
   806 	LOG_FUNC;
       
   807 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   808 
       
   809 	// Get the calling bearer from aAddr and get the new command from it.
       
   810 	MRemConBearerInterface* const bearerIf = BearerIf(aAddr.BearerUid());
       
   811 	ASSERT_DEBUG(bearerIf);
       
   812 	TUid interfaceUid;
       
   813 	TUint transactionId;
       
   814 	TUint operationId;
       
   815 	RBuf8 data;
       
   816 	TRemConAddress addr;
       
   817 	LEAVEIFERRORL(bearerIf->GetCommand(interfaceUid,
       
   818 		transactionId, 
       
   819 		operationId, 
       
   820 		data, 
       
   821 		addr));
       
   822 	LOG3(_L("\treceived command with interfaceUid [0x%08x], operationId 0x%02x, data.Length = %d"), 
       
   823 		interfaceUid, operationId, data.Length());
       
   824 	// We now own what's pointed to by 'data'.
       
   825 	CleanupClosePushL(data);
       
   826 
       
   827 	CRemConMessage* msg = CRemConMessage::NewL(
       
   828 		aAddr,
       
   829 		aClient,
       
   830 		ERemConCommand,
       
   831 		ERemConMessageDefault,
       
   832 		interfaceUid,
       
   833 		operationId,
       
   834 		data,
       
   835 		0, // session ID as yet unknown
       
   836 		transactionId);
       
   837 	// 'msg' now has a pointer to the memory pointed to by 'data', and owns 
       
   838 	// it.
       
   839 	CLEANUPSTACK_POP1(&data);
       
   840 	// Give the new command to the server, which takes ownership of it. 
       
   841 	iServer.NewCommand(*msg);
       
   842 	}
       
   843 
       
   844 TInt CBearerManager::MrcboDoNewNotifyCommand(const TRemConAddress& aAddr)
       
   845 	{
       
   846 	LOG(KNullDesC8());
       
   847 	LOG_FUNC;
       
   848 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   849 
       
   850 	TRAPD(err, NewNotifyCommandL(aAddr, KNullClientId));
       
   851 
       
   852 	LOG1(_L("\terr = %d"), err);
       
   853 	return err;
       
   854 	}
       
   855 
       
   856 TInt CBearerManager::MrcboDoNewNotifyCommand(const TRemConAddress& aAddr, const TRemConClientId& aClient)
       
   857 	{
       
   858 	LOG(KNullDesC8());
       
   859 	LOG_FUNC;
       
   860 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   861 
       
   862 	TRAPD(err, NewNotifyCommandL(aAddr, aClient));
       
   863 
       
   864 	LOG1(_L("\terr = %d"), err);
       
   865 	return err;	}
       
   866 
       
   867 void CBearerManager::NewNotifyCommandL(const TRemConAddress& aAddr, const TRemConClientId& aClient)
       
   868 	{
       
   869 	LOG_FUNC;
       
   870 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   871 
       
   872 	// Get the calling bearer from aAddr and get the new command from it.
       
   873 	MRemConBearerInterfaceV2* const bearerIfV2 = BearerIfV2(aAddr.BearerUid());
       
   874 	
       
   875 	// We only get here because the bearer has told us it's got a notify.  In
       
   876 	// order to use notifies it must use the V2 bearer interface.
       
   877 	ASSERT_DEBUG(bearerIfV2); 
       
   878 	
       
   879 	TUid interfaceUid;
       
   880 	TUint transactionId;
       
   881 	TUint operationId;
       
   882 	RBuf8 data;
       
   883 	TRemConAddress addr;
       
   884 	LEAVEIFERRORL(bearerIfV2->GetNotifyCommand(interfaceUid,
       
   885 		transactionId, 
       
   886 		operationId, 
       
   887 		data, 
       
   888 		addr));
       
   889 	LOG3(_L("\treceived command with interfaceUid [0x%08x], operationId 0x%02x, data.Length = %d"), 
       
   890 		interfaceUid, operationId, data.Length());
       
   891 	// We now own what's pointed to by 'data'.
       
   892 	CleanupClosePushL(data);
       
   893 
       
   894 	CRemConMessage* msg = CRemConMessage::NewL(
       
   895 		aAddr,
       
   896 		aClient,
       
   897 		ERemConNotifyCommand,
       
   898 		ERemConNotifyCommandAwaitingInterim,
       
   899 		interfaceUid,
       
   900 		operationId,
       
   901 		data,
       
   902 		0, // session ID as yet unknown
       
   903 		transactionId);
       
   904 	// 'msg' now has a pointer to the memory pointed to by 'data', and owns 
       
   905 	// it.
       
   906 	CLEANUPSTACK_POP1(&data);
       
   907 	// Give the new command to the server, which takes ownership of it. 
       
   908 	iServer.NewNotifyCommand(*msg);
       
   909 	}
       
   910 
       
   911 TInt CBearerManager::MrcboDoConnectIndicate(const TRemConAddress& aAddr)
       
   912 	{
       
   913 	LOG(KNullDesC8());
       
   914 	LOG_FUNC;
       
   915 
       
   916 	// Just call the handler for new connections.
       
   917 	TInt ret = iServer.HandleConnection(aAddr, KErrNone);
       
   918 	LOG1(_L("\tret = %d"), ret);
       
   919 
       
   920 	return ret;
       
   921 	}
       
   922 
       
   923 void CBearerManager::MrcboDoDisconnectIndicate(const TRemConAddress& aAddr)
       
   924 	{
       
   925 	LOG(KNullDesC8());
       
   926 	LOG_FUNC;
       
   927 	
       
   928 	// Just call the handler for removed connections.
       
   929 	iServer.RemoveConnection(aAddr);
       
   930 	}
       
   931 
       
   932 TInt CBearerManager::MrcboDoConnectConfirm(const TRemConAddress& aAddr, TInt aError)
       
   933 	{
       
   934 	LOG(KNullDesC8());
       
   935 	LOG_FUNC;
       
   936 	LOG2(_L("\taError = %d, aAddr.BearerUid = 0x%08x"), aError, aAddr.BearerUid());
       
   937 
       
   938 	TInt index = iCurrentlyBeingConnected.Find(aAddr, RemConAddrsMatch);
       
   939 	ASSERT_DEBUG(index != KErrNotFound);
       
   940 	iCurrentlyBeingConnected.Remove(index);
       
   941 
       
   942 	TInt ret = iServer.HandleConnection(aAddr, aError);
       
   943 
       
   944 	LOG1(_L("\tret = %d"), ret);
       
   945 	return ret;
       
   946 	}
       
   947 
       
   948 void CBearerManager::MrcboDoDisconnectConfirm(const TRemConAddress& aAddr, TInt aError)
       
   949 	{
       
   950 	LOG(KNullDesC8());
       
   951 	LOG_FUNC;
       
   952 	LOG2(_L("\taError = %d, aAddr.BearerUid = 0x%08x"), aError, aAddr.BearerUid());
       
   953 
       
   954 	TInt index = iCurrentlyBeingDisconnected.Find(aAddr, RemConAddrsMatch);
       
   955 	ASSERT_DEBUG(index != KErrNotFound);
       
   956 	iCurrentlyBeingDisconnected.Remove(index);
       
   957 
       
   958 	if ( aError == KErrNone )
       
   959 		{
       
   960 		// Remove connection and complete notifications.
       
   961 		iServer.RemoveConnection(aAddr);
       
   962 		}
       
   963 
       
   964 	// Complete the specific request(s) that caused a DisconnectRequest on the 
       
   965 	// bearer. Tell all sessions- they remember the address they wanted to 
       
   966 	// connect to, and will filter on the address we give them.
       
   967 	const TUint count = iServer.Sessions().Count();
       
   968 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   969 		{
       
   970 		ASSERT_DEBUG(iServer.Sessions()[ii]);
       
   971 		iServer.Sessions()[ii]->CompleteDisconnect(aAddr, aError);
       
   972 		}
       
   973 	}
       
   974 
       
   975 TUint CBearerManager::MrcboDoNewTransactionId()
       
   976 	{
       
   977 	TUint newId = iRunningTransactionId;
       
   978 
       
   979 	if ( iRunningTransactionId == KMaxTUint )
       
   980 		{
       
   981 		iRunningTransactionId = 0;
       
   982 		}
       
   983 	else
       
   984 		{
       
   985 		++iRunningTransactionId;
       
   986 		}
       
   987 	
       
   988 	LOG1(_L("CBearerManager::MrcboDoNewTransactionId newId = %d"), newId);
       
   989 	return newId;
       
   990 	}
       
   991 
       
   992 TInt CBearerManager::MrcboDoInterfaceToBearer(TUid aBearerUid,
       
   993 		TUid aInterfaceUid, 
       
   994 		TUint aOperationId,
       
   995 		const TDesC8& aData,
       
   996 		TRemConMessageType aMsgType, 
       
   997 		TDes8& aBearerData) const
       
   998 	{
       
   999 	LOG(KNullDesC8());
       
  1000 	LOG_FUNC;
       
  1001 	LOG4(_L("\taBearerUid = 0x%08x, aInterfaceUid = 0x%08x, aOperationId = 0x%02x, aMsgType = %d"), 
       
  1002 		aBearerUid, aInterfaceUid, aOperationId, aMsgType);
       
  1003 
       
  1004 	MRemConConverterInterface* conv = iServer.Converter(aInterfaceUid, aBearerUid);
       
  1005 	TInt ret = KErrNotSupported;
       
  1006 	if ( conv )
       
  1007 		{
       
  1008 		ret = conv->InterfaceToBearer(aInterfaceUid, aOperationId, aData, aMsgType, aBearerData);
       
  1009 		}
       
  1010 
       
  1011 	LOG1(_L("\tret = %d"), ret);
       
  1012 	return ret;
       
  1013 	}
       
  1014 
       
  1015 TInt CBearerManager::MrcboDoBearerToInterface(TUid aBearerUid,
       
  1016 		const TDesC8& aInterfaceData, 
       
  1017 		const TDesC8& aBearerData,
       
  1018 		TUid& aInterfaceUid, 
       
  1019 		TUint& aOperationId,
       
  1020 		TRemConMessageType& aMsgType, 
       
  1021 		TDes8& aData) const
       
  1022 	{
       
  1023 	LOG(KNullDesC8());
       
  1024 	LOG_FUNC;
       
  1025 	LOG1(_L("\taBearerUid = 0x%08x"), aBearerUid);
       
  1026 
       
  1027 	MRemConConverterInterface* conv = iServer.Converter(aInterfaceData, aBearerUid);
       
  1028 	TInt ret = KErrNotSupported;
       
  1029 	if ( conv )
       
  1030 		{
       
  1031 		ret = conv->BearerToInterface(aBearerData, aInterfaceUid, aOperationId, aMsgType, aData);
       
  1032 		}
       
  1033 
       
  1034 	LOG1(_L("\tret = %d"), ret);
       
  1035 	return ret;
       
  1036 	}
       
  1037 
       
  1038 void CBearerManager::MrcboDoSetRemoteAddressedClient(const TUid& aBearerUid, const TRemConClientId& aId)
       
  1039 	{
       
  1040 	LOG_FUNC
       
  1041 	LOG2(_L("\taBearerUid = 0x%08x, aId = %d"), aBearerUid, aId);
       
  1042 	
       
  1043 	iServer.SetRemoteAddressedClient(aBearerUid, aId);
       
  1044 	}
       
  1045 
       
  1046 void CBearerManager::MrcboDoCommandExpired(TUint aTransactionId)
       
  1047 	{
       
  1048 	iServer.CommandExpired(aTransactionId);
       
  1049 	}
       
  1050 
       
  1051 TSglQue<TBearerSecurity>& CBearerManager::BearerSecurityPolicies()
       
  1052 	{
       
  1053 	return iBearerSecurityPolicies;
       
  1054 	}
       
  1055 
       
  1056 TBool CBearerManager::IsConnecting(const TRemConAddress& aAddr) const
       
  1057 	{
       
  1058 	LOG_FUNC;
       
  1059 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
  1060 	
       
  1061 	TInt index = iCurrentlyBeingConnected.Find(aAddr, RemConAddrsMatch);
       
  1062 	TInt ret = ( index != KErrNotFound ) ? ETrue : EFalse;
       
  1063 	
       
  1064 	LOG1(_L("\tret = %d"), ret);
       
  1065 	return ret;
       
  1066 	}
       
  1067 
       
  1068 TBool CBearerManager::IsDisconnecting(const TRemConAddress& aAddr) const
       
  1069 	{
       
  1070 	LOG_FUNC;
       
  1071 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
  1072 	
       
  1073 	TInt index = iCurrentlyBeingDisconnected.Find(aAddr, RemConAddrsMatch);
       
  1074 	TInt ret = ( index != KErrNotFound ) ? ETrue : EFalse;
       
  1075 	
       
  1076 	LOG1(_L("\tret = %d"), ret);
       
  1077 	return ret;
       
  1078 	}
       
  1079 
       
  1080 void CBearerManager::BulkInterfacesL(RArray<TBulkInterfaceInfo>& aBulkInterfaces) const
       
  1081 	{
       
  1082 	LOG_FUNC
       
  1083 	ASSERT_DEBUG(aBulkInterfaces.Count() == 0);
       
  1084 	CleanupResetPushL(aBulkInterfaces);
       
  1085 	MRemConBearerBulkInterface* bulkIf = NULL;
       
  1086 	for(TInt i=0; i<iBearers.Count(); i++)
       
  1087 		{
       
  1088 		ASSERT_DEBUG(iBearers[i]);
       
  1089 		bulkIf = reinterpret_cast<MRemConBearerBulkInterface*>(iBearers[i]->GetInterface(TUid::Uid(KRemConBearerBulkInterface1)));
       
  1090 		if(bulkIf)
       
  1091 			{
       
  1092 			TBulkInterfaceInfo ifInfo;
       
  1093 			ifInfo.iIf = bulkIf;
       
  1094 			ifInfo.iIfUid = TUid::Uid(KRemConBearerBulkInterface1);
       
  1095 			ifInfo.iBearerUid = iBearers[i]->Uid();
       
  1096 			aBulkInterfaces.AppendL(ifInfo);
       
  1097 			}
       
  1098 		}
       
  1099 	CleanupStack::Pop(&aBulkInterfaces);
       
  1100 	}
       
  1101 
       
  1102 TInt CBearerManager::MrcboDoSupportedInterfaces(const TRemConClientId& aId, RArray<TUid>& aUids)
       
  1103 	{
       
  1104 	LOG_FUNC
       
  1105 	return iServer.SupportedInterfaces(aId, aUids);
       
  1106 	}
       
  1107 
       
  1108 TInt CBearerManager::MrcboDoSupportedOperations(const TRemConClientId& aId, TUid aInterfaceUid, RArray<TUint>& aOperations)
       
  1109 	{
       
  1110 	LOG_FUNC
       
  1111 	return iServer.SupportedOperations(aId, aInterfaceUid, aOperations);
       
  1112 	}
       
  1113 
       
  1114 TInt CBearerManager::SetLocalAddressedClient(const TUid& aBearerUid, TRemConClientId aClientId)
       
  1115 	{
       
  1116 	LOG_FUNC;
       
  1117 	
       
  1118 	MRemConBearerInterfaceV3* const bearerIfV3 = BearerIfV3(aBearerUid);
       
  1119 	if(bearerIfV3)
       
  1120 		{
       
  1121 		return bearerIfV3->SetLocalAddressedClient(aClientId);
       
  1122 		}
       
  1123 	else
       
  1124 		{
       
  1125 		return KErrNotFound;
       
  1126 		}
       
  1127 	}
       
  1128 
       
  1129