|
1 /* |
|
2 * Copyright (c) 2008-2009 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: provide synchronized access to file systema and metadata source |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <aknViewAppUi.h> // CAknViewAppUi |
|
22 #include <avkon.rsg> |
|
23 #include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR |
|
24 #include <eikapp.h> // CEikApplication |
|
25 #include <glxfetcherdialog.rsg> // FOR GETTING VIEW ID AND RESOURCE ID |
|
26 #include <glxcollectionpluginall.hrh> // All item collection plugin id |
|
27 #include <glxlog.h> // Logging macros |
|
28 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
|
29 #include <glxcommandhandlerhelp.h> |
|
30 #include <mglxmedialist.h> // MGlxMediaList, CMPXCollectionPath |
|
31 |
|
32 #include "glxfetcher.hrh" // For implementation id |
|
33 #include "glxfetcherdialog.h" // CGlxFetcherDialog |
|
34 #include "glxfetcher.h" // CGlxFetcher |
|
35 #include "glxtracer.h" |
|
36 #include "glxlog.h" |
|
37 |
|
38 _LIT(KFetcherGridViewResource,"glxfetcherdialog.rsc"); //FetcherGridDialog Resource File |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // Two-phased constructor. |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CGlxFetcher* CGlxFetcher::NewL() |
|
45 { |
|
46 TRACER("CGlxFetcher::NewL"); |
|
47 CGlxFetcher* self = new( ELeave ) CGlxFetcher(); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 CleanupStack::Pop( self ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Symbian 2nd phase constructor can leave. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 void CGlxFetcher::ConstructL() |
|
59 { |
|
60 TRACER("CGlxFetcher::ConstructL"); |
|
61 // No implementation required |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // C++ default constructor can NOT contain any code, that might leave. |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 CGlxFetcher::CGlxFetcher() |
|
69 { |
|
70 TRACER("CGlxFetcher::CGlxFetcher"); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Destructor |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CGlxFetcher::~CGlxFetcher() |
|
78 { |
|
79 TRACER("CGlxFetcher::~CGlxFetcher"); |
|
80 |
|
81 if ( iResourceOffset ) |
|
82 { |
|
83 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
|
84 } |
|
85 if(iDialog) |
|
86 { |
|
87 iDialog = NULL; |
|
88 } |
|
89 delete iSelectionSoftkey; |
|
90 delete iTitle; |
|
91 |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // SetMultiSelectionL |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 void CGlxFetcher::SetMultiSelectionL( TBool aMultiSelect ) |
|
99 { |
|
100 TRACER("CGlxFetcher::SetMultiSelectionL"); |
|
101 iIsMultiSelection = aMultiSelect; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // SetMimeTypesL |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CGlxFetcher::SetMimeTypesL( const MDesCArray& /*aMimeTypes*/ ) |
|
109 { |
|
110 TRACER("CGlxFetcher::SetMimeTypesL (not supported)"); |
|
111 // No implementation required (not supported) |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // SetSelectionSoftkeyL |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CGlxFetcher::SetSelectionSoftkeyL( const TDesC& aSelectionSoftkey ) |
|
119 { |
|
120 TRACER("CGlxFetcher::SetSelectionSoftkeyL"); |
|
121 |
|
122 HBufC* tmp = aSelectionSoftkey.AllocL(); |
|
123 delete iSelectionSoftkey; |
|
124 iSelectionSoftkey = tmp; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // SetHeadingL |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CGlxFetcher::SetHeadingL( const TDesC& aTitle ) |
|
132 { |
|
133 TRACER("CGlxFetcher::SetHeadingL"); |
|
134 |
|
135 HBufC* tmp = aTitle.AllocL(); |
|
136 delete iTitle; |
|
137 iTitle = tmp; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // SetVerifierL |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CGlxFetcher::SetVerifierL( MMGFetchVerifier& aVerifier ) |
|
145 { |
|
146 TRACER("CGlxFetcher::SetVerifierL"); |
|
147 |
|
148 iVerifier = &aVerifier; |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // GetCancelerL |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CGlxFetcher::GetCancelerL( MMGFetchCanceler*& aCanceler ) |
|
156 { |
|
157 TRACER("CGlxFetcher::GetCancelerL"); |
|
158 |
|
159 aCanceler = this; |
|
160 } |
|
161 |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // LaunchL |
|
165 // --------------------------------------------------------------------------- |
|
166 // |
|
167 TBool CGlxFetcher::LaunchL( CDesCArray& aSelectedFiles, |
|
168 TMediaFileType aMediaType ) |
|
169 { |
|
170 TRACER("CGlxFetcher::LaunchL"); |
|
171 TInt buttonId; |
|
172 TFileName resFile; |
|
173 TParse parse; |
|
174 parse.Set(KFetcherGridViewResource, &KDC_APP_RESOURCE_DIR, NULL); |
|
175 |
|
176 resFile.Append(parse.FullName()); |
|
177 CGlxResourceUtilities::GetResourceFilenameL(resFile); |
|
178 iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resFile); |
|
179 |
|
180 // Configure heading and filter type |
|
181 switch ( aMediaType ) |
|
182 { |
|
183 case EImageFile: |
|
184 { |
|
185 iTitle = TitleForImageFetcherL(); |
|
186 iFilterType = EGlxFilterImage; |
|
187 break; |
|
188 } |
|
189 case EVideoFile: |
|
190 { |
|
191 iTitle = TitleForVideoFetcherL(); |
|
192 iFilterType = EGlxFilterVideo; |
|
193 break; |
|
194 } |
|
195 default: |
|
196 { |
|
197 GLX_LOG_INFO("CGlxFetcher::LaunchL - Error: Unsupported media type, Leaving"); |
|
198 User::Leave( KErrNotSupported ); |
|
199 } |
|
200 } |
|
201 // create the dialog first |
|
202 iDialog = CGlxFetcherDialog::NewL(aSelectedFiles, iVerifier, iFilterType, |
|
203 *iTitle, iIsMultiSelection); |
|
204 // Returns zero when Fetcher is cancelled by User. |
|
205 |
|
206 buttonId = iDialog->ExecuteLD( R_GLX_FETCHER_DIALOG ); |
|
207 // Return false if the fetcher was canceled by user |
|
208 return ( 0 != buttonId && aSelectedFiles.Count()!=0); |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // Return Dialog title |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 HBufC* CGlxFetcher::TitleForImageFetcherL() const |
|
216 { |
|
217 TRACER("CGlxFetcher::TitleForImageFetcherL()"); |
|
218 return TitleL( R_FETCHER_DIALOG_TITLE_IMAGE, R_FETCHER_DIALOG_TITLE_IMAGES ); |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // Return Dialog title |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 HBufC* CGlxFetcher::TitleForVideoFetcherL() const |
|
226 { |
|
227 TRACER("CGlxFetcher::TitleForVideoFetcherL()"); |
|
228 return TitleL( R_FETCHER_DIALOG_TITLE_VIDEO, R_FETCHER_DIALOG_TITLE_VIDEOS ); |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // Return Dialog title |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 HBufC* CGlxFetcher::TitleL( TInt aSingleSelectionTitleResourceId, |
|
236 TInt aMultiSelectionTitleResourceId ) const |
|
237 { |
|
238 TRACER("CGlxFetcher::TitleL()"); |
|
239 if( !iTitle ) |
|
240 { |
|
241 TInt resourceId = aSingleSelectionTitleResourceId; |
|
242 if ( iIsMultiSelection ) |
|
243 { |
|
244 resourceId = aMultiSelectionTitleResourceId; |
|
245 } |
|
246 return CCoeEnv::Static()->AllocReadResourceL( resourceId ); |
|
247 } |
|
248 return iTitle; |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // From MMGFetchCanceler |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 void CGlxFetcher::CancelFetcherL() |
|
256 { |
|
257 TRACER("CGlxFetcher::CancelFetcherL"); |
|
258 //pass EAknCmdExit as parameter to exit the fetcher dialog |
|
259 if(iDialog) |
|
260 { |
|
261 iDialog->CallCancelFetcherL(EAknCmdExit ); |
|
262 } |
|
263 } |