libraries/iosrv/server/persistentconsole.cpp
changeset 0 7f656887cf89
child 83 706c7a69e448
equal deleted inserted replaced
-1:000000000000 0:7f656887cf89
       
     1 // persistentconsole.cpp
       
     2 // 
       
     3 // Copyright (c) 2008 - 2010 Accenture. All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of the "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 // 
       
     9 // Initial Contributors:
       
    10 // Accenture - Initial contribution
       
    11 //
       
    12 
       
    13 #include "persistentconsole.h"
       
    14 #include <e32hashtab.h>
       
    15 
       
    16 
       
    17 static void CleanupNullPointer(TAny* aPtrPtr)
       
    18 	{
       
    19 	*((TAny**)aPtrPtr) = NULL;
       
    20 	}
       
    21 	
       
    22 static void CleanupNullPointerPushL(TAny** aPtr)
       
    23 	{
       
    24 	CleanupStack::PushL(TCleanupItem(CleanupNullPointer, aPtr));
       
    25 	}
       
    26 	
       
    27 _LIT(KProxySuffix, "_proxy");
       
    28 
       
    29 //______________________________________________________________________________
       
    30 //						CIoPersistentConsole
       
    31 CIoPersistentConsole* CIoPersistentConsole::NewLC(const TDesC& aName, const TDesC& aTitle, CIoServer& aServer, const RMsg& aMessage)
       
    32 	{
       
    33 	CIoPersistentConsole* self = new(ELeave)CIoPersistentConsole(aServer);
       
    34 	CleanupClosePushL(*self);
       
    35 	self->ConstructL(aName, aTitle, aMessage);
       
    36 	return self;
       
    37 	}
       
    38 	
       
    39 TBool CIoPersistentConsole::CanConnectReaderL(const MIoReadEndPoint& aReader) const
       
    40 	{
       
    41 	// check that the candidate end point will not result in a circular connection of
       
    42 	// persistent consoles if it's connected to this one.
       
    43 	
       
    44 	RHashSet<TInt> chained; // addresses of CIoPersistentConsole's in any chain
       
    45 	CleanupClosePushL(chained);
       
    46 	chained.InsertL((TInt)this);
       
    47 	const MIoReadEndPoint* nextReader = &aReader;
       
    48 	while (nextReader && nextReader->IoepIsType(RIoHandle::EPersistentConsole))
       
    49 		{
       
    50 		const CIoPersistentConsole* next = (const CIoPersistentConsole*)nextReader;
       
    51 		if (chained.Find((TInt)next))
       
    52 			{
       
    53 			CleanupStack::PopAndDestroy();
       
    54 			return EFalse;
       
    55 			}
       
    56 		chained.InsertL((TInt)next);
       
    57 		nextReader = next->TransientReader();
       
    58 		}
       
    59 	CleanupStack::PopAndDestroy();
       
    60 	return ETrue;	
       
    61 	}
       
    62 	
       
    63 void CIoPersistentConsole::AttachTransientReaderL(MIoReadEndPoint& aReader, CIoSession* aDetachOnClose)
       
    64 	{
       
    65 	if (!CanConnectReaderL(aReader)) User::Leave(KErrCouldNotConnect);	
       
    66 		
       
    67 	if (iTransientReadEndPoint)
       
    68 		{
       
    69 		User::Leave(KErrInUse);
       
    70 		}
       
    71 		
       
    72 	
       
    73 	iTransientReadEndPoint = &aReader;
       
    74 	CleanupNullPointerPushL((TAny**)&iTransientReadEndPoint);
       
    75 	
       
    76 	TInt fgProxyPos = ReaderProxyIndex(AttachedReader());
       
    77 	if (fgProxyPos != KErrNotFound)
       
    78 		{
       
    79 		iTransientReadEndPoint->IorepAttachL(*iReaderProxies[fgProxyPos], RIoEndPoint::EForeground);
       
    80 		}
       
    81 	
       
    82 	TInt i = 0;
       
    83 	TRAPD(err, 
       
    84 		for (i=0; i<iReaderProxies.Count(); ++i)
       
    85 			{
       
    86 			if (i != fgProxyPos)
       
    87 				{
       
    88 				iTransientReadEndPoint->IorepAttachL(*iReaderProxies[i], RIoEndPoint::EBackground);
       
    89 				}
       
    90 			}
       
    91 		);
       
    92 		
       
    93 	if (err)
       
    94 		{
       
    95 		// deatch the readers the we successfully attached before failure
       
    96 		for (TInt j=0; j<i; ++j)
       
    97 			{
       
    98 			iTransientReadEndPoint->IorepDetach(*iReaderProxies[j]);
       
    99 			}
       
   100 		// also make sure that the foreground reader is deatched
       
   101 		if (fgProxyPos >= i)
       
   102 			{
       
   103 			iTransientReadEndPoint->IorepDetach(*iReaderProxies[fgProxyPos]);
       
   104 			}
       
   105 		User::Leave(err);
       
   106 		}
       
   107 	CleanupStack::Pop();
       
   108 	
       
   109 	iReadEndPointDetachOnClose = aDetachOnClose;
       
   110 		
       
   111 	// now foreward any outstanding read requests
       
   112 	for (TInt i=0; i<iReaderProxies.Count(); ++i)
       
   113 		{
       
   114 		iReaderProxies[i]->TransientReaderAttached(*iTransientReadEndPoint);
       
   115 		}
       
   116 		
       
   117 	MIoReader* fg = AttachedReader();
       
   118 	if (fg)
       
   119 		{
       
   120 		fg->IorReaderChange(RIoReadHandle::EGainedForeground | RIoReadHandle::EConsoleSizeChanged);
       
   121 		}
       
   122 	}
       
   123 	
       
   124 void CIoPersistentConsole::DetachTransientReader()
       
   125 	{
       
   126 	if (!iTransientReadEndPoint)
       
   127 		{
       
   128 		return;
       
   129 		}
       
   130 	MIoReadEndPoint* detaching = iTransientReadEndPoint;
       
   131 	iTransientReadEndPoint = NULL;
       
   132 
       
   133 	TInt fgReaderPos = ReaderProxyIndex(AttachedReader());
       
   134 	for (TInt i=0; i<iReaderProxies.Count(); ++i)
       
   135 		{
       
   136 		if (i!=fgReaderPos)
       
   137 			{
       
   138 			detaching->IorepDetach(*iReaderProxies[i]);
       
   139 			}
       
   140 		}
       
   141 	if (fgReaderPos!=KErrNotFound)
       
   142 		{
       
   143 		detaching->IorepDetach(*iReaderProxies[fgReaderPos]);
       
   144 		}
       
   145 	iReadEndPointDetachOnClose = NULL;
       
   146 
       
   147 	SendReadDetachNotifications();
       
   148 	}
       
   149 	
       
   150 const MIoReadEndPoint* CIoPersistentConsole::TransientReader() const
       
   151 	{
       
   152 	return iTransientReadEndPoint;
       
   153 	}	
       
   154 
       
   155 TBool CIoPersistentConsole::CanConnectWriterL(const MIoWriteEndPoint& aWriter) const
       
   156 	{
       
   157 	// check that the candidate end point will not result in a circular connection of
       
   158 	// persistent consoles if it's connected to this one.
       
   159 	
       
   160 	RHashSet<TInt> chained; // addresses of CIoPersistentConsole's in any chain
       
   161 	CleanupClosePushL(chained);
       
   162 	chained.InsertL((TInt)this);
       
   163 	const MIoWriteEndPoint* nextWriter = &aWriter;
       
   164 	while (nextWriter && nextWriter->IoepIsType(RIoHandle::EPersistentConsole))
       
   165 		{
       
   166 		const CIoPersistentConsole* next = (const CIoPersistentConsole*)nextWriter;
       
   167 		if (chained.Find((TInt)next))
       
   168 			{
       
   169 			CleanupStack::PopAndDestroy();
       
   170 			return EFalse;
       
   171 			}
       
   172 		chained.InsertL((TInt)next);
       
   173 		nextWriter = next->TransientWriter();
       
   174 		}
       
   175 	CleanupStack::PopAndDestroy();
       
   176 	return ETrue;	
       
   177 	}
       
   178 	
       
   179 void CIoPersistentConsole::AttachTransientWriterL(MIoWriteEndPoint& aWriter, CIoSession* aDetachOnClose)
       
   180 	{
       
   181 	if (!CanConnectWriterL(aWriter)) User::Leave(KErrCouldNotConnect);	
       
   182 	
       
   183 	if (iTransientWriteEndPoint)
       
   184 		{
       
   185 		User::Leave(KErrInUse);
       
   186 		}
       
   187 	iTransientWriteEndPoint = &aWriter;
       
   188 	CleanupNullPointerPushL((TAny**)&iTransientWriteEndPoint);
       
   189 	
       
   190 	TInt i = 0;
       
   191 	TRAPD(err, 
       
   192 		for (i=0; i<iWriterProxies.Count(); ++i)
       
   193 			{
       
   194 			iTransientWriteEndPoint->IowepAttachL(*iWriterProxies[i]);
       
   195 			}
       
   196 		);
       
   197 	if (err)
       
   198 		{
       
   199 		// deatch the writers the we successfully attached before failure
       
   200 		for (TInt j=0; j<i; ++j)
       
   201 			{
       
   202 			iWriterProxies[j]->TransientWriterDetach(*iTransientWriteEndPoint);
       
   203 			}
       
   204 		User::Leave(err);
       
   205 		}
       
   206 	CleanupStack::Pop();
       
   207 	
       
   208 	iWriteEndPointDetachOnClose = aDetachOnClose;
       
   209 	
       
   210 	TRAP_IGNORE(iTransientWriteEndPoint->IowepSetTitleL(iTitleSetter));
       
   211 	
       
   212 	for (TInt i=0; i<iWriterProxies.Count(); ++i)
       
   213 		{
       
   214 		iWriterProxies[i]->TransientWriterAttached(*iTransientWriteEndPoint);
       
   215 		}		
       
   216 	}
       
   217 	
       
   218 void CIoPersistentConsole::DetachTransientWriter()
       
   219 	{
       
   220 	if (!iTransientWriteEndPoint)
       
   221 		{
       
   222 		return;
       
   223 		}
       
   224 	MIoWriteEndPoint* detaching = iTransientWriteEndPoint;
       
   225 	iTransientWriteEndPoint = NULL;
       
   226 	for (TInt i=0; i<iWriterProxies.Count(); ++i)
       
   227 		{
       
   228 		iWriterProxies[i]->TransientWriterDetach(*detaching);
       
   229 		}
       
   230 	iWriteEndPointDetachOnClose = NULL;
       
   231 	
       
   232 	SendWriteDetachNotifications();
       
   233 	}
       
   234 	
       
   235 const MIoWriteEndPoint* CIoPersistentConsole::TransientWriter() const
       
   236 	{
       
   237 	return iTransientWriteEndPoint;
       
   238 	}
       
   239 	
       
   240 MIoWriteEndPoint* CIoPersistentConsole::TransientWriter()
       
   241 	{
       
   242 	return iTransientWriteEndPoint;
       
   243 	}
       
   244 	
       
   245 void CIoPersistentConsole::NotifyReadDetachL(const RMsg& aMessage)
       
   246 	{
       
   247 	if ((iReaderProxies.Count()==0) || !iTransientReadEndPoint)
       
   248 		{
       
   249 		Complete(aMessage, KErrNone);
       
   250 		}
       
   251 	else
       
   252 		{
       
   253 		iReadDetachNotifications.AppendL(aMessage);
       
   254 		}
       
   255 	}
       
   256 	
       
   257 void CIoPersistentConsole::CancelNotifyReadDetach(TRequestStatus* aClientStatus)
       
   258 	{
       
   259 	for (TInt i=0; i<iReadDetachNotifications.Count(); ++i)
       
   260 		{
       
   261 		if (iReadDetachNotifications[i].ClientStatus() == aClientStatus)
       
   262 			{
       
   263 			Complete(iReadDetachNotifications[i], KErrCancel);
       
   264 			iReadDetachNotifications.Remove(i);
       
   265 			return;
       
   266 			}
       
   267 		}
       
   268 	}
       
   269 	
       
   270 void CIoPersistentConsole::NotifyWriteDetachL(const RMsg& aMessage)
       
   271 	{
       
   272 	if ((iWriterProxies.Count()==0) || !iTransientWriteEndPoint)
       
   273 		{
       
   274 		Complete(aMessage, KErrNone);
       
   275 		}
       
   276 	else
       
   277 		{
       
   278 		iWriteDetachNotifications.AppendL(aMessage);
       
   279 		}
       
   280 	}
       
   281 	
       
   282 void CIoPersistentConsole::CancelNotifyWriteDetach(TRequestStatus* aClientStatus)
       
   283 	{
       
   284 	for (TInt i=0; i<iWriteDetachNotifications.Count(); ++i)
       
   285 		{
       
   286 		if (iWriteDetachNotifications[i].ClientStatus() == aClientStatus)
       
   287 			{
       
   288 			Complete(iWriteDetachNotifications[i], KErrCancel);
       
   289 			iWriteDetachNotifications.Remove(i);
       
   290 			return;
       
   291 			}
       
   292 		}
       
   293 	}
       
   294 	
       
   295 TName CIoPersistentConsole::TransientReaderName()
       
   296 	{
       
   297 	if (iTransientReadEndPoint)
       
   298 		{
       
   299 		return iTransientReadEndPoint->IoepName();
       
   300 		}
       
   301 	else
       
   302 		{
       
   303 		return KNullDesC();
       
   304 		}
       
   305 	}
       
   306 	
       
   307 TName CIoPersistentConsole::TransientWriterName()
       
   308 	{
       
   309 	if (iTransientWriteEndPoint)
       
   310 		{
       
   311 		return iTransientWriteEndPoint->IoepName();
       
   312 		}
       
   313 	else
       
   314 		{
       
   315 		return KNullDesC();
       
   316 		}
       
   317 	}
       
   318 	
       
   319 TThreadId CIoPersistentConsole::Creator()
       
   320 	{
       
   321 	return iCreator.Id();
       
   322 	}
       
   323 	
       
   324 TName CIoPersistentConsole::Name() const
       
   325 	{
       
   326 	return iName;
       
   327 	}
       
   328 
       
   329 TBool CIoPersistentConsole::IsType(RIoHandle::TType aType) const
       
   330 	{
       
   331 	if (aType == RIoHandle::EPersistentConsole)
       
   332 		{
       
   333 		return ETrue;
       
   334 		}
       
   335 	else
       
   336 		{
       
   337 		return CIoConsole::IsType(aType);
       
   338 		}
       
   339 	}
       
   340 	
       
   341 void CIoPersistentConsole::SessionClosed(const CIoSession& aSession)
       
   342 	{
       
   343 	if (&aSession == iReadEndPointDetachOnClose)
       
   344 		{
       
   345 		DetachTransientReader();
       
   346 		}
       
   347 	if (&aSession == iWriteEndPointDetachOnClose)
       
   348 		{
       
   349 		DetachTransientWriter();
       
   350 		}
       
   351 	}
       
   352 	
       
   353 void CIoPersistentConsole::ClosedBy(const CIoSession& aSession)
       
   354 	{
       
   355 	SessionClosed(aSession);
       
   356 	}
       
   357 	
       
   358 void CIoPersistentConsole::SendReadDetachNotifications()
       
   359 	{
       
   360 	for (TInt i=0; i<iReadDetachNotifications.Count(); ++i)
       
   361 		{
       
   362 		Complete(iReadDetachNotifications[i], KErrNone);
       
   363 		}
       
   364 	iReadDetachNotifications.Reset();
       
   365 	}
       
   366 	
       
   367 void CIoPersistentConsole::SendWriteDetachNotifications()
       
   368 	{
       
   369 	for (TInt i=0; i<iWriteDetachNotifications.Count(); ++i)
       
   370 		{
       
   371 		Complete(iWriteDetachNotifications[i], KErrNone);
       
   372 		}
       
   373 	iWriteDetachNotifications.Reset();
       
   374 	}
       
   375 
       
   376 //______________________________________________________________________________
       
   377 //		MIoReadEndPoint implementation - to handle reads from persistent side
       
   378 TInt CIoPersistentConsole::HandleReaderAttached(MIoReader& aReader)
       
   379 	{
       
   380 	TIoReaderProxy* proxy = new TIoReaderProxy(aReader, *this);
       
   381 	TInt err = proxy ? KErrNone : KErrNoMemory;
       
   382 	if (err==KErrNone)
       
   383 		{
       
   384 		err = iReaderProxies.Append(proxy);
       
   385 		}
       
   386 	
       
   387 	if ((err == KErrNone) && iTransientReadEndPoint)
       
   388 		{
       
   389 		TRAP(err, iTransientReadEndPoint->IorepAttachL(*proxy, RIoEndPoint::EBackground));
       
   390 		}
       
   391 
       
   392 	if (err != KErrNone)
       
   393 		{
       
   394 		TInt pos = ReaderProxyIndex(proxy);
       
   395 		if (pos!=KErrNotFound)
       
   396 			{
       
   397 			iReaderProxies.Remove(pos);
       
   398 			}
       
   399 		delete proxy;
       
   400 		}		
       
   401 	return err;
       
   402 	}
       
   403 	
       
   404 void CIoPersistentConsole::HandleReaderDetached(MIoReader& aReader)
       
   405 	{
       
   406 	TInt pos = ReaderProxyIndex(&aReader);
       
   407 	if (pos!=KErrNotFound)
       
   408 		{
       
   409 		if (iTransientReadEndPoint)
       
   410 			{
       
   411 			iTransientReadEndPoint->IorepDetach(*iReaderProxies[pos]);
       
   412 			}
       
   413 		delete iReaderProxies[pos];
       
   414 		iReaderProxies.Remove(pos);
       
   415 		
       
   416 		if (iReaderProxies.Count()==0)
       
   417 			{
       
   418 			SendReadDetachNotifications();
       
   419 			}
       
   420 		}
       
   421 	}
       
   422 	
       
   423 void CIoPersistentConsole::HandleForegroundReaderChanged()
       
   424 	{
       
   425 	if (iTransientReadEndPoint)
       
   426 		{
       
   427 		CIoEndPoint::HandleForegroundReaderChanged();
       
   428 		}
       
   429 	else
       
   430 		{
       
   431 		ForegroundReaderChanged();
       
   432 		}
       
   433 	}
       
   434 	
       
   435 void CIoPersistentConsole::ForegroundReaderChanged()
       
   436 	{
       
   437 	MIoReader* fgReader = AttachedReader();
       
   438 	if (iTransientReadEndPoint && fgReader)
       
   439 		{
       
   440 		TInt fgPos = ReaderProxyIndex(fgReader);
       
   441 		ASSERT(fgPos != KErrNotFound);
       
   442 		TRAPD(err, iTransientReadEndPoint->IorepSetForegroundReaderL(*iReaderProxies[fgPos]));
       
   443 		__ASSERT_ALWAYS(err == KErrNone, User::Invariant());
       
   444 		// this would only fail if this endpoints list of readers differs from the transient
       
   445 		// endpoints list; the two should always be kept in sync.
       
   446 		}
       
   447 	}
       
   448 	
       
   449 TInt CIoPersistentConsole::ReaderProxyIndex(MIoReader* aReader) const
       
   450 	{
       
   451 	for (TInt i=0; i<iReaderProxies.Count(); ++i)
       
   452 		{
       
   453 		if (&iReaderProxies[i]->ClientReader() == aReader)
       
   454 			{
       
   455 			return i;
       
   456 			}
       
   457 		}
       
   458 	return KErrNotFound;
       
   459 	}
       
   460 
       
   461 void CIoPersistentConsole::IorepReadL(MIoReader& aReader)
       
   462 	{
       
   463 	TInt pos = ReaderProxyIndex(&aReader);
       
   464 	ASSERT(pos!=KErrNotFound);
       
   465 	iReaderProxies[pos]->ReadL(iTransientReadEndPoint);
       
   466 	}
       
   467 
       
   468 void CIoPersistentConsole::IorepReadKeyL(MIoReader& aReader)
       
   469 	{
       
   470 	TInt pos = ReaderProxyIndex(&aReader);
       
   471 	ASSERT(pos!=KErrNotFound);
       
   472 	iReaderProxies[pos]->ReadKeyL(iTransientReadEndPoint);
       
   473 	}
       
   474 
       
   475 void CIoPersistentConsole::IorepSetConsoleModeL(RIoReadWriteHandle::TMode aMode, MIoReader& aReader)
       
   476 	{
       
   477 	iPersistentConsoleMode = aMode;
       
   478 	GetReaderProxy(&aReader).SetConsoleModeL(iTransientReadEndPoint, aMode);
       
   479 	}
       
   480 
       
   481 //______________________________________________________________________________
       
   482 //		MIoWriteEndPoint implementation - to handles writes from persistent side
       
   483 TInt CIoPersistentConsole::HandleWriterAttached(MIoWriter& aWriter)
       
   484 	{
       
   485 	// call from CIoEndPoint
       
   486 	TIoWriterProxy* proxy = new TIoWriterProxy(aWriter, *this);
       
   487 	TInt err = proxy ? KErrNone : KErrNoMemory;
       
   488 	if (err==KErrNone)
       
   489 		{
       
   490 		err = iWriterProxies.Append(proxy);
       
   491 		}
       
   492 	
       
   493 	if ((err == KErrNone) && iTransientWriteEndPoint)
       
   494 		{
       
   495 		TRAP(err, iTransientWriteEndPoint->IowepAttachL(*proxy));
       
   496 		}
       
   497 
       
   498 	if (err != KErrNone)
       
   499 		{
       
   500 		TInt pos = WriterProxyIndex(proxy);
       
   501 		if (pos!=KErrNotFound)
       
   502 			{
       
   503 			iWriterProxies.Remove(pos);
       
   504 			}
       
   505 		delete proxy;
       
   506 		}		
       
   507 	return err;
       
   508 	}
       
   509 	
       
   510 void CIoPersistentConsole::HandleWriterDetached(MIoWriter& aWriter)
       
   511 	{
       
   512 	TInt pos = WriterProxyIndex(&aWriter);
       
   513 	if (pos!=KErrNotFound)
       
   514 		{
       
   515 		if (iTransientWriteEndPoint)
       
   516 			{
       
   517 			iWriterProxies[pos]->TransientWriterDetach(*iTransientWriteEndPoint);
       
   518 			}
       
   519 		delete iWriterProxies[pos];
       
   520 		iWriterProxies.Remove(pos);
       
   521 		
       
   522 		if (iWriterProxies.Count()==0)
       
   523 			{
       
   524 			SendWriteDetachNotifications();
       
   525 			}
       
   526 		}
       
   527 		
       
   528 	}
       
   529 	
       
   530 TInt CIoPersistentConsole::WriterProxyIndex(MIoWriter* aWriter) const
       
   531 	{
       
   532 	for (TInt i=0; i<iWriterProxies.Count(); ++i)
       
   533 		{
       
   534 		if (&iWriterProxies[i]->ClientWriter() == aWriter)
       
   535 			{
       
   536 			return i;
       
   537 			}
       
   538 		}
       
   539 	return KErrNotFound;
       
   540 	}
       
   541 	
       
   542 CIoPersistentConsole::TIoWriterProxy& CIoPersistentConsole::GetWriterProxy(MIoWriter* aWriter) const
       
   543 	{
       
   544 	TInt pos = WriterProxyIndex(aWriter);
       
   545 	ASSERT(pos!=KErrNotFound);
       
   546 	return *iWriterProxies[pos];
       
   547 	}
       
   548 	
       
   549 CIoPersistentConsole::TIoReaderProxy& CIoPersistentConsole::GetReaderProxy(MIoReader* aWriter) const
       
   550 	{
       
   551 	TInt pos = ReaderProxyIndex(aWriter);
       
   552 	ASSERT(pos!=KErrNotFound);
       
   553 	return *iReaderProxies[pos];
       
   554 	}
       
   555 
       
   556 void CIoPersistentConsole::IowepWriteL(MIoWriter& aWriter)
       
   557 	{
       
   558 	TInt pos = WriterProxyIndex(&aWriter);
       
   559 	ASSERT(pos!=KErrNotFound);
       
   560 	iWriterProxies[pos]->WriteL(iTransientWriteEndPoint);
       
   561 
       
   562 	// move the proxy to the end of the array so that we service the writes 
       
   563 	// in the correct order when we get a write end point, or when the end
       
   564 	// point goes away and comes back
       
   565 	TIoWriterProxy* proxy(iWriterProxies[pos]);
       
   566 	iWriterProxies.Remove(pos);
       
   567 	iWriterProxies.Append(proxy);
       
   568 	}
       
   569 	
       
   570 void CIoPersistentConsole::IowepWriteCancel(MIoWriter& aWriter)
       
   571 	{
       
   572 	TInt pos = WriterProxyIndex(&aWriter);
       
   573 	ASSERT(pos!=KErrNotFound);
       
   574 	iWriterProxies[pos]->WriteCancel(iTransientWriteEndPoint);
       
   575 	}
       
   576 
       
   577 void CIoPersistentConsole::IowepCursorPosL(MIoWriter& aWriter) const
       
   578 	{
       
   579 	GetWriterProxy(&aWriter).GetCursorPosL(iTransientWriteEndPoint);
       
   580 	}
       
   581 
       
   582 void CIoPersistentConsole::IowepSetCursorPosAbsL(const TPoint& aPoint, MIoWriter& aWriter)
       
   583 	{
       
   584 	GetWriterProxy(&aWriter).SetCursorPosAbsL(aPoint, iTransientWriteEndPoint);
       
   585 	}
       
   586 
       
   587 void CIoPersistentConsole::IowepSetCursorPosRelL(const TPoint& aPoint, MIoWriter& aWriter)
       
   588 	{
       
   589 	GetWriterProxy(&aWriter).SetCursorPosRelL(aPoint, iTransientWriteEndPoint);
       
   590 	}
       
   591 
       
   592 void CIoPersistentConsole::IowepSetCursorHeightL(TInt aPercentage, MIoWriter& aWriter)
       
   593 	{
       
   594 	GetWriterProxy(&aWriter).SetCursorHeightL(aPercentage, iTransientWriteEndPoint);
       
   595 	// TODO cache cursor height
       
   596 	}
       
   597 
       
   598 void CIoPersistentConsole::IowepSetTitleL(MIoWriter& aWriter)
       
   599 	{
       
   600 	delete iTitle;
       
   601 	iTitle = NULL;
       
   602 	TRAP_IGNORE(iTitle = aWriter.IowTitleLC(); CleanupStack::Pop(iTitle)); // not much we can do if this fails
       
   603 	GetWriterProxy(&aWriter).SetTitleL(iTransientWriteEndPoint);
       
   604 	}
       
   605 
       
   606 void CIoPersistentConsole::IowepClearScreenL(MIoWriter& aWriter)
       
   607 	{
       
   608 	GetWriterProxy(&aWriter).ClearScreenL(iTransientWriteEndPoint);
       
   609 	}
       
   610 
       
   611 void CIoPersistentConsole::IowepClearToEndOfLineL(MIoWriter& aWriter)
       
   612 	{
       
   613 	GetWriterProxy(&aWriter).ClearToEndOfLineL(iTransientWriteEndPoint);
       
   614 	}
       
   615 
       
   616 void CIoPersistentConsole::IowepScreenSizeL(MIoWriter& aWriter) const
       
   617 	{
       
   618 	GetWriterProxy(&aWriter).GetScreenSizeL(iTransientWriteEndPoint);
       
   619 	}
       
   620 
       
   621 void CIoPersistentConsole::IowepSetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriter& aWriter)
       
   622 	{
       
   623 	GetWriterProxy(&aWriter).SetAttributesL(aAttributes, aForegroundColor, aBackgroundColor, iTransientWriteEndPoint);
       
   624 	}
       
   625 	
       
   626 CIoPersistentConsole::CIoPersistentConsole(CIoServer& aServer)
       
   627 	: CIoConsole(aServer.Config()), iServer(aServer), iTitleSetter(iTitle)
       
   628 	{
       
   629 	}
       
   630 	
       
   631 CIoPersistentConsole::~CIoPersistentConsole()
       
   632 	{
       
   633 	iServer.PersistentConsoleRemove(iName, *this);
       
   634 	SendReadDetachNotifications();
       
   635 	iReadDetachNotifications.Close();
       
   636 	SendWriteDetachNotifications();
       
   637 	iWriteDetachNotifications.Close();
       
   638 	
       
   639 	delete iTitle;
       
   640 	iWriterProxies.ResetAndDestroy();
       
   641 	iReaderProxies.ResetAndDestroy();
       
   642 	
       
   643 	iCreator.Close();
       
   644 	}
       
   645 
       
   646 _LIT(KPersistentConsoleImplementation, "<persistent console>");
       
   647 
       
   648 void CIoPersistentConsole::ConstructL(const TDesC& aName, const TDesC& aTitle, const RMsg& aMessage)
       
   649 	{
       
   650 	LOG(CIoLog::Printf(_L("Persistent console %S @ 0x%08x created"), &aName, this));
       
   651 	iName = aName.Left(KMaxName);
       
   652 	iServer.PersistentConsoleAddL(iName, *this);
       
   653 	iImplementation = KPersistentConsoleImplementation().AllocL();
       
   654 	iTitle = aTitle.AllocL();
       
   655 	aMessage.ClientL(iCreator);
       
   656 	}
       
   657 
       
   658 //______________________________________________________________________________
       
   659 //							TIoWriterProxy
       
   660 // MIoWriter proxy to service write requests from the transient side
       
   661 CIoPersistentConsole::TIoWriterProxy::TIoWriterProxy(MIoWriter& aWriter, CIoPersistentConsole& aOwner)
       
   662 	: iWriter(aWriter)
       
   663 	, iOwner(aOwner)
       
   664 	, iFlags(0)
       
   665 	{
       
   666 	}
       
   667 	
       
   668 TBool CIoPersistentConsole::TIoWriterProxy::GetFlag(TFlags aFlag)
       
   669 	{
       
   670 	return iFlags & aFlag;
       
   671 	}
       
   672 	
       
   673 void CIoPersistentConsole::TIoWriterProxy::SetFlag(TFlags aFlag)
       
   674 	{
       
   675 	iFlags |= aFlag;
       
   676 	}
       
   677 	
       
   678 void CIoPersistentConsole::TIoWriterProxy::ClearFlag(TFlags aFlag)
       
   679 	{
       
   680 	iFlags &= (~aFlag);
       
   681 	}
       
   682 	
       
   683 #define TRAP_OR(x, y) {TRAPD(err, x); if (err!=KErrNone) {y;} }
       
   684 	
       
   685 	
       
   686 void CIoPersistentConsole::TIoWriterProxy::TransientWriterAttached(MIoWriteEndPoint& aEndPoint)
       
   687 	{
       
   688 	if (GetFlag(EWritePending))
       
   689 		{
       
   690 		TRAP_OR(aEndPoint.IowepWriteL(*this), IowComplete(err));
       
   691 		}
       
   692 	if (GetFlag(EGetCursorPosPending))
       
   693 		{
       
   694 		TRAP_OR(aEndPoint.IowepCursorPosL(*this), IowCursorPos(err, TPoint(0,0)));
       
   695 		}
       
   696 	if (GetFlag(ESetCursorPosAbsPending))
       
   697 		{
       
   698 		TRAP_OR(aEndPoint.IowepSetCursorPosAbsL(iSetCursPosAbsPoint, *this), IowSetCursorPosAbsComplete(err));
       
   699 		}
       
   700 	if (GetFlag(ESetCursorPosRelPending))
       
   701 		{
       
   702 		TRAP_OR(aEndPoint.IowepSetCursorPosRelL(iSetCursPosRelPoint, *this), IowSetCursorPosRelComplete(err));
       
   703 		}
       
   704 	if (GetFlag(ESetCursorHeightPending))
       
   705 		{
       
   706 		TRAP_OR(aEndPoint.IowepSetCursorHeightL(iSetCursorHeight, *this), IowSetCursorHeightComplete(err));
       
   707 		}
       
   708 	if (GetFlag(ESetTitlePending))
       
   709 		{
       
   710 		TRAP_OR(aEndPoint.IowepSetTitleL(*this), IowSetTitleComplete(err));
       
   711 		}
       
   712 	if (GetFlag(EClearScreenPending))
       
   713 		{
       
   714 		TRAP_OR(aEndPoint.IowepClearScreenL(*this), IowClearScreenComplete(err));
       
   715 		}
       
   716 	if (GetFlag(EClearToEndOfLinePending))
       
   717 		{
       
   718 		TRAP_OR(aEndPoint.IowepClearToEndOfLineL(*this), IowClearToEndOfLineComplete(err));
       
   719 		}
       
   720 	if (GetFlag(EGetScreenSizePending))
       
   721 		{
       
   722 		TRAP_OR(aEndPoint.IowepScreenSizeL(*this), IowScreenSize(err, TSize(0,0)));
       
   723 		}
       
   724 	if (GetFlag(ESetAttributesPending))
       
   725 		{
       
   726 		TRAP_OR(aEndPoint.IowepSetAttributesL(iAttributes, iForegroundColor, iBackgroundColor, *this), IowSetAttributesComplete(err));
       
   727 		}
       
   728 	}
       
   729 	
       
   730 void CIoPersistentConsole::TIoWriterProxy::TransientWriterDetach(MIoWriteEndPoint& aEndPoint)
       
   731 	{
       
   732 	if (GetFlag(EDetaching)) return;
       
   733 	if (GetFlag(EWritePending))
       
   734 		{
       
   735 		aEndPoint.IowepWriteCancel(*this);
       
   736 		// leave the write pending so it is serviced when we get a new transient end point
       
   737 		}
       
   738 	aEndPoint.IowepDetach(*this);
       
   739 	}
       
   740 	
       
   741 void CIoPersistentConsole::TIoWriterProxy::WriteL(MIoWriteEndPoint* aEndPoint)
       
   742 	{
       
   743 	SetFlag(EWritePending);
       
   744 	if (aEndPoint)
       
   745 		{
       
   746 		TRAPD(err, aEndPoint->IowepWriteL(*this));
       
   747 		if (err)
       
   748 			{
       
   749 			ClearFlag(EWritePending);
       
   750 			User::Leave(err);
       
   751 			}
       
   752 		}
       
   753 	}
       
   754 	
       
   755 void CIoPersistentConsole::TIoWriterProxy::WriteCancel(MIoWriteEndPoint* aEndPoint)
       
   756 	{
       
   757 	if (aEndPoint)
       
   758 		{
       
   759 		aEndPoint->IowepWriteCancel(*this);
       
   760 		}
       
   761 	ClearFlag(EWritePending);
       
   762 	}
       
   763 
       
   764 	
       
   765 MIoWriter& CIoPersistentConsole::TIoWriterProxy::ClientWriter() const
       
   766 	{
       
   767 	return iWriter;
       
   768 	}
       
   769 	
       
   770 void CIoPersistentConsole::TIoWriterProxy::GetCursorPosL(MIoWriteEndPoint* aEndPoint)
       
   771 	{
       
   772 	SetFlag(EGetCursorPosPending);
       
   773 	if (aEndPoint)
       
   774 		{
       
   775 		aEndPoint->IowepCursorPosL(*this);
       
   776 		}
       
   777 	}
       
   778 
       
   779 void CIoPersistentConsole::TIoWriterProxy::SetCursorPosAbsL(const TPoint& aPos, MIoWriteEndPoint* aEndPoint)
       
   780 	{
       
   781 	SetFlag(ESetCursorPosAbsPending);
       
   782 	iSetCursPosAbsPoint = aPos;
       
   783 	if (aEndPoint)
       
   784 		{
       
   785 		aEndPoint->IowepSetCursorPosAbsL(iSetCursPosAbsPoint, *this);
       
   786 		}
       
   787 	}
       
   788 
       
   789 void CIoPersistentConsole::TIoWriterProxy::SetCursorPosRelL(const TPoint& aPos, MIoWriteEndPoint* aEndPoint)
       
   790 	{
       
   791 	SetFlag(ESetCursorPosRelPending);
       
   792 	iSetCursPosRelPoint = aPos;
       
   793 	if (aEndPoint)
       
   794 		{
       
   795 		aEndPoint->IowepSetCursorPosRelL(iSetCursPosRelPoint, *this);
       
   796 		}
       
   797 	}
       
   798 	
       
   799 void CIoPersistentConsole::TIoWriterProxy::SetCursorHeightL(TInt aPercentage, MIoWriteEndPoint* aEndPoint)
       
   800 	{
       
   801 	SetFlag(ESetCursorHeightPending);
       
   802 	iSetCursorHeight = aPercentage;
       
   803 	if (aEndPoint)
       
   804 		{
       
   805 		aEndPoint->IowepSetCursorHeightL(iSetCursorHeight, *this);
       
   806 		}
       
   807 	}
       
   808 	
       
   809 void CIoPersistentConsole::TIoWriterProxy::SetTitleL(MIoWriteEndPoint* aEndPoint)
       
   810 	{
       
   811 	SetFlag(ESetTitlePending);
       
   812 	if (aEndPoint)
       
   813 		{
       
   814 		aEndPoint->IowepSetTitleL(*this);
       
   815 		}
       
   816 	}
       
   817 
       
   818 void CIoPersistentConsole::TIoWriterProxy::ClearScreenL(MIoWriteEndPoint* aEndPoint)
       
   819 	{
       
   820 	SetFlag(EClearScreenPending);
       
   821 	if (aEndPoint)
       
   822 		{
       
   823 		aEndPoint->IowepClearScreenL(*this);
       
   824 		}
       
   825 	}
       
   826 
       
   827 void CIoPersistentConsole::TIoWriterProxy::ClearToEndOfLineL(MIoWriteEndPoint* aEndPoint)
       
   828 	{
       
   829 	SetFlag(EClearToEndOfLinePending);
       
   830 	if (aEndPoint)
       
   831 		{
       
   832 		aEndPoint->IowepClearToEndOfLineL(*this);
       
   833 		}
       
   834 	}
       
   835 
       
   836 void CIoPersistentConsole::TIoWriterProxy::GetScreenSizeL(MIoWriteEndPoint* aEndPoint)
       
   837 	{
       
   838 	SetFlag(EGetScreenSizePending);
       
   839 	if (aEndPoint)
       
   840 		{
       
   841 		aEndPoint->IowepScreenSizeL(*this);
       
   842 		}
       
   843 	}
       
   844 
       
   845 void CIoPersistentConsole::TIoWriterProxy::SetAttributesL(TUint aAttributes, ConsoleAttributes::TColor aForegroundColor, ConsoleAttributes::TColor aBackgroundColor, MIoWriteEndPoint* aEndPoint)
       
   846 	{
       
   847 	SetFlag(ESetAttributesPending);
       
   848 	iAttributes = aAttributes;
       
   849 	iForegroundColor = aForegroundColor;
       
   850 	iBackgroundColor = aBackgroundColor;
       
   851 	if (aEndPoint)
       
   852 		{
       
   853 		aEndPoint->IowepSetAttributesL(iAttributes, iForegroundColor, iBackgroundColor, *this);
       
   854 		}
       
   855 	}
       
   856 
       
   857 TInt CIoPersistentConsole::TIoWriterProxy::IowWriteLength() const
       
   858 	{
       
   859 	return iWriter.IowWriteLength();
       
   860 	}
       
   861 
       
   862 TInt CIoPersistentConsole::TIoWriterProxy::IowWrite(TDes& aBuf)
       
   863 	{
       
   864 	return iWriter.IowWrite(aBuf);
       
   865 	}
       
   866 
       
   867 void CIoPersistentConsole::TIoWriterProxy::IowComplete(TInt aError)
       
   868 	{
       
   869 	if (aError == KErrNone)
       
   870 		{
       
   871 		iWriter.IowComplete(KErrNone);
       
   872 		ClearFlag(EWritePending);
       
   873 		}
       
   874 	else
       
   875 		{
       
   876 		SetFlag(EDetaching);
       
   877 		iOwner.DetachTransientWriter();
       
   878 		ClearFlag(EDetaching);
       
   879 		}
       
   880 	}
       
   881 
       
   882 TName CIoPersistentConsole::TIoWriterProxy::IowName()
       
   883 	{
       
   884 	TName name(iWriter.IowName());
       
   885 	if (name.Length() + KProxySuffix().Length() > name.MaxLength())
       
   886 		{
       
   887 		name.SetLength(name.MaxLength() - KProxySuffix().Length());
       
   888 		}
       
   889 	name.Append(KProxySuffix);
       
   890 	return name;
       
   891 	}
       
   892 
       
   893 RIoReadWriteHandle::TMode CIoPersistentConsole::TIoWriterProxy::IorwMode() const
       
   894 	{
       
   895 	return iWriter.IorwMode();
       
   896 	}
       
   897 	
       
   898 void CIoPersistentConsole::TIoWriterProxy::IowCursorPos(TInt aError, TPoint aPos)
       
   899 	{
       
   900 	ClearFlag(EGetCursorPosPending);
       
   901 	iWriter.IowCursorPos(aError, aPos);
       
   902 	}
       
   903 
       
   904 void CIoPersistentConsole::TIoWriterProxy::IowSetCursorPosAbsComplete(TInt aError)
       
   905 	{
       
   906 	ClearFlag(ESetCursorPosAbsPending);
       
   907 	iWriter.IowSetCursorPosAbsComplete(aError);
       
   908 	}
       
   909 
       
   910 void CIoPersistentConsole::TIoWriterProxy::IowSetCursorPosRelComplete(TInt aError)
       
   911 	{
       
   912 	ClearFlag(ESetCursorPosRelPending);
       
   913 	iWriter.IowSetCursorPosRelComplete(aError);
       
   914 	}
       
   915 	
       
   916 void CIoPersistentConsole::TIoWriterProxy::IowSetCursorHeightComplete(TInt aError)
       
   917 	{
       
   918 	ClearFlag(ESetCursorHeightPending);
       
   919 	iWriter.IowSetCursorHeightComplete(aError);
       
   920 	}
       
   921 	
       
   922 void CIoPersistentConsole::TIoWriterProxy::IowSetTitleComplete(TInt aError)
       
   923 	{
       
   924 	ClearFlag(ESetTitlePending);
       
   925 	iWriter.IowSetTitleComplete(aError);
       
   926 	}
       
   927 
       
   928 void CIoPersistentConsole::TIoWriterProxy::IowClearScreenComplete(TInt aError)
       
   929 	{
       
   930 	ClearFlag(EClearScreenPending);
       
   931 	iWriter.IowClearScreenComplete(aError);
       
   932 	}
       
   933 
       
   934 void CIoPersistentConsole::TIoWriterProxy::IowClearToEndOfLineComplete(TInt aError)
       
   935 	{
       
   936 	ClearFlag(EClearToEndOfLinePending);
       
   937 	iWriter.IowClearToEndOfLineComplete(aError);
       
   938 	}
       
   939 
       
   940 void CIoPersistentConsole::TIoWriterProxy::IowScreenSize(TInt aError, TSize aSize)
       
   941 	{
       
   942 	ClearFlag(EGetScreenSizePending);
       
   943 	iWriter.IowScreenSize(aError, aSize);
       
   944 	}
       
   945 
       
   946 void CIoPersistentConsole::TIoWriterProxy::IowSetAttributesComplete(TInt aError)
       
   947 	{
       
   948 	ClearFlag(ESetAttributesPending);
       
   949 	iWriter.IowSetAttributesComplete(aError);
       
   950 	}
       
   951 	
       
   952 HBufC* CIoPersistentConsole::TIoWriterProxy::IowTitleLC()
       
   953 	{
       
   954 	return iWriter.IowTitleLC();
       
   955 	}
       
   956 
       
   957 //______________________________________________________________________________
       
   958 //							TIoReaderProxy
       
   959 //	MIoReader proxy - to service read requests from transient side
       
   960 CIoPersistentConsole::TIoReaderProxy::TIoReaderProxy(MIoReader& aReader, CIoPersistentConsole& aOwner)
       
   961 	: iReader(aReader), iOwner(aOwner), iDetaching(EFalse), iSetConsoleModePending(EFalse)
       
   962 	{
       
   963 	}
       
   964 	
       
   965 void CIoPersistentConsole::TIoReaderProxy::TransientReaderAttached(MIoReadEndPoint& aReader)
       
   966 	{
       
   967 	if (iReader.IorReadPending())
       
   968 		{
       
   969 		TRAPD(err, aReader.IorepReadL(*this));
       
   970 		if (err)
       
   971 			{
       
   972 			IorReadComplete(err);
       
   973 			}
       
   974 		}
       
   975 	if (iReader.IorReadKeyPending())
       
   976 		{
       
   977 		TRAPD(err, aReader.IorepReadKeyL(*this));
       
   978 		if (err)
       
   979 			{
       
   980 			IorReadKeyComplete(err, EKeyNull, 0);
       
   981 			}
       
   982 		}
       
   983 	if (iSetConsoleModePending)
       
   984 		{
       
   985 		TRAP_OR(aReader.IorepSetConsoleModeL(iSetConsoleMode, *this), IorSetConsoleModeComplete(err));
       
   986 		}
       
   987 	}
       
   988 	
       
   989 void CIoPersistentConsole::TIoReaderProxy::ReadL(MIoReadEndPoint* aEndPoint)
       
   990 	{
       
   991 	if (aEndPoint)
       
   992 		{
       
   993 		aEndPoint->IorepReadL(*this);
       
   994 		}
       
   995 	}
       
   996 	
       
   997 void CIoPersistentConsole::TIoReaderProxy::ReadKeyL(MIoReadEndPoint* aEndPoint)
       
   998 	{
       
   999 	if (aEndPoint)
       
  1000 		{
       
  1001 		aEndPoint->IorepReadKeyL(*this);
       
  1002 		}
       
  1003 	}
       
  1004 	
       
  1005 void CIoPersistentConsole::TIoReaderProxy::SetConsoleModeL(MIoReadEndPoint* aEndPoint, RIoReadWriteHandle::TMode aMode)
       
  1006 	{
       
  1007 	iSetConsoleModePending = ETrue;
       
  1008 	iSetConsoleMode = aMode;
       
  1009 	if (aEndPoint)
       
  1010 		{
       
  1011 		CleanupNullPointerPushL((TAny**)&iSetConsoleModePending);
       
  1012 		aEndPoint->IorepSetConsoleModeL(iSetConsoleMode, *this);
       
  1013 		CleanupStack::Pop();
       
  1014 		}
       
  1015 	}
       
  1016 	
       
  1017 MIoReader& CIoPersistentConsole::TIoReaderProxy::ClientReader() const
       
  1018 	{
       
  1019 	return iReader;
       
  1020 	}
       
  1021 
       
  1022 RIoReadWriteHandle::TMode CIoPersistentConsole::TIoReaderProxy::IorwMode() const
       
  1023 	{
       
  1024 	return iReader.IorwMode();
       
  1025 	}
       
  1026 
       
  1027 TBool CIoPersistentConsole::TIoReaderProxy::IorReadPending() const
       
  1028 	{
       
  1029 	return iReader.IorReadPending();
       
  1030 	}
       
  1031 
       
  1032 TBool CIoPersistentConsole::TIoReaderProxy::IorReadKeyPending() const
       
  1033 	{
       
  1034 	return iReader.IorReadKeyPending();
       
  1035 	}
       
  1036 
       
  1037 
       
  1038 TDes& CIoPersistentConsole::TIoReaderProxy::IorReadBuf()
       
  1039 	{
       
  1040 	return iReader.IorReadBuf();
       
  1041 	}
       
  1042 
       
  1043 void CIoPersistentConsole::TIoReaderProxy::IorDataBuffered(TInt aLength)
       
  1044 	{
       
  1045 	iReader.IorDataBuffered(aLength);
       
  1046 	}
       
  1047 
       
  1048 TBool CIoPersistentConsole::TIoReaderProxy::IorDataIsBuffered() const
       
  1049 	{
       
  1050 	return iReader.IorDataIsBuffered();
       
  1051 	}
       
  1052 
       
  1053 
       
  1054 TBool CIoPersistentConsole::TIoReaderProxy::IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers)
       
  1055 	{
       
  1056 	return iReader.IorIsKeyCaptured(aKeyCode, aModifiers);
       
  1057 	}
       
  1058 
       
  1059 void CIoPersistentConsole::TIoReaderProxy::IorReadComplete(TInt /*aError*/)
       
  1060 	{
       
  1061 	// indicates that the read end point will be providing no more data
       
  1062 	// so detatch it
       
  1063 	iDetaching = ETrue;
       
  1064 	iOwner.DetachTransientReader();
       
  1065 	iDetaching = EFalse;
       
  1066 	}
       
  1067 
       
  1068 void CIoPersistentConsole::TIoReaderProxy::IorReadKeyComplete(TInt aError, TUint aKeyCode, TUint aModifiers)
       
  1069 	{
       
  1070 	if (aError == KErrEof)
       
  1071 		{
       
  1072 		// indicates that the read end point will be providing no more data
       
  1073 		// so detatch it
       
  1074 		iOwner.DetachTransientReader();
       
  1075 		}
       
  1076 	else
       
  1077 		{
       
  1078 		iReader.IorReadKeyComplete(aError, aKeyCode, aModifiers);
       
  1079 		}
       
  1080 	}
       
  1081 
       
  1082 TName CIoPersistentConsole::TIoReaderProxy::IorName()
       
  1083 	{
       
  1084 	TName name(iReader.IorName());
       
  1085 	if (name.Length() + KProxySuffix().Length() > name.MaxLength())
       
  1086 		{
       
  1087 		name.SetLength(name.MaxLength() - KProxySuffix().Length());
       
  1088 		}
       
  1089 	name.Append(KProxySuffix);
       
  1090 	return name;
       
  1091 	}
       
  1092 
       
  1093 void CIoPersistentConsole::TIoReaderProxy::IorReaderChange(TUint aChange)
       
  1094 	{
       
  1095 	iReader.IorReaderChange(aChange);
       
  1096 	}
       
  1097 
       
  1098 void CIoPersistentConsole::TIoReaderProxy::IorSetConsoleModeComplete(TInt aError)
       
  1099 	{
       
  1100 	iSetConsoleModePending = EFalse;
       
  1101 	iReader.IorSetConsoleModeComplete(aError);
       
  1102 	}
       
  1103 
       
  1104 //______________________________________________________________________________
       
  1105 //						TConsoleTitleSetter
       
  1106 TConsoleTitleSetter::TConsoleTitleSetter(HBufC*& aTitle)
       
  1107 	: iTitle(aTitle)
       
  1108 	{
       
  1109 	}
       
  1110 
       
  1111 TInt TConsoleTitleSetter::IowWriteLength() const
       
  1112 	{
       
  1113 	ASSERT(0);
       
  1114 	return 0;
       
  1115 	}
       
  1116 
       
  1117 TInt TConsoleTitleSetter::IowWrite(TDes&)
       
  1118 	{
       
  1119 	ASSERT(0);
       
  1120 	return 0;
       
  1121 	}
       
  1122 
       
  1123 void TConsoleTitleSetter::IowComplete(TInt)
       
  1124 	{
       
  1125 	ASSERT(0);
       
  1126 	}
       
  1127 
       
  1128 TName TConsoleTitleSetter::IowName()
       
  1129 	{
       
  1130 	ASSERT(0);
       
  1131 	return TName();
       
  1132 	}
       
  1133 
       
  1134 RIoReadWriteHandle::TMode TConsoleTitleSetter::IorwMode() const
       
  1135 	{
       
  1136 	ASSERT(0);
       
  1137 	return RIoReadWriteHandle::EText;
       
  1138 	}
       
  1139 
       
  1140 void TConsoleTitleSetter::IowCursorPos(TInt, TPoint)
       
  1141 	{
       
  1142 	ASSERT(0);
       
  1143 	}
       
  1144 
       
  1145 void TConsoleTitleSetter::IowSetCursorPosAbsComplete(TInt)
       
  1146 	{
       
  1147 	ASSERT(0);
       
  1148 	}
       
  1149 
       
  1150 void TConsoleTitleSetter::IowSetCursorPosRelComplete(TInt)
       
  1151 	{
       
  1152 	ASSERT(0);
       
  1153 	}
       
  1154 
       
  1155 void TConsoleTitleSetter::IowSetCursorHeightComplete(TInt)
       
  1156 	{
       
  1157 	ASSERT(0);
       
  1158 	}
       
  1159 
       
  1160 void TConsoleTitleSetter::IowSetTitleComplete(TInt)
       
  1161 	{
       
  1162 	}
       
  1163 
       
  1164 void TConsoleTitleSetter::IowClearScreenComplete(TInt)
       
  1165 	{
       
  1166 	ASSERT(0);
       
  1167 	}
       
  1168 
       
  1169 void TConsoleTitleSetter::IowClearToEndOfLineComplete(TInt)
       
  1170 	{
       
  1171 	ASSERT(0);
       
  1172 	}
       
  1173 
       
  1174 void TConsoleTitleSetter::IowScreenSize(TInt, TSize)
       
  1175 	{
       
  1176 	ASSERT(0);
       
  1177 	}
       
  1178 
       
  1179 void TConsoleTitleSetter::IowSetAttributesComplete(TInt)
       
  1180 	{
       
  1181 	ASSERT(0);
       
  1182 	}
       
  1183 
       
  1184 HBufC* TConsoleTitleSetter::IowTitleLC()
       
  1185 	{
       
  1186 	return iTitle->AllocLC();
       
  1187 	}
       
  1188 
       
  1189