00001 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // Contains definition of functions defined in the CUserInterface class. 00015 // 00016 00017 00018 00023 #include "userinterface.h" 00030 CUserInterface* CUserInterface::NewL(CConsoleBase* aConsole,CTimerEntry* aTimerEntry) 00031 { 00032 CUserInterface* self = new (ELeave)CUserInterface; 00033 self->Initialize(aConsole,aTimerEntry); 00034 return self; 00035 } 00036 00042 void CUserInterface::Initialize(CConsoleBase* aConsole,CTimerEntry* aTimerEntry) 00043 { 00044 iConsole = aConsole; 00045 iTimerEntry = aTimerEntry; 00046 CActiveScheduler::Add(this); 00047 iTimerEntry->IssueRequest(); 00048 } 00049 00053 CUserInterface::CUserInterface():CActive(CActive::EPriorityUserInput) 00054 { 00055 } 00056 00061 void CUserInterface::RunL() 00062 { 00063 // Get the key code. 00064 TUint8 option = iConsole->KeyCode(); 00065 // Print the selected option. 00066 _LIT(KTextFormat,"%c\n"); 00067 iConsole->Printf(KTextFormat,option); 00068 CActiveScheduler::Stop(); 00069 } 00070 00074 void CUserInterface::ReadFunc() 00075 { 00076 // Print the menu. 00077 _LIT(KTxtOption,"***\nPress any key to stop the scheduler\n***\n"); 00078 iConsole->Printf(KTxtOption); 00079 // Wait for a key press event. 00080 iConsole->Read(iStatus); 00081 SetActive(); 00082 } 00083 00087 void CUserInterface::DoCancel() 00088 { 00089 if(IsActive()) 00090 { 00091 // Cancel any outstanding read requests. 00092 iConsole->ReadCancel(); 00093 } 00094 } 00095 00099 CUserInterface::~CUserInterface() 00100 { 00101 Cancel(); 00102 }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.