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 TIntAllowDismount(TIntaDrive)

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 aDriveA drive identifier specified by TDriveNumber

CancelNotifyDisk()

IMPORT_C voidCancelNotifyDisk()

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 voidCancelNotifyDiskSpace(const TInt64 &aThreshold,
TIntaDrive
)

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 & aThresholdA threshold that causes notification when crossed.
TInt aDriveA drive identifier specified by TDriveNumber

CancelNotifyDiskSpace(TInt)

IMPORT_C voidCancelNotifyDiskSpace(TIntaDrive)

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 aDriveA drive identifier specified by TDriveNumber

CancelNotifyDiskSpace()

IMPORT_C voidCancelNotifyDiskSpace()

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 voidCancelNotifyDismount(TIntaDrive)

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 aDriveA drive identifier specified by TDriveNumber

CancelNotifyDismount()

IMPORT_C voidCancelNotifyDismount()

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 voidCancelNotifyEntry(TNotifyTypeaType,
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 aTypeA type of notification specified by TNotifyType.
const TDesC & aEntryA full path of the file or folder entry to listen.

CancelNotifyEntry(const TDesC &)

IMPORT_C voidCancelNotifyEntry(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 & aEntryA full path of the file or folder to be listened.

CancelNotifyEntry()

IMPORT_C voidCancelNotifyEntry()

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 voidCancelStartedDismount(TIntaDrive)

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 aDriveA drive identifier specified by TDriveNumber

CancelStartedDismount()

IMPORT_C voidCancelStartedDismount()

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 &)

voidConstructL(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 & aCallbackReference to a callback instance, MDiskNotifyHandlerCallback
RFs & aFsReference 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 TIntNotifyDisk()

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 TIntNotifyDiskSpace(const TInt64 &aThreshold,
TIntaDrive
)

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.

Parameters

const TInt64 & aThresholdA threshold that causes notification when crossed.
TInt aDriveA drive identifier specified by TDriveNumber

NotifyDismount(TInt)

IMPORT_C TIntNotifyDismount(TIntaDrive)

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.

Parameters

TInt aDriveA drive identifier specified by TDriveNumber

NotifyEntry(TNotifyType, const TDesC &)

IMPORT_C TIntNotifyEntry(TNotifyTypeaType,
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.

Parameters

TNotifyType aTypeA type of notification specified by TNotifyType.
const TDesC & aEntryA full path of the file or folder to be listened.

StartDismount(TInt, TTimeIntervalMicroSeconds32)

IMPORT_C TIntStartDismount(TIntaDrive,
TTimeIntervalMicroSeconds32aForcedTimeout
)

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 aDriveA drive identifier specified by TDriveNumber
TTimeIntervalMicroSeconds32 aForcedTimeoutA timeout to forced dismount in micro seconds.

Member Data Documentation

CDiskNotifyHandlerImpl * iImpl

CDiskNotifyHandlerImpl *iImpl[private]