|
1 /* |
|
2 * Copyright (c) 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: Document class required by AVKON application framework. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <AiwGenericParam.h> |
|
21 #include <mpxviewutility.h> |
|
22 |
|
23 #include "mpxdocument.h" |
|
24 #include "mpxappui.h" |
|
25 #include "mpxtlshelper.h" |
|
26 |
|
27 |
|
28 // ======== MEMBER FUNCTIONS ======== |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // C++ constructor. |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CMPXDocument::CMPXDocument( CEikApplication& aApp ) |
|
35 : CAiwGenericParamConsumer( aApp ) |
|
36 { |
|
37 } |
|
38 |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // Symbian 2nd phase constructor can leave. |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 void CMPXDocument::ConstructL() |
|
45 { |
|
46 // Initialize TLS |
|
47 MPXTlsHelper::InitializeL(); |
|
48 |
|
49 // Get view utility. View utility must be created before AppUi. |
|
50 iViewUtility = MMPXViewUtility::UtilityL(); |
|
51 } |
|
52 |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Two-phased constructor. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CMPXDocument* CMPXDocument::NewL( |
|
59 CEikApplication& aApp ) |
|
60 { |
|
61 CMPXDocument* self = new ( ELeave ) CMPXDocument( aApp ); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop(); |
|
65 |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Destructor |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CMPXDocument::~CMPXDocument() |
|
75 { |
|
76 if ( iViewUtility ) |
|
77 { |
|
78 iViewUtility->Close(); |
|
79 } |
|
80 |
|
81 // Release resources in TLS |
|
82 MPXTlsHelper::Uninitialize(); |
|
83 } |
|
84 |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // Parse input paramaters from AIW interface. |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 TBool CMPXDocument::ParseInputParameters() |
|
91 { |
|
92 TBool openFile( ETrue ); |
|
93 TPtrC buf; |
|
94 TPtrC name; |
|
95 |
|
96 const CAiwGenericParamList* params = GetInputParameters(); |
|
97 if ( params ) |
|
98 { |
|
99 TInt index( 0 ); |
|
100 const TAiwGenericParam* param = params->FindFirst( |
|
101 index, |
|
102 EGenericParamPlayerInitMode, |
|
103 EVariantTypeTInt32 ); |
|
104 |
|
105 if ( !param ) |
|
106 { |
|
107 index = 0; |
|
108 param = params->FindFirst( |
|
109 index, |
|
110 EGenericParamUnspecified, |
|
111 EVariantTypeTInt32 ); |
|
112 } |
|
113 |
|
114 if ( index >= 0 && param ) |
|
115 { |
|
116 TInt32 value( 0 ); |
|
117 param->Value().Get( value ); |
|
118 TRAP_IGNORE( MPXTlsHelper::SetLaunchModeL( |
|
119 static_cast<TMPXLaunchMode>( value ) ) ); |
|
120 } |
|
121 |
|
122 // Get album contents, if available |
|
123 index = 0; |
|
124 param = params->FindFirst( |
|
125 index, |
|
126 EGenericParamAlbumItems, |
|
127 EVariantTypeDesC ); |
|
128 |
|
129 if ( index >= 0 && param ) |
|
130 { |
|
131 buf.Set( param->Value().AsDes() ); |
|
132 } |
|
133 |
|
134 // Get album name, if available |
|
135 index = 0; |
|
136 param = params->FindFirst( |
|
137 index, |
|
138 EGenericParamAlbumName, |
|
139 EVariantTypeDesC ); |
|
140 |
|
141 if ( index >= 0 && param ) |
|
142 { |
|
143 name.Set( param->Value().AsDes() ); |
|
144 } |
|
145 |
|
146 // Get host application UID |
|
147 index = 0; |
|
148 param = params->FindFirst( |
|
149 index, |
|
150 EGenericParamApplication, |
|
151 EVariantTypeTUid ); |
|
152 |
|
153 if ( index >= 0 && param ) |
|
154 { |
|
155 TUid uid( KNullUid ); |
|
156 param->Value().Get( uid ); |
|
157 TRAP_IGNORE( MPXTlsHelper::SetHostUidL( uid ) ); |
|
158 } |
|
159 |
|
160 // Check allow save flag |
|
161 index = 0; |
|
162 param = params->FindFirst( |
|
163 index, |
|
164 EGenericParamAllowSave ); |
|
165 |
|
166 if ( index >= 0 && param ) |
|
167 { |
|
168 TInt32 value( 0 ); |
|
169 param->Value().Get( value ); |
|
170 MPXTlsHelper::SetNeedSave( value ); |
|
171 } |
|
172 |
|
173 // Check allow move flag |
|
174 index = 0; |
|
175 param = params->FindFirst( |
|
176 index, |
|
177 EGenericParamAllowMove, |
|
178 EVariantTypeTInt32 ); |
|
179 |
|
180 if ( index >= 0 && param ) |
|
181 { |
|
182 TInt32 value( 0 ); |
|
183 param->Value().Get( value ); |
|
184 MPXTlsHelper::SetAllowMove( value ); |
|
185 } |
|
186 } |
|
187 |
|
188 if ( buf.Length() > 0 ) |
|
189 { |
|
190 // TODO: Support for album items |
|
191 openFile = EFalse; |
|
192 } |
|
193 |
|
194 return openFile; |
|
195 } |
|
196 |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // From class CEikDocument. |
|
200 // Constructs CMPXAppUi |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 CEikAppUi* CMPXDocument::CreateAppUiL() |
|
204 { |
|
205 return new ( ELeave ) CMPXAppUi; |
|
206 } |
|
207 |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // From class CAknDocument. |
|
211 // Called by the framework to open a file. |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 CFileStore* CMPXDocument::OpenFileL( |
|
215 TBool aDoOpen, |
|
216 const TDesC& aFilename, |
|
217 RFs& aFs ) |
|
218 { |
|
219 if ( aDoOpen ) |
|
220 { |
|
221 if ( ParseInputParameters() ) |
|
222 { |
|
223 iAppUi->OpenFileL( aFilename ); |
|
224 } |
|
225 } |
|
226 |
|
227 return CAknDocument::OpenFileL( aDoOpen, aFilename, aFs ); |
|
228 } |
|
229 |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // From class CAknDocument. |
|
233 // Called by the framework to open a file. |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 void CMPXDocument::OpenFileL( |
|
237 CFileStore*& aFileStore, |
|
238 RFile& aFile ) |
|
239 { |
|
240 if ( ParseInputParameters() ) |
|
241 { |
|
242 const CAiwGenericParamList* params = GetInputParameters(); |
|
243 static_cast<CMPXAppUi*>(iAppUi)->OpenFileL( aFileStore, aFile, params ); |
|
244 } |
|
245 |
|
246 return CAknDocument::OpenFileL( aFileStore, aFile ); |
|
247 } |
|
248 |
|
249 |
|
250 // End of File |