|
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: This class browses file system |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "glxcollectionplugincamera.h" |
|
24 |
|
25 #include <e32cmn.h> |
|
26 #include <mpxcollectionpath.h> |
|
27 #include <mpxcollectionpluginobserver.h> |
|
28 #include <mpxcmn.h> |
|
29 #include <mpxcollectionmessagedefs.h> |
|
30 #include <glxcollectionmessagedefs.h> |
|
31 #include <mpxmediageneraldefs.h> |
|
32 #include <mpxmediacontainerdefs.h> |
|
33 #include <mpxmedia.h> |
|
34 #include <mpxmediaarray.h> |
|
35 #include <glxmediageneraldefs.h> |
|
36 #include <glxcollectiongeneraldefs.h> |
|
37 #include <glxplugincamera.rsg> |
|
38 #include <StringLoader.h> |
|
39 #include <glxmediacollectioninternaldefs.h> |
|
40 #include <glxpanic.h> |
|
41 #include <mglxdatasource.h> |
|
42 #include <glxrequest.h> |
|
43 #include <glxidlistrequest.h> |
|
44 #include <glxfilterfactory.h> |
|
45 #include <glxlog.h> |
|
46 #include <glxtracer.h> |
|
47 |
|
48 #include "glxcollectionplugincamera.hrh" |
|
49 |
|
50 /** |
|
51 * @internal reviewed 14/06/2007 by Alex Birkett |
|
52 */ |
|
53 |
|
54 // CONSTANTS |
|
55 |
|
56 // ============================ LOCAL FUNCTIONS ============================== |
|
57 |
|
58 // ============================ MEMBER FUNCTIONS ============================== |
|
59 // ---------------------------------------------------------------------------- |
|
60 // Two-phased constructor. |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 CGlxCollectionPluginCamera* CGlxCollectionPluginCamera::NewL(TAny* aObs) |
|
64 { |
|
65 CGlxCollectionPluginCamera* self = new (ELeave) CGlxCollectionPluginCamera( |
|
66 static_cast<MMPXCollectionPluginObserver*>(aObs)); |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop(self); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // Destructor |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 CGlxCollectionPluginCamera::~CGlxCollectionPluginCamera() |
|
78 { |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // Constructor |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 CGlxCollectionPluginCamera::CGlxCollectionPluginCamera( |
|
86 MMPXCollectionPluginObserver* aObs) |
|
87 { |
|
88 iObs = aObs; |
|
89 } |
|
90 |
|
91 // ---------------------------------------------------------------------------- |
|
92 // ConstructL |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 void CGlxCollectionPluginCamera::ConstructL() |
|
96 { |
|
97 iDataSource = MGlxDataSource::OpenDataSourceL(KGlxDefaultDataSourceUid, *this); |
|
98 } |
|
99 // ---------------------------------------------------------------------------- |
|
100 // CpiAttributeAdditionalAttributesL |
|
101 // ---------------------------------------------------------------------------- |
|
102 // |
|
103 void CGlxCollectionPluginCamera::CpiAttributeAdditionalAttributesL( |
|
104 const TMPXAttribute& aCpiAttribute, |
|
105 RArray<TMPXAttribute>& aAttributeArray) |
|
106 { |
|
107 TRACER("CGlxCollectionPluginCamera::CpiAttributeAdditionalAttributesL"); |
|
108 // Only need to process KGlxMediaCollectionPluginSpecificSubTitle here as |
|
109 // all the other attributes are reading straight from resource files |
|
110 // KGlxMediaCollectionPluginSpecificSubTitle requires a image and the |
|
111 // Video count in the collection |
|
112 |
|
113 if (aCpiAttribute == KGlxMediaCollectionPluginSpecificSubTitle) |
|
114 { |
|
115 // need to add the usage count. but check first if it is already present |
|
116 TInt attrCount = aAttributeArray.Count(); |
|
117 |
|
118 TBool found = EFalse; |
|
119 |
|
120 #ifdef GLX_SUB_TITLE_REL8 |
|
121 |
|
122 TBool videofound = EFalse; |
|
123 TBool imagefound = EFalse; |
|
124 |
|
125 for ( TInt index = 0; index < attrCount; index++) |
|
126 { |
|
127 if (aAttributeArray[index] == KMPXMediaGeneralCount) |
|
128 { |
|
129 found = ETrue; |
|
130 } |
|
131 else if (aAttributeArray[index] == KGlxMediaItemTypeVideo) |
|
132 { |
|
133 videofound = ETrue; |
|
134 } |
|
135 else if(aAttributeArray[index] == KGlxMediaItemTypeImage) |
|
136 { |
|
137 imagefound = ETrue; |
|
138 } |
|
139 |
|
140 if (!videofound) |
|
141 { |
|
142 aAttributeArray.AppendL(KGlxMediaItemTypeVideo); |
|
143 } |
|
144 if (!imagefound) |
|
145 { |
|
146 aAttributeArray.AppendL(KGlxMediaItemTypeImage); |
|
147 } |
|
148 if (!found) |
|
149 { |
|
150 aAttributeArray.AppendL(KMPXMediaGeneralCount); |
|
151 } |
|
152 |
|
153 #else |
|
154 |
|
155 for (TInt index = 0; index < attrCount; index++) |
|
156 { |
|
157 if (aAttributeArray[index] == KMPXMediaGeneralCount) |
|
158 { |
|
159 found = ETrue; |
|
160 } |
|
161 } |
|
162 if (!found) |
|
163 { |
|
164 aAttributeArray.AppendL(KMPXMediaGeneralCount); |
|
165 } |
|
166 #endif |
|
167 } |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------------------------- |
|
171 // HandleCpiAttributeResponseL |
|
172 // ---------------------------------------------------------------------------- |
|
173 // |
|
174 void CGlxCollectionPluginCamera::HandleCpiAttributeResponseL( |
|
175 CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes, |
|
176 TArray<TGlxMediaId> /* aMediaIds */) |
|
177 { |
|
178 TRACER("CGlxCollectionPluginCamera::HandleCpiAttributeResponseL"); |
|
179 |
|
180 _LIT(KResourceFile, "z:glxplugincamera.rsc"); |
|
181 |
|
182 TInt count = aCpiAttributes.Count(); |
|
183 |
|
184 for (TInt index = 0; index < count ; index++) |
|
185 { |
|
186 const TMPXAttribute attr = aCpiAttributes[index]; |
|
187 |
|
188 if (attr == KGlxMediaCollectionPluginSpecificSubTitle) |
|
189 { |
|
190 GLX_LOG_INFO("Attribute is :Subtitle"); |
|
191 |
|
192 if (!aResponse->IsSupported(KMPXMediaGeneralCount)) |
|
193 { |
|
194 User::Leave(KErrNotSupported); |
|
195 } |
|
196 |
|
197 else |
|
198 { |
|
199 TInt usageCount = aResponse->ValueTObjectL<TInt>(KMPXMediaGeneralCount); |
|
200 |
|
201 HBufC* tempTitle = NULL; |
|
202 |
|
203 #ifdef GLX_SUB_TITLE_REL8 |
|
204 |
|
205 if (!aResponse->IsSupported(KGlxMediaItemTypeImage)) |
|
206 { |
|
207 User::Leave(KErrNotSupported); |
|
208 } |
|
209 |
|
210 if (!aResponse->IsSupported(KGlxMediaItemTypeVideo)) |
|
211 { |
|
212 User::Leave(KErrNotSupported); |
|
213 } |
|
214 |
|
215 TInt videoCount = aResponse->ValueTObjectL<TInt>(KGlxMediaItemTypeVideo); |
|
216 |
|
217 TInt imageCount = aResponse->ValueTObjectL<TInt>(KGlxMediaItemTypeImage); |
|
218 |
|
219 //No Images or Videos |
|
220 if ((0 == videoCount) && (0 == imageCount )) |
|
221 { |
|
222 GLX_LOG_INFO("ImageCount and VideoCount is 0"); |
|
223 |
|
224 tempTitle = LoadLocalizedStringLC(KResourceFile, |
|
225 R_CAMERA_SUB_TITLE_NO_IMAGE_NO_VIDEO); |
|
226 aResponse->SetTextValueL(attr, *tempTitle); |
|
227 } |
|
228 |
|
229 // 1 Image and multi/0 Videos |
|
230 else if (1 == imageCount) |
|
231 { |
|
232 GLX_LOG_INFO1("ImageCount is 0 and VideoCount is %d",videoCount); |
|
233 |
|
234 tempTitle = LoadLocalizedStringLC(KResourceFile, |
|
235 R_CAMERA_SUB_TITLE_ONE_IMAGE_MULTI_VIDEO); |
|
236 |
|
237 TPtr formatString = tempTitle->Des(); |
|
238 |
|
239 // Now create a buffer that will contain the result. needs to be |
|
240 // length of format string plus a few extra for the number |
|
241 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
242 TPtr ptr = title->Des(); |
|
243 |
|
244 StringLoader::Format(ptr, formatString, -1, videoCount); |
|
245 |
|
246 // Set the title in the response. |
|
247 aResponse->SetTextValueL(attr, *title); |
|
248 |
|
249 CleanupStack::PopAndDestroy(title); |
|
250 } |
|
251 |
|
252 // Multi/0 Image and 1 Video |
|
253 else if (1 == videoCount) |
|
254 { |
|
255 GLX_LOG_INFO1("ImageCount is %d and VideoCount is 0",imageCount); |
|
256 |
|
257 tempTitle = LoadLocalizedStringLC(KResourceFile, |
|
258 R_CAMERA_SUB_TITLE_MULTI_IMAGE_ONE_VIDEO); |
|
259 |
|
260 TPtr formatString = tempTitle->Des(); |
|
261 |
|
262 // Now create a buffer that will contain the result. needs to be |
|
263 // length of format string plus a few extra for the number |
|
264 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
265 TPtr ptr = title->Des(); |
|
266 |
|
267 StringLoader::Format(ptr, formatString, -1, imageCount); |
|
268 |
|
269 // Set the title in the response. |
|
270 aResponse->SetTextValueL(attr, *title); |
|
271 |
|
272 CleanupStack::PopAndDestroy(title); |
|
273 } |
|
274 |
|
275 // Multi Image and Multi Video |
|
276 else |
|
277 { |
|
278 GLX_LOG_INFO2("ImageCount is %d,VideoCount is %d",imageCount,videoCount); |
|
279 |
|
280 tempTitle = LoadLocalizedStringLC(KResourceFile, |
|
281 R_CAMERA_SUB_TITLE_MULTI_IMAGE_MULTI_VIDEO); |
|
282 TPtr formatString = tempTitle->Des(); |
|
283 |
|
284 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
285 TPtr ptr = title->Des(); |
|
286 |
|
287 HBufC* title1 = HBufC::NewLC(formatString.Length() + 10); |
|
288 TPtr ptr1 = title1->Des(); |
|
289 |
|
290 StringLoader::Format(ptr, formatString, 0, imageCount); |
|
291 StringLoader::Format(ptr1, ptr, 1, videoCount); |
|
292 |
|
293 // Set the title in the response. |
|
294 aResponse->SetTextValueL(attr, *title1); |
|
295 |
|
296 CleanupStack::PopAndDestroy(title1); |
|
297 CleanupStack::PopAndDestroy(title); |
|
298 } |
|
299 CleanupStack::PopAndDestroy(tempTitle); |
|
300 |
|
301 #else |
|
302 if(0 == usageCount) |
|
303 { |
|
304 tempTitle = LoadLocalizedStringLC(KResourceFile, |
|
305 R_CAMERA_SUB_TITLE_NO_IMAGE_NO_VIDEO); |
|
306 // Set the title in the response. |
|
307 aResponse->SetTextValueL(attr, *tempTitle); |
|
308 CleanupStack::PopAndDestroy(tempTitle); |
|
309 continue; |
|
310 } |
|
311 // Get the format string |
|
312 else if (1 == usageCount) |
|
313 { |
|
314 tempTitle = LoadLocalizedStringLC(KResourceFile, R_CAMERA_SUB_TITLE_SINGLE); |
|
315 aResponse->SetTextValueL(attr, *tempTitle); |
|
316 CleanupStack::PopAndDestroy(tempTitle); |
|
317 continue; |
|
318 } |
|
319 else |
|
320 { |
|
321 tempTitle = LoadLocalizedStringLC(KResourceFile, R_CAMERA_SUB_TITLE_MULTI); |
|
322 } |
|
323 TPtr formatString = tempTitle->Des(); |
|
324 |
|
325 // Now create a buffer that will contain the result. needs to be |
|
326 // length of format string plus a few extra for the number |
|
327 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
328 TPtr ptr = title->Des(); |
|
329 StringLoader::Format(ptr, formatString, -1, usageCount); |
|
330 |
|
331 // Set the title in the response. |
|
332 aResponse->SetTextValueL(attr, *title); |
|
333 |
|
334 CleanupStack::PopAndDestroy(title); |
|
335 CleanupStack::PopAndDestroy(tempTitle); |
|
336 #endif |
|
337 } |
|
338 } |
|
339 |
|
340 else if (attr == KGlxMediaCollectionPluginSpecificSelectMediaPopupTitle) |
|
341 { |
|
342 GLX_LOG_INFO("Attribute is :MediaPopupTitle"); |
|
343 |
|
344 User::Leave(KErrNotSupported); |
|
345 } |
|
346 else if (attr == KGlxMediaCollectionPluginSpecificNewMediaItemTitle) |
|
347 { |
|
348 GLX_LOG_INFO("Attribute is :NewMediaItemTitle"); |
|
349 |
|
350 User::Leave(KErrNotSupported); |
|
351 } |
|
352 else if (attr == KGlxMediaCollectionPluginSpecificDefaultMediaTitle) |
|
353 { |
|
354 GLX_LOG_INFO("Attribute is :DefaultMediaTitle"); |
|
355 |
|
356 User::Leave(KErrNotSupported); |
|
357 } |
|
358 else if (attr == KMPXMediaGeneralTitle) |
|
359 { |
|
360 GLX_LOG_INFO("Attribute is :GenrealTitle"); |
|
361 |
|
362 HBufC* title = LoadLocalizedStringLC(KResourceFile, R_CAMERA_GENERAL_TITLE); |
|
363 // Set the title in the response. |
|
364 aResponse->SetTextValueL(attr, *title); |
|
365 CleanupStack::PopAndDestroy(title); |
|
366 } |
|
367 } |
|
368 aResponse->Delete(KGlxMediaItemTypeImage); |
|
369 aResponse->Delete(KGlxMediaItemTypeVideo); |
|
370 |
|
371 } |
|
372 |
|
373 // ---------------------------------------------------------------------------- |
|
374 // IsUpdateMessageIgnoredL |
|
375 // ---------------------------------------------------------------------------- |
|
376 // |
|
377 TBool CGlxCollectionPluginCamera::IsUpdateMessageIgnoredL(CMPXMessage& /*aMessage*/) |
|
378 { |
|
379 TRACER("CGlxCollectionPluginCamera::IsUpdateMessageIgnoredL"); |
|
380 |
|
381 TBool ignore = EFalse; |
|
382 return ignore; |
|
383 } |
|
384 |
|
385 // ---------------------------------------------------------------------------- |
|
386 // DefaultFilter |
|
387 // ---------------------------------------------------------------------------- |
|
388 // |
|
389 TGlxFilterProperties CGlxCollectionPluginCamera::DefaultFilter(TInt aLevel) |
|
390 { |
|
391 TRACER("CGlxCollectionPluginCamera::DefaultFilter"); |
|
392 |
|
393 __ASSERT_DEBUG(( (aLevel == KGlxCollectionRootLevel) || (aLevel == KGlxCollectionRootLevel+1) |
|
394 || (aLevel == KGlxCollectionRootLevel+2) ), Panic(EGlxPanicInvalidPathLevel)); |
|
395 TGlxFilterProperties filterProperties; |
|
396 |
|
397 filterProperties.iSortOrder = EGlxFilterSortOrderModifiedDate; |
|
398 filterProperties.iSortDirection = EGlxFilterSortDirectionDescending; |
|
399 |
|
400 filterProperties.iOrigin = EGlxFilterOriginCamera; |
|
401 |
|
402 return filterProperties; |
|
403 } |
|
404 |
|
405 // End of file |