layouts/cdl/CdlServer/inc/CdlSFiles.h
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #ifndef CDLSFILES
       
    18 #define CDLSFILES
       
    19 
       
    20 #include <CdlDllWatcher.h>
       
    21 
       
    22 /**
       
    23 * A collection of CDir objects.
       
    24 */
       
    25 class CCdlDirs : public CArrayPtrFlat<CDir>
       
    26 	{
       
    27 public:
       
    28 	CCdlDirs();
       
    29 	~CCdlDirs();
       
    30 	};
       
    31 
       
    32 /**
       
    33 * Mixin interface for objects that want to observe activity in the file system watcher
       
    34 */
       
    35 class MFsWatcherObserver
       
    36 	{
       
    37 public:
       
    38 	virtual void NewDirsList(CCdlDirs* aNewDirs) = 0;
       
    39 	};
       
    40 
       
    41 /**
       
    42 * The file system watcher active object.
       
    43 * This watches the ?:\system\cdl directories for changes in the available CDL DLLs.
       
    44 */
       
    45 class CFsWatcher : public CActive
       
    46 	{
       
    47 public:
       
    48 	CFsWatcher(RFs& aFs, MFsWatcherObserver& aObserver);
       
    49 	~CFsWatcher();
       
    50 	void ConstructL();
       
    51 
       
    52 	CCdlDirs* CreateDirsListL() const;
       
    53 
       
    54 private:
       
    55 	void DoCancel();
       
    56 	void RunL();
       
    57 	void DoRunL();
       
    58 	void Queue();
       
    59 
       
    60 private:
       
    61 	RFs& iFs;
       
    62 	MFsWatcherObserver& iObserver;
       
    63 	};
       
    64 
       
    65 
       
    66 /**
       
    67 * Self driven active object that maintains a list of the currently available CDL DLLs.
       
    68 * It trickles changes in this set of DLLs to it's observer. This is done one DLL at a time
       
    69 * to avoid hanging up the server on a long running scan of all CDL DLLs.
       
    70 */
       
    71 class CCdlDllsWatcher : public CCdlDllsWatcherBase, MFsWatcherObserver
       
    72 	{
       
    73 public:
       
    74 	CCdlDllsWatcher(RFs& aFs, MCdlDllsObserver* aObserver);
       
    75 	~CCdlDllsWatcher();
       
    76 	void ConstructL();
       
    77 
       
    78 private: // from CActive
       
    79 	void DoCancel();
       
    80 	void RunL();
       
    81 
       
    82 private: // from MFsWatcherObserver
       
    83 	void NewDirsList(CCdlDirs* aNewDirs);
       
    84 
       
    85 private:
       
    86 	void DoRunL();
       
    87 	void Queue();
       
    88 
       
    89 	void StartTellingObserverIfNecessaryL();
       
    90 	void AddNewToObserverL();
       
    91 	void RemoveCurrentFromObserverL();
       
    92 
       
    93 private: // from CCdlDllsWatcherBase
       
    94 	TInt IsPluginInRom(const TDesC& aFileName, TBool& aIsInRom) const;
       
    95 
       
    96 private:
       
    97 	class TDllList
       
    98 		{
       
    99 	public:
       
   100 		// List functions.
       
   101 		// These functions iterate all the DLLs in name order.
       
   102 		// Drive order is ignored, except when the same name appears in more
       
   103 		// than one drive, when CDL drive priority rules are observed.
       
   104 		void Reset();
       
   105 		const TEntry& Current() const;
       
   106 		TBool AtEnd() const;
       
   107 		void Next();
       
   108 
       
   109 		// Current entry comparison operators.
       
   110 		// These compare the current entry for two DLL lists by name then 
       
   111 		// date modified.
       
   112 		TBool operator==(const TDllList& aRhs) const;
       
   113 		TBool operator<(const TDllList& aRhs) const;
       
   114 
       
   115 	private:
       
   116 		void SetCurrent();
       
   117 
       
   118 	public:
       
   119 		CCdlDirs* iDirs;			// not owned
       
   120 		TInt iIndices[KMaxDrives];
       
   121 		const TEntry* iCurrent;
       
   122 		};
       
   123 
       
   124 	TDllList iCurrent;				// .iDirs is owned
       
   125 	TDllList iNew;					// .iDirs is owned
       
   126 	CCdlDirs* iNext;				// owned, temporary storage for new dirs list while processing on-going
       
   127 	TBool iTellingObserver;
       
   128 	MCdlDllsObserver* iObserver;
       
   129 	CFsWatcher* iFsWatcher;			// owned
       
   130 	};
       
   131 
       
   132 #endif