|
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 |
|
19 // INCLUDE FILES |
|
20 #include "xnwallpaperview.h" |
|
21 #include "xnwallpapercontainer.h" |
|
22 #include "xnuiengine.h" |
|
23 #include "xneditor.h" |
|
24 |
|
25 // SYSTEM INCLUDE FILES |
|
26 #include <aknappui.h> |
|
27 #include <eikbtgpc.h> |
|
28 #include <avkon.rsg> |
|
29 #include <AknsWallpaperUtils.h> |
|
30 #include <MGFetch.h> |
|
31 |
|
32 _LIT8( KMulti, "multi" ); |
|
33 const TInt KFileArrayGranularity = 6; |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // C++ default constructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CXnWallpaperView::CXnWallpaperView( CXnUiEngine& aEngine ) : |
|
42 iEngine( aEngine ) |
|
43 { |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // Symbian 2nd phase constructor. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CXnWallpaperView::ConstructL() |
|
51 { |
|
52 BaseConstructL(); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // Two-phased constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CXnWallpaperView* CXnWallpaperView::NewL( CXnUiEngine& aEngine ) |
|
60 { |
|
61 CXnWallpaperView* self = new (ELeave) CXnWallpaperView( aEngine ); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // Destructor. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CXnWallpaperView::~CXnWallpaperView() |
|
73 { |
|
74 if ( iContainer ) |
|
75 { |
|
76 delete iContainer; |
|
77 iContainer = NULL; |
|
78 } |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CXnWallpaperView::Id |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 TUid CXnWallpaperView::Id() const |
|
86 { |
|
87 return KWallpaperViewUid; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CXnWallpaperView::DoActivateL |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void CXnWallpaperView::DoActivateL( |
|
95 const TVwsViewId& aPrevViewId, |
|
96 TUid aCustomMessageId, |
|
97 const TDesC8& aCustomMessage ) |
|
98 { |
|
99 iAvkonAppUi->StatusPane()->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL ); |
|
100 iAvkonAppUi->StatusPane()->DrawNow(); |
|
101 if ( !iContainer ) |
|
102 { |
|
103 iContainer = CXnWallpaperContainer::NewL(); |
|
104 iAvkonAppUi->AddToStackL( *this, iContainer ); |
|
105 iContainer->ActivateL(); |
|
106 iContainer->DrawNow(); |
|
107 } |
|
108 |
|
109 CDesCArrayFlat* files = |
|
110 new (ELeave) CDesCArrayFlat( KFileArrayGranularity ); |
|
111 CleanupStack::PushL( files ); |
|
112 TBool selected = EFalse; |
|
113 |
|
114 TBool multiple=EFalse; |
|
115 if( aCustomMessage == KMulti ) |
|
116 { |
|
117 multiple = ETrue; |
|
118 } |
|
119 TRAPD( err, selected = MGFetch::RunL( *files, EImageFile, multiple ) ); |
|
120 if ( err == KErrNone && |
|
121 selected && |
|
122 files->MdcaCount() > 0 ) |
|
123 { |
|
124 // set wallpaper. |
|
125 if( files->MdcaCount() == 1 ) |
|
126 { |
|
127 AknsWallpaperUtils::SetIdleWallpaper( |
|
128 files->MdcaPoint( 0 ), |
|
129 NULL ); |
|
130 } |
|
131 //set slideshow |
|
132 else |
|
133 { |
|
134 AknsWallpaperUtils::SetSlidesetWallpaper( |
|
135 *files, |
|
136 NULL ); |
|
137 } |
|
138 } |
|
139 |
|
140 CleanupStack::PopAndDestroy( files ); |
|
141 |
|
142 iAvkonAppUi->ActivateViewL( aPrevViewId ); |
|
143 |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CXnWallpaperView::DoActivateL |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CXnWallpaperView::DoDeactivate() |
|
151 { |
|
152 if ( iContainer ) |
|
153 { |
|
154 iAvkonAppUi->RemoveFromStack( iContainer ); |
|
155 delete iContainer; |
|
156 iContainer = NULL; |
|
157 } |
|
158 } |
|
159 |
|
160 // End of File |