34
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Wallpaper view.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System includes
|
|
19 |
#include <eikbtgpc.h>
|
|
20 |
#include <avkon.rsg>
|
|
21 |
#include <MGFetch.h>
|
|
22 |
#include <bautils.h>
|
|
23 |
#include <data_caging_path_literals.hrh>
|
|
24 |
|
|
25 |
// User includes
|
|
26 |
#include <xnwallpaperview.rsg>
|
|
27 |
#include "xnwallpaperview.h"
|
|
28 |
#include "xnwallpapercontainer.h"
|
|
29 |
#include "xnuiengine.h"
|
|
30 |
#include "xnappuiadapter.h"
|
|
31 |
#include "xnviewadapter.h"
|
|
32 |
#include "xnviewmanager.h"
|
|
33 |
#include "xneffectmanager.h"
|
|
34 |
#include "xnspbgcleaner.h"
|
|
35 |
|
|
36 |
// Constants
|
|
37 |
_LIT( KResourceDrive, "z:" );
|
|
38 |
_LIT( KResourceFile, "xnwallpaperview.rsc" );
|
|
39 |
|
|
40 |
_LIT8( KMulti, "multi" );
|
|
41 |
_LIT8( KSetWallpaper, "setwallpaper" );
|
|
42 |
|
|
43 |
const TInt KFileArrayGranularity( 6 );
|
|
44 |
|
|
45 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
46 |
|
|
47 |
// -----------------------------------------------------------------------------
|
|
48 |
// C++ default constructor.
|
|
49 |
//
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
CXnWallpaperView::CXnWallpaperView( CXnUiEngine& aEngine )
|
|
53 |
: iEngine( aEngine ), iAppUi( iEngine.AppUiAdapter() )
|
|
54 |
{
|
|
55 |
}
|
|
56 |
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
// Symbian 2nd phase constructor.
|
|
59 |
//
|
|
60 |
// -----------------------------------------------------------------------------
|
|
61 |
//
|
|
62 |
void CXnWallpaperView::ConstructL()
|
|
63 |
{
|
|
64 |
TFileName resFile;
|
|
65 |
resFile.Append( KResourceDrive );
|
|
66 |
resFile.Append( KDC_APP_RESOURCE_DIR );
|
|
67 |
resFile.Append( KResourceFile );
|
|
68 |
|
|
69 |
CCoeEnv* env( CCoeEnv::Static() );
|
|
70 |
|
|
71 |
BaflUtils::NearestLanguageFile( env->FsSession(), resFile );
|
|
72 |
|
|
73 |
iResourceOffset = env->AddResourceFileL( resFile );
|
|
74 |
|
|
75 |
BaseConstructL( R_WALLPAPER_VIEW );
|
|
76 |
|
|
77 |
TCallBack cb( HandleCallback, this );
|
|
78 |
|
|
79 |
iAsyncCb = new ( ELeave ) CAsyncCallBack( cb, CActive::EPriorityHigh );
|
|
80 |
|
|
81 |
iFiles = new ( ELeave ) CDesCArrayFlat( KFileArrayGranularity );
|
|
82 |
}
|
|
83 |
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
// Two-phased constructor.
|
|
86 |
//
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
CXnWallpaperView* CXnWallpaperView::NewL( CXnUiEngine& aEngine )
|
|
90 |
{
|
|
91 |
CXnWallpaperView* self = new (ELeave) CXnWallpaperView( aEngine );
|
|
92 |
CleanupStack::PushL( self );
|
|
93 |
self->ConstructL();
|
|
94 |
CleanupStack::Pop( self );
|
|
95 |
return self;
|
|
96 |
}
|
|
97 |
|
|
98 |
// -----------------------------------------------------------------------------
|
|
99 |
// Destructor.
|
|
100 |
//
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
//
|
|
103 |
CXnWallpaperView::~CXnWallpaperView()
|
|
104 |
{
|
|
105 |
CCoeEnv::Static()->DeleteResourceFile( iResourceOffset );
|
|
106 |
|
|
107 |
if ( iFiles )
|
|
108 |
{
|
|
109 |
iFiles->Reset();
|
|
110 |
}
|
|
111 |
|
|
112 |
delete iFiles;
|
|
113 |
delete iContainer;
|
|
114 |
delete iSpBgCleaner;
|
|
115 |
delete iAsyncCb;
|
|
116 |
}
|
|
117 |
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
// CXnWallpaperView::Id
|
|
120 |
//
|
|
121 |
// -----------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
TUid CXnWallpaperView::Id() const
|
|
124 |
{
|
|
125 |
return KWallpaperViewUid;
|
|
126 |
}
|
|
127 |
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
// CXnWallpaperView::DoActivateL
|
|
130 |
//
|
|
131 |
// -----------------------------------------------------------------------------
|
|
132 |
//
|
|
133 |
void CXnWallpaperView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
|
|
134 |
TUid /*aCustomMessageId*/, const TDesC8& aCustomMessage )
|
|
135 |
{
|
|
136 |
// switch layout
|
|
137 |
CEikStatusPane* sp( iAppUi.StatusPane() );
|
|
138 |
|
|
139 |
// setup status pane layout
|
|
140 |
sp->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL_FLAT );
|
|
141 |
// apply changes
|
|
142 |
sp->ApplyCurrentSettingsL();
|
|
143 |
// disable transparancy
|
|
144 |
sp->EnableTransparent( EFalse );
|
|
145 |
|
|
146 |
// create background cleaner for sp
|
|
147 |
if ( !iSpBgCleaner )
|
|
148 |
{
|
|
149 |
iSpBgCleaner = CXnSpBgCleaner::NewL();
|
|
150 |
AppUi()->AddToStackL( *this, iSpBgCleaner );
|
|
151 |
}
|
|
152 |
|
|
153 |
// update sp
|
|
154 |
iSpBgCleaner->DrawNow();
|
|
155 |
sp->DrawNow();
|
|
156 |
|
|
157 |
// update cba
|
|
158 |
CEikButtonGroupContainer* bgc( Cba() );
|
|
159 |
CEikCba* cba = static_cast< CEikCba* >( bgc->ButtonGroup() );
|
|
160 |
|
|
161 |
if ( cba )
|
|
162 |
{
|
|
163 |
bgc->SetBoundingRect( TRect() );
|
|
164 |
cba->DrawNow();
|
|
165 |
}
|
|
166 |
|
|
167 |
if ( !iContainer )
|
|
168 |
{
|
|
169 |
iContainer = CXnWallpaperContainer::NewL();
|
|
170 |
iAppUi.AddToStackL( *this, iContainer );
|
|
171 |
iContainer->ActivateL();
|
|
172 |
iContainer->DrawNow();
|
|
173 |
}
|
|
174 |
|
|
175 |
iAppUi.EffectManager()->EndFullscreenEffect( KGfxContextOpenWallpaperView );
|
|
176 |
|
|
177 |
iMultiple = ( aCustomMessage == KMulti ) ? ETrue : EFalse;
|
|
178 |
|
|
179 |
// Run image selection dialog asynchronously
|
|
180 |
iAsyncCb->CallBack();
|
|
181 |
}
|
|
182 |
|
|
183 |
// -----------------------------------------------------------------------------
|
|
184 |
// CXnWallpaperView::DoDeactivate
|
|
185 |
//
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
void CXnWallpaperView::DoDeactivate()
|
|
189 |
{
|
|
190 |
if ( iContainer )
|
|
191 |
{
|
|
192 |
iAppUi.RemoveFromStack( iContainer );
|
|
193 |
delete iContainer;
|
|
194 |
iContainer = NULL;
|
|
195 |
}
|
|
196 |
|
|
197 |
if ( iSpBgCleaner )
|
|
198 |
{
|
|
199 |
AppUi()->RemoveFromStack( iSpBgCleaner );
|
|
200 |
delete iSpBgCleaner;
|
|
201 |
iSpBgCleaner = NULL;
|
|
202 |
}
|
|
203 |
|
|
204 |
iAppUi.EffectManager()->EndFullscreenEffect( KGfxContextCloseWallpaperView );
|
|
205 |
}
|
|
206 |
|
|
207 |
// -----------------------------------------------------------------------------
|
|
208 |
// CXnWallpaperView::SelectedWallpaper
|
|
209 |
//
|
|
210 |
// -----------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
void CXnWallpaperView::SelectedWallpaper( TFileName& aFileName ) const
|
|
213 |
{
|
|
214 |
aFileName.Copy( iFileName );
|
|
215 |
}
|
|
216 |
|
|
217 |
// -----------------------------------------------------------------------------
|
|
218 |
// CXnWallpaperView::HandleCallback
|
|
219 |
//
|
|
220 |
// -----------------------------------------------------------------------------
|
|
221 |
//
|
|
222 |
TInt CXnWallpaperView::HandleCallback( TAny* aAny )
|
|
223 |
{
|
|
224 |
CXnWallpaperView* self = static_cast< CXnWallpaperView* >( aAny );
|
|
225 |
|
|
226 |
TRAP_IGNORE( self->DoHandleCallbackL() );
|
|
227 |
|
|
228 |
return KErrNone;
|
|
229 |
}
|
|
230 |
|
|
231 |
// -----------------------------------------------------------------------------
|
|
232 |
// CXnWallpaperView::DoHandleCallbackL
|
|
233 |
//
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
void CXnWallpaperView::DoHandleCallbackL()
|
|
237 |
{
|
|
238 |
// Reset
|
|
239 |
iFileName = KNullDesC();
|
|
240 |
iFiles->Reset();
|
|
241 |
|
|
242 |
TBool selected( EFalse );
|
|
243 |
|
|
244 |
TRAP_IGNORE( selected =
|
|
245 |
MGFetch::RunL( *iFiles, EImageFile, iMultiple ) );
|
|
246 |
|
|
247 |
if ( selected && iFiles->MdcaCount() > 0 )
|
|
248 |
{
|
|
249 |
// Reset
|
|
250 |
selected = EFalse;
|
|
251 |
|
|
252 |
if( iFiles->MdcaCount() == 1 )
|
|
253 |
{
|
|
254 |
TPtrC fileName( iFiles->MdcaPoint( 0 ) );
|
|
255 |
|
|
256 |
RFs& fs( CEikonEnv::Static()->FsSession() );
|
|
257 |
|
|
258 |
if ( BaflUtils::FileExists( fs, fileName ) )
|
|
259 |
{
|
|
260 |
// Accept the selected file
|
|
261 |
selected = ETrue;
|
|
262 |
iFileName.Copy( fileName );
|
|
263 |
}
|
|
264 |
}
|
|
265 |
|
|
266 |
iFiles->Reset();
|
|
267 |
}
|
|
268 |
|
|
269 |
// Default view
|
|
270 |
TVwsViewId xmlViewId( iAppUi.View().ViewId() );
|
|
271 |
|
|
272 |
const TDesC8& param( selected ? KSetWallpaper() : KNullDesC8() );
|
|
273 |
|
|
274 |
iAppUi.EffectManager()->BeginFullscreenEffectL( KGfxContextCloseWallpaperView );
|
|
275 |
|
|
276 |
iAppUi.ActivateLocalViewL( xmlViewId.iViewUid, TUid(), param );
|
|
277 |
}
|
|
278 |
|
|
279 |
// End of File
|