|
1 /* |
|
2 * Copyright (c) 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 FILES |
|
20 #include "loadgen_appui.h" |
|
21 #include "loadgen_mainview.h" |
|
22 #include "loadgen.hrh" |
|
23 #include "loadgen_model.h" |
|
24 #include "loadgen_document.h" |
|
25 #include <loadgen.rsg> |
|
26 |
|
27 #include <avkon.hrh> |
|
28 #include <aknquerydialog.h> |
|
29 #include <aknmessagequerydialog.h> |
|
30 |
|
31 |
|
32 // ================= MEMBER FUNCTIONS ======================= |
|
33 |
|
34 void CLoadGenAppUi::ConstructL() |
|
35 { |
|
36 // disable window server priority control for this application |
|
37 iEikonEnv->WsSession().ComputeMode( RWsSession::EPriorityControlDisabled ); |
|
38 |
|
39 // set as system application to prevent getting shut down events |
|
40 iEikonEnv->SetSystem(ETrue); |
|
41 |
|
42 |
|
43 BaseConstructL(EAknEnableSkin); |
|
44 |
|
45 iModel = static_cast<CLoadGenDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model(); |
|
46 |
|
47 CLoadGenMainView* mainView = new(ELeave) CLoadGenMainView; |
|
48 CleanupStack::PushL(mainView); |
|
49 mainView->ConstructL(); |
|
50 AddViewL(mainView); // transfer ownership to CAknViewAppUi |
|
51 CleanupStack::Pop(); // mainView |
|
52 |
|
53 SetDefaultViewL(*mainView); |
|
54 |
|
55 // notify the model that everything has been constructed |
|
56 iModel->ActivateModelL(); |
|
57 } |
|
58 |
|
59 // -------------------------------------------------------------------------------------------- |
|
60 |
|
61 CLoadGenAppUi::~CLoadGenAppUi() |
|
62 { |
|
63 // notify the model that the application is closing |
|
64 if (iModel) |
|
65 TRAP_IGNORE(iModel->DeActivateModelL()); |
|
66 } |
|
67 |
|
68 // -------------------------------------------------------------------------------------------- |
|
69 |
|
70 void CLoadGenAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
71 { |
|
72 if (aResourceId == R_LOADGEN_APP_MENU) |
|
73 { |
|
74 aMenuPane->SetItemDimmed(ELoadGenStopAll, !iModel->LoadItemsExists()); |
|
75 aMenuPane->SetItemDimmed(ELoadGenSuspendAll, !iModel->LoadItemsExists()); |
|
76 aMenuPane->SetItemDimmed(ELoadGenResumeAll, !iModel->LoadItemsExists()); |
|
77 } |
|
78 } |
|
79 |
|
80 // -------------------------------------------------------------------------------------------- |
|
81 |
|
82 TKeyResponse CLoadGenAppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) |
|
83 { |
|
84 return EKeyWasNotConsumed; |
|
85 } |
|
86 |
|
87 // -------------------------------------------------------------------------------------------- |
|
88 |
|
89 void CLoadGenAppUi::HandleCommandL(TInt aCommand) |
|
90 { |
|
91 switch ( aCommand ) |
|
92 { |
|
93 case ELoadGenCmdLaunchPerfMon: |
|
94 { |
|
95 // launch Performance Monitor |
|
96 const TUid KUidPerfMon = { 0x20011385 }; |
|
97 |
|
98 RWsSession ws; |
|
99 User::LeaveIfError( ws.Connect() ); |
|
100 CleanupClosePushL(ws); |
|
101 |
|
102 RApaLsSession ls; |
|
103 User::LeaveIfError( ls.Connect() ); |
|
104 CleanupClosePushL(ls); |
|
105 |
|
106 |
|
107 // try to find the task of PerfMon |
|
108 TApaTaskList tasklist(ws); |
|
109 TApaTask task = tasklist.FindApp(KUidPerfMon); |
|
110 |
|
111 if (task.Exists()) |
|
112 { |
|
113 // task exists, bring it to foreground |
|
114 task.BringToForeground(); |
|
115 } |
|
116 else |
|
117 { |
|
118 TApaAppInfo appInfo; |
|
119 User::LeaveIfError(ls.GetAppInfo(appInfo, KUidPerfMon)); |
|
120 |
|
121 CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); |
|
122 cmdLine->SetExecutableNameL(appInfo.iFullName); |
|
123 cmdLine->SetCommandL(EApaCommandBackground); |
|
124 |
|
125 // start the app |
|
126 User::LeaveIfError(ls.StartApp(*cmdLine)); |
|
127 |
|
128 CleanupStack::PopAndDestroy(); //cmdLine |
|
129 } |
|
130 |
|
131 CleanupStack::PopAndDestroy(2); //ws,ls |
|
132 } |
|
133 break; |
|
134 |
|
135 case ELoadGenCmdAbout: |
|
136 { |
|
137 CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog; |
|
138 dialog->ExecuteLD(R_LOADGEN_ABOUT_DIALOG); |
|
139 } |
|
140 break; |
|
141 |
|
142 // a normal way to close an application |
|
143 case EAknCmdExit: |
|
144 case EEikCmdExit: |
|
145 case EAknSoftkeyExit: |
|
146 { |
|
147 Exit(); |
|
148 } |
|
149 break; |
|
150 |
|
151 default: |
|
152 break; |
|
153 } |
|
154 } |
|
155 |
|
156 // -------------------------------------------------------------------------------------------- |
|
157 |
|
158 // End of File |