0
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2009 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "activeconsole.h"
|
|
20 |
|
|
21 |
CActiveConsole* CActiveConsole::NewL(CConsoleBase* aConsole,CStatController *aController,CStatConsole* aStatConsole,TInt aSessionID, MNotifyLogMessage *const aMsg)
|
|
22 |
{
|
|
23 |
CActiveConsole* self=new(ELeave)CActiveConsole(aConsole,aController,aStatConsole,aSessionID,aMsg);
|
|
24 |
CleanupStack::PushL(self);
|
|
25 |
self->ConstructL();
|
|
26 |
CleanupStack::Pop();
|
|
27 |
return self;
|
|
28 |
}
|
|
29 |
|
|
30 |
CActiveConsole::CActiveConsole(CConsoleBase* aConsole,CStatController *aController,CStatConsole* aStatConsole,TInt aSessionID, MNotifyLogMessage *const aMsg) : CActive(0)
|
|
31 |
{
|
|
32 |
iConsole=aConsole;
|
|
33 |
iController=aController;
|
|
34 |
iSessionID=aSessionID;
|
|
35 |
iStatConsole=aStatConsole;
|
|
36 |
iMsg = aMsg;
|
|
37 |
}
|
|
38 |
|
|
39 |
void CActiveConsole::ConstructL()
|
|
40 |
{
|
|
41 |
iMsg->Msg( _L("ACTIVECONSOLE: Adding self to scheduler.") );
|
|
42 |
CActiveScheduler::Add(this);
|
|
43 |
}
|
|
44 |
|
|
45 |
CActiveConsole::~CActiveConsole()
|
|
46 |
{
|
|
47 |
Cancel();
|
|
48 |
}
|
|
49 |
|
|
50 |
//Checks for user input to console.
|
|
51 |
void CActiveConsole::RunL()
|
|
52 |
{
|
|
53 |
TChar gChar = TChar(iConsole->KeyCode());
|
|
54 |
|
|
55 |
switch (gChar)
|
|
56 |
{
|
|
57 |
case EKeyEscape: //escape exits
|
|
58 |
case '2': //2 exits
|
|
59 |
iConsole->Printf( _L("Processing escape request.") );
|
|
60 |
iMsg->Msg( _L("ACTIVECONSOLE: Processing escape request.") );
|
|
61 |
iStatConsole->UserExitRequest();
|
|
62 |
iController->StopSession(iSessionID);
|
|
63 |
return;
|
|
64 |
case '1': //1 sets system to forground
|
|
65 |
case 'b': //b or B sets system to forground
|
|
66 |
case 'B':
|
|
67 |
PushToBack();
|
|
68 |
break;
|
|
69 |
default:
|
|
70 |
break;
|
|
71 |
}
|
|
72 |
|
|
73 |
if(iStatus!=KErrNone)
|
|
74 |
{
|
|
75 |
iConsole->Printf(_L("** error reading from active console **"));
|
|
76 |
iConsole->Getch();
|
|
77 |
}
|
|
78 |
iConsole->Read(iStatus);
|
|
79 |
SetActive();
|
|
80 |
}
|
|
81 |
|
|
82 |
void CActiveConsole::DoCancel()
|
|
83 |
{
|
|
84 |
}
|
|
85 |
|
|
86 |
//Initial request
|
|
87 |
void CActiveConsole::Start()
|
|
88 |
{
|
|
89 |
iConsole->Read(iStatus);
|
|
90 |
SetActive();
|
|
91 |
}
|
|
92 |
|
|
93 |
//Push statapi to background by switching to the system window
|
|
94 |
void CActiveConsole::PushToBack()
|
|
95 |
{
|
|
96 |
#ifndef LIGHT_MODE
|
|
97 |
RWsSession Ws;
|
|
98 |
|
|
99 |
//conect to windows server
|
|
100 |
Ws.Connect();
|
|
101 |
TInt wsHandle = Ws.WsHandle();
|
|
102 |
|
|
103 |
if(0!=wsHandle)
|
|
104 |
{
|
|
105 |
TApaTaskList taskList(Ws);
|
|
106 |
|
|
107 |
//switch to system
|
|
108 |
TApaTask newTask = taskList.FindApp(KTxtExampleCode);
|
|
109 |
|
|
110 |
if( newTask.WgId() != KErrNotFound )
|
|
111 |
newTask.SendToBackground();
|
|
112 |
|
|
113 |
//clean up RWsSession
|
|
114 |
Ws.Close();
|
|
115 |
}
|
|
116 |
else
|
|
117 |
{
|
|
118 |
iConsole->Printf(_L("Error: Unable to connect to windows server."));
|
|
119 |
}
|
|
120 |
#endif // ifndef LIGHT_MODE
|
|
121 |
}
|
|
122 |
|
|
123 |
/////////////////////////////////////////////////////////////////////////////
|
|
124 |
/////////////////////////////////////////////////////////////////////////////
|
|
125 |
|