diff -r 2014ca87e772 -r 235a7fc86938 imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h --- a/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h Tue Jan 26 15:18:05 2010 +0200 +++ b/imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailstore.h Tue Feb 02 00:23:15 2010 +0200 @@ -20,6 +20,8 @@ #define THUMBNAILSTORE_H #include +#include +#include #include "thumbnailcenrep.h" #include "thumbnailmanagerconstants.h" #include "thumbnaillog.h" @@ -55,11 +57,137 @@ /** +* MMdSDiskSpaceNotifierObserver +* Observer interface for a disk space notifier. +*/ +class MThumbnailStoreDiskSpaceNotifierObserver + { + public : + /** + * Called to notify the observer that disk space has crossed the specified threshold value. + * + * @param aDiskFull is disk full (freespace under specified threshold level) + */ + virtual void HandleDiskSpaceNotificationL(TBool aDiskFull) = 0; + + /** + * Called to if disk space notifier has an error situation. + * + * @param aError error code + */ + virtual void HandleDiskSpaceError(TInt aError) = 0; + + }; + +/** +* CMSDiskSpaceNotifierAO. +* A disk space notifier class +*/ +class CThumbnailStoreDiskSpaceNotifierAO : public CActive + { + public: + enum TDiskSpaceNotifierState + { + ENormal, + EIterate + }; + + public : // Constructors and destructors + /** + * Constructs a disk space notifier implementation. + * + * @param aThreshold minimum free disk space threshold level in bytes + * @param aFilename filename which defines monitored drive's number + * @return implementation + */ + static CThumbnailStoreDiskSpaceNotifierAO* NewL( + MThumbnailStoreDiskSpaceNotifierObserver& aObserver, + TInt64 aThreshold, const TDesC& aFilename); + + /** + * Constructs a disk space notifier implementation and leaves it + * in the cleanup stack. + * + * @param aThreshold minimum free disk space threshold level in bytes + * @return implementation + */ + static CThumbnailStoreDiskSpaceNotifierAO* NewLC( + MThumbnailStoreDiskSpaceNotifierObserver& aObserver, + TInt64 aThreshold, const TDesC& aFilename ); + + /** + * Destructor. + */ + virtual ~CThumbnailStoreDiskSpaceNotifierAO(); + + TBool DiskFull() const; + + protected: // Functions from base classes + /** + * From CActive + * Callback function. + * Invoked to handle responses from the server. + */ + void RunL(); + + /** + * From CActive + * Handles errors that occur during notifying the observer. + */ + TInt RunError(TInt aError); + + /** + * From CActive + * Cancels any outstanding operation. + */ + void DoCancel(); + + private: // Constructors and destructors + + /** + * constructor + */ + CThumbnailStoreDiskSpaceNotifierAO( + MThumbnailStoreDiskSpaceNotifierObserver& aObserver, + TInt64 aThreshold, TDriveNumber aDrive ); + + /** + * 2nd phase constructor + * @param aThreshold minimum free disk space threshold level in bytes + * @param aDrive monitored drive's number + */ + void ConstructL(); + + private: // New methods + + void StartNotifier(); + + static TDriveNumber GetDriveNumberL( const TDesC& aFilename ); + + private: // Data + + MThumbnailStoreDiskSpaceNotifierObserver& iObserver; + + RFs iFileServerSession; + + const TInt64 iThreshold; + + const TDriveNumber iDrive; + + TDiskSpaceNotifierState iState; + + TInt iIterationCount; + + TBool iDiskFull; + }; + + +/** * Store for thumbnails. * * @since S60 v5.0 */ -class CThumbnailStore: public CBase +class CThumbnailStore: public CBase, public MThumbnailStoreDiskSpaceNotifierObserver { // Bitmasked Flags typedef enum @@ -316,6 +444,8 @@ */ TInt CheckRowIDsL(); + + TBool IsDiskFull(); private: /** @@ -426,6 +556,11 @@ */ void RemoveDbFlagL(TThumbnailDbFlags aFlag); +public : // From MThumbnailStoreDiskSpaceNotifierObserver + void HandleDiskSpaceNotificationL(TBool aDiskFull); + + void HandleDiskSpaceError(TInt aError); + private: // data @@ -472,6 +607,15 @@ * Periodic timer handling automatic flushing of db cache */ CPeriodic* iAutoFlushTimer; + + /** + * Notifier for situations where free disk space runs out. + */ + CThumbnailStoreDiskSpaceNotifierAO* iDiskFullNotifier; + + TBool iDiskFull; }; +// End of File + #endif // THUMBNAILSTORE_H