mmtestenv/mmtestfw/Source/TestFrameworkServer/ServerConsole.cpp
changeset 32 ae690a8c4a18
parent 31 ae0addfe117e
child 41 f7bf1ed8db72
equal deleted inserted replaced
31:ae0addfe117e 32:ae690a8c4a18
    46  * @xxxx
    46  * @xxxx
    47  *
    47  *
    48  */
    48  */
    49 CServerConsole::~CServerConsole()
    49 CServerConsole::~CServerConsole()
    50 	{
    50 	{
       
    51 	Cancel();
       
    52 	delete iConsoleReader;
    51 	delete iWindowName;
    53 	delete iWindowName;
    52 	delete iInstructions;
    54 	delete iInstructions;
    53 	delete iConsole;
    55 	delete iConsole;
    54 	}
    56 	}
    55 
    57 
    60  *
    62  *
    61  * @xxxx
    63  * @xxxx
    62  *
    64  *
    63  */
    65  */
    64 CServerConsole::CServerConsole()
    66 CServerConsole::CServerConsole()
    65 	{
    67 	:CActive(EPriorityHigh)
       
    68 	{
       
    69 	CActiveScheduler::Add(this);
    66 	}
    70 	}
    67 
    71 
    68 /**
    72 /**
    69  *
    73  *
    70  * Second-phase constructor for CServerConsole.
    74  * Second-phase constructor for CServerConsole.
    78  */
    82  */
    79 void CServerConsole::ConstructL(const TDesC& aName)
    83 void CServerConsole::ConstructL(const TDesC& aName)
    80 	{
    84 	{
    81 	iWindowName = aName.AllocL();
    85 	iWindowName = aName.AllocL();
    82 	iConsole =  Console::NewL(*iWindowName, TSize(KConsFullScreen,KConsFullScreen));
    86 	iConsole =  Console::NewL(*iWindowName, TSize(KConsFullScreen,KConsFullScreen));
       
    87 	iConsoleReader = CConsoleReader::NewL(*iConsole);
    83 	}
    88 	}
    84 
    89 
    85 /**
    90 /**
    86  *
    91  *
    87  * Accessor for base console.
    92  * Accessor for base console.
   117 	iInstructions = aInstructions.AllocL();
   122 	iInstructions = aInstructions.AllocL();
   118 	iConsole->ClearScreen();
   123 	iConsole->ClearScreen();
   119 	iConsole->Write(*iInstructions);
   124 	iConsole->Write(*iInstructions);
   120 	}
   125 	}
   121 
   126 
       
   127 /**
       
   128  *
       
   129  * Starts the console reader listening for input.
       
   130  *
       
   131  * @param	"MConsoleReader& aReader"
       
   132  *			The console reader.
       
   133  *
       
   134  * @xxxx 
       
   135  *
       
   136  */
       
   137 void CServerConsole::Read(MConsoleReader& aReader)
       
   138 	{
       
   139 	iConsoleReader->DoRead(aReader);
       
   140 	}
       
   141 
       
   142 /**
       
   143  *
       
   144  * Stops the console reader listening for input.
       
   145  *
       
   146  *
       
   147  * @xxxx 
       
   148  *
       
   149  */
       
   150 void CServerConsole::ReadCancel()
       
   151 	{
       
   152 	iConsoleReader->Cancel();
       
   153 	}
       
   154 
       
   155 /**
       
   156  *
       
   157  * RunL method for active object CServerConsole.
       
   158  *
       
   159  * @xxxx
       
   160  *
       
   161  */
       
   162 void CServerConsole::RunL()
       
   163 	{
       
   164 	User::LeaveIfError(iStatus.Int());
       
   165 	TBool reading = iConsoleReader->IsActive();
       
   166 	iConsoleReader->Cancel();
       
   167 
       
   168 	//listen for key input if we were before...
       
   169 	if (reading)
       
   170 		iConsoleReader->DoRead();
       
   171 	}
       
   172 
       
   173 /**
       
   174  *
       
   175  * DoCancel method for active object CServerConsole.
       
   176  *
       
   177  * @xxxx
       
   178  *
       
   179  */
       
   180 void CServerConsole::DoCancel()
       
   181 	{
       
   182 	ReadCancel();
       
   183 	}
       
   184 
       
   185 /**
       
   186  *
       
   187  * Error handler for active object CServerConsole.
       
   188  * (Currently a stub)
       
   189  *
       
   190  * @param	"TInt aError"
       
   191  *			The error code
       
   192  *
       
   193  * @return	"TInt"
       
   194  *			The error code
       
   195  *
       
   196  * @xxxx
       
   197  *
       
   198  */
       
   199 TInt CServerConsole::RunError(TInt aError)
       
   200 	{
       
   201 	return aError;
       
   202 	}
       
   203 
       
   204 
       
   205 
       
   206 /**
       
   207  *
       
   208  * Static constructor for CConsoleReader.
       
   209  *
       
   210  * @param	"CConsoleBase& aConsole"
       
   211  *			The console we are to read
       
   212  *
       
   213  * @return	"CConsoleReader*"
       
   214  *			The constructed CConsoleReader
       
   215  *
       
   216  * @xxxx
       
   217  *
       
   218  */
       
   219 CConsoleReader* CConsoleReader::NewL(CConsoleBase& aConsole)
       
   220 	{
       
   221 	CConsoleReader* s = new(ELeave) CConsoleReader(aConsole);
       
   222 	return s;
       
   223 	}
       
   224 
       
   225 /**
       
   226  *
       
   227  * First-phase constructor for CConsoleReader.
       
   228  * Adds itself to the Active Scheduler.
       
   229  *
       
   230  * @param	"CConsoleBase& aConsole"
       
   231  *			console to read from
       
   232  *
       
   233  * @xxxx
       
   234  *
       
   235  */
       
   236 CConsoleReader::CConsoleReader(CConsoleBase& aConsole) :
       
   237 	CActive(EPriorityUserInput),
       
   238 	iConsole(aConsole)
       
   239 	{
       
   240 	CActiveScheduler::Add(this);
       
   241 	}
       
   242 
       
   243 /**
       
   244  *
       
   245  * Destructor for CConsoleReader.
       
   246  *
       
   247  * @xxxx
       
   248  *
       
   249  */
       
   250 CConsoleReader::~CConsoleReader()
       
   251 	{
       
   252 	Cancel();
       
   253 	}
       
   254 
       
   255 /**
       
   256  *
       
   257  * DoRead method for active object CConsoleReader;
       
   258  * sets client and starts reading
       
   259  *
       
   260  * @param	"MConsoleReader& aClient"
       
   261  *			client MConsoleReader (which will process the input)
       
   262  *
       
   263  * @xxxx
       
   264  *
       
   265  */
       
   266 void CConsoleReader::DoRead(MConsoleReader& aClient)
       
   267 	{
       
   268 	iClient = &aClient;
       
   269 	DoRead();
       
   270 	}
       
   271 
       
   272 /**
       
   273  *
       
   274  * DoRead method for active object CConsoleReader;
       
   275  * starts reading from current client
       
   276  *
       
   277  * @xxxx
       
   278  *
       
   279  */
       
   280 void CConsoleReader::DoRead()
       
   281 	{
       
   282 	iConsole.Read(iStatus);
       
   283 	SetActive();
       
   284 	}
       
   285 
       
   286 /**
       
   287  *
       
   288  * RunL method for active object CConsoleReader;
       
   289  * fetches a keystroke and sends it to its client for processing.
       
   290  *
       
   291  * @xxxx
       
   292  *
       
   293  */
       
   294 void CConsoleReader::RunL()
       
   295 	{
       
   296 	iKeyStroke = iConsole.KeyCode();
       
   297 	if (iStatus.Int())
       
   298 		iClient->Error(iStatus.Int());
       
   299 	else
       
   300 		iClient->InputReceived(iKeyStroke);
       
   301 	}
       
   302 
       
   303 /**
       
   304  *
       
   305  * DoCancel method for active object CConsoleReader
       
   306  *
       
   307  * @xxxx
       
   308  *
       
   309  */
       
   310 void CConsoleReader::DoCancel()
       
   311 	{
       
   312 	iConsole.ReadCancel();
       
   313 	}