19 |
19 |
20 #include <e32std.h> |
20 #include <e32std.h> |
21 |
21 |
22 #include <ecom/implementationproxy.h> |
22 #include <ecom/implementationproxy.h> |
23 #include <contentharvesterpluginuids.hrh> |
23 #include <contentharvesterpluginuids.hrh> |
24 #include <liwservicehandler.h> |
24 #include <LiwServiceHandler.h> |
|
25 |
25 #include "cpglobals.h" |
26 #include "cpglobals.h" |
|
27 #include "chswiusbhandler.h" |
|
28 #include "chswiusbobserver.h" |
26 |
29 |
27 _LIT( KHsWidgetPublisher, "hswidgetpublisher"); |
30 _LIT( KHsWidgetPublisher, "hswidgetpublisher"); |
28 _LIT( KHsPublisher, "ai3templatedwidget" ); |
31 _LIT( KHsPublisher, "ai3templatedwidget" ); |
29 _LIT8( KWidgetUid, "widget_uid"); |
32 _LIT8( KWidgetUid, "widget_uid"); |
30 |
33 |
|
34 const TInt KWidgetArrayGran = 8; |
|
35 |
31 // Map the interface UIDs to implementation factory functions |
36 // Map the interface UIDs to implementation factory functions |
32 // ============================= LOCAL FUNCTIONS =============================== |
37 // ============================= LOCAL FUNCTIONS =============================== |
33 |
38 |
34 // Map the interface UIDs to implementation factory functions |
39 // Map the interface UIDs to implementation factory functions |
35 const TImplementationProxy ImplementationTable[] = |
40 const TImplementationProxy ImplementationTable[] = |
115 { |
129 { |
116 TRAP_IGNORE( UpdateWidgetsL() ); |
130 TRAP_IGNORE( UpdateWidgetsL() ); |
117 } |
131 } |
118 |
132 |
119 // ---------------------------------------------------------------------------- |
133 // ---------------------------------------------------------------------------- |
|
134 // CCHSwiPlugin::HandleMassStorageModeEndEvent |
|
135 // (refer to MCHSwiMassModeObserver declaration). |
|
136 // ---------------------------------------------------------------------------- |
|
137 // |
|
138 void CCHSwiPlugin::HandleMassStorageModeEndEvent() |
|
139 { |
|
140 TRAP_IGNORE( UpdateWidgetsL() ); |
|
141 } |
|
142 |
|
143 // ---------------------------------------------------------------------------- |
|
144 // CCHSwiPlugin::HandleSuccessfulAsynchDriveScan |
|
145 // (refer to MCHSwiMassModeObserver declaration). |
|
146 // ---------------------------------------------------------------------------- |
|
147 // |
|
148 void CCHSwiPlugin::HandleSuccessfulAsynchDriveScan() |
|
149 { |
|
150 iUsbObserver->Start(); |
|
151 } |
|
152 |
|
153 // ---------------------------------------------------------------------------- |
120 // CCHSwiPlugin::UpdateWidgetsL |
154 // CCHSwiPlugin::UpdateWidgetsL |
121 // MMC watcher callback. |
155 // MMC watcher callback. |
122 // ---------------------------------------------------------------------------- |
156 // ---------------------------------------------------------------------------- |
123 // |
157 // |
124 void CCHSwiPlugin::UpdateWidgetsL() |
158 void CCHSwiPlugin::UpdateWidgetsL() |
125 { |
159 { |
126 CLiwGenericParamList* inparam = CLiwGenericParamList::NewLC( ); |
160 CLiwGenericParamList* inparam = CLiwGenericParamList::NewLC( ); |
127 CLiwGenericParamList* outparam = CLiwGenericParamList::NewLC( ); |
161 CLiwGenericParamList* outparam = CLiwGenericParamList::NewLC( ); |
128 inparam->AppendL( TLiwGenericParam( KType, TLiwVariant( KPublisher ) ) ); |
162 inparam->AppendL( TLiwGenericParam( KType, TLiwVariant( KPublisher ) ) ); |
129 CLiwDefaultMap* filter = CLiwDefaultMap::NewLC(); |
163 CLiwDefaultMap* filter = CLiwDefaultMap::NewLC(); |
130 |
164 |
131 filter->InsertL( KPublisherId, TLiwVariant( KHsWidgetPublisher )); |
165 filter->InsertL( KPublisherId, TLiwVariant( KHsWidgetPublisher )); |
132 filter->InsertL( KContentType, TLiwVariant( KHsPublisher )); |
166 filter->InsertL( KContentType, TLiwVariant( KHsPublisher )); |
133 inparam->AppendL( TLiwGenericParam( KFilter, TLiwVariant( filter ) ) ); |
167 inparam->AppendL( TLiwGenericParam( KFilter, TLiwVariant( filter ) ) ); |
134 |
168 |
135 iCPSInterface->ExecuteCmdL( KGetList, *inparam, *outparam ); |
169 iCPSInterface->ExecuteCmdL( KGetList, *inparam, *outparam ); |
136 |
170 |
137 RemoveWidgetsL( outparam ); |
171 RemoveWidgetsL( outparam ); |
138 |
172 |
139 CleanupStack::PopAndDestroy( filter ); |
173 CleanupStack::PopAndDestroy( filter ); |
140 CleanupStack::PopAndDestroy( outparam ); |
174 CleanupStack::PopAndDestroy( outparam ); |
141 CleanupStack::PopAndDestroy( inparam ); |
175 CleanupStack::PopAndDestroy( inparam ); |
142 } |
176 } |
143 |
177 |
144 // ---------------------------------------------------------------------------- |
178 // ---------------------------------------------------------------------------- |
145 // CCHSwiPlugin::RemoveWidgetsL |
179 // CCHSwiPlugin::RemoveWidgetsL |
146 // MMC watcher callback. |
180 // MMC watcher callback. |
147 // ---------------------------------------------------------------------------- |
181 // ---------------------------------------------------------------------------- |
148 // |
182 // |
149 void CCHSwiPlugin::RemoveWidgetsL( CLiwGenericParamList* aWidgets ) |
183 void CCHSwiPlugin::RemoveWidgetsL( CLiwGenericParamList* aWidgets ) |
150 { |
184 { |
151 TInt pos ( 0 ); |
185 TInt pos ( 0 ); |
152 aWidgets->FindFirst( pos, KResults ); |
186 aWidgets->FindFirst( pos, KResults ); |
153 if( pos != KErrNotFound ) |
187 |
|
188 if ( pos != KErrNotFound ) |
154 { |
189 { |
|
190 CDesC16ArrayFlat* notFoundWidgets = new (ELeave) CDesC16ArrayFlat( KWidgetArrayGran ); |
|
191 CleanupStack::PushL( notFoundWidgets ); |
|
192 |
155 TLiwVariant variant = (*aWidgets)[pos].Value(); |
193 TLiwVariant variant = (*aWidgets)[pos].Value(); |
156 variant.PushL(); |
194 variant.PushL(); |
157 CLiwIterable* iterable = variant.AsIterable(); |
195 CLiwIterable* iterable = variant.AsIterable(); |
158 iterable->Reset(); |
196 iterable->Reset(); |
159 if( iterable->NextL( variant ) ) |
197 |
|
198 while ( iterable->NextL( variant ) ) |
160 { |
199 { |
161 CLiwDefaultMap *map = CLiwDefaultMap::NewLC(); |
200 CLiwDefaultMap *map = CLiwDefaultMap::NewLC(); |
162 variant.Get( *map ); |
201 variant.Get( *map ); |
163 if ( map->FindL( KDataMap, variant) ) |
202 if ( map->FindL( KDataMap, variant) ) |
164 { |
203 { |
171 if( KErrNotFound == iApaLsSession.GetAppInfo( |
210 if( KErrNotFound == iApaLsSession.GetAppInfo( |
172 appInfo, TUid::Uid( variant.AsTInt32() ) ) ) |
211 appInfo, TUid::Uid( variant.AsTInt32() ) ) ) |
173 { |
212 { |
174 if( map->FindL( KContentId, variant ) ) |
213 if( map->FindL( KContentId, variant ) ) |
175 { |
214 { |
176 RemoveWidgetL( KPublisher, variant.AsDes() ); |
215 notFoundWidgets->AppendL( variant.AsDes() ); |
177 RemoveWidgetL( KCpData, variant.AsDes() ); |
|
178 } |
216 } |
179 } |
217 } |
180 } |
218 } |
181 CleanupStack::PopAndDestroy( dataMap ); |
219 CleanupStack::PopAndDestroy( dataMap ); |
182 } |
220 } |
183 CleanupStack::PopAndDestroy( map ); |
221 CleanupStack::PopAndDestroy( map ); |
184 } |
222 } |
185 CleanupStack::PopAndDestroy(&variant); |
223 |
|
224 if ( notFoundWidgets->Count() > 0 ) |
|
225 { |
|
226 iUsbHandler->SynchronousDriveScan(); |
|
227 |
|
228 if ( !IsMassStorageMode() ) |
|
229 { |
|
230 for ( TInt i = 0; i < notFoundWidgets->Count(); i++ ) |
|
231 { |
|
232 RemoveWidgetL( KPublisher, (*notFoundWidgets)[i] ); |
|
233 RemoveWidgetL( KCpData, (*notFoundWidgets)[i] ); |
|
234 } |
|
235 } |
|
236 } |
|
237 |
|
238 CleanupStack::PopAndDestroy( &variant ); |
|
239 CleanupStack::PopAndDestroy( notFoundWidgets ); |
186 } |
240 } |
|
241 |
|
242 |
187 } |
243 } |
188 |
244 |
189 // ---------------------------------------------------------------------------- |
245 // ---------------------------------------------------------------------------- |
190 // CCHSwiPlugin::RemoveWidgetL |
246 // CCHSwiPlugin::RemoveWidgetL |
191 // MMC watcher callback. |
247 // MMC watcher callback. |
209 CleanupStack::PopAndDestroy( filter ); |
265 CleanupStack::PopAndDestroy( filter ); |
210 CleanupStack::PopAndDestroy( outparam ); |
266 CleanupStack::PopAndDestroy( outparam ); |
211 CleanupStack::PopAndDestroy( inparam ); |
267 CleanupStack::PopAndDestroy( inparam ); |
212 } |
268 } |
213 |
269 |
|
270 // ---------------------------------------------------------------------------- |
|
271 // CCHSwiPlugin::SetMassStorageMode |
|
272 // Sets Mass Storage mode. |
|
273 // ---------------------------------------------------------------------------- |
|
274 // |
|
275 void CCHSwiPlugin::SetMassStorageMode( TBool aMode ) |
|
276 { |
|
277 iMassStorageMode = aMode; |
|
278 } |
|
279 |
|
280 // ---------------------------------------------------------------------------- |
|
281 // CCHSwiPlugin::IsMassStorageMode |
|
282 // Gets Mass Storage mode. |
|
283 // ---------------------------------------------------------------------------- |
|
284 // |
|
285 TBool CCHSwiPlugin::IsMassStorageMode() |
|
286 { |
|
287 return iMassStorageMode; |
|
288 } |
|
289 |
214 // End of File |
290 // End of File |