CDiskNotifyHandler Class Reference

class CDiskNotifyHandler : public CBase

Disk Notification API provides an easy-to-use implementation of a wrapper to handle file server notifications. It contains all required active objects needed for handling the notifications. In the most cases, it automatically resubscribes the notifications. The API consists of classes CDiskNotifyHandler and MDiskNotifyHandlerCallback . The user of CDiskNotifyHandler class needs to implement relevant MDiskNotifyHandlerCallback interface methods to handle the notifications.

Usage:

Initialization example (from a class that implements MDiskNotifyHandlerCallback interface):
        // iFsSession contains open file server session
 iNotifyHandler = CDiskNotifyHandler::NewL( *this, iFsSession );
 User::LeaveIfError( iNotifyHandler->NotifyDisk() ); // Subscribe disk notifications
 // Note that also the other notifications can be subcribed simultaneously using 
 // the same disk notify handler
       
Uninitialization example:
        delete iNotifyHandler; // Cancel all notifications set by this handler
       
Handler method implementation example:
        // Implement just the needed callback methods
 void CMyDiskNotifyTest::HandleNotifyDisk( TInt aError, const TDiskEvent& aEvent )
    {
    // Print out the event data
    RDebug::Print( _L("Error: %d, Disk %d changed, Change type: %d"),
       aError, aEvent.iDrive, aEvent.iType );
    }
       
disknotifyhandler.lib
Since
S60 5.0

Inherits from

Constructor & Destructor Documentation

CDiskNotifyHandler()

CDiskNotifyHandler ( ) [private]

C++ default constructor.

~CDiskNotifyHandler()

IMPORT_C ~CDiskNotifyHandler ( )

Destructor.

Member Functions Documentation

AllowDismount(TInt)

IMPORT_C TInt AllowDismount ( TInt aDrive )

When this method is called, the CDiskNotifyHandler allows the dismount of given drive. If it is not listening the dismount of given drive, nothing happens.

This method must be called only from MDiskNotifyHandlerCallback's HandleNotifyDismount to inform file server that dismount of the drive can be done.

Since
S60 5.0
TDriveNumber

Parameters

TInt aDrive A drive identifier specified by TDriveNumber

CancelNotifyDisk()

IMPORT_C void CancelNotifyDisk ( )

When this method is called, the CDiskNotifyHandler cancels listening for disk notifications. If it is not listening disk notifications, nothing happens.

Since
S60 5.0

CancelNotifyDiskSpace(const TInt64 &, TInt)

IMPORT_C void CancelNotifyDiskSpace ( const TInt64 & aThreshold,
TInt aDrive
)

When this method is called, the CDiskNotifyHandler cancels listening for disk space notification of given drive with given threshold. If it is not listening the disk space of given drive with given threshold, nothing happens.

Since
S60 5.0
TDriveNumber

Parameters

const TInt64 & aThreshold A threshold that causes notification when crossed.
TInt aDrive A drive identifier specified by TDriveNumber

CancelNotifyDiskSpace(TInt)

IMPORT_C void CancelNotifyDiskSpace ( TInt aDrive )

When this method is called, the CDiskNotifyHandler cancels listening for all disk space notifications of given drive. If it is not listening the disk space of given drive, nothing happens.

Since
S60 5.0
TDriveNumber

Parameters

TInt aDrive A drive identifier specified by TDriveNumber

CancelNotifyDiskSpace()

IMPORT_C void CancelNotifyDiskSpace ( )

When this method is called, the CDiskNotifyHandler cancels listening for all disk space notifications that are set by this handler. If it is not listening any disk space notifications, nothing happens.

Since
S60 5.0

CancelNotifyDismount(TInt)

IMPORT_C void CancelNotifyDismount ( TInt aDrive )

When this method is called, the CDiskNotifyHandler cancels listening for dismount notification of given drive. If it is not listening the dismount of given drive, nothing happens.

Since
S60 5.0
TDriveNumber

Parameters

TInt aDrive A drive identifier specified by TDriveNumber

CancelNotifyDismount()

IMPORT_C void CancelNotifyDismount ( )

When this method is called, the CDiskNotifyHandler cancels listening for all dismount notifications that are set by this handler. If it is not listening any dismount notifications, nothing happens.

Since
S60 5.0

CancelNotifyEntry(TNotifyType, const TDesC &)

IMPORT_C void CancelNotifyEntry ( TNotifyType aType,
const TDesC & aEntry
)

When this method is called, the CDiskNotifyHandler cancels listening for change notification of given entry with notify type. If it is not listening the given entry with notify type, nothing happens.

Since
S60 5.0
TDriveNumber

Parameters

TNotifyType aType A type of notification specified by TNotifyType.
const TDesC & aEntry A full path of the file or folder entry to listen.

CancelNotifyEntry(const TDesC &)

IMPORT_C void CancelNotifyEntry ( const TDesC & aEntry )

When this method is called, the CDiskNotifyHandler cancels listening for all change notifications of given entry. If it is not listening the given entry, nothing happens.

Since
S60 5.0
TDriveNumber

Parameters

const TDesC & aEntry A full path of the file or folder to be listened.

CancelNotifyEntry()

IMPORT_C void CancelNotifyEntry ( )

When this method is called, the CDiskNotifyHandler cancels listening for entry notifications that are set by this handler. If it is not listening any entry notifications, nothing happens.

Since
S60 5.0

CancelStartedDismount(TInt)

IMPORT_C void CancelStartedDismount ( TInt aDrive )

When this method is called, the CDiskNotifyHandler cancels started dismount of given drive. If dismount of given drive was not started, nothing happens.

Since
S60 5.2

Parameters

TInt aDrive A drive identifier specified by TDriveNumber

CancelStartedDismount()

IMPORT_C void CancelStartedDismount ( )

When this method is called, the CDiskNotifyHandler cancels all started dismounts. If any dismount was not started, nothing happens.

Since
S60 5.2

ConstructL(MDiskNotifyHandlerCallback &, RFs &)

void ConstructL ( MDiskNotifyHandlerCallback & aCallback,
RFs & aFs
) [private]

Symbian two-phased constructor.

Parameters

MDiskNotifyHandlerCallback & aCallback
RFs & aFs

NewL(MDiskNotifyHandlerCallback &, RFs &)

IMPORT_C CDiskNotifyHandler * NewL ( MDiskNotifyHandlerCallback & aCallback,
RFs & aFs
) [static]

This is a two-phase constructor method that is used to create a new instance for listening to the disk changes.

Parameters

MDiskNotifyHandlerCallback & aCallback Reference to a callback instance, MDiskNotifyHandlerCallback
RFs & aFs Reference to an open file server session, RFs Do not close this session until all CDiskNotifyHandler instances referring to it have been deleted.

NotifyDisk()

IMPORT_C TInt NotifyDisk ( )

When this method is called, the CDiskNotifyHandler starts listening for disk notifications. If it is already listening disk notifications, KErrAlreadyExists is returned.

This notification is automatically resubscibed until explicitly canceled or error has happened. The notifications and errors are informed using MDiskNotifyHandlerCallback's HandleNotifyDisk method.

NotifyDiskSpace(const TInt64 &, TInt)

IMPORT_C TInt NotifyDiskSpace ( const TInt64 & aThreshold,
TInt aDrive
)

When this method is called, the CDiskNotifyHandler starts listening for disk space notifications. If it is already listening disk space for given drive with given threshold, KErrAlreadyExists is returned.

This notification is automatically resubscibed until explicitly canceled or error has happened. The notification and error are informed using MDiskNotifyHandlerCallback's HandleNotifyDiskSpace method.

Since
S60 5.0
TDriveNumber MDiskNotifyHandlerCallback

Parameters

const TInt64 & aThreshold A threshold that causes notification when crossed.
TInt aDrive A drive identifier specified by TDriveNumber

NotifyDismount(TInt)

IMPORT_C TInt NotifyDismount ( TInt aDrive )

When this method is called, the CDiskNotifyHandler starts listening for dismount notification. If it is already listening dismount notification for given drive, KErrAlreadyExists is returned.

This notification is not resubscibed because drive is not available anymore after dismount notification. The notification and error are informed using MDiskNotifyHandlerCallback's HandleNotifyDismount method.

Since
S60 5.0
TDriveNumber MDiskNotifyHandlerCallback

Parameters

TInt aDrive A drive identifier specified by TDriveNumber

NotifyEntry(TNotifyType, const TDesC &)

IMPORT_C TInt NotifyEntry ( TNotifyType aType,
const TDesC & aEntry
)

When this method is called, the CDiskNotifyHandler starts listening for entry (i.e. file or folder) change notifications. If it is already listening any type of change notification for given entry with given notification type, KErrAlreadyExists is returned.

A given folder entry's full path must include backslash ending.

This notification is automatically resubscibed until explicitly canceled or error has happened. The notification and error are informed using MDiskNotifyHandlerCallback's HandleNotifyEntry method.

Since
S60 5.0
TNotifyType TDriveNumber MDiskNotifyHandlerCallback

Parameters

TNotifyType aType A type of notification specified by TNotifyType.
const TDesC & aEntry A full path of the file or folder to be listened.

StartDismount(TInt, TTimeIntervalMicroSeconds32)

IMPORT_C TInt StartDismount ( TInt aDrive,
TTimeIntervalMicroSeconds32 aForcedTimeout
)

When this method is called, the CDiskNotifyHandler starts dismount with sending notification to registered clients. If dismount is pending after given timeout, forced dismount is done. If dismount of given drive was already started, KErrAlreadyExists is returned.

This notification is not resubscibed because drive is not available anymore after dismount. The notification and error are informed using MDiskNotifyHandlerCallback's HandleNotifyDismountFinished method.

Since
S60 5.2

Parameters

TInt aDrive A drive identifier specified by TDriveNumber
TTimeIntervalMicroSeconds32 aForcedTimeout A timeout to forced dismount in micro seconds.

Member Data Documentation

CDiskNotifyHandlerImpl * iImpl

CDiskNotifyHandlerImpl * iImpl [private]