Migrated from FCL: foreach bugfix, ConsoleSize::ReportedCorrectly() and ConsoleSize::NotifySizeChanged() console extensions
authorTom Sutcliffe <thomas.sutcliffe@accenture.com>
Thu, 04 Nov 2010 23:22:39 +0000
changeset 83 706c7a69e448
parent 82 a6fec624de6c
child 84 048f57d1123c
Migrated from FCL: foreach bugfix, ConsoleSize::ReportedCorrectly() and ConsoleSize::NotifySizeChanged() console extensions
core/builtins/hello.cpp
core/builtins/hello.h
core/src/commands.cpp
core/src/commands.h
core/src/parser.cpp
core/src/parser.h
documentation/change_history.pod
libraries/iosrv/data/iosrv.idf
libraries/iosrv/data/iosrv.ini.econs
libraries/iosrv/data/iosrv.ini.econs_fb
libraries/iosrv/data/iosrv.ini.eka2
libraries/iosrv/data/iosrv.ini.noautodetect
libraries/iosrv/group/bld.inf
libraries/iosrv/server/config.cpp
libraries/iosrv/server/config.h
libraries/iosrv/server/console.cpp
libraries/iosrv/server/console.h
libraries/iosrv/server/persistentconsole.cpp
libraries/iosrv/server/persistentconsole.h
libraries/iosrv/server/readwrite.cpp
libraries/iosrv/server/readwrite.h
plugins/consoles/common/consoleextensions.cpp
plugins/consoles/common/consoleextensions.h
plugins/consoles/common/consoleextensions.inl
plugins/consoles/defcons/src/defcons.cpp
plugins/consoles/guicons/src/guicons.cpp
plugins/consoles/nullcons/src/nullcons.cpp
plugins/consoles/rcons/client/group/remote_console.mmp
plugins/consoles/tefcons/tefcons.cpp
plugins/consoles/vt100cons/doc/vt100cons.pod
plugins/consoles/vt100cons/inc/vtc_controller.h
plugins/consoles/vt100cons/src/vt100/vtc_controller.cpp
--- a/core/builtins/hello.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/core/builtins/hello.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -12,7 +12,6 @@
 
 #include "hello.h"
 
-
 CCommandBase* CCmdHello::NewLC()
 	{
 	CCmdHello* self = new(ELeave) CCmdHello();
@@ -21,14 +20,6 @@
 	return self;
 	}
 
-CCmdHello::~CCmdHello()
-	{
-	}
-
-CCmdHello::CCmdHello()
-	{
-	}
-
 const TDesC& CCmdHello::Name() const
 	{
 	_LIT(KName, "hello");
--- a/core/builtins/hello.h	Thu Nov 04 20:51:05 2010 +0000
+++ b/core/builtins/hello.h	Thu Nov 04 23:22:39 2010 +0000
@@ -18,9 +18,6 @@
 	{
 public:
 	static CCommandBase* NewLC();
-	~CCmdHello();
-private:
-	CCmdHello();
 private: // From CCommandBase.
 	virtual const TDesC& Name() const;
 	virtual void DoRunL();
--- a/core/src/commands.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/core/src/commands.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -3880,7 +3880,16 @@
 		{
 		aError.Report();
 		}
-
+	IterationComplete(aError.Error());
+	}
+
+void CCmdTime::HandleParserExit(CParser&)
+	{
+	IterationComplete(KErrNone);
+	}
+
+void CCmdTime::IterationComplete(TInt aError)
+	{
 	TUint32 countAfter = iFastCounter ? User::FastCounter() : User::NTickCount();
 	
 	TUint64 difference;
@@ -3938,9 +3947,9 @@
 			Printf(_L("%Lu\r\n"), difference);
 			}
 		}
-	if (aError.Error() < 0 || iIteration == iRepeatCount)
-		{
-		Complete(aError.Error());
+	if (aError < 0 || iIteration == iRepeatCount)
+		{
+		Complete(aError);
 		}
 	else
 		{
@@ -4009,21 +4018,29 @@
 
 void CCmdRepeat::HandleParserComplete(CParser&, const TError& aError)
 	{
-	TRAPD(err, HandleParserCompleteL(aError));
+	if (aError.Error() < 0)
+		{
+		aError.Report();
+		}
+	TRAPD(err, HandleParserCompleteL(aError.Error()));
 	if (err)
 		{
 		Complete(err);
 		}
 	}
 
-void CCmdRepeat::HandleParserCompleteL(const TError& aError)
-	{
-	if (aError.Error() < 0)
-		{
-		aError.Report();
-		}
-
-	if (((aError.Error() == KErrNone) || iKeepGoing) && ((++iCount < iNumRepeats) || iForever))
+void CCmdRepeat::HandleParserExit(CParser&)
+	{
+	TRAPD(err, HandleParserCompleteL(KErrNone));
+	if (err)
+		{
+		Complete(err);
+		}
+	}
+
+void CCmdRepeat::HandleParserCompleteL(TInt aError)
+	{
+	if (((aError == KErrNone) || iKeepGoing) && ((++iCount < iNumRepeats) || iForever))
 		{
 		delete iParser;
 		iParser = NULL;
@@ -4032,7 +4049,7 @@
 		}
 	else
 		{
-		Complete(aError.Error());
+		Complete(aError);
 		}
 	}
 
@@ -6183,8 +6200,17 @@
 		PrintError(err, _L("Aborted \"%S\" at line %d"), &aError.ScriptFileName(), aError.ScriptLineNumber());
 		iLastError = err;
 		}
-
-	if ((err < 0) && !iKeepGoing)
+	IterationComplete(err);
+	}
+
+void CCmdForEach::HandleParserExit(CParser&)
+	{
+	IterationComplete(KErrNone);
+	}
+
+void CCmdForEach::IterationComplete(TInt aError)
+	{
+	if ((aError < 0) && !iKeepGoing)
 		{
 		Complete(iLastError);
 		}
--- a/core/src/commands.h	Thu Nov 04 20:51:05 2010 +0000
+++ b/core/src/commands.h	Thu Nov 04 23:22:39 2010 +0000
@@ -820,6 +820,7 @@
 private:
 	CCmdTime();
 	void NextIterationL();
+	void IterationComplete(TInt aError);
 private: // From CCommandBase.
 	virtual const TDesC& Name() const;
 	virtual void DoRunL();
@@ -827,6 +828,7 @@
 	virtual void OptionsL(RCommandOptionList& aOptions);
 private: // From MParserObserver.
 	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+	virtual void HandleParserExit(CParser& aParser);
 private:
 	HBufC* iCommandLine;
 	TUint32 iCountBefore;
@@ -847,7 +849,7 @@
 private:
 	CCmdRepeat();
 	void CreateParserL();
-	void HandleParserCompleteL(const TError& aError);
+	void HandleParserCompleteL(TInt aError);
 private: // From CCommandBase.
 	virtual const TDesC& Name() const;
 	virtual void DoRunL();
@@ -855,6 +857,7 @@
 	virtual void OptionsL(RCommandOptionList& aOptions);
 private: // From MParserObserver.
 	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+	virtual void HandleParserExit(CParser& aParser);
 private:
 	HBufC* iCommandLine;
 	CParser* iParser;
@@ -1254,12 +1257,14 @@
 private:
 	CCmdForEach();
 	void DoNextL(TBool aFirstTime=EFalse);
+	void IterationComplete(TInt aError);
 private: // From CCommandBase.
 	virtual const TDesC& Name() const;
 	virtual void DoRunL();
 	virtual void ArgumentsL(RCommandArgumentList& aArguments);
 private: // From MParserObserver.
 	virtual void HandleParserComplete(CParser& aParser, const TError& aError);
+	virtual void HandleParserExit(CParser& aParser);
 private:
 	TFileName2 iDirName;
 	RDir iDir;
--- a/core/src/parser.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/core/src/parser.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -44,6 +44,11 @@
 _LIT(KDollar, "$");
 
 
+void MParserObserver::HandleParserExit(CParser&)
+	{
+	CActiveScheduler::Stop();
+	}
+
 void MParserObserver::AboutToExecuteLine(const TDesC&, const TDesC&)
 	{
 	}
@@ -488,16 +493,8 @@
 			// thread or in the thread belonging to a 'source' or 'debug' command) to be dropped. That's a good thing, because local commands
 			// can't synchronously interact with iosrv without risk of deadlock when two or more thread commands are run in a pipe-line. 
 			CleanupStack::PopAndDestroy(2, &pipeSections);
-			if (CActiveScheduler::Current()->StackDepth() > 0)
-				{
-				CActiveScheduler::Stop();
-				}
-			else
-				{
-				// The active scheduler hasn't been started yet. Probably because someone is doing something crazy like 'fshell -e exit'.
-				iExitCallBack = new(ELeave) CAsyncCallBack(TCallBack(ExitCallBack, this), CActive::EPriorityStandard);
-				iExitCallBack->Call();
-				}
+			iExitCallBack = new(ELeave) CAsyncCallBack(TCallBack(ExitCallBack, this), CActive::EPriorityStandard);
+			iExitCallBack->Call();
 			}
 		else
 			{
@@ -819,9 +816,10 @@
 	return KErrNone;
 	}
 
-TInt CParser::ExitCallBack(TAny*)
+TInt CParser::ExitCallBack(TAny* aSelf)
 	{
-	CActiveScheduler::Stop();
+	CParser* self = static_cast<CParser*>(aSelf);
+	self->iObserver->HandleParserExit(*self);
 	return KErrNone;
 	}
 
--- a/core/src/parser.h	Thu Nov 04 20:51:05 2010 +0000
+++ b/core/src/parser.h	Thu Nov 04 23:22:39 2010 +0000
@@ -25,6 +25,7 @@
 	{
 public:
 	virtual void HandleParserComplete(CParser& aParser, const TError& aError) = 0;
+	virtual void HandleParserExit(CParser& aParser);
 	virtual void AboutToExecuteLine(const TDesC& aOrignalLine, const TDesC& aExpandedLine);
 	virtual void LineReturned(TInt aError);
 	};
--- a/documentation/change_history.pod	Thu Nov 04 20:51:05 2010 +0000
+++ b/documentation/change_history.pod	Thu Nov 04 23:22:39 2010 +0000
@@ -74,6 +74,19 @@
 
 Fixed a bug in iocli.dll that could cause environment variable updates to be ignored.
 
+=item *
+
+Fixed a bug in fshell that could cause 'foreach' commands to exit prematurely.
+
+=item *
+
+Added new console extension functions: ConsoleSize::ReportedCorrectly(), ConsoleSize::NotifySizeChanged().
+
+=item *
+
+Removed iosrv.ini's console_size_detect setting. It is now calculated on a per-console basis whether the console requires size detection, based on whether the console implements the C<ConsoleSize::ReportedCorrectly()> extension. All the fshell-supplied consoles have been updated to implement this extension as appropriate, meaning that size detection will no longer be run unnecessarily on (for eg) win32cons when you run fshell.bat. As part of this work, the laziness of defcons (CDefaultConsole) has been removed as it overlapped unnecessarily with CLazyConsole. Defcons's sole responsibility now is to pick an appropriate console; lazycons is responsible for making sure it isn't instantiated prematurely.
+
+
 =back
 
 =head2 Release 001
--- a/libraries/iosrv/data/iosrv.idf	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/data/iosrv.idf	Thu Nov 04 23:22:39 2010 +0000
@@ -18,8 +18,3 @@
 console_size_adjustment 		string
 console_size_adjustment.name		Console size adjustment
 console_size_adjustment.description	Console size adjustment, in format 'x,y'
-
-console_size_detect			boolean
-console_size_detect.name		Autodetect console size
-console_size_detect.description		Automatically detect the size of consoles that are created by the IO server
-console_size_detect.default		true
--- a/libraries/iosrv/data/iosrv.ini.econs	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/data/iosrv.ini.econs	Thu Nov 04 23:22:39 2010 +0000
@@ -11,4 +11,3 @@
 # Accenture - Initial contribution
 #
 console			econs.dll
-console_size_detect	1
--- a/libraries/iosrv/data/iosrv.ini.econs_fb	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/data/iosrv.ini.econs_fb	Thu Nov 04 23:22:39 2010 +0000
@@ -11,4 +11,3 @@
 # Accenture - Initial contribution
 #
 console			econs_fb.dll
-console_size_detect	1
--- a/libraries/iosrv/data/iosrv.ini.eka2	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/data/iosrv.ini.eka2	Thu Nov 04 23:22:39 2010 +0000
@@ -11,4 +11,3 @@
 # Accenture - Initial contribution
 #
 console			econseik.dll
-console_size_detect	1
--- a/libraries/iosrv/data/iosrv.ini.noautodetect	Thu Nov 04 20:51:05 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-#!iniedit -i \resource\iosrv.idf
-# iosrv.ini.noautodetect
-# 
-# Copyright (c) 2010 Accenture. All rights reserved.
-# This component and the accompanying materials are made available
-# under the terms of the "Eclipse Public License v1.0"
-# which accompanies this distribution, and is available
-# at the URL "http://www.eclipse.org/legal/epl-v10.html".
-# 
-# Initial Contributors:
-# Accenture - Initial contribution
-#
-
-console_size_detect false
--- a/libraries/iosrv/group/bld.inf	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/group/bld.inf	Thu Nov 04 23:22:39 2010 +0000
@@ -23,7 +23,6 @@
 ..\data\iosrv.ini.remote \epoc32\winscw\c\system\console\iosrv.ini.remote
 
 ..\data\iosrv.ini.econs_fb Z:\system\console\iosrv.ini.econs_fb
-..\data\iosrv.ini.noautodetect Z:\system\console\iosrv.ini.noautodetect
 ..\data\iosrv.ini.bluetooth Z:\system\console\iosrv.ini.bluetooth
 
 PRJ_MMPFILES
--- a/libraries/iosrv/server/config.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/server/config.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -25,11 +25,10 @@
 // Configuration attributes.
 _LIT(KAttConsole, "console");
 _LIT(KAttConsoleSizeAdjustment, "console_size_adjustment");
-_LIT(KAttConsoleSizeDetect, "console_size_detect");
 
 
 TIoConfig::TIoConfig()
-	: iConsoleImplementation(KDefaultConsole), iConsoleSizeAdjustment(KDefaultSizeAdjustment), iConsoleSizeDetect(ETrue)
+	: iConsoleImplementation(KDefaultConsole), iConsoleSizeAdjustment(KDefaultSizeAdjustment)
 	{
 	}
 
@@ -46,7 +45,6 @@
 	{
 	TInt ret = KErrNone;
 	iConsoleImplementation.Copy(iniFile->GetString(KAttConsole).Left(iConsoleImplementation.MaxLength()));
-	iConsoleSizeDetect = iniFile->GetBool(KAttConsoleSizeDetect);
 	const TDesC& sizeAdjust(iniFile->GetString(KAttConsoleSizeAdjustment));
 	if (sizeAdjust.Length())
 		{
@@ -56,7 +54,6 @@
 		lex.Get(); // Skip delimiter.
 		ret = lex.Val(iConsoleSizeAdjustment.iHeight);
 		if (ret) return ret;
-		iConsoleSizeDetect = EFalse;
 		}
 	return ret;
 	}
@@ -70,8 +67,3 @@
 	{
 	return iConsoleSizeAdjustment;
 	}
-
-TBool TIoConfig::ConsoleSizeDetect() const
-	{
-	return iConsoleSizeDetect;
-	}
--- a/libraries/iosrv/server/config.h	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/server/config.h	Thu Nov 04 23:22:39 2010 +0000
@@ -26,13 +26,11 @@
 	TInt Init();
 	const TDesC& ConsoleImplementation() const;
 	const TSize& ConsoleSizeAdjustment() const;
-	TBool ConsoleSizeDetect() const;
 private:
 	TInt DoInit(LtkUtils::CIniFile* iniFile);
 
 private:
 	TFileName iConsoleImplementation;
 	TSize iConsoleSizeAdjustment;
-	TBool iConsoleSizeDetect;
 	};
 
--- a/libraries/iosrv/server/console.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/server/console.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -52,8 +52,9 @@
 	iRequestQueue.Close();
 	delete iImplementation;
 	delete iReader;
+	delete iConsoleSizeChangedNotifier;
 	iConsole.Close();
-	delete iCreationTitle ;
+	delete iCreationTitle;
 	iServerThread.Close();
 	}
 
@@ -99,10 +100,7 @@
 
 void CIoConsole::IorepReadL(MIoReader&)
 	{
-	if (!iReader->IsActive())
-		{
-		iReader->QueueRead();
-		}
+	QueueReaderIfRequired();
 	}
 
 void CIoConsole::IorepReadKeyL(MIoReader& aReader)
@@ -197,10 +195,6 @@
 		{
 		User::LeaveIfError(iConsole.SetLazyConstruct());
 		}
-	if (iConfig.ConsoleSizeDetect())
-		{
-		User::LeaveIfError(iConsole.SetConsoleSizeDetect());
-		}
 	if (aUnderlying)
 		{
 		User::LeaveIfError(aUnderlying->Open());
@@ -211,6 +205,7 @@
 	NewRequest(new(ELeave)TConsoleCreateRequest(*this));
 		
 	iReader = CConsoleReader::NewL(*this);
+	iConsoleSizeChangedNotifier = new(ELeave) CConsoleSizeChangedNotifier(*this);
 	}
 	
 void CIoConsole::CreateComplete(TInt aError)
@@ -276,16 +271,7 @@
 		{
 		if (reader->IorIsKeyCaptured(aKeyCode, aModifiers))
 			{
-			if (reader->IorReadPending())
-				{
-				TPtrC keyCodePtr((TUint16*)&aKeyCode, 1);
-				reader->IorReadBuf().Append(keyCodePtr);
-				reader->IorDataBuffered(1);
-				}
-			else
-				{
-				reader->IorReadKeyComplete(KErrNone, aKeyCode, aModifiers);
-				}
+			reader->IorReadKeyComplete(KErrNone, aKeyCode, aModifiers);
 			keyHandled = ETrue;
 			break;
 			}
@@ -306,6 +292,7 @@
 	TBool pendingReader(EFalse);
 	TInt index = 0;
 	MIoReader* reader = AttachedReader(index++);
+	TBool foregroundReader(ETrue);
 	while (reader)
 		{
 		if (reader->IorReadPending() || reader->IorReadKeyPending())
@@ -313,7 +300,13 @@
 			pendingReader = ETrue;
 			break;
 			}
+		if (foregroundReader && reader->IorAllKeysCaptured())
+			{
+			// If the foreground reader has captured all keys, we don't care about the background readers.
+			break;
+			}
 		reader = AttachedReader(index++);
+		foregroundReader = EFalse;
 		}
 
 	if (pendingReader && !iReader->IsActive())
@@ -841,11 +834,6 @@
 
 //______________________________________________________________________________
 //						RIoConsoleProxy
-TInt RIoConsoleProxy::SetConsoleSizeDetect()
-	{
-	return SendReceive(ESetConsoleSizeDetect);
-	}
-	
 TInt RIoConsoleProxy::SetLazyConstruct()
 	{
 	return SendReceive(ESetLazyConstruct);
@@ -871,6 +859,16 @@
 	SendReceive(EWriteStdErr, TIpcArgs(&aDescriptor), aStatus);
 	}
 
+void RIoConsoleProxy::NotifySizeChanged(TRequestStatus& aStatus)
+	{
+	SendReceive(ENotifySizeChange, TIpcArgs(), aStatus);
+	}
+
+void RIoConsoleProxy::CancelNotifySizeChanged()
+	{
+	SendReceive(ECancelNotifySizeChange, TIpcArgs());
+	}
+
 //______________________________________________________________________________
 //						CIoConsoleProxyServer
 CConsoleProxyServer* CIoConsoleProxyServerNewL(TAny* aParams)
@@ -983,6 +981,7 @@
 
 CIoConsoleProxySession::~CIoConsoleProxySession()
 	{
+	delete iSizeChangedMessageCompleter;
 	delete iUnderlyingConsole;
 	}
 
@@ -990,11 +989,6 @@
 	{
 	switch (aMessage.Function())
 		{
-	case RIoConsoleProxy::ESetConsoleSizeDetect:
-		if (iConsole) User::Leave(KErrNotReady); // too late!
-		SetFlag(EAutoDetectSize, ETrue);
-		aMessage.Complete(KErrNone);
-		return;
 	case RIoConsoleProxy::ESetLazyConstruct:
 		if (iConsole) User::Leave(KErrNotReady); // too late!
 		SetFlag(ELazy, ETrue);
@@ -1010,11 +1004,12 @@
 		OpenExistingL(aMessage);
 		return;	
 	case RConsoleProxy::EGetScreenSize:
-		if (GetFlag(EAutoDetectSize) && !GetFlag(ELazy))
+		if (GetFlag(EHaveDetectedSize))
 			{
 			DetectSizeL(aMessage);
 			return;
 			}
+		// Otherwise drop through to CConsoleProxySession's implementation
 		break;
 	case RIoConsoleProxy::EWriteStdErr:
 		{
@@ -1040,6 +1035,26 @@
 		aMessage.Complete(KErrNone);
 		return;
 		}
+	case RIoConsoleProxy::ENotifySizeChange:
+		{
+		if (iSizeChangedMessageCompleter == NULL)
+			{
+			iSizeChangedMessageCompleter = new(ELeave) CSizeChangeMessageCompleter;
+			if (iConsole) iSizeChangedMessageCompleter->SetConsole(iConsole->Console());
+			}
+		iSizeChangedMessageCompleter->NotifySizeChange(const_cast<RMessage2&>(aMessage));
+		return;
+		}
+	case RIoConsoleProxy::ECancelNotifySizeChange:
+		{
+		//RDebug::Printf("case RIoConsoleProxy::ECancelNotifySizeChange ");
+		if (iSizeChangedMessageCompleter)
+			{
+			iSizeChangedMessageCompleter->CancelNotify();
+			}
+		aMessage.Complete(KErrNone);
+		return;
+		}
 	default:
 		break;
 		}
@@ -1057,7 +1072,7 @@
 	MProxiedConsole* cons;
 	if (GetFlag(ELazy))
 		{
-		CLazyConsole* lazy = new(ELeave)CLazyConsole(iConsoleCreate, GetFlag(EAutoDetectSize));
+		CLazyConsole* lazy = new(ELeave) CLazyConsole(iConsoleCreate);
 		CleanupStack::PushL(lazy);
 		cons = MProxiedConsole::DefaultL(lazy);
 		CleanupStack::Pop();
@@ -1086,10 +1101,18 @@
 	
 void CIoConsoleProxySession::ConsoleCreatedL(MProxiedConsole* aConsole)
 	{
-	if (GetFlag(EAutoDetectSize) && !(GetFlag(ELazy)))
+	if (!GetFlag(ELazy))
 		{
-		iDetectedSize = DetectConsoleSize(aConsole->Console());
+		// If it's lazy, we can't check ReportedCorrectly until it's been instantiated
+		CConsoleBase* console = aConsole->Console();
+		if (!ConsoleSize::ReportedCorrectly(console))
+			{
+			iDetectedSize = DetectConsoleSize(console);
+			SetFlag(EHaveDetectedSize, ETrue);
+			}
 		}
+
+	if (iSizeChangedMessageCompleter) iSizeChangedMessageCompleter->SetConsole(aConsole->Console());
 	}
 
 void CIoConsoleProxySession::DetectSizeL(const RMessage2& aMessage)
@@ -1207,8 +1230,8 @@
 
 //______________________________________________________________________________
 //						CLazyConsole
-CLazyConsole::CLazyConsole(TConsoleCreateFunction aConsoleCreate, TBool aAutoDetectSize)
-	: iConsoleCreate(aConsoleCreate), iSizeAutoDetect(aAutoDetectSize)
+CLazyConsole::CLazyConsole(TConsoleCreateFunction aConsoleCreate)
+	: iConsoleCreate(aConsoleCreate)
 	{
 	}
 
@@ -1240,10 +1263,17 @@
 		iCreateError = iConsole->Create(iTitle, iSize);
 		User::RenameProcess(procName.Left(procName.Locate('['))); // ...so restore it just in case
 		}
-	if ((iCreateError == KErrNone) && iSizeAutoDetect)
+	if ((iCreateError == KErrNone) && !ConsoleSize::ReportedCorrectly(iConsole))
 		{
 		iDetectedSize = DetectConsoleSize(iConsole);
+		iHaveDetectedSize = ETrue;
 		}
+	if (iCreateError == KErrNone && iStatusForNotifySizeRequest != NULL)
+		{
+		ConsoleSize::NotifySizeChanged(iConsole, *iStatusForNotifySizeRequest);
+		iStatusForNotifySizeRequest = NULL;
+		}
+
 	if (iCreateError != KErrNone)
 		{
 		delete iConsole;
@@ -1341,7 +1371,7 @@
 	{
 	if (CheckCreated() == KErrNone)
 		{
-		if (iSizeAutoDetect)
+		if (iHaveDetectedSize)
 			{
 			return iDetectedSize;
 			}
@@ -1382,6 +1412,23 @@
 		*constructed = (iConsole != NULL);
 		return KErrNone;
 		}
+	else if (iConsole == NULL && aExtensionId == ConsoleMode::KSetConsoleModeExtension && (ConsoleMode::TMode)(TUint)a1 == ConsoleMode::EText)
+		{
+		// A console that isn't created yet will default to text mode anyway so we don't need to force instantiation. This works around an issue with iosrv calling ConsoleMode::Set even on the underlying console
+		return KErrNone;
+		}
+	else if (iConsole == NULL && aExtensionId == ConsoleSize::KConsoleSizeNotifyChangedExtension)
+		{
+		// Remember this notify for later
+		TRequestStatus* stat = (TRequestStatus*)a1;
+		//RDebug::Printf("Lazycons KConsoleSizeNotifyChangedExtension a1=%x iStatusForNotifySizeRequest=%x", a1, iStatusForNotifySizeRequest);
+		if (stat == NULL && iStatusForNotifySizeRequest != NULL)
+			{
+			User::RequestComplete(iStatusForNotifySizeRequest, KErrCancel);
+			}
+		iStatusForNotifySizeRequest = stat;
+		return KErrNone; // It's ok to say KErrNone now but complete the TRequestStatus with KErrExtensionNotSupported later
+		}
 	else 
 		{
 		TInt err = CheckCreated();
@@ -1392,3 +1439,100 @@
 		return err;
 		}
 	}
+
+//
+
+CIoConsole::CConsoleSizeChangedNotifier::CConsoleSizeChangedNotifier(CIoConsole& aConsole)
+	: CActive(CActive::EPriorityStandard), iConsole(aConsole)
+	{
+	CActiveScheduler::Add(this);
+	iConsole.iConsole.NotifySizeChanged(iStatus);
+	SetActive();
+	}
+
+CIoConsole::CConsoleSizeChangedNotifier::~CConsoleSizeChangedNotifier()
+	{
+	Cancel();
+	}
+
+void CIoConsole::CConsoleSizeChangedNotifier::RunL()
+	{
+	if (iStatus.Int() != KErrNone) // eg KErrExtensionNotSupported
+		{
+		return;
+		}
+
+	iConsole.iConsole.NotifySizeChanged(iStatus);
+	SetActive();
+
+	MIoReader* fg = iConsole.AttachedReader();
+	if (fg)
+		{
+		fg->IorReaderChange(RIoReadHandle::EConsoleSizeChanged);
+		}
+	}
+
+void CIoConsole::CConsoleSizeChangedNotifier::DoCancel()
+	{
+	//RDebug::Printf("Calling RIoConsoleProxt::CancelNotifySizeChanged");
+	iConsole.iConsole.CancelNotifySizeChanged();
+	}
+
+//
+
+CSizeChangeMessageCompleter::CSizeChangeMessageCompleter()
+	: CActive(CActive::EPriorityStandard)
+	{
+	CActiveScheduler::Add(this);
+	}
+
+CSizeChangeMessageCompleter::~CSizeChangeMessageCompleter()
+	{
+	Cancel();
+	}
+
+void CSizeChangeMessageCompleter::NotifySizeChange(RMessagePtr2& aMessage)
+	{
+	iMessage = aMessage;
+	if (iActualConsole)
+		{
+		ConsoleSize::NotifySizeChanged(iActualConsole, iStatus);
+		SetActive();
+		}
+	}
+
+void CSizeChangeMessageCompleter::RunL()
+	{
+	iMessage.Complete(iStatus.Int());
+	}
+
+void CSizeChangeMessageCompleter::DoCancel()
+	{
+	ASSERT(iActualConsole);
+	ConsoleSize::CancelNotifySizeChanged(iActualConsole);
+	}
+
+void CSizeChangeMessageCompleter::SetConsole(CConsoleBase* aConsole)
+	{
+	ASSERT(iActualConsole == NULL);
+	iActualConsole = aConsole;
+	if (!iMessage.IsNull())
+		{
+		ConsoleSize::NotifySizeChanged(iActualConsole, iStatus);
+		SetActive();
+		}
+	}
+
+void CSizeChangeMessageCompleter::CancelNotify()
+	{
+	//RDebug::Printf("CSizeChangeMessageCompleter::CancelNotify");
+	if (IsActive())
+		{
+		Cancel();
+		}
+	
+	if (!iMessage.IsNull())
+		{
+		iMessage.Complete(KErrCancel);
+		}
+	}
--- a/libraries/iosrv/server/console.h	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/server/console.h	Thu Nov 04 23:22:39 2010 +0000
@@ -25,20 +25,23 @@
 public:
 	enum TOpCode
 		{
-		ESetConsoleSizeDetect = RConsoleProxy::EOpCodeCustomBase,
+		EUnusedOpCode = RConsoleProxy::EOpCodeCustomBase,
 		ESetLazyConstruct,
 		ESetConsoleMode,
 		ESetUnderlyingConsole,
 		EOpenExistingConsole,
 		EWriteStdErr,
+		ENotifySizeChange,
+		ECancelNotifySizeChange,
 		};
 public:
-	TInt SetConsoleSizeDetect();
 	TInt SetLazyConstruct();
 	void SetConsoleMode(RIoReadWriteHandle::TMode aMode, TRequestStatus& aStatus);
 	void SetUnderlyingConsole(const RIoConsoleProxy& aUnderlyingSession, TRequestStatus& aStatus);
 	TInt OpenExisting();
 	void WriteStdErr(const TDesC& aDescriptor, TRequestStatus& aStatus);
+	void NotifySizeChanged(TRequestStatus& aStatus);
+	void CancelNotifySizeChanged();
 	};
 	
 class CIoConsole : public CIoEndPoint
@@ -288,6 +291,20 @@
 		CIoConsole& iConsole;
 		TConsoleRequest* iCurrentRequest;
 		};
+
+	class CConsoleSizeChangedNotifier : public CActive
+		{
+	public:
+		CConsoleSizeChangedNotifier(CIoConsole& aConsole);
+		~CConsoleSizeChangedNotifier();
+	private:
+		void RunL();
+		void DoCancel();
+
+	private:
+		CIoConsole& iConsole;
+		};
+	friend class CConsoleSizeChangedNotifier;
 		
 	class CServerDeathWatcher : public CActive
 		{
@@ -320,6 +337,7 @@
 	RServer2 iThreadServer;
 	RThread iServerThread;
 	CServerDeathWatcher* iThreadWatcher;
+	CConsoleSizeChangedNotifier* iConsoleSizeChangedNotifier;
 	};
 	
 class CIoConsoleProxyServer : public CConsoleProxyServer
@@ -339,6 +357,24 @@
 
 CConsoleProxyServer* CIoConsoleProxyServerNewL(TAny* aParams);
 
+class CSizeChangeMessageCompleter : public CActive
+	{
+public:
+	CSizeChangeMessageCompleter();
+	~CSizeChangeMessageCompleter();
+	void SetConsole(CConsoleBase* aConsole);
+	void NotifySizeChange(RMessagePtr2& aMessage);
+	void CancelNotify();
+
+protected:
+	void RunL();
+	void DoCancel();
+
+private:
+	RMessagePtr2 iMessage;
+	CConsoleBase* iActualConsole;
+	};
+
 class CIoConsoleProxySession : public CConsoleProxySession
 	{
 public:
@@ -352,7 +388,7 @@
 	enum TFlag
 		{
 		ELazy				= 0x01,
-		EAutoDetectSize		= 0x02,
+		EHaveDetectedSize   = 0x02,
 		ESupportsStdErr		= 0x04,
 		};
 private:
@@ -368,6 +404,7 @@
 	CConsoleProxy* iUnderlyingConsole;
 	TUint iFlags;
 	TSize iDetectedSize;
+	CSizeChangeMessageCompleter* iSizeChangedMessageCompleter;
 	};
 	
 class CWriteOnlyConsoleProxy : public CConsoleProxy
@@ -386,7 +423,7 @@
 class CLazyConsole : public CConsoleBase
 	{
 public:
-	CLazyConsole(TConsoleCreateFunction aConsoleCreate, TBool aAutoDetectSize);
+	CLazyConsole(TConsoleCreateFunction aConsoleCreate);
 	~CLazyConsole();
 public: // from CConsoleBase
 	virtual TInt Create(const TDesC &aTitle,TSize aSize);
@@ -408,12 +445,13 @@
 	TInt CheckCreated() const;
 private:
 	TConsoleCreateFunction iConsoleCreate;
-	TBool iSizeAutoDetect;
 	RBuf iTitle;
 	TSize iSize;
+	mutable TBool iHaveDetectedSize;
 	mutable TSize iDetectedSize;
 	mutable TInt iCreateError;
 	mutable CConsoleBase* iConsole;
+	mutable TRequestStatus* iStatusForNotifySizeRequest; // Only needed if a notify request comes in before we've instantiated
 	};
 
 #endif //__CONSOLE_H__
--- a/libraries/iosrv/server/persistentconsole.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/server/persistentconsole.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -1051,11 +1051,16 @@
 	}
 
 
-TBool CIoPersistentConsole::TIoReaderProxy::IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers)
+TBool CIoPersistentConsole::TIoReaderProxy::IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers) const
 	{
 	return iReader.IorIsKeyCaptured(aKeyCode, aModifiers);
 	}
 
+TBool CIoPersistentConsole::TIoReaderProxy::IorAllKeysCaptured() const
+	{
+	return iReader.IorAllKeysCaptured();
+	}
+
 void CIoPersistentConsole::TIoReaderProxy::IorReadComplete(TInt /*aError*/)
 	{
 	// indicates that the read end point will be providing no more data
--- a/libraries/iosrv/server/persistentconsole.h	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/server/persistentconsole.h	Thu Nov 04 23:22:39 2010 +0000
@@ -202,7 +202,8 @@
 		virtual TDes& IorReadBuf();
 		virtual void IorDataBuffered(TInt aLength);
 		virtual TBool IorDataIsBuffered() const;
-		virtual TBool IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers);
+		virtual TBool IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers) const;
+		virtual TBool IorAllKeysCaptured() const;
 		virtual void IorReadComplete(TInt aError);
 		virtual void IorReadKeyComplete(TInt aError, TUint aKeyCode, TUint aModifiers);
 		virtual TName IorName();
--- a/libraries/iosrv/server/readwrite.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/server/readwrite.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -602,18 +602,31 @@
 	TInt mode(aMessage.Int0());
 	if ((mode >= RIoWriteHandle::EText) && (mode <= RIoWriteHandle::EBinary))
 		{
+		TInt err = KErrNone;
 		if (ReadEndPoint() && ReadEndPoint()->IorepIsForegroundL(*this))
 			{
 			__ASSERT_RETURN(!MessagePending(iSetModeMessage), PanicClient(aMessage, EPanicSetModeAlreadyPending));
-			ReadEndPoint()->IorepSetConsoleModeL((RIoReadWriteHandle::TMode)mode, *this);
 			iSetModeMessage = aMessage;
+			TRAP(err, ReadEndPoint()->IorepSetConsoleModeL((RIoReadWriteHandle::TMode)mode, *this));
+			if (err && MessagePending(iSetModeMessage))
+				{
+				if (err == KErrNotSupported)
+					{
+					// Ignore KErrNotSupported from the console to allow iMode to be set anyway, thereby getting at least the iosrv level behavior.
+					err = KErrNone;
+					}
+				Complete(iSetModeMessage, err);
+				}
 			}
 		else
 			{
 			Complete(aMessage, KErrNone);
 			}
 
-		iMode = static_cast<RIoWriteHandle::TMode>(mode);
+		if (err == KErrNone)
+			{
+			iMode = static_cast<RIoWriteHandle::TMode>(mode);
+			}
 		}
 	else
 		{
@@ -654,7 +667,7 @@
 	return (iBuf->Length() > 0);
 	}
 
-TBool CIoReadObject::IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers)
+TBool CIoReadObject::IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers) const
 	{
 	if (iCaptureAllKeys)
 		{
@@ -672,6 +685,11 @@
 	return EFalse;
 	}
 
+TBool CIoReadObject::IorAllKeysCaptured() const
+	{
+	return iCaptureAllKeys;
+	}
+
 void CIoReadObject::IorReadComplete(TInt aError)
 	{
 	if ((aError == KErrNone) || (aError==KErrEof))
--- a/libraries/iosrv/server/readwrite.h	Thu Nov 04 20:51:05 2010 +0000
+++ b/libraries/iosrv/server/readwrite.h	Thu Nov 04 23:22:39 2010 +0000
@@ -37,7 +37,8 @@
 	virtual TDes& IorReadBuf() = 0;
 	virtual void IorDataBuffered(TInt aLength) = 0;
 	virtual TBool IorDataIsBuffered() const = 0;
-	virtual TBool IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers) = 0;
+	virtual TBool IorIsKeyCaptured(TUint aKeyCode, TUint aModifiers) const = 0;
+	virtual TBool IorAllKeysCaptured() const = 0;
 	virtual void IorReadComplete(TInt aError) = 0;
 	virtual void IorReadKeyComplete(TInt aError, TUint aKeyCode, TUint aModifiers) = 0;
 	virtual TName IorName() = 0;
@@ -181,7 +182,8 @@
 	virtual TDes& IorReadBuf();
 	virtual void IorDataBuffered(TInt aLength);
 	virtual TBool IorDataIsBuffered() const;
-	virtual TBool IorIsKeyCaptured(TUint aKeyCode, TUint aModifier);
+	virtual TBool IorIsKeyCaptured(TUint aKeyCode, TUint aModifier) const;
+	virtual TBool IorAllKeysCaptured() const;
 	virtual void IorReadComplete(TInt aError);
 	virtual void IorReadKeyComplete(TInt aError, TUint aKeyCode, TUint aModifiers);
 	virtual TName IorName();
--- a/plugins/consoles/common/consoleextensions.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/common/consoleextensions.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -73,6 +73,11 @@
 		const TDesC* des = (const TDesC*)a1;
 		return WriteStdErr(*des);
 		}
+	else if (aExtensionId == ConsoleSize::KConsoleSizeReportedCorrectlyExtension)
+		{
+		// all the consoles that derive from this are expected to get the size right
+		return KErrNone;
+		}
 	else
 		{
 		return KErrExtensionNotSupported;
--- a/plugins/consoles/common/consoleextensions.h	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/common/consoleextensions.h	Thu Nov 04 23:22:39 2010 +0000
@@ -120,6 +120,27 @@
 	static inline TInt Write(CBase* aConsole, const TDesC& aDes);
 	};
 
+class ConsoleSize
+	{
+public:
+	static const TInt KConsoleSizeReportedCorrectlyExtension = 0x10286F75;
+	static const TInt KConsoleSizeNotifyChangedExtension = 0x10286F78;
+public:
+	/**
+	Returns true if the console is known to correctly report its size (and thus that the console size detect routines
+	in iosrv do not need to be run). Only needed because econs.dll (the text windowserver one, which we can't change)
+	doesn't.
+	*/
+	static inline TBool ReportedCorrectly(CBase* aConsole);
+
+	/**
+	If not supported, aStatus is completed with KErrExtensionNotSupported
+	Only one notification can be outstanding on a given console at a given time.
+	*/
+	static inline void NotifySizeChanged(CBase* aConsole, TRequestStatus& aStatus);
+	static inline void CancelNotifySizeChanged(CBase* aConsole);
+	};
+
 // BC on this interface is not guaranteed - only for use by things inside /fshell/plugins/consoles
 class MIosrvConsoleHelper
 	{
--- a/plugins/consoles/common/consoleextensions.inl	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/common/consoleextensions.inl	Thu Nov 04 23:22:39 2010 +0000
@@ -59,5 +59,29 @@
 TInt ConsoleStdErr::Write(CBase* aConsole, const TDesC& aDes)
 	{
 	TAny* ignore;
-	return ((CBaseExtensionDummy*)aConsole)->Extension_(KWriteStdErrConsoleExtension, ignore, const_cast<TAny*>((const TAny*)&aDes));
+	return ((CBaseExtensionDummy*)aConsole)->Extension_(KWriteStdErrConsoleExtension, ignore, (TAny*)&aDes);
+	}
+
+TBool ConsoleSize::ReportedCorrectly(CBase* aConsole)
+	{
+	TAny* ignore;
+	return ((CBaseExtensionDummy*)aConsole)->Extension_(KConsoleSizeReportedCorrectlyExtension, ignore, NULL) == KErrNone;
 	}
+
+void ConsoleSize::NotifySizeChanged(CBase* aConsole, TRequestStatus& aStatus)
+	{
+	TAny* ignore;
+	TBool supported = ((CBaseExtensionDummy*)aConsole)->Extension_(KConsoleSizeNotifyChangedExtension, ignore, (TAny*)&aStatus) == KErrNone;
+	if (!supported)
+		{
+		TRequestStatus* stat = &aStatus;
+		User::RequestComplete(stat, KErrExtensionNotSupported);
+		}
+	}
+
+void ConsoleSize::CancelNotifySizeChanged(CBase* aConsole)
+	{
+	TAny* ignore;
+	((CBaseExtensionDummy*)aConsole)->Extension_(KConsoleSizeNotifyChangedExtension, ignore, NULL);
+	}
+
--- a/plugins/consoles/defcons/src/defcons.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/defcons/src/defcons.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -18,6 +18,7 @@
 #include <e32wins.h>
 #endif
 #include <fshell/descriptorutils.h>
+#include <fshell/consoleextensions.h>
 
 
 //
@@ -36,33 +37,17 @@
 
 /**
 
-  The default console implementation, used by iosrv. This console implentation has
-  two reasons to exist:
+  The default console implementation, used by iosrv. This console implementation has
+  one reason to exist (there used to be more):
 
   1) To hunt for a suitable real console implementation to be used by default. On
      GUI configurations this will either be guicons.dll or econseik.dll. On text
 	 configurations this will be econs.dll.
 
-  2) To delay the creation of the real console implementation until it is known
-     to be needed. This is useful because CCommandBase creates a default console
-	 even if --console has been specified on the command line. The default console
-	 may be used by the specified console during its construction to interact with
-	 the user (e.g. vt100tcpcons uses it to tell the user which TCP port and IP
-	 address it is listening on). However, if it weren't to be used, the user
-	 would see the default console briefly appear and then disappear when the
-	 actual console is created. Delaying the creation of the console underlying
-	 the default console avoids this.
-
 */
 NONSHARABLE_CLASS(CDefaultConsole) : public CConsoleBase
 	{
 public:
-	enum TPanicReason
-		{
-		EDoubleRead = 0,
-		EUnableToCreateConsole = 1
-		};
-public:
 	CDefaultConsole();
 	virtual ~CDefaultConsole();
 	virtual TInt Create(const TDesC &aTitle, TSize aSize);
@@ -81,10 +66,8 @@
 	virtual TUint KeyModifiers() const;
 	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
 private:
-	void CreateIfRequired();
-	void CreateIfRequired() const;
+	TInt DoCreate();
 	TInt TryCreateConsole(const TDesC& aImplementation);
-	void Panic(TPanicReason aReason);
 private:
 	HBufC* iTitle;
 	TSize iSize;
@@ -109,114 +92,96 @@
 	if (iTitle)
 		{
 		iSize = aSize;
-		return KErrNone;
+		return DoCreate();
 		}
 	return KErrNoMemory;
 	}
 
 void CDefaultConsole::Read(TRequestStatus& aStatus)
 	{
-	CreateIfRequired();
 	iUnderlyingConsole->Read(aStatus);
 	}
 
 void CDefaultConsole::ReadCancel()
 	{
-	if (iUnderlyingConsole)
-		{
-		iUnderlyingConsole->ReadCancel();
-		}
+	iUnderlyingConsole->ReadCancel();
 	}
 
 void CDefaultConsole::Write(const TDesC& aDes)
 	{
-	CreateIfRequired();
 	iUnderlyingConsole->Write(aDes);
 	}
 
 TPoint CDefaultConsole::CursorPos() const
 	{
-	CreateIfRequired();
 	return iUnderlyingConsole->CursorPos();
 	}
 
 void CDefaultConsole::SetCursorPosAbs(const TPoint& aPoint)
 	{
-	CreateIfRequired();
 	iUnderlyingConsole->SetCursorPosAbs(aPoint);
 	}
 
 void CDefaultConsole::SetCursorPosRel(const TPoint& aPoint)
 	{
-	CreateIfRequired();
 	iUnderlyingConsole->SetCursorPosRel(aPoint);
 	}
 
 void CDefaultConsole::SetCursorHeight(TInt aPercentage)
 	{
-	CreateIfRequired();
 	iUnderlyingConsole->SetCursorHeight(aPercentage);
 	}
 
 void CDefaultConsole::SetTitle(const TDesC& aTitle)
 	{
-	CreateIfRequired();
 	iUnderlyingConsole->SetTitle(aTitle);
 	}
 
 void CDefaultConsole::ClearScreen()
 	{
-	CreateIfRequired();
 	iUnderlyingConsole->ClearScreen();
 	}
 
 void CDefaultConsole::ClearToEndOfLine()
 	{
-	CreateIfRequired();
 	iUnderlyingConsole->ClearToEndOfLine();
 	}
 
 TSize CDefaultConsole::ScreenSize() const
 	{
-	CreateIfRequired();
 	return iUnderlyingConsole->ScreenSize();
 	}
 
 TKeyCode CDefaultConsole::KeyCode() const
 	{
-	CreateIfRequired();
 	return iUnderlyingConsole->KeyCode();
 	}
 
 TUint CDefaultConsole::KeyModifiers() const
 	{
-	CreateIfRequired();
 	return iUnderlyingConsole->KeyModifiers();
 	}
 
 TInt CDefaultConsole::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
 	{
-	CreateIfRequired();
 	return ((CDefaultConsole*)iUnderlyingConsole)->Extension_(aExtensionId, a0, a1); // Evil cast to work around the fact that Extension_ is protected in CConsoleBase.
 	}
 
-void CDefaultConsole::CreateIfRequired()
+TInt CDefaultConsole::DoCreate()
 	{
-	if (iUnderlyingConsole == NULL)
-		{
-		TInt err = KErrGeneral;
+	TInt err = KErrGeneral;
 #ifdef __WINS__
-		if (EmulatorNoGui())
-			{
-			err = TryCreateConsole(_L("nullcons"));
-			}
-		else if (EmulatorTextShell())
-			{
-			err = TryCreateConsole(_L("econs"));
-			}
-		else
-			{
+	if (EmulatorNoGui())
+		{
+		err = TryCreateConsole(_L("nullcons"));
+		}
+	else if (EmulatorTextShell())
+		{
+		err = TryCreateConsole(_L("econs"));
+		}
+	else
 #endif
+		{
 		for (TInt i = 0; i < KNumConsoleImplementations; ++i)
 			{
 			err = TryCreateConsole(KConsoleImplementations[i]);
@@ -226,17 +191,8 @@
 				}
 			}
 
-#ifdef __WINS__
-			}
-#endif
-
-		__ASSERT_ALWAYS(err == KErrNone, Panic(EUnableToCreateConsole));
 		}
-	}
-
-void CDefaultConsole::CreateIfRequired() const
-	{
-	const_cast<CDefaultConsole*>(this)->CreateIfRequired();
+	return err;
 	}
 
 TInt CDefaultConsole::TryCreateConsole(const TDesC& aImplementation)
@@ -263,12 +219,6 @@
 	return err;
 	}
 
-void CDefaultConsole::Panic(TPanicReason aReason)
-	{
-	_LIT(KCategory, "defcons");
-	User::Panic(KCategory, aReason);
-	}
-
 extern "C" EXPORT_C TAny *NewConsole()
 	{
 	return(new CDefaultConsole);
--- a/plugins/consoles/guicons/src/guicons.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/guicons/src/guicons.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -1576,6 +1576,10 @@
 		ConsoleAttributes::TAttributes* attributes = (ConsoleAttributes::TAttributes*)a1;
 		return iControl.SetAttributes(attributes->iAttributes, attributes->iForegroundColor, attributes->iBackgroundColor);
 		}
+	else if (aExtensionId == ConsoleSize::KConsoleSizeReportedCorrectlyExtension)
+		{
+		return KErrNone;
+		}
 	return KErrNotSupported;
 	}
 
--- a/plugins/consoles/nullcons/src/nullcons.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/nullcons/src/nullcons.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -13,6 +13,7 @@
 #include <e32std.h>
 #include <e32cons.h>
 #include <e32keys.h>
+#include <fshell/consoleextensions.h>
 
 NONSHARABLE_CLASS(CNullConsole) : public CConsoleBase
 	{
@@ -33,6 +34,7 @@
 	virtual TSize ScreenSize() const;
 	virtual TKeyCode KeyCode() const;
 	virtual TUint KeyModifiers() const;
+	virtual TInt Extension_(TUint aExtensionId, TAny*& a0, TAny* a1);
 	};
 
 CNullConsole::CNullConsole()
@@ -106,6 +108,17 @@
 	return 0;
 	}
 
+TInt CNullConsole::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
+	{
+	if (aExtensionId == ConsoleSize::KConsoleSizeReportedCorrectlyExtension)
+		{
+		// No point attempting size detection on nullcons
+		return KErrNone;
+		}
+
+	return CConsoleBase::Extension_(aExtensionId, a0, a1);
+	}
+
 extern "C" EXPORT_C TAny *NewConsole()
 	{
 	return(new CNullConsole);
--- a/plugins/consoles/rcons/client/group/remote_console.mmp	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/rcons/client/group/remote_console.mmp	Thu Nov 04 23:22:39 2010 +0000
@@ -25,11 +25,11 @@
 source			remote_console_config.cpp
 
 library			ltkutils.lib
-library			EUSER.LIB
-library			EFSRV.LIB
-library			ESOCK.LIB
-library			INSOCK.LIB
-library			COMMDB.LIB
+library			euser.lib
+library			efsrv.lib
+library			esock.lib
+library			insock.lib
+library			commdb.lib
 
 deffile			remote_console.def
 
--- a/plugins/consoles/tefcons/tefcons.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/tefcons/tefcons.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -162,6 +162,10 @@
 		WriteStdErr(*des);
 		return KErrNone;
 		}
+	else if (aExtensionId == ConsoleSize::KConsoleSizeReportedCorrectlyExtension)
+		{
+		return KErrNone;
+		}
 	else
 		{
 		return CConsoleBase::Extension_(aExtensionId, a0, a1);
--- a/plugins/consoles/vt100cons/doc/vt100cons.pod	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/vt100cons/doc/vt100cons.pod	Thu Nov 04 23:22:39 2010 +0000
@@ -266,7 +266,7 @@
 
 =item *
 
-Console size detection is not supported, and must be disabled in iosrv.ini (eg by including iosrv.ini.noautodetect). The console will always be assumed to be 80x24.
+Console size detection is not supported, and will always be assumed to be 80x24.
 
 =item *
 
--- a/plugins/consoles/vt100cons/inc/vtc_controller.h	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/vt100cons/inc/vtc_controller.h	Thu Nov 04 23:22:39 2010 +0000
@@ -96,12 +96,12 @@
 	void DoExtendedEscapeKey();
 	static TInt EscapeTimeoutS(TAny* aSelf);
 	TInt EscapeTimeout();
-	void ReadKeyPress();
-	void CompleteKeyPressRequest(TInt aError);
-	void CompleteKeyPressRequest(TKeyCode aKeyCode);
-	void CompleteKeyPressRequest(TKeyCode aKeyCode1, TKeyCode aKeyCode2);
+	void ProcessInputBuffer();
+	void CompleteReadRequest(TInt aError);
+	void CompleteReadRequest(TKeyCode aKeyCode);
+	void CompleteReadRequest(TKeyCode aKeyCode1, TKeyCode aKeyCode2);
 	void Reset();
-	void ReadInput();
+	void RequestInput();
 private: // From CActive.
 	virtual void RunL();
 	virtual void DoCancel();
--- a/plugins/consoles/vt100cons/src/vt100/vtc_controller.cpp	Thu Nov 04 20:51:05 2010 +0000
+++ b/plugins/consoles/vt100cons/src/vt100/vtc_controller.cpp	Thu Nov 04 23:22:39 2010 +0000
@@ -650,16 +650,16 @@
 	if (iKeyCodePending)
 		{
 		iKeyCodePending = EFalse;
-		CompleteKeyPressRequest(iPendingKeyCode);
+		CompleteReadRequest(iPendingKeyCode);
 		}
 	else if (iInputError)
 		{
-		CompleteKeyPressRequest(iInputError);
+		CompleteReadRequest(iInputError);
 		iInputError = KErrNone;
 		}
 	else
 		{
-		ReadKeyPress();
+		ProcessInputBuffer();
 		}
 	}
 
@@ -668,7 +668,7 @@
 	Cancel();
 	if (iClientRequestStatus)
 		{
-		CompleteKeyPressRequest(KErrCancel);
+		CompleteReadRequest(KErrCancel);
 		}
 	}
 
@@ -678,7 +678,7 @@
 	iMode = aMode;
 	}
 
-void CVtConsoleInputController::ReadKeyPress()
+void CVtConsoleInputController::ProcessInputBuffer()
 	{
 	iEscapeTimer->Cancel();
 
@@ -687,7 +687,7 @@
 		TUint8 c = iBuf[iBufPos++];
 		if (iMode == ConsoleMode::EBinary)
 			{
-			CompleteKeyPressRequest((TKeyCode)c);
+			CompleteReadRequest((TKeyCode)c);
 			}
 		else
 			{
@@ -704,7 +704,7 @@
 					}
 				else
 					{
-					CompleteKeyPressRequest((TKeyCode)c);
+					CompleteReadRequest((TKeyCode)c);
 					}
 				break;
 			case EWaitingForEscapeChar2:
@@ -718,7 +718,7 @@
 					}
 				else
 					{
-					CompleteKeyPressRequest(EKeyEscape, (TKeyCode)c);
+					CompleteReadRequest(EKeyEscape, (TKeyCode)c);
 					iState = ENormal;
 					}
 				break;
@@ -751,24 +751,24 @@
 					{
 					// Gone off the rails, bail
 					iState = ENormal;
-					CompleteKeyPressRequest((TKeyCode)c);
+					CompleteReadRequest((TKeyCode)c);
 					}
 				break;
 				}
 			}
 		}
 
-	ReadInput();
+	RequestInput();
 	}
 
-void CVtConsoleInputController::CompleteKeyPressRequest(TInt aError)
+void CVtConsoleInputController::CompleteReadRequest(TInt aError)
 	{
 	ASSERT(iClientKeyPress && iClientRequestStatus);
 	iClientKeyPress = NULL;
 	User::RequestComplete(iClientRequestStatus, aError);
 	}
 
-void CVtConsoleInputController::CompleteKeyPressRequest(TKeyCode aKeyCode)
+void CVtConsoleInputController::CompleteReadRequest(TKeyCode aKeyCode)
 	{
 	ASSERT(iClientKeyPress && iClientRequestStatus);
 	iClientKeyPress->iCode = (TKeyCode)aKeyCode;
@@ -777,13 +777,13 @@
 	User::RequestComplete(iClientRequestStatus, KErrNone);
 	}
 
-void CVtConsoleInputController::CompleteKeyPressRequest(TKeyCode aKeyCode1, TKeyCode aKeyCode2)
+void CVtConsoleInputController::CompleteReadRequest(TKeyCode aKeyCode1, TKeyCode aKeyCode2)
 	{
 	ASSERT(!iKeyCodePending);
 	// Store the second key-code in a member variable to be used the next time GetKeyPress is called.
 	iKeyCodePending = ETrue;
 	iPendingKeyCode = aKeyCode2;
-	CompleteKeyPressRequest(aKeyCode1);
+	CompleteReadRequest(aKeyCode1);
 	}
 
 void CVtConsoleInputController::Reset()
@@ -794,7 +794,7 @@
 	iKeyCodePending = EFalse;
 	}
 
-void CVtConsoleInputController::ReadInput()
+void CVtConsoleInputController::RequestInput()
 	{
 	if (iClientRequestStatus && !IsActive()) // Note, if the escape timer expired we could already be active.
 		{
@@ -812,17 +812,17 @@
 #ifdef FSHELL_PLATFORM_OPP
 	if (err == KErrAbort)
 		{
-		ReadInput();
+		RequestInput();
 		return;
 		}
 #endif
 	if (err == KErrNone)
 		{
-		ReadKeyPress();
+		ProcessInputBuffer();
 		}
 	else if (iClientRequestStatus)
 		{
-		CompleteKeyPressRequest(err);
+		CompleteReadRequest(err);
 		}
 	else
 		{
@@ -843,7 +843,7 @@
 		{
 		if (aChar == aMappings[j].iEscapeChar)
 			{
-			CompleteKeyPressRequest(aMappings[j].iKeyCode);
+			CompleteReadRequest(aMappings[j].iKeyCode);
 			return;
 			}
 		}
@@ -853,7 +853,7 @@
 	{
 	ASSERT(iState == EWaitingForEscapeChar2);
 	iState = ENormal;
-	CompleteKeyPressRequest(EKeyEscape);
+	CompleteReadRequest(EKeyEscape);
 	return KErrNone;
 	}
 
@@ -876,7 +876,7 @@
 		const TLongerEscapeMapping& mapping = KExtendedEscapeMappings[j];
 		if (escape1 == mapping.iEscapeChar1 && escape2 == mapping.iEscapeChar2)
 			{
-			CompleteKeyPressRequest(mapping.iKeyCode);
+			CompleteReadRequest(mapping.iKeyCode);
 			return;
 			}
 		}