sdkcreationmw/sdkcommonutils/util/Inc/FolderScanner.h
author rajpuroh
Wed, 21 Apr 2010 09:56:53 +0530
changeset 1 ac50fd48361b
parent 0 b26acd06ea60
permissions -rw-r--r--
Second Contribution
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     1
/*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     2
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     3
* All rights reserved.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     4
* This component and the accompanying materials are made available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     6
* which accompanies this distribution, and is available
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     8
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
     9
* Initial Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    11
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    12
* Contributors:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    13
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    14
* Description: 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    15
*
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    16
*/
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    17
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    18
#ifndef _FolderScanner_STM_H_
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    19
#define _FolderScanner_STM_H_
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    20
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    21
// Constants
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    22
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    23
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    24
// Include files 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    25
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    26
#include <e32base.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    27
#include <f32file.h>
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    28
#include "SysTimer.h"
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    29
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    30
// Constants 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    31
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    32
static const int KDefaultScanPeriod = 500;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    33
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    34
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    35
// Interface class definition
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    36
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    37
class CFolderScanner_if
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    38
	{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    39
	friend class CFolderScanner;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    40
	protected:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    41
		virtual void FileFound(const TDesC& filename) = 0;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    42
	};
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    43
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    44
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    45
// Class definition 
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    46
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    47
class CFolderScanner :    public CBase
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    48
						, public CSysTimer_if
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    49
	{
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    50
	protected:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    51
		// Constructor
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    52
		CFolderScanner() {}
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    53
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    54
		// Second phase constructor
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    55
		void ConstructL(			// Users client
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    56
			  CFolderScanner_if* client
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    57
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    58
			// Source folder to scan
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    59
			, const TDesC& folder
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    60
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    61
			// Extension
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    62
			, const TDesC& ext
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    63
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    64
			// Scanning period in milliseconds
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    65
			, int aScanPeriod		
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    66
			);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    67
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    68
	public:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    69
		// Destructor	
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    70
		IMPORT_C ~CFolderScanner();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    71
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    72
		// Construction initiator - use this to construct objects
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    73
		IMPORT_C static CFolderScanner* NewL(
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    74
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    75
			// Users client
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    76
			  CFolderScanner_if* client
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    77
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    78
			// Source folder to scan
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    79
			, const TDesC& folder
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    80
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    81
			// Extension
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    82
			, const TDesC& ext
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    83
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    84
			// Scanning period in milliseconds
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    85
			, int aScanPeriod = KDefaultScanPeriod		
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    86
			);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    87
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    88
		// The scanner stops when it has found something
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    89
		// Call this to continue scanning
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    90
		IMPORT_C void ContinueScan();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    91
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    92
	protected:
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    93
		CFolderScanner_if* iClient;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    94
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    95
		// Classes for scannning dirs
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    96
		RFs				iFs;		// Fileserver session
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    97
		CSysTimer*		iTimer;		// Timer for scanning
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    98
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
    99
		// Timeout
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   100
		int				iTimeout;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   101
		
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   102
		HBufC*			iFolder;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   103
		HBufC*			iScanPath;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   104
		HBufC*			iScanExt;
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   105
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   106
		void Timer(int);
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   107
		inline bool ScanOnce();
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   108
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   109
	};
b26acd06ea60 First Contribution of SDK components
rajpuroh
parents:
diff changeset
   110
#endif // _FolderScanner_STM_H_