mpx/tsrc/public/basic/common/testviewframework/src/consolereader.cpp
changeset 62 b276843a15ba
equal deleted inserted replaced
58:c76ea6caa649 62:b276843a15ba
       
     1 /*
       
     2 * Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "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 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CConsoleReader class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "consolereader.h"
       
    19 #include "consolemain.h"
       
    20 
       
    21 /*
       
    22 -------------------------------------------------------------------------------
       
    23 
       
    24     Class: CConsoleReader
       
    25 
       
    26     Method: CConsoleReader
       
    27 
       
    28     Description: Constructor.
       
    29 
       
    30     Parameters: CConsoleMain* aMain: in: Pointer to main console
       
    31                 CConsoleBase* aConsole: in: Console pointer
       
    32 
       
    33     Return Values: None
       
    34 
       
    35     Errors/Exceptions: None
       
    36 
       
    37     Status: Draft
       
    38 
       
    39 -------------------------------------------------------------------------------
       
    40 */
       
    41 CConsoleReader::CConsoleReader( CConsoleMain* aMain, 
       
    42                                 CConsoleBase* aConsole ): 
       
    43     CActive( EPriorityStandard )
       
    44     {
       
    45     
       
    46     iMain = aMain;
       
    47     iConsole = aConsole;
       
    48     
       
    49     CActiveScheduler::Add( this );
       
    50 
       
    51     }
       
    52 
       
    53 /*
       
    54 -------------------------------------------------------------------------------
       
    55 
       
    56     Class: CConsoleReader
       
    57 
       
    58     Method: ~CConsoleReader
       
    59 
       
    60     Description: Destructor
       
    61 
       
    62     Parameters: None
       
    63 
       
    64     Return Values: None
       
    65 
       
    66     Errors/Exceptions: None
       
    67 
       
    68     Status: Draft
       
    69 
       
    70 -------------------------------------------------------------------------------
       
    71 */
       
    72 CConsoleReader::~CConsoleReader( )
       
    73     {	
       
    74     
       
    75     Cancel();    
       
    76     
       
    77     }
       
    78 
       
    79 /*
       
    80 -------------------------------------------------------------------------------
       
    81 
       
    82     Class: CConsoleReader
       
    83 
       
    84     Method: ConstructL
       
    85 
       
    86     Description: Second level constructor.
       
    87     
       
    88     Parameters: None
       
    89 
       
    90     Return Values: None
       
    91 
       
    92     Errors/Exceptions: 
       
    93 
       
    94     Status: Draft
       
    95 
       
    96 -------------------------------------------------------------------------------
       
    97 */
       
    98 void CConsoleReader::ConstructL( )
       
    99     {
       
   100     }
       
   101 
       
   102 /*
       
   103 -------------------------------------------------------------------------------
       
   104 
       
   105     Class: CConsoleReader
       
   106 
       
   107     Method: DoCancel
       
   108 
       
   109     Description: Cancel request
       
   110 
       
   111     Parameters: None
       
   112 
       
   113     Return Values: None
       
   114 
       
   115     Errors/Exceptions: None
       
   116 
       
   117     Status: Draft
       
   118 
       
   119 -------------------------------------------------------------------------------
       
   120 */
       
   121 void CConsoleReader::DoCancel()
       
   122     {
       
   123     
       
   124     iConsole->ReadCancel();
       
   125     
       
   126     }
       
   127 
       
   128 /*
       
   129 -------------------------------------------------------------------------------
       
   130 
       
   131     Class: CConsoleReader
       
   132 
       
   133     Method: NewL
       
   134 
       
   135     Description: Construct the console main class
       
   136 
       
   137     Parameters: CConsoleMain* aMain: in: Pointer to main console
       
   138                 CConsoleBase* aConsole: in: Console pointer
       
   139 
       
   140     Return Values: CConsoleReader*                    New object
       
   141 
       
   142     Errors/Exceptions: Leaves if memory allocation fails or
       
   143                        ConstructL leaves.
       
   144 
       
   145     Status: Draft
       
   146 
       
   147 -------------------------------------------------------------------------------
       
   148 */
       
   149 CConsoleReader* CConsoleReader::NewL( CConsoleMain* aMain, 
       
   150                                       CConsoleBase* aConsole )
       
   151     {
       
   152 
       
   153     CConsoleReader* self = 
       
   154         new ( ELeave ) CConsoleReader( aMain, aConsole );
       
   155     CleanupStack::PushL( self );
       
   156     self->ConstructL();
       
   157     CleanupStack::Pop( self );
       
   158     return self;
       
   159 
       
   160     }
       
   161 
       
   162 /*
       
   163 -------------------------------------------------------------------------------
       
   164 
       
   165     Class: CConsoleReader
       
   166 
       
   167     Method: RunL
       
   168 
       
   169     Description: Process keyboard events. Print new menu
       
   170 
       
   171     Parameters: None
       
   172 
       
   173     Return Values: None
       
   174 
       
   175     Errors/Exceptions: Leaves if SelectL leaves
       
   176 
       
   177     Status: Draft
       
   178 
       
   179 -------------------------------------------------------------------------------
       
   180 */
       
   181 void CConsoleReader::RunL()
       
   182     {
       
   183 
       
   184 	User::LeaveIfError(iStatus.Int());
       
   185     iMain->KeyPressedL();
       
   186     
       
   187     }
       
   188 
       
   189 /*
       
   190 -------------------------------------------------------------------------------
       
   191 
       
   192     Class: CConsoleReader
       
   193 
       
   194     Method: Start
       
   195 
       
   196     Description: Construct menu objects and start the menu handling
       
   197 
       
   198     Parameters: None
       
   199 
       
   200     Return Values: None
       
   201 
       
   202     Errors/Exceptions:
       
   203 
       
   204     Status: Draft
       
   205 
       
   206 -------------------------------------------------------------------------------
       
   207 */
       
   208 void CConsoleReader::Start( )
       
   209     {
       
   210 
       
   211     // Start to process keyboard events
       
   212     iConsole->Read(iStatus);
       
   213     SetActive();
       
   214     }