×
Namespaces

Variants
Actions
Revision as of 14:56, 17 December 2007 by Forum Nokia KB (Talk | contribs)

Archived:Monitoring MMC insertion/removal events using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search


Template:KBTS

ID TSS000794 Creation date December 17, 2007
Platform S60 3rd Edition,
S60 3rd Edition, FP1
Devices  
Category Symbian C++ Subcategory Base/System

Overview

Applications can be notified about the insertion or removal of the MMC using the NotifyDiskSpace() method from class RFs.


Solution

In order to receive these events, the UI application should be made a system application to prevent it from being automatically closed when removing a memory card.

CEikonEnv::Static()->SetSystem( ETrue );
 

After this, notification requests for memory card insertion or removal can be created as follows:

const TInt64 KThreshold = 0x1000; // Threshold value for free disk space

CEikonEnv::Static()->FsSession().NotifyDiskSpace(KThreshold, EDriveE, iStatus);
SetActive();
 

RFs::NotifyDiskSpace() is an asynchronous method that completes when the threshold value is crossed (in either direction). The above code snippet is meant to be used inside a CActive-derived class.

These notifications can also be received from a non-UI application, by constructing a window group:

During the construction of a CActive-derived class:

// iWg is of type RWindowGroup*
// iWs is an open window server session (RWsSession)
// iFs is an open file server session (RFs)
   
iWg = new (ELeave) RWindowGroup( iWs );
User::LeaveIfError( iWg->Construct( (TUint32)iWg, EFalse ) );

iWg->SetOrdinalPosition( -1 );
iWg->EnableReceiptOfFocus( EFalse );
   
iWgName = CApaWindowGroupName::NewL( iWs );
iWgName->SetSystem( ETrue );
iWgName->SetHidden( ETrue );
iWgName->SetWindowGroupName( *iWg );
   
iFs.NotifyDiskSpace( KThreshold, EDriveE, iStatus );
SetActive();

Implementation of CActive::RunL():

if(iStatus == KErrNone)
  {
  // Threshold value has been crossed - memory card has been
  // inserted or removed
   
  iFs.NotifyDiskSpace(KThreshold, EDriveE, iStatus);
  SetActive();
  }

Implementation of CActive::DoCancel();

iFs.NotifyDiskSpaceCancel();


60 page views in the last 30 days.