56
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2006 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: Main state view for Psln application.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include <psln.rsg>
|
|
22 |
|
|
23 |
#include <eikbtgpc.h>
|
|
24 |
#include <avkon.rsg>
|
|
25 |
|
|
26 |
#include "PslnMainView.h"
|
|
27 |
#include "PslnMainViewContainer.h"
|
|
28 |
#include "PslnUi.h"
|
|
29 |
|
|
30 |
// Framework
|
|
31 |
#include <pslnfwplugininterface.h>
|
|
32 |
#include "PslnPluginHandler.h"
|
|
33 |
|
|
34 |
// CONSTANTS
|
|
35 |
// Main view indexes of default plugins.
|
|
36 |
const TInt KPslnASPluginLoc = 1;
|
|
37 |
const TInt KPslnAIPluginLoc = 2;
|
|
38 |
|
|
39 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
// Two-phased constructor.
|
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
CPslnMainView* CPslnMainView::NewLC()
|
|
45 |
{
|
|
46 |
CPslnMainView* self = new (ELeave) CPslnMainView();
|
|
47 |
CleanupStack::PushL( self );
|
|
48 |
self->ConstructL();
|
|
49 |
return self;
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// Symbian 2nd phase constructor can leave.
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
void CPslnMainView::ConstructL()
|
|
57 |
{
|
|
58 |
BaseConstructL( R_PSLN_MAIN_VIEW );
|
|
59 |
|
|
60 |
ConstructViewArrayL();
|
|
61 |
// Start background operation and create tabgroup.
|
|
62 |
iPslnUi->LoadViewsWhenIdleL();
|
|
63 |
iPslnUi->ConstructTabGroupL();
|
|
64 |
}
|
|
65 |
|
|
66 |
// ---------------------------------------------------------------------------
|
|
67 |
// C++ default constructor can NOT contain any code, that might leave.
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
CPslnMainView::CPslnMainView()
|
|
71 |
{
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
// Destructor.
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
CPslnMainView::~CPslnMainView()
|
|
79 |
{
|
|
80 |
iViewIds.Close();
|
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
// TUid CPslnMainView::Id()
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
TUid CPslnMainView::Id() const
|
|
88 |
{
|
|
89 |
return KPslnMainView2;
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
// CPslnMainView::HandleCommandL
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
void CPslnMainView::HandleCommandL( TInt aCommand )
|
|
97 |
{
|
|
98 |
switch ( aCommand )
|
|
99 |
{
|
|
100 |
case EPslnCmdAppOpen:
|
|
101 |
DoActivateLocalViewL();
|
|
102 |
break;
|
|
103 |
// If view was launched externally, handle back as exit.
|
|
104 |
case EAknSoftkeyBack:
|
|
105 |
case EAknSoftkeyExit:
|
|
106 |
aCommand = EAknCmdExit;
|
|
107 |
//lint -fallthrough
|
|
108 |
default:
|
|
109 |
iPslnUi->HandleCommandL( aCommand );
|
|
110 |
break;
|
|
111 |
}
|
|
112 |
}
|
|
113 |
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
// CPslnMainView::ActiveView
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
//
|
|
118 |
TInt CPslnMainView::ActiveView() const
|
|
119 |
{
|
|
120 |
return iCurrentItem;
|
|
121 |
}
|
|
122 |
|
|
123 |
// ---------------------------------------------------------------------------
|
|
124 |
// CPslnMainView::SetActiveFolder
|
|
125 |
// ---------------------------------------------------------------------------
|
|
126 |
//
|
|
127 |
void CPslnMainView::SetActiveFolder( TInt aIndex )
|
|
128 |
{
|
|
129 |
iCurrentItem = aIndex;
|
|
130 |
}
|
|
131 |
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
// CPslnMainView::ActiveFolderUid
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
TInt CPslnMainView::ActiveFolderUid()
|
|
137 |
{
|
|
138 |
if ( ( iCurrentItem > iViewIds.Count() )||
|
|
139 |
( iCurrentItem < 0 ) )
|
|
140 |
{
|
|
141 |
// If index is out-of-bounds, set first item active.
|
|
142 |
iCurrentItem = 0;
|
|
143 |
return 0;
|
|
144 |
}
|
|
145 |
return iViewIds[ iCurrentItem ].iUid;
|
|
146 |
}
|
|
147 |
|
|
148 |
// ---------------------------------------------------------------------------
|
|
149 |
// CPslnMainView::SetActiveFolder
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
void CPslnMainView::SetActiveFolder( TUid aUid )
|
|
153 |
{
|
|
154 |
for ( TInt idx = 0; idx < iViewIds.Count(); idx++ )
|
|
155 |
{
|
|
156 |
if ( iViewIds[ idx ].iUid == aUid.iUid )
|
|
157 |
{
|
|
158 |
iCurrentItem = idx;
|
|
159 |
}
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
// CPslnMainView::DoActivateL
|
|
165 |
// ---------------------------------------------------------------------------
|
|
166 |
void CPslnMainView::DoActivateL(
|
|
167 |
const TVwsViewId& aPrevViewId,
|
|
168 |
TUid aCustomMessageId,
|
|
169 |
const TDesC8& aCustomMessage )
|
|
170 |
{
|
|
171 |
// If application is launched through NULL thread, it means that it is
|
|
172 |
// launched as embedded application
|
|
173 |
if ( aPrevViewId.iAppUid.iUid == KUidPsln.iUid &&
|
|
174 |
aPrevViewId.iViewUid.iUid == KPslnGeneralView.iUid )
|
|
175 |
{
|
|
176 |
MAknsSkinInstance* si = AknsUtils::SkinInstance();
|
|
177 |
si->SetChangeEventsEnabled( EFalse );
|
|
178 |
si->RemoveLocalItemDefs();
|
|
179 |
si->SetChangeEventsEnabled( ETrue );
|
|
180 |
}
|
|
181 |
|
|
182 |
CPslnBaseView::DoActivateL(
|
|
183 |
aPrevViewId,
|
|
184 |
aCustomMessageId,
|
|
185 |
aCustomMessage );
|
|
186 |
|
|
187 |
// Set middle softkey label.
|
|
188 |
CPslnBaseView::SetMiddleSoftKeyLabelL(
|
|
189 |
R_PSLN_MSK_OPEN,
|
|
190 |
EPslnCmdAppOpen );
|
|
191 |
|
|
192 |
//set highlight ,if returning from other view
|
|
193 |
if(iContainer && aPrevViewId.iAppUid.iUid == KUidPsln.iUid)
|
|
194 |
{
|
|
195 |
//search which item should be highlighted
|
|
196 |
TInt activateItem = GetListboxItemIndexByViewId(aPrevViewId);
|
|
197 |
if(activateItem != KErrNotFound)
|
|
198 |
{
|
|
199 |
iContainer->SetCurrentItemIndex( activateItem );
|
|
200 |
}
|
|
201 |
else
|
|
202 |
{
|
|
203 |
iContainer->SetCurrentItemIndex( iCurrentItem );
|
|
204 |
}
|
|
205 |
}
|
|
206 |
}
|
|
207 |
|
|
208 |
// ---------------------------------------------------------------------------
|
|
209 |
// CPslnMainView::DynInitMenuPaneL
|
|
210 |
// ---------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
void CPslnMainView::DynInitMenuPaneL(
|
|
213 |
TInt aResourceId, CEikMenuPane* aMenuPane )
|
|
214 |
{
|
|
215 |
CPslnBaseView::DynInitMenuPaneL( aResourceId, aMenuPane );
|
|
216 |
}
|
|
217 |
|
|
218 |
// ---------------------------------------------------------------------------
|
|
219 |
// CPslnMainView::HandleListBoxSelectionL
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
//
|
|
222 |
void CPslnMainView::HandleListBoxSelectionL()
|
|
223 |
{
|
|
224 |
HandleCommandL( EPslnCmdAppOpen );
|
|
225 |
}
|
|
226 |
|
|
227 |
// ---------------------------------------------------------------------------
|
|
228 |
// CPslnMainView::NewContainerL
|
|
229 |
// ---------------------------------------------------------------------------
|
|
230 |
//
|
|
231 |
void CPslnMainView::NewContainerL()
|
|
232 |
{
|
|
233 |
iContainer = new(ELeave) CPslnMainViewContainer( iPslnUi );
|
|
234 |
}
|
|
235 |
|
|
236 |
// ---------------------------------------------------------------------------
|
|
237 |
// CPslnMainView::ConstructViewArrayL
|
|
238 |
// ---------------------------------------------------------------------------
|
|
239 |
//
|
|
240 |
void CPslnMainView::ConstructViewArrayL()
|
|
241 |
{
|
|
242 |
// First add static views.
|
|
243 |
iViewIds.AppendL( KPslnGeneralView );
|
|
244 |
|
|
245 |
TBitFlags views = iPslnUi->ViewSupport();
|
|
246 |
if ( views.IsSet( CPslnUi::EPslnWallpaperView ) )
|
|
247 |
{
|
|
248 |
iViewIds.AppendL( KPslnWallpaperView );
|
|
249 |
}
|
|
250 |
|
|
251 |
if ( views.IsSet ( CPslnUi::EPslnScreensaverView ) )
|
|
252 |
{
|
|
253 |
iViewIds.AppendL( KPslnScreenSaverView );
|
|
254 |
}
|
|
255 |
|
|
256 |
// Then start looking for plugins.
|
|
257 |
CArrayPtrFlat<CPslnFWPluginInterface>* array =
|
|
258 |
iPslnUi->PluginHandler()->GetPluginArray();
|
|
259 |
CleanupStack::PushL ( array );
|
|
260 |
if ( array )
|
|
261 |
{
|
|
262 |
TBool appShellPluginInserted = EFalse;
|
|
263 |
for ( TInt i = 0; i < array->Count(); i++ )
|
|
264 |
{
|
|
265 |
CAknView* view = array->At( i );
|
|
266 |
|
|
267 |
// If plugin is either AS or AI, insert between static views.
|
|
268 |
if ( view->Id().iUid == KPslnASPluginUid.iUid )
|
|
269 |
{
|
|
270 |
iViewIds.InsertL( view->Id(), KPslnASPluginLoc );
|
|
271 |
appShellPluginInserted = ETrue;
|
|
272 |
}
|
|
273 |
else if ( view->Id().iUid == KPslnAIPluginUid.iUid )
|
|
274 |
{
|
|
275 |
if ( appShellPluginInserted )
|
|
276 |
{
|
|
277 |
iViewIds.InsertL( view->Id(), KPslnAIPluginLoc );
|
|
278 |
}
|
|
279 |
else
|
|
280 |
{
|
|
281 |
// If there is ASplugin - claim it's place.
|
|
282 |
// note that ASplugin maybe later inserted to this place.
|
|
283 |
iViewIds.InsertL( view->Id(), KPslnASPluginLoc );
|
|
284 |
}
|
|
285 |
}
|
|
286 |
// Other plugins are just appended in order from plugin array.
|
|
287 |
// Plugins are already ordered in PluginHandler.
|
|
288 |
else
|
|
289 |
{
|
|
290 |
iViewIds.AppendL( view->Id() );
|
|
291 |
}
|
|
292 |
}
|
|
293 |
}
|
|
294 |
CleanupStack::Pop( array );
|
|
295 |
}
|
|
296 |
|
|
297 |
// ---------------------------------------------------------------------------
|
|
298 |
// CPslnMainView::CbaExitEnabled
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
TInt CPslnMainView::CbaResourceId( const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/ )
|
|
302 |
{
|
|
303 |
TBool value = iEikonEnv->StartedAsServerApp();
|
|
304 |
return value ? R_AVKON_SOFTKEYS_OPTIONS_BACK
|
|
305 |
: R_AVKON_SOFTKEYS_OPTIONS_EXIT;
|
|
306 |
}
|
|
307 |
|
|
308 |
// ---------------------------------------------------------------------------
|
|
309 |
// Tries to activate local view from UI class. If class is not yet
|
|
310 |
// created, instructs UI class to create the view first.
|
|
311 |
// ---------------------------------------------------------------------------
|
|
312 |
//
|
|
313 |
void CPslnMainView::DoActivateLocalViewL()
|
|
314 |
{
|
|
315 |
if ( iContainer )
|
|
316 |
{
|
|
317 |
iCurrentItem = iContainer->CurrentItemIndex();
|
|
318 |
}
|
|
319 |
if ( iCurrentItem > iViewIds.Count() )
|
|
320 |
{
|
|
321 |
User::Leave( KErrOverflow );
|
|
322 |
}
|
|
323 |
// These views are possibly done dynamically. It is possible that due to
|
|
324 |
// idle time, they have already been created.
|
|
325 |
if ( iCurrentItem == KPslnGeneralView.iUid ||
|
|
326 |
iCurrentItem == KPslnWallpaperView.iUid ||
|
|
327 |
iCurrentItem == KPslnScreenSaverView.iUid )
|
|
328 |
{
|
|
329 |
iPslnUi->CreateViewL( iViewIds[ iCurrentItem ] );
|
|
330 |
}
|
|
331 |
iPslnUi->ActivateLocalViewL( iViewIds[ iCurrentItem ] );
|
|
332 |
}
|
|
333 |
|
|
334 |
// ---------------------------------------------------------------------------
|
|
335 |
// Return given view's index by searching the view id
|
|
336 |
// ---------------------------------------------------------------------------
|
|
337 |
//
|
|
338 |
TInt CPslnMainView::GetListboxItemIndexByViewId(const TVwsViewId& aViewId) const
|
|
339 |
{
|
|
340 |
TInt listBoxItemIndex = KErrNotFound;
|
|
341 |
|
|
342 |
for( int i=0; i<iViewIds.Count(); i++ )
|
|
343 |
{
|
|
344 |
if( iViewIds[i] == aViewId.iViewUid )
|
|
345 |
{
|
|
346 |
listBoxItemIndex = i;
|
|
347 |
}
|
|
348 |
}
|
|
349 |
|
|
350 |
return listBoxItemIndex;
|
|
351 |
};
|
|
352 |
|
|
353 |
// End of File
|