|
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 #include <e32cmn.h> |
|
23 #include <mpxcollectionpath.h> |
|
24 #include <mpxcollectionpluginobserver.h> |
|
25 #include <mpxcmn.h> |
|
26 #include <mpxcollectionmessagedefs.h> |
|
27 #include <glxcollectionmessagedefs.h> |
|
28 #include <mpxmediageneraldefs.h> |
|
29 #include <mpxmediacontainerdefs.h> |
|
30 #include <mpxmedia.h> |
|
31 #include <mpxmediaarray.h> |
|
32 #include <glxpluginimageviewer.rsg> |
|
33 #include <StringLoader.h> |
|
34 #include <glxtracer.h> |
|
35 |
|
36 #include "glxcollectionpluginimageviewer.h" |
|
37 #include "glxcollectionpluginimageviewer.hrh" |
|
38 #include <glxmediageneraldefs.h> |
|
39 #include <glxmediacollectioninternaldefs.h> |
|
40 #include <glxcollectiongeneraldefs.h> |
|
41 |
|
42 #include <glxpanic.h> |
|
43 #include <mglxdatasource.h> |
|
44 #include <glxrequest.h> |
|
45 #include <glxidlistrequest.h> |
|
46 #include <glxfilterfactory.h> |
|
47 #include <glxlog.h> |
|
48 |
|
49 // ============================ LOCAL FUNCTIONS ============================== |
|
50 |
|
51 // ============================ MEMBER FUNCTIONS ============================== |
|
52 // ---------------------------------------------------------------------------- |
|
53 // Two-phased constructor. |
|
54 // ---------------------------------------------------------------------------- |
|
55 // |
|
56 CGlxCollectionPluginImageViewer* CGlxCollectionPluginImageViewer::NewL(TAny* aObs) |
|
57 { |
|
58 CGlxCollectionPluginImageViewer* self = |
|
59 new (ELeave) CGlxCollectionPluginImageViewer( |
|
60 static_cast<MMPXCollectionPluginObserver*>(aObs)); |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop(self); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // Destructor |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 CGlxCollectionPluginImageViewer::~CGlxCollectionPluginImageViewer() |
|
72 { |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // Constructor |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 CGlxCollectionPluginImageViewer::CGlxCollectionPluginImageViewer( |
|
80 MMPXCollectionPluginObserver* aObs) |
|
81 { |
|
82 iObs = aObs; |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // ConstructL |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 void CGlxCollectionPluginImageViewer::ConstructL() |
|
90 { |
|
91 iDataSource = MGlxDataSource::OpenDataSourceL(KGlxDefaultDataSourceUid, *this); |
|
92 } |
|
93 |
|
94 void CGlxCollectionPluginImageViewer::CpiAttributeAdditionalAttributes( |
|
95 const TMPXAttribute& aCpiAttribute, |
|
96 RArray<TMPXAttribute>& aAttributeArray) |
|
97 { |
|
98 // Nothing to be shared apart from the ones that are commonly loaded. |
|
99 } |
|
100 |
|
101 void CGlxCollectionPluginImageViewer::HandleCpiAttributeResponseL( |
|
102 CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes, |
|
103 TArray<TGlxMediaId> aMediaIds) |
|
104 { |
|
105 TRACER("CGlxCollectionPluginImageViewer::HandleCpiAttributeResponseL"); |
|
106 const TInt mediaIdCount = aMediaIds.Count(); |
|
107 |
|
108 switch (mediaIdCount) |
|
109 { |
|
110 case 0: |
|
111 User::Leave(KErrNotSupported); |
|
112 break; |
|
113 case 1: |
|
114 HandleCpiAttributeResponseL(aResponse, aCpiAttributes, aMediaIds[0]); |
|
115 break; |
|
116 default: |
|
117 { |
|
118 // We have an array of CMPXMedia items |
|
119 |
|
120 if (TGlxMediaId(KGlxCollectionRootId) == aMediaIds[0]) |
|
121 { |
|
122 User::Leave(KErrNotSupported); |
|
123 } |
|
124 |
|
125 CMPXMediaArray* mediaArray = aResponse->ValueCObjectL<CMPXMediaArray>(KMPXMediaArrayContents); |
|
126 CleanupStack::PushL(mediaArray); |
|
127 |
|
128 const TInt arrayCount = mediaArray->Count(); |
|
129 |
|
130 // Sanity check |
|
131 if (arrayCount != mediaIdCount) |
|
132 { |
|
133 User::Leave(KErrArgument); |
|
134 } |
|
135 |
|
136 for (TInt index = 0; index < arrayCount; index++) |
|
137 { |
|
138 HandleCpiAttributeResponseL((*mediaArray)[index], aCpiAttributes, aMediaIds[index]); |
|
139 } |
|
140 |
|
141 aResponse->SetCObjectValueL(KMPXMediaArrayContents, mediaArray); |
|
142 CleanupStack::PopAndDestroy(mediaArray); |
|
143 } |
|
144 break; |
|
145 } |
|
146 } |
|
147 |
|
148 void CGlxCollectionPluginImageViewer::HandleCpiAttributeResponseL( |
|
149 CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes, |
|
150 TGlxMediaId aMediaId) |
|
151 { |
|
152 const TInt attribCount = aCpiAttributes.Count(); |
|
153 |
|
154 for (TInt index = 0; index < attribCount ; index++) |
|
155 { |
|
156 const TMPXAttribute attr = aCpiAttributes[index]; |
|
157 |
|
158 if (attr == KGlxMediaCollectionPluginSpecificSubTitle) |
|
159 { |
|
160 User::Leave(KErrNotSupported); |
|
161 } |
|
162 else if (attr == KGlxMediaCollectionPluginSpecificSelectMediaPopupTitle) |
|
163 { |
|
164 User::Leave(KErrNotSupported); |
|
165 } |
|
166 else if (attr == KGlxMediaCollectionPluginSpecificNewMediaItemTitle) |
|
167 { |
|
168 User::Leave(KErrNotSupported); |
|
169 } |
|
170 else if (attr == KGlxMediaCollectionPluginSpecificDefaultMediaTitle) |
|
171 { |
|
172 User::Leave(KErrNotSupported); |
|
173 } |
|
174 else if (attr == KMPXMediaGeneralTitle) |
|
175 { |
|
176 User::Leave(KErrNotSupported); |
|
177 } |
|
178 } |
|
179 } |
|
180 |
|
181 TBool CGlxCollectionPluginImageViewer::IsUpdateMessageIgnored(CMPXMessage& /*aMessage*/) |
|
182 { |
|
183 TBool ignore = EFalse; |
|
184 return ignore; |
|
185 } |
|
186 |
|
187 TGlxFilterProperties CGlxCollectionPluginImageViewer::DefaultFilter(TInt /*aLevel*/) |
|
188 { |
|
189 TGlxFilterProperties filterProperties; |
|
190 |
|
191 filterProperties.iSortDirection = EGlxFilterSortDirectionAscending; |
|
192 filterProperties.iMinCount = 1; |
|
193 filterProperties.iItemType = EGlxFilterImage; |
|
194 |
|
195 return filterProperties; |
|
196 } |