|
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 <glxpluginall.rsg> |
|
33 #include <StringLoader.h> |
|
34 #include <glxtracer.h> |
|
35 |
|
36 #include "glxcollectionpluginall.h" |
|
37 #include "glxcollectionpluginall.hrh" |
|
38 #include "glxmediageneraldefs.h" |
|
39 #include "glxcollectiongeneraldefs.h" |
|
40 #include "glxlog.h" |
|
41 |
|
42 |
|
43 #include "glxpanic.h" |
|
44 #include "mglxdatasource.h" |
|
45 #include "glxrequest.h" |
|
46 #include "glxidlistrequest.h" |
|
47 #include "glxfilterfactory.h" |
|
48 |
|
49 /** |
|
50 * @internal reviewed 13/06/2007 by Alex Birkett |
|
51 */ |
|
52 |
|
53 // CONSTANTS |
|
54 |
|
55 // ============================ LOCAL FUNCTIONS ============================== |
|
56 |
|
57 // ============================ MEMBER FUNCTIONS ============================== |
|
58 // ---------------------------------------------------------------------------- |
|
59 // Two-phased constructor. |
|
60 // ---------------------------------------------------------------------------- |
|
61 // |
|
62 CGlxCollectionPluginAll* CGlxCollectionPluginAll::NewL(TAny* aObs) |
|
63 { |
|
64 CGlxCollectionPluginAll* self = new (ELeave) CGlxCollectionPluginAll( |
|
65 static_cast<MMPXCollectionPluginObserver*>(aObs)); |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop(self); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // Destructor |
|
74 // ---------------------------------------------------------------------------- |
|
75 // |
|
76 CGlxCollectionPluginAll::~CGlxCollectionPluginAll() |
|
77 { |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // Constructor |
|
82 // ---------------------------------------------------------------------------- |
|
83 // |
|
84 CGlxCollectionPluginAll::CGlxCollectionPluginAll( |
|
85 MMPXCollectionPluginObserver* aObs) |
|
86 { |
|
87 iObs = aObs; |
|
88 } |
|
89 |
|
90 // ---------------------------------------------------------------------------- |
|
91 // ConstructL |
|
92 // ---------------------------------------------------------------------------- |
|
93 // |
|
94 void CGlxCollectionPluginAll::ConstructL() |
|
95 { |
|
96 iDataSource = MGlxDataSource::OpenDataSourceL(KGlxDefaultDataSourceUid, *this); |
|
97 } |
|
98 |
|
99 void CGlxCollectionPluginAll::CpiAttributeAdditionalAttributes(const TMPXAttribute& aCpiAttribute, RArray<TMPXAttribute>& aAttributeArray) |
|
100 { |
|
101 TRACER("CGlxCollectionPluginAll::CpiAttributeAdditionalAttributes()"); |
|
102 // Only need to process KGlxMediaCollectionPluginSpecificSubTitle here as all the others are reading straight from resource files |
|
103 // KGlxMediaCollectionPluginSpecificSubTitle requires a usage count |
|
104 if (aCpiAttribute == KGlxMediaCollectionPluginSpecificSubTitle) |
|
105 { |
|
106 // need to add the usage count. but check first if it is already present |
|
107 TInt attrCount = aAttributeArray.Count(); |
|
108 TBool found = EFalse; |
|
109 |
|
110 for ( TInt index = 0 ; index < attrCount ; index++) |
|
111 { |
|
112 if (aAttributeArray[index] == KMPXMediaGeneralCount) |
|
113 { |
|
114 found = ETrue; |
|
115 break; |
|
116 } |
|
117 } |
|
118 |
|
119 if (!found) |
|
120 { |
|
121 aAttributeArray.Append(KMPXMediaGeneralCount); |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 void CGlxCollectionPluginAll::HandleCpiAttributeResponseL(CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes, TArray<TGlxMediaId> /* aMediaIds */) |
|
127 { |
|
128 TRACER("CGlxCollectionPluginAll::HandleCpiAttributeResponseL"); |
|
129 _LIT(KResourceFile, "z:glxpluginall.rsc"); |
|
130 |
|
131 TInt count = aCpiAttributes.Count(); |
|
132 |
|
133 for (TInt index = 0; index < count ; index++) |
|
134 { |
|
135 const TMPXAttribute attr = aCpiAttributes[index]; |
|
136 |
|
137 if (attr == KGlxMediaCollectionPluginSpecificSubTitle) |
|
138 { |
|
139 if (!aResponse->IsSupported(KMPXMediaGeneralCount)) |
|
140 { |
|
141 User::Leave(KErrNotSupported); |
|
142 } |
|
143 else |
|
144 { |
|
145 TInt usageCount = aResponse->ValueTObjectL<TInt>(KMPXMediaGeneralCount); |
|
146 HBufC* tempTitle = NULL; |
|
147 |
|
148 if(0 == usageCount) |
|
149 { |
|
150 tempTitle = LoadLocalizedStringLC(KResourceFile, R_ALL_ITEM_SUB_TITLE_EMPTY); |
|
151 // Set the title in the response. |
|
152 aResponse->SetTextValueL(attr, *tempTitle); |
|
153 CleanupStack::PopAndDestroy(tempTitle); |
|
154 continue; |
|
155 } |
|
156 // Get the format string |
|
157 else if (1 == usageCount) |
|
158 { |
|
159 tempTitle = LoadLocalizedStringLC(KResourceFile, R_ALL_SUB_TITLE_SINGLE); |
|
160 aResponse->SetTextValueL(attr, *tempTitle); |
|
161 CleanupStack::PopAndDestroy(tempTitle); |
|
162 continue; |
|
163 } |
|
164 else |
|
165 { |
|
166 tempTitle = LoadLocalizedStringLC(KResourceFile, R_ALL_SUB_TITLE_MULTI); |
|
167 } |
|
168 TPtr formatString = tempTitle->Des(); |
|
169 |
|
170 // Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number |
|
171 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
172 TPtr ptr = title->Des(); |
|
173 StringLoader::Format(ptr, formatString, -1, usageCount); |
|
174 |
|
175 // Set the title in the response. |
|
176 aResponse->SetTextValueL(attr, *title); |
|
177 |
|
178 CleanupStack::PopAndDestroy(title); |
|
179 CleanupStack::PopAndDestroy(tempTitle); |
|
180 } |
|
181 } |
|
182 else if (attr == KGlxMediaCollectionPluginSpecificSelectMediaPopupTitle) |
|
183 { |
|
184 User::Leave(KErrNotSupported); |
|
185 } |
|
186 else if (attr == KGlxMediaCollectionPluginSpecificNewMediaItemTitle) |
|
187 { |
|
188 User::Leave(KErrNotSupported); |
|
189 } |
|
190 else if (attr == KGlxMediaCollectionPluginSpecificDefaultMediaTitle) |
|
191 { |
|
192 User::Leave(KErrNotSupported); |
|
193 } |
|
194 else if (attr == KMPXMediaGeneralTitle) |
|
195 { |
|
196 HBufC* title = LoadLocalizedStringLC(KResourceFile, R_ALL_GENERAL_TITLE); |
|
197 // Set the title in the response. |
|
198 aResponse->SetTextValueL(attr, *title); |
|
199 CleanupStack::PopAndDestroy(title); |
|
200 } |
|
201 } |
|
202 } |
|
203 |
|
204 TBool CGlxCollectionPluginAll::IsUpdateMessageIgnoredL(CMPXMessage& /*aMessage*/) |
|
205 { |
|
206 TBool ignore = EFalse; |
|
207 return ignore; |
|
208 } |
|
209 |
|
210 // End of file |