contentpublishingsrv/contentharvester/contentharvesterswiplugin/src/chswiplugin.cpp
--- a/contentpublishingsrv/contentharvester/contentharvesterswiplugin/src/chswiplugin.cpp Mon Jan 18 20:32:13 2010 +0200
+++ b/contentpublishingsrv/contentharvester/contentharvesterswiplugin/src/chswiplugin.cpp Tue Jan 26 12:11:15 2010 +0200
@@ -21,13 +21,18 @@
#include <ecom/implementationproxy.h>
#include <contentharvesterpluginuids.hrh>
-#include <liwservicehandler.h>
+#include <LiwServiceHandler.h>
+
#include "cpglobals.h"
+#include "chswiusbhandler.h"
+#include "chswiusbobserver.h"
_LIT( KHsWidgetPublisher, "hswidgetpublisher");
_LIT( KHsPublisher, "ai3templatedwidget" );
_LIT8( KWidgetUid, "widget_uid");
+const TInt KWidgetArrayGran = 8;
+
// Map the interface UIDs to implementation factory functions
// ============================= LOCAL FUNCTIONS ===============================
@@ -69,6 +74,12 @@
{
iNotifier = CApaAppListNotifier::NewL( this, CActive::EPriorityStandard );
User::LeaveIfError( iApaLsSession.Connect() );
+ User::LeaveIfError( iFs.Connect() );
+
+ iUsbHandler = CCHSwiUsbHandler::NewL( this, iFs );
+
+ iUsbObserver = CCHSwiUsbObserver::NewL( iUsbHandler, iFs );
+ iUsbObserver->Start();
}
// ----------------------------------------------------------------------------
@@ -92,8 +103,11 @@
//
CCHSwiPlugin::~CCHSwiPlugin()
{
+ delete iNotifier;
+ delete iUsbHandler;
+ delete iUsbObserver;
iApaLsSession.Close();
- delete iNotifier;
+ iFs.Close();
}
// ----------------------------------------------------------------------------
@@ -117,28 +131,48 @@
}
// ----------------------------------------------------------------------------
+// CCHSwiPlugin::HandleMassStorageModeEndEvent
+// (refer to MCHSwiMassModeObserver declaration).
+// ----------------------------------------------------------------------------
+//
+void CCHSwiPlugin::HandleMassStorageModeEndEvent()
+ {
+ TRAP_IGNORE( UpdateWidgetsL() );
+ }
+
+// ----------------------------------------------------------------------------
+// CCHSwiPlugin::HandleSuccessfulAsynchDriveScan
+// (refer to MCHSwiMassModeObserver declaration).
+// ----------------------------------------------------------------------------
+//
+void CCHSwiPlugin::HandleSuccessfulAsynchDriveScan()
+ {
+ iUsbObserver->Start();
+ }
+
+// ----------------------------------------------------------------------------
// CCHSwiPlugin::UpdateWidgetsL
// MMC watcher callback.
// ----------------------------------------------------------------------------
//
void CCHSwiPlugin::UpdateWidgetsL()
{
- CLiwGenericParamList* inparam = CLiwGenericParamList::NewLC( );
- CLiwGenericParamList* outparam = CLiwGenericParamList::NewLC( );
- inparam->AppendL( TLiwGenericParam( KType, TLiwVariant( KPublisher ) ) );
- CLiwDefaultMap* filter = CLiwDefaultMap::NewLC();
-
- filter->InsertL( KPublisherId, TLiwVariant( KHsWidgetPublisher ));
- filter->InsertL( KContentType, TLiwVariant( KHsPublisher ));
- inparam->AppendL( TLiwGenericParam( KFilter, TLiwVariant( filter ) ) );
-
- iCPSInterface->ExecuteCmdL( KGetList, *inparam, *outparam );
-
- RemoveWidgetsL( outparam );
-
- CleanupStack::PopAndDestroy( filter );
- CleanupStack::PopAndDestroy( outparam );
- CleanupStack::PopAndDestroy( inparam );
+ CLiwGenericParamList* inparam = CLiwGenericParamList::NewLC( );
+ CLiwGenericParamList* outparam = CLiwGenericParamList::NewLC( );
+ inparam->AppendL( TLiwGenericParam( KType, TLiwVariant( KPublisher ) ) );
+ CLiwDefaultMap* filter = CLiwDefaultMap::NewLC();
+
+ filter->InsertL( KPublisherId, TLiwVariant( KHsWidgetPublisher ));
+ filter->InsertL( KContentType, TLiwVariant( KHsPublisher ));
+ inparam->AppendL( TLiwGenericParam( KFilter, TLiwVariant( filter ) ) );
+
+ iCPSInterface->ExecuteCmdL( KGetList, *inparam, *outparam );
+
+ RemoveWidgetsL( outparam );
+
+ CleanupStack::PopAndDestroy( filter );
+ CleanupStack::PopAndDestroy( outparam );
+ CleanupStack::PopAndDestroy( inparam );
}
// ----------------------------------------------------------------------------
@@ -149,14 +183,19 @@
void CCHSwiPlugin::RemoveWidgetsL( CLiwGenericParamList* aWidgets )
{
TInt pos ( 0 );
- aWidgets->FindFirst( pos, KResults );
- if( pos != KErrNotFound )
+ aWidgets->FindFirst( pos, KResults );
+
+ if ( pos != KErrNotFound )
{
+ CDesC16ArrayFlat* notFoundWidgets = new (ELeave) CDesC16ArrayFlat( KWidgetArrayGran );
+ CleanupStack::PushL( notFoundWidgets );
+
TLiwVariant variant = (*aWidgets)[pos].Value();
variant.PushL();
CLiwIterable* iterable = variant.AsIterable();
iterable->Reset();
- if( iterable->NextL( variant ) )
+
+ while ( iterable->NextL( variant ) )
{
CLiwDefaultMap *map = CLiwDefaultMap::NewLC();
variant.Get( *map );
@@ -173,8 +212,7 @@
{
if( map->FindL( KContentId, variant ) )
{
- RemoveWidgetL( KPublisher, variant.AsDes() );
- RemoveWidgetL( KCpData, variant.AsDes() );
+ notFoundWidgets->AppendL( variant.AsDes() );
}
}
}
@@ -182,8 +220,26 @@
}
CleanupStack::PopAndDestroy( map );
}
- CleanupStack::PopAndDestroy(&variant);
+
+ if ( notFoundWidgets->Count() > 0 )
+ {
+ iUsbHandler->SynchronousDriveScan();
+
+ if ( !IsMassStorageMode() )
+ {
+ for ( TInt i = 0; i < notFoundWidgets->Count(); i++ )
+ {
+ RemoveWidgetL( KPublisher, (*notFoundWidgets)[i] );
+ RemoveWidgetL( KCpData, (*notFoundWidgets)[i] );
+ }
+ }
+ }
+
+ CleanupStack::PopAndDestroy( &variant );
+ CleanupStack::PopAndDestroy( notFoundWidgets );
}
+
+
}
// ----------------------------------------------------------------------------
@@ -211,4 +267,24 @@
CleanupStack::PopAndDestroy( inparam );
}
+// ----------------------------------------------------------------------------
+// CCHSwiPlugin::SetMassStorageMode
+// Sets Mass Storage mode.
+// ----------------------------------------------------------------------------
+//
+void CCHSwiPlugin::SetMassStorageMode( TBool aMode )
+ {
+ iMassStorageMode = aMode;
+ }
+
+// ----------------------------------------------------------------------------
+// CCHSwiPlugin::IsMassStorageMode
+// Gets Mass Storage mode.
+// ----------------------------------------------------------------------------
+//
+TBool CCHSwiPlugin::IsMassStorageMode()
+ {
+ return iMassStorageMode;
+ }
+
// End of File