1 /* |
|
2 * Copyright (c) 2002 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: Dumper application |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CWPCxView.h" |
|
21 #include <aknviewappui.h> |
|
22 #include <aknnotewrappers.h> |
|
23 #include <aknquerydialog.h> |
|
24 #include <StringLoader.h> |
|
25 #include <ProvisioningCx.rsg> |
|
26 #include <featmgr.h> |
|
27 #include <bldvariant.hrh> |
|
28 #include <eikmenup.h> |
|
29 #include <eikmenub.h> |
|
30 #include "CWPEngine.h" |
|
31 #include "CWPCxContainer.h" |
|
32 #include "CWPCxDeleter.h" |
|
33 #include "ProvisioningCx.hrh" |
|
34 #include <csxhelp/prov.hlp.hrh> |
|
35 |
|
36 // CONSTANTS |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ======================= |
|
39 |
|
40 // --------------------------------------------------------- |
|
41 // CWPCxView::ConstructL |
|
42 // Symbian second phase constructor |
|
43 // --------------------------------------------------------- |
|
44 // |
|
45 void CWPCxView::ConstructL() |
|
46 { |
|
47 BaseConstructL( R_PROVISIONINGCX_VIEW1 ); |
|
48 FeatureManager::InitializeLibL(); |
|
49 iEngine = CWPEngine::NewL(); |
|
50 iEngine->RegisterContextObserverL( this ); |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------- |
|
54 // CWPCxView::~CWPCxView |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 CWPCxView::~CWPCxView() |
|
58 { |
|
59 if ( iContainer ) |
|
60 { |
|
61 AppUi()->RemoveFromStack( iContainer ); |
|
62 } |
|
63 |
|
64 delete iContainer; |
|
65 delete iEngine; |
|
66 FeatureManager::UnInitializeLib(); |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // TUid CWPCxView::Id |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 TUid CWPCxView::Id() const |
|
74 { |
|
75 return KProvisioningCxViewId; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CWPCxView::HandleCommandL |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 void CWPCxView::HandleCommandL(TInt aCommand) |
|
83 { |
|
84 switch ( aCommand ) |
|
85 { |
|
86 case EProvisioningCxCmdDeleteContext: |
|
87 { |
|
88 DeleteContextL(); |
|
89 break; |
|
90 } |
|
91 case EAknSoftkeyBack: |
|
92 { |
|
93 AppUi()->HandleCommandL(EEikCmdExit); |
|
94 break; |
|
95 } |
|
96 case EProvisioningCxCmdSelect: |
|
97 { |
|
98 LaunchPopupL(); |
|
99 break; |
|
100 } |
|
101 default: |
|
102 { |
|
103 AppUi()->HandleCommandL(aCommand); |
|
104 break; |
|
105 } |
|
106 } |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------- |
|
110 // CWPCxView::HandleClientRectChange |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 void CWPCxView::HandleClientRectChange() |
|
114 { |
|
115 if ( iContainer ) |
|
116 { |
|
117 iContainer->SetRect( ClientRect() ); |
|
118 } |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // CWPCxView::DoActivateL |
|
123 // --------------------------------------------------------- |
|
124 // |
|
125 void CWPCxView::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
126 TUid /*aCustomMessageId*/, |
|
127 const TDesC8& /*aCustomMessage*/) |
|
128 { |
|
129 iContainer = new (ELeave) CWPCxContainer( *iEngine, *this ); |
|
130 iContainer->ConstructL( ClientRect() ); |
|
131 iContainer->SetMopParent( this ); |
|
132 AppUi()->AddToStackL( *this, iContainer ); |
|
133 #ifdef __SERIES60_32__ |
|
134 MenuBar()->SetContextMenuTitleResourceId( R_PROVISIONINGCX_CONTEXT_MENUBAR ); |
|
135 |
|
136 CEikButtonGroupContainer* bgc(NULL); |
|
137 CCoeControl* MSK(NULL); |
|
138 CEikCba* cba(NULL); |
|
139 MopGetObject (bgc); |
|
140 TInt count(iContainer->ContextCount()); |
|
141 |
|
142 |
|
143 if (bgc) |
|
144 { |
|
145 cba = ( static_cast<CEikCba*>( bgc->ButtonGroup() ) ); // downcast from MEikButtonGroup |
|
146 if (cba) |
|
147 { |
|
148 MSK = cba->Control(3); // MSK's position is 3 |
|
149 } |
|
150 |
|
151 MSK->MakeVisible((count > 0)); |
|
152 } |
|
153 |
|
154 #endif |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------- |
|
158 // CWPCxView::DoDeactivate |
|
159 // --------------------------------------------------------- |
|
160 // |
|
161 void CWPCxView::DoDeactivate() |
|
162 { |
|
163 if ( iContainer ) |
|
164 { |
|
165 AppUi()->RemoveFromStack( iContainer ); |
|
166 } |
|
167 |
|
168 delete iContainer; |
|
169 iContainer = NULL; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------- |
|
173 // CWPCxView::ContextChangeL |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 void CWPCxView::ContextChangeL( RDbNotifier::TEvent /*aEvent*/ ) |
|
177 { |
|
178 iContainer->UpdateContextsL(); |
|
179 |
|
180 #ifdef __SERIES60_32__ |
|
181 CEikButtonGroupContainer* bgc(NULL); |
|
182 CCoeControl* MSK(NULL); |
|
183 CEikCba* cba(NULL); |
|
184 MopGetObject (bgc); |
|
185 TInt count(iContainer->ContextCount()); |
|
186 |
|
187 |
|
188 if (bgc) |
|
189 { |
|
190 cba = ( static_cast<CEikCba*>( bgc->ButtonGroup() ) ); // downcast from MEikButtonGroup |
|
191 if (cba) |
|
192 { |
|
193 MSK = cba->Control(3); // MSK's position is 3 |
|
194 } |
|
195 |
|
196 MSK->MakeVisible((count > 0)); |
|
197 } |
|
198 |
|
199 #endif |
|
200 } |
|
201 |
|
202 // ------------------------------------------------------------------------------ |
|
203 // CWPCxView::::DynInitMenuPaneL |
|
204 // ------------------------------------------------------------------------------ |
|
205 // |
|
206 void CWPCxView::DynInitMenuPaneL( |
|
207 TInt aResourceId,CEikMenuPane* aMenuPane) |
|
208 { |
|
209 switch( aResourceId ) |
|
210 { |
|
211 case R_PROVISIONINGCX_APP_MENU: |
|
212 { |
|
213 if( !FeatureManager::FeatureSupported(KFeatureIdHelp) ) |
|
214 { |
|
215 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
216 } |
|
217 |
|
218 if( iContainer->ContextCount() == 0 ) |
|
219 { |
|
220 aMenuPane->SetItemDimmed( EProvisioningCxCmdDeleteContext, ETrue ); |
|
221 } |
|
222 |
|
223 break; |
|
224 } |
|
225 |
|
226 case R_PROVISIONINGCX_CONTEXT_MENU: |
|
227 { |
|
228 if( iContainer->ContextCount() == 0 ) |
|
229 { |
|
230 aMenuPane->SetItemDimmed( EProvisioningCxCmdDeleteContext, ETrue ); |
|
231 } |
|
232 break; |
|
233 } |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 // ------------------------------------------------------------------------------ |
|
239 // CWPCxView::::DeleteContextL |
|
240 // ------------------------------------------------------------------------------ |
|
241 // |
|
242 void CWPCxView::DeleteContextL() |
|
243 { |
|
244 if(iContainer->ContextCount() == 0 ) |
|
245 { |
|
246 return; |
|
247 } |
|
248 TPtrC name( iContainer->CurrentContextName() ); |
|
249 HBufC* query = StringLoader::LoadLC( R_QTN_OP_DELETE_CONTEXT, name ); |
|
250 |
|
251 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
252 if ( dlg->ExecuteLD( R_PROVISIONCX_QUERY_DELETE, *query ) ) |
|
253 { |
|
254 TUint32 cx( iContainer->CurrentContext() ); |
|
255 CWPCxDeleter* deleter = new(ELeave) CWPCxDeleter( *iEngine, cx ); |
|
256 TInt numDeleted( 0 ); |
|
257 TInt err( deleter->ExecuteLD( numDeleted ) ); |
|
258 if( err == KErrNone ) |
|
259 { |
|
260 iEngine->DeleteContextL( cx ); |
|
261 } |
|
262 else if( err != KErrCancel ) |
|
263 { |
|
264 // Some problem in saving or user cancelled. |
|
265 HBufC* text = StringLoader::LoadLC( R_TEXT_QTN_OP_DEL_CONT_NO ); |
|
266 CAknErrorNote* note = new(ELeave)CAknErrorNote( ETrue ); |
|
267 note->ExecuteLD(*text); |
|
268 CleanupStack::PopAndDestroy(); // text |
|
269 } |
|
270 } |
|
271 CleanupStack::PopAndDestroy(); // query |
|
272 } |
|
273 |
|
274 |
|
275 // ---------------------------------------------------- |
|
276 // CWPCxView::LaunchPopupL |
|
277 // ---------------------------------------------------- |
|
278 // |
|
279 void CWPCxView::LaunchPopupL() |
|
280 { |
|
281 CEikMenuBar* menu = MenuBar(); |
|
282 |
|
283 menu->SetMenuTitleResourceId( R_PROVISIONINGCX_CONTEXT_MENUBAR ); |
|
284 TRAPD( err, menu->TryDisplayMenuBarL() ); |
|
285 menu->SetMenuTitleResourceId( R_PROVISIONINGCX_MENUBAR_VIEW1 ); |
|
286 |
|
287 User::LeaveIfError( err ); |
|
288 |
|
289 } |
|
290 |
|
291 // End of File |
|