remotecontrol/remotecontrolfw/server/src/bearermanager.cpp
changeset 51 20ac952a623c
equal deleted inserted replaced
48:22de2e391156 51:20ac952a623c
       
     1 // Copyright (c) 2004-2010 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::TargetClientAvailable(TRemConClientId aId, const TPlayerType& aClientType, const TPlayerSubType& aClientSubType, const TDesC8& aName)
       
   461 	{
       
   462 	LOG_FUNC;
       
   463 		
       
   464 	const TUint count = iBearerIfs.Count();
       
   465 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   466 		{
       
   467 		// maintain the controller and target count for each bearer 
       
   468 		// tell the bearer if the count has increased to 1
       
   469 		// by doing this in this loop we are sure we only 
       
   470 		// tell the bearer when we need to */
       
   471 		MRemConBearerInterface* const bearerIf = iBearerIfs[ii].iIf;
       
   472 		ASSERT_DEBUG(bearerIf);
       
   473 		iBearerIfs[ii].iTargetCount++;
       
   474 		if (1 == iBearerIfs[ii].iTargetCount)
       
   475 			{
       
   476 			bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   477 			}
       
   478 		
       
   479 		MRemConBearerInterfaceV3* const bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   480 		if(bearerIfV3)
       
   481 			{
       
   482 			bearerIfV3->ClientAvailable(aId, aClientType, aClientSubType, aName);
       
   483 			}
       
   484 		}
       
   485 	}
       
   486 
       
   487 void CBearerManager::TargetFeaturesUpdated(TRemConClientId aId, const TPlayerType& aPlayerType, const TPlayerSubType& aPlayerSubType, const TDesC8& aName)
       
   488     {
       
   489     LOG_FUNC;
       
   490         
       
   491     const TUint count = iBearerIfs.Count();
       
   492     for ( TUint ii = 0 ; ii < count ; ++ii )
       
   493         {
       
   494         MRemConBearerInterfaceV3* const bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   495 
       
   496         if(bearerIfV3)
       
   497             {
       
   498             bearerIfV3->TargetFeaturesUpdated(aId, aPlayerType, aPlayerSubType, aName);
       
   499             }
       
   500         }
       
   501     }
       
   502 
       
   503 void CBearerManager::ControllerClientAvailable()
       
   504 	{
       
   505 	LOG_FUNC;
       
   506 	
       
   507 	RArray<TUid> supportedInterfaces;
       
   508 	TInt err = iServer.ControllerSupportedInterfaces(supportedInterfaces);
       
   509 	LOG2(_L("\tGot %d supported interfaces with result %d"), supportedInterfaces.Count(), err);
       
   510 	
       
   511 	const TUint count = iBearerIfs.Count();
       
   512 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   513 		{
       
   514 		// maintain the controller and target count for each bearer 
       
   515 		// tell the bearer if the count has increased to 1
       
   516 		// by doing this in this loop we are sure we only 
       
   517 		// tell the bearer when we need to
       
   518 		MRemConBearerInterface* const bearerIf = iBearerIfs[ii].iIf;
       
   519 		ASSERT_DEBUG(bearerIf);
       
   520 		iBearerIfs[ii].iControllerCount++;
       
   521 		if (1 == iBearerIfs[ii].iControllerCount)
       
   522 			{
       
   523 			bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   524 			}
       
   525 
       
   526 		if(!err)
       
   527 			{
       
   528 			// If we know what the supported interface are we can tell the bearer
       
   529 			MRemConBearerInterfaceV3* const bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   530 
       
   531 			if(bearerIfV3)
       
   532 				{
       
   533 				bearerIfV3->ControllerFeaturesUpdated(supportedInterfaces);
       
   534 				}
       
   535 			}
       
   536 		}
       
   537 	
       
   538 	supportedInterfaces.Close();
       
   539 	}
       
   540 
       
   541 void CBearerManager::ClientConnectionOriented(TUid aUid)
       
   542 	{
       
   543 	LOG_FUNC;
       
   544 
       
   545 	const TUint count = iBearerIfs.Count();
       
   546 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   547 		{
       
   548 		MRemConBearerInterface* const bearerIf = iBearerIfs[ii].iIf;
       
   549 		ASSERT_DEBUG(bearerIf);
       
   550 		// maintain the controller and target count for each bearer 
       
   551 		// target count won't change for this
       
   552 		// Controller won't change if we are the bearer being targetted by the controller
       
   553 		// it will go down if we're not.
       
   554 		// Tell the bearer if the controller count has decreased to zero
       
   555 		if (aUid != iBearerIfs[ii].iBearerUid)
       
   556 			{
       
   557 			iBearerIfs[ii].iControllerCount--;
       
   558 			if (0 == iBearerIfs[ii].iControllerCount)
       
   559 				{
       
   560 				bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   561 				}
       
   562 			}
       
   563 		}
       
   564 	}
       
   565 
       
   566 void CBearerManager::ClientConnectionless(TUid aUid)
       
   567 	{
       
   568 	LOG_FUNC;
       
   569 	
       
   570 	RArray<TUid> supportedInterfaces;
       
   571 	TInt err = iServer.ControllerSupportedInterfaces(supportedInterfaces);
       
   572 	LOG2(_L("\tGot %d supported interfaces with result %d"), supportedInterfaces.Count(), err);
       
   573 
       
   574 	const TUint count = iBearerIfs.Count();
       
   575 	for ( TUint ii = 0 ; ii < count ; ++ii )
       
   576 		{
       
   577 		MRemConBearerInterface* const bearerIf = iBearerIfs[ii].iIf;
       
   578 		MRemConBearerInterfaceV3* const bearerIfV3 = iBearerIfs[ii].iIfV3;
       
   579 		ASSERT_DEBUG(bearerIf);
       
   580 
       
   581 		// maintain the controller and target count for each bearer 
       
   582 		// target count won't change for this
       
   583 		// Controller won't change if we were the bearer being targetted by the controller
       
   584 		// it will go up if we're not.
       
   585 		// tell the bearer if the controller count has increased to 1 and provide
       
   586 		// it with the current feature list.	   
       
   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 		if (aController)
       
   629 			{
       
   630 			// so if the aUid is not null then the closed session affects only
       
   631 			// the bearer it was pointing at. If the uid is NULL then its affecting
       
   632 			// all bearers
       
   633 			// tell the bearer if controller or target count has reached zero.
       
   634 			// If there are controllers left then let the bearer know the current
       
   635 			// feature set.
       
   636 			if ((aUid == iBearerIfs[ii].iBearerUid) || (KNullUid == aUid))
       
   637 				{
       
   638 				iBearerIfs[ii].iControllerCount--;
       
   639 				if (0 == iBearerIfs[ii].iControllerCount)
       
   640 					{
       
   641 					bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   642 					}
       
   643 				else if(!err && bearerIfV3)
       
   644 					{
       
   645 					bearerIfV3->ControllerFeaturesUpdated(supportedInterfaces);
       
   646 					}
       
   647 				}
       
   648 			}
       
   649 		else
       
   650 			{
       
   651 			iBearerIfs[ii].iTargetCount--;
       
   652 			if (0 == iBearerIfs[ii].iTargetCount)
       
   653 				{
       
   654 				bearerIf->ClientStatus(TBool(iBearerIfs[ii].iControllerCount), TBool(iBearerIfs[ii].iTargetCount));
       
   655 				}
       
   656 			if(bearerIfV3)
       
   657 				{
       
   658 				bearerIfV3->ClientNotAvailable(aClientId);
       
   659 				}
       
   660 			}
       
   661 		}
       
   662 	
       
   663 	supportedInterfaces.Close();
       
   664 	}
       
   665 
       
   666 TInt CBearerManager::MrcboDoNewResponse(const TRemConAddress& aAddr)
       
   667 	{
       
   668 	LOG(KNullDesC8());
       
   669 	LOG_FUNC;
       
   670 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   671 	
       
   672 	TRAPD(err, NewResponseL(aAddr));
       
   673 
       
   674 	LOG1(_L("\terr = %d"), err);
       
   675 	return err;
       
   676 	}
       
   677 TInt CBearerManager::MrcboDoNewNotifyResponse(const TRemConAddress& aAddr)
       
   678 	{
       
   679 	LOG(KNullDesC8());
       
   680 	LOG_FUNC;
       
   681 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   682 	
       
   683 	TRAPD(err, NewNotifyResponseL(aAddr));
       
   684 
       
   685 	LOG1(_L("\terr = %d"), err);
       
   686 	return err;
       
   687 	}
       
   688 
       
   689 void CBearerManager::NewResponseL(const TRemConAddress& aAddr)
       
   690 	{
       
   691 	LOG(KNullDesC8());
       
   692 	LOG_FUNC;
       
   693 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   694 
       
   695 	// Get the calling bearer from aAddr, call GetResponse on it, parse the 
       
   696 	// new message and find the originating command in the 'sent commands' 
       
   697 	// log. Give the new message to the session which sent that command. 
       
   698 	MRemConBearerInterface* bearerIf = BearerIf(aAddr.BearerUid());
       
   699 	ASSERT_DEBUG(bearerIf);
       
   700 	TUid interfaceUid;
       
   701 	TUint transactionId;
       
   702 	TUint operationId;
       
   703 	RBuf8 data;
       
   704 	TRemConAddress addr;
       
   705 	LEAVEIFERRORL(bearerIf->GetResponse(interfaceUid,
       
   706 		transactionId,
       
   707 		operationId, 
       
   708 		data, 
       
   709 		addr));
       
   710 	LOG4(_L("\treceived response with interfaceUid [0x%08x], operationId 0x%02x, transactionId %d, data.Length = %d"), 
       
   711 		interfaceUid, operationId, transactionId, data.Length());
       
   712 	// We now own what's pointed to by 'data'.
       
   713 	CleanupClosePushL(data);
       
   714 
       
   715 	CRemConMessage* msg = CRemConMessage::NewL(
       
   716 		aAddr,
       
   717 		KNullClientId,
       
   718 		ERemConResponse,
       
   719 		ERemConMessageDefault,
       
   720 		interfaceUid,
       
   721 		operationId,
       
   722 		data,
       
   723 		0, // session ID as yet unknown
       
   724 		transactionId);
       
   725 	CLEANUPSTACK_POP1(&data); // owned by msg
       
   726 	// Give the new response to the server to find the corresponding outgoing 
       
   727 	// command we sent, then use that to route the new response to a client 
       
   728 	// session.
       
   729 	iServer.NewResponse(*msg); // ownership of msg is always taken by NewResponse
       
   730 	}
       
   731 
       
   732 void CBearerManager::NewNotifyResponseL(const TRemConAddress& aAddr)
       
   733 	{
       
   734 	LOG(KNullDesC8());
       
   735 	LOG_FUNC;
       
   736 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   737 
       
   738 	// Get the calling bearer from aAddr, call GetResponse on it, parse the 
       
   739 	// new message and find the originating command in the 'sent commands' 
       
   740 	// log. Give the new message to the session which sent that command. 
       
   741 	MRemConBearerInterfaceV3* bearerIfV3 = BearerIfV3(aAddr.BearerUid());
       
   742 	ASSERT_DEBUG(bearerIfV3);
       
   743 	TUid interfaceUid;
       
   744 	TUint transactionId;
       
   745 	TUint operationId;
       
   746 	RBuf8 data;
       
   747 	TRemConAddress addr;
       
   748 	TRemConMessageSubType subMessageType;
       
   749 	LEAVEIFERRORL(bearerIfV3->GetNotifyResponse(interfaceUid,
       
   750 		transactionId,
       
   751 		operationId, 
       
   752 		data, 
       
   753 		addr,
       
   754 		subMessageType));
       
   755 	LOG4(_L("\treceived response with interfaceUid [0x%08x], operationId 0x%02x, transactionId %d, data.Length = %d"), 
       
   756 		interfaceUid, operationId, transactionId, data.Length());
       
   757 	// We now own what's pointed to by 'data'.
       
   758 	CleanupClosePushL(data);
       
   759 
       
   760 	CRemConMessage* msg = CRemConMessage::NewL(
       
   761 		aAddr,
       
   762 		KNullClientId,
       
   763 		ERemConResponse,
       
   764 		subMessageType,
       
   765 		interfaceUid,
       
   766 		operationId,
       
   767 		data,
       
   768 		0, // session ID as yet unknown
       
   769 		transactionId);
       
   770 	CLEANUPSTACK_POP1(&data); // owned by msg
       
   771 	// Give the new response to the server to find the corresponding outgoing 
       
   772 	// command we sent, then use that to route the new response to a client 
       
   773 	// session.
       
   774 	iServer.NewNotifyResponse(*msg); // ownership of msg is always taken by NewResponse
       
   775 	}
       
   776 
       
   777 TInt CBearerManager::MrcboDoNewCommand(const TRemConAddress& aAddr)
       
   778 	{
       
   779 	LOG(KNullDesC8());
       
   780 	LOG_FUNC;
       
   781 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   782 
       
   783 	TRAPD(err, NewCommandL(aAddr, KNullClientId));
       
   784 
       
   785 	LOG1(_L("\terr = %d"), err);
       
   786 	return err;
       
   787 	}
       
   788 
       
   789 TInt CBearerManager::MrcboDoNewCommand(const TRemConAddress& aAddr, const TRemConClientId& aClient)
       
   790 	{
       
   791 	LOG(KNullDesC8());
       
   792 	LOG_FUNC;
       
   793 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   794 
       
   795 	TRAPD(err, NewCommandL(aAddr, aClient));
       
   796 
       
   797 	LOG1(_L("\terr = %d"), err);
       
   798 	return err;
       
   799 	}
       
   800 
       
   801 void CBearerManager::NewCommandL(const TRemConAddress& aAddr, const TRemConClientId& aClient)
       
   802 	{
       
   803 	LOG_FUNC;
       
   804 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   805 
       
   806 	// Get the calling bearer from aAddr and get the new command from it.
       
   807 	MRemConBearerInterface* const bearerIf = BearerIf(aAddr.BearerUid());
       
   808 	ASSERT_DEBUG(bearerIf);
       
   809 	TUid interfaceUid;
       
   810 	TUint transactionId;
       
   811 	TUint operationId;
       
   812 	RBuf8 data;
       
   813 	TRemConAddress addr;
       
   814 	LEAVEIFERRORL(bearerIf->GetCommand(interfaceUid,
       
   815 		transactionId, 
       
   816 		operationId, 
       
   817 		data, 
       
   818 		addr));
       
   819 	LOG3(_L("\treceived command with interfaceUid [0x%08x], operationId 0x%02x, data.Length = %d"), 
       
   820 		interfaceUid, operationId, data.Length());
       
   821 	// We now own what's pointed to by 'data'.
       
   822 	CleanupClosePushL(data);
       
   823 
       
   824 	CRemConMessage* msg = CRemConMessage::NewL(
       
   825 		aAddr,
       
   826 		aClient,
       
   827 		ERemConCommand,
       
   828 		ERemConMessageDefault,
       
   829 		interfaceUid,
       
   830 		operationId,
       
   831 		data,
       
   832 		0, // session ID as yet unknown
       
   833 		transactionId);
       
   834 	// 'msg' now has a pointer to the memory pointed to by 'data', and owns 
       
   835 	// it.
       
   836 	CLEANUPSTACK_POP1(&data);
       
   837 	// Give the new command to the server, which takes ownership of it. 
       
   838 	iServer.NewCommand(*msg);
       
   839 	}
       
   840 
       
   841 TInt CBearerManager::MrcboDoNewNotifyCommand(const TRemConAddress& aAddr)
       
   842 	{
       
   843 	LOG(KNullDesC8());
       
   844 	LOG_FUNC;
       
   845 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   846 
       
   847 	TRAPD(err, NewNotifyCommandL(aAddr, KNullClientId));
       
   848 
       
   849 	LOG1(_L("\terr = %d"), err);
       
   850 	return err;
       
   851 	}
       
   852 
       
   853 TInt CBearerManager::MrcboDoNewNotifyCommand(const TRemConAddress& aAddr, const TRemConClientId& aClient)
       
   854 	{
       
   855 	LOG(KNullDesC8());
       
   856 	LOG_FUNC;
       
   857 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   858 
       
   859 	TRAPD(err, NewNotifyCommandL(aAddr, aClient));
       
   860 
       
   861 	LOG1(_L("\terr = %d"), err);
       
   862 	return err;	}
       
   863 
       
   864 void CBearerManager::NewNotifyCommandL(const TRemConAddress& aAddr, const TRemConClientId& aClient)
       
   865 	{
       
   866 	LOG_FUNC;
       
   867 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
   868 
       
   869 	// Get the calling bearer from aAddr and get the new command from it.
       
   870 	MRemConBearerInterfaceV2* const bearerIfV2 = BearerIfV2(aAddr.BearerUid());
       
   871 	
       
   872 	// We only get here because the bearer has told us it's got a notify.  In
       
   873 	// order to use notifies it must use the V2 bearer interface.
       
   874 	ASSERT_DEBUG(bearerIfV2); 
       
   875 	
       
   876 	TUid interfaceUid;
       
   877 	TUint transactionId;
       
   878 	TUint operationId;
       
   879 	RBuf8 data;
       
   880 	TRemConAddress addr;
       
   881 	LEAVEIFERRORL(bearerIfV2->GetNotifyCommand(interfaceUid,
       
   882 		transactionId, 
       
   883 		operationId, 
       
   884 		data, 
       
   885 		addr));
       
   886 	LOG3(_L("\treceived command with interfaceUid [0x%08x], operationId 0x%02x, data.Length = %d"), 
       
   887 		interfaceUid, operationId, data.Length());
       
   888 	// We now own what's pointed to by 'data'.
       
   889 	CleanupClosePushL(data);
       
   890 
       
   891 	CRemConMessage* msg = CRemConMessage::NewL(
       
   892 		aAddr,
       
   893 		aClient,
       
   894 		ERemConNotifyCommand,
       
   895 		ERemConNotifyCommandAwaitingInterim,
       
   896 		interfaceUid,
       
   897 		operationId,
       
   898 		data,
       
   899 		0, // session ID as yet unknown
       
   900 		transactionId);
       
   901 	// 'msg' now has a pointer to the memory pointed to by 'data', and owns 
       
   902 	// it.
       
   903 	CLEANUPSTACK_POP1(&data);
       
   904 	// Give the new command to the server, which takes ownership of it. 
       
   905 	iServer.NewNotifyCommand(*msg);
       
   906 	}
       
   907 
       
   908 TInt CBearerManager::MrcboDoConnectIndicate(const TRemConAddress& aAddr)
       
   909 	{
       
   910 	LOG(KNullDesC8());
       
   911 	LOG_FUNC;
       
   912 
       
   913 	// Just call the handler for new connections.
       
   914 	TInt ret = iServer.HandleConnection(aAddr, KErrNone);
       
   915 	LOG1(_L("\tret = %d"), ret);
       
   916 
       
   917 	return ret;
       
   918 	}
       
   919 
       
   920 void CBearerManager::MrcboDoDisconnectIndicate(const TRemConAddress& aAddr)
       
   921 	{
       
   922 	LOG(KNullDesC8());
       
   923 	LOG_FUNC;
       
   924 	
       
   925 	// Just call the handler for removed connections.
       
   926 	iServer.RemoveConnection(aAddr, KErrNone);
       
   927 	}
       
   928 
       
   929 TInt CBearerManager::MrcboDoConnectConfirm(const TRemConAddress& aAddr, TInt aError)
       
   930 	{
       
   931 	LOG(KNullDesC8());
       
   932 	LOG_FUNC;
       
   933 	LOG2(_L("\taError = %d, aAddr.BearerUid = 0x%08x"), aError, aAddr.BearerUid());
       
   934 
       
   935 	TInt index = iCurrentlyBeingConnected.Find(aAddr, RemConAddrsMatch);
       
   936 	ASSERT_DEBUG(index != KErrNotFound);
       
   937 	iCurrentlyBeingConnected.Remove(index);
       
   938 
       
   939 	TInt ret = iServer.HandleConnection(aAddr, aError);
       
   940 
       
   941 	LOG1(_L("\tret = %d"), ret);
       
   942 	return ret;
       
   943 	}
       
   944 
       
   945 void CBearerManager::MrcboDoDisconnectConfirm(const TRemConAddress& aAddr, TInt aError)
       
   946 	{
       
   947 	LOG(KNullDesC8());
       
   948 	LOG_FUNC;
       
   949 	LOG2(_L("\taError = %d, aAddr.BearerUid = 0x%08x"), aError, aAddr.BearerUid());
       
   950 
       
   951 	TInt index = iCurrentlyBeingDisconnected.Find(aAddr, RemConAddrsMatch);
       
   952 	ASSERT_DEBUG(index != KErrNotFound);
       
   953 	iCurrentlyBeingDisconnected.Remove(index);
       
   954 
       
   955 	if ( aError == KErrNone )
       
   956 		{
       
   957 		// Remove connection and complete notifications.
       
   958 		iServer.RemoveConnection(aAddr, aError);
       
   959 		}
       
   960 	}
       
   961 
       
   962 TUint CBearerManager::MrcboDoNewTransactionId()
       
   963 	{
       
   964 	TUint newId = iRunningTransactionId;
       
   965 
       
   966 	if ( iRunningTransactionId == KMaxTUint )
       
   967 		{
       
   968 		iRunningTransactionId = 0;
       
   969 		}
       
   970 	else
       
   971 		{
       
   972 		++iRunningTransactionId;
       
   973 		}
       
   974 	
       
   975 	LOG1(_L("CBearerManager::MrcboDoNewTransactionId newId = %d"), newId);
       
   976 	return newId;
       
   977 	}
       
   978 
       
   979 TInt CBearerManager::MrcboDoInterfaceToBearer(TUid aBearerUid,
       
   980 		TUid aInterfaceUid, 
       
   981 		TUint aOperationId,
       
   982 		const TDesC8& aData,
       
   983 		TRemConMessageType aMsgType, 
       
   984 		TDes8& aBearerData) const
       
   985 	{
       
   986 	LOG(KNullDesC8());
       
   987 	LOG_FUNC;
       
   988 	LOG4(_L("\taBearerUid = 0x%08x, aInterfaceUid = 0x%08x, aOperationId = 0x%02x, aMsgType = %d"), 
       
   989 		aBearerUid, aInterfaceUid, aOperationId, aMsgType);
       
   990 
       
   991 	MRemConConverterInterface* conv = iServer.Converter(aInterfaceUid, aBearerUid);
       
   992 	TInt ret = KErrNotSupported;
       
   993 	if ( conv )
       
   994 		{
       
   995 		ret = conv->InterfaceToBearer(aInterfaceUid, aOperationId, aData, aMsgType, aBearerData);
       
   996 		}
       
   997 
       
   998 	LOG1(_L("\tret = %d"), ret);
       
   999 	return ret;
       
  1000 	}
       
  1001 
       
  1002 TInt CBearerManager::MrcboDoBearerToInterface(TUid aBearerUid,
       
  1003 		const TDesC8& aInterfaceData, 
       
  1004 		const TDesC8& aBearerData,
       
  1005 		TUid& aInterfaceUid, 
       
  1006 		TUint& aOperationId,
       
  1007 		TRemConMessageType& aMsgType, 
       
  1008 		TDes8& aData) const
       
  1009 	{
       
  1010 	LOG(KNullDesC8());
       
  1011 	LOG_FUNC;
       
  1012 	LOG1(_L("\taBearerUid = 0x%08x"), aBearerUid);
       
  1013 
       
  1014 	MRemConConverterInterface* conv = iServer.Converter(aInterfaceData, aBearerUid);
       
  1015 	TInt ret = KErrNotSupported;
       
  1016 	if ( conv )
       
  1017 		{
       
  1018 		ret = conv->BearerToInterface(aBearerData, aInterfaceUid, aOperationId, aMsgType, aData);
       
  1019 		}
       
  1020 
       
  1021 	LOG1(_L("\tret = %d"), ret);
       
  1022 	return ret;
       
  1023 	}
       
  1024 
       
  1025 void CBearerManager::MrcboDoSetRemoteAddressedClient(const TUid& aBearerUid, const TRemConClientId& aId)
       
  1026 	{
       
  1027 	LOG_FUNC
       
  1028 	LOG2(_L("\taBearerUid = 0x%08x, aId = %d"), aBearerUid, aId);
       
  1029 	
       
  1030 	iServer.SetRemoteAddressedClient(aBearerUid, aId);
       
  1031 	}
       
  1032 
       
  1033 void CBearerManager::MrcboDoCommandExpired(TUint aTransactionId)
       
  1034 	{
       
  1035 	iServer.CommandExpired(aTransactionId);
       
  1036 	}
       
  1037 
       
  1038 TSglQue<TBearerSecurity>& CBearerManager::BearerSecurityPolicies()
       
  1039 	{
       
  1040 	return iBearerSecurityPolicies;
       
  1041 	}
       
  1042 
       
  1043 TBool CBearerManager::IsConnecting(const TRemConAddress& aAddr) const
       
  1044 	{
       
  1045 	LOG_FUNC;
       
  1046 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
  1047 	
       
  1048 	TInt index = iCurrentlyBeingConnected.Find(aAddr, RemConAddrsMatch);
       
  1049 	TInt ret = ( index != KErrNotFound ) ? ETrue : EFalse;
       
  1050 	
       
  1051 	LOG1(_L("\tret = %d"), ret);
       
  1052 	return ret;
       
  1053 	}
       
  1054 
       
  1055 TBool CBearerManager::IsDisconnecting(const TRemConAddress& aAddr) const
       
  1056 	{
       
  1057 	LOG_FUNC;
       
  1058 	LOG1(_L("\taAddr.BearerUid = 0x%08x"), aAddr.BearerUid());
       
  1059 	
       
  1060 	TInt index = iCurrentlyBeingDisconnected.Find(aAddr, RemConAddrsMatch);
       
  1061 	TInt ret = ( index != KErrNotFound ) ? ETrue : EFalse;
       
  1062 	
       
  1063 	LOG1(_L("\tret = %d"), ret);
       
  1064 	return ret;
       
  1065 	}
       
  1066 
       
  1067 void CBearerManager::BulkInterfacesL(RArray<TBulkInterfaceInfo>& aBulkInterfaces) const
       
  1068 	{
       
  1069 	LOG_FUNC
       
  1070 	ASSERT_DEBUG(aBulkInterfaces.Count() == 0);
       
  1071 	CleanupResetPushL(aBulkInterfaces);
       
  1072 	MRemConBearerBulkInterface* bulkIf = NULL;
       
  1073 	for(TInt i=0; i<iBearers.Count(); i++)
       
  1074 		{
       
  1075 		ASSERT_DEBUG(iBearers[i]);
       
  1076 		bulkIf = reinterpret_cast<MRemConBearerBulkInterface*>(iBearers[i]->GetInterface(TUid::Uid(KRemConBearerBulkInterface1)));
       
  1077 		if(bulkIf)
       
  1078 			{
       
  1079 			TBulkInterfaceInfo ifInfo;
       
  1080 			ifInfo.iIf = bulkIf;
       
  1081 			ifInfo.iIfUid = TUid::Uid(KRemConBearerBulkInterface1);
       
  1082 			ifInfo.iBearerUid = iBearers[i]->Uid();
       
  1083 			aBulkInterfaces.AppendL(ifInfo);
       
  1084 			}
       
  1085 		}
       
  1086 	CleanupStack::Pop(&aBulkInterfaces);
       
  1087 	}
       
  1088 
       
  1089 TInt CBearerManager::MrcboDoSupportedInterfaces(const TRemConClientId& aId, RArray<TUid>& aUids)
       
  1090 	{
       
  1091 	LOG_FUNC
       
  1092 	return iServer.SupportedInterfaces(aId, aUids);
       
  1093 	}
       
  1094 
       
  1095 TInt CBearerManager::MrcboDoSupportedOperations(const TRemConClientId& aId, TUid aInterfaceUid, RArray<TUint>& aOperations)
       
  1096 	{
       
  1097 	LOG_FUNC
       
  1098 	return iServer.SupportedOperations(aId, aInterfaceUid, aOperations);
       
  1099 	}
       
  1100 
       
  1101 TInt CBearerManager::MrcboDoRegisterLocalAddressedClientObserver(const TUid& aBearerUid)
       
  1102 	{
       
  1103 	return iServer.RegisterLocalAddressedClientObserver(aBearerUid);
       
  1104 	}
       
  1105 
       
  1106 TInt CBearerManager::MrcboDoUnregisterLocalAddressedClientObserver(const TUid& aBearerUid)
       
  1107 	{
       
  1108 	return iServer.UnregisterLocalAddressedClientObserver(aBearerUid);
       
  1109 	}
       
  1110 
       
  1111 TInt CBearerManager::SetLocalAddressedClient(const TUid& aBearerUid, TRemConClientId aClientId)
       
  1112 	{
       
  1113 	LOG_FUNC;
       
  1114 	
       
  1115 	MRemConBearerInterfaceV3* const bearerIfV3 = BearerIfV3(aBearerUid);
       
  1116 	if(bearerIfV3)
       
  1117 		{
       
  1118 		return bearerIfV3->SetLocalAddressedClient(aClientId);
       
  1119 		}
       
  1120 	else
       
  1121 		{
       
  1122 		return KErrNotFound;
       
  1123 		}
       
  1124 	}
       
  1125 
       
  1126