|
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.hrh" |
|
21 #include "loadgen_mainview.h" |
|
22 #include "loadgen_maincontainer.h" |
|
23 #include "loadgen_document.h" |
|
24 #include "loadgen_model.h" |
|
25 #include "loadgen_traces.h" |
|
26 #include <loadgen.rsg> |
|
27 |
|
28 #include <eikenv.h> |
|
29 #include <aknviewappui.h> |
|
30 #include <aknnotewrappers.h> |
|
31 |
|
32 |
|
33 // ================= MEMBER FUNCTIONS ======================= |
|
34 |
|
35 // --------------------------------------------------------- |
|
36 // CLoadGenMainView::ConstructL(const TRect& aRect) |
|
37 // EPOC two-phased constructor |
|
38 // --------------------------------------------------------- |
|
39 // |
|
40 void CLoadGenMainView::ConstructL() |
|
41 { |
|
42 BaseConstructL( R_LOADGEN_VIEW_MAIN ); |
|
43 iModel = static_cast<CLoadGenDocument*>(reinterpret_cast<CEikAppUi*>(iEikonEnv->AppUi())->Document())->Model(); |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------- |
|
47 // CLoadGenMainView::~CLoadGenMainView() |
|
48 // --------------------------------------------------------- |
|
49 // |
|
50 CLoadGenMainView::~CLoadGenMainView() |
|
51 { |
|
52 if (iContainer) |
|
53 { |
|
54 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
55 delete iContainer; |
|
56 iContainer = NULL; |
|
57 } |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // TUid CLoadGenMainView::Id() |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 TUid CLoadGenMainView::Id() const |
|
65 { |
|
66 return KMainViewUID; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // TUid CLoadGenMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CLoadGenMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) |
|
74 { |
|
75 AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane); |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CLoadGenMainView::HandleCommandL(TInt aCommand) |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 void CLoadGenMainView::HandleCommandL(TInt aCommand) |
|
84 { |
|
85 switch ( aCommand ) |
|
86 { |
|
87 case ELoadGenCmdNewLoadCPULoad: |
|
88 case ELoadGenCmdNewLoadEatMemory: |
|
89 case ELoadGenCmdNewLoadPhoneCall: |
|
90 case ELoadGenCmdNewLoadNetConn: |
|
91 case ELoadGenCmdNewLoadKeyPress: |
|
92 case ELoadGenCmdNewLoadMessages: |
|
93 case ELoadGenCmdNewLoadApplications: |
|
94 case ELoadGenCmdNewLoadPhotoCaptures: |
|
95 case ELoadGenCmdNewLoadBluetooth: |
|
96 case ELoadGenCmdNewLoadPointerEvent: |
|
97 { |
|
98 TRAPD(err, iModel->StartNewLoadL(aCommand)); |
|
99 if( err != KErrNone ) |
|
100 { |
|
101 LOGSTRING2("LoadGen: Load (command: %d) start failed!", aCommand); |
|
102 _LIT(message, "Load start failed!"); |
|
103 CAknErrorNote* errorNote = new(ELeave) CAknErrorNote; |
|
104 errorNote->ExecuteLD(message); |
|
105 } |
|
106 break; |
|
107 } |
|
108 case ELoadGenStopAll: |
|
109 { |
|
110 iModel->StopAllLoadItemsL(); |
|
111 break; |
|
112 } |
|
113 case ELoadGenSuspendAll: |
|
114 { |
|
115 iModel->SuspendAllLoadItemsL(); |
|
116 break; |
|
117 } |
|
118 case ELoadGenResumeAll: |
|
119 { |
|
120 iModel->ResumeAllLoadItemsL(); |
|
121 break; |
|
122 } |
|
123 default: |
|
124 { |
|
125 AppUi()->HandleCommandL(aCommand); |
|
126 break; |
|
127 } |
|
128 } |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------- |
|
132 // CLoadGenMainView::HandleClientRectChange() |
|
133 // --------------------------------------------------------- |
|
134 // |
|
135 void CLoadGenMainView::HandleClientRectChange() |
|
136 { |
|
137 if ( iContainer ) |
|
138 { |
|
139 iContainer->SetRect( ClientRect() ); |
|
140 } |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------- |
|
144 // CLoadGenMainView::DoActivateL(...) |
|
145 // --------------------------------------------------------- |
|
146 // |
|
147 void CLoadGenMainView::DoActivateL( |
|
148 const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, |
|
149 const TDesC8& /*aCustomMessage*/) |
|
150 { |
|
151 if (!iContainer) |
|
152 { |
|
153 iContainer = new (ELeave) CLoadGenMainContainer; |
|
154 iModel->SetMainContainer(iContainer); |
|
155 iContainer->SetMopParent(this); |
|
156 iContainer->ConstructL( ClientRect() ); |
|
157 AppUi()->AddToStackL( *this, iContainer ); |
|
158 } |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------- |
|
162 // CLoadGenMainView::DoDeactivate() |
|
163 // --------------------------------------------------------- |
|
164 // |
|
165 void CLoadGenMainView::DoDeactivate() |
|
166 { |
|
167 if (iContainer) |
|
168 { |
|
169 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
170 delete iContainer; |
|
171 iContainer = NULL; |
|
172 } |
|
173 } |
|
174 |
|
175 // End of File |