|
1 /* |
|
2 * Copyright (c) 2006-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: Monitors file creations, modifications and deletions.* |
|
15 */ |
|
16 |
|
17 #include "mdeharvestersession.h" |
|
18 #include "filemonitorplugin.h" |
|
19 #include "processoriginmapper.h" |
|
20 #include "harvestercenreputil.h" |
|
21 |
|
22 // --------------------------------------------------------------------------- |
|
23 // CFileMonitorPlugin::NewL() |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 CFileMonitorPlugin* CFileMonitorPlugin::NewL() |
|
27 { |
|
28 CFileMonitorPlugin* self = new (ELeave) CFileMonitorPlugin(); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CFileMonitorPlugin::~CFileMonitorPlugin() |
|
37 // destruct |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CFileMonitorPlugin::~CFileMonitorPlugin() |
|
41 { |
|
42 delete iFileMonitor; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CFileMonitorPlugin::StartMonitoring() |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 TBool CFileMonitorPlugin::StartMonitoring( MMonitorPluginObserver& aObserver, |
|
50 CMdESession* aMdEClient, CContextEngine* /*aCtxEngine*/, |
|
51 CHarvesterPluginFactory* aHarvesterPluginFactory ) |
|
52 { |
|
53 _LIT( KDrive, "c:" ); |
|
54 _LIT( KMonitorPath, "\\Data" ); |
|
55 _LIT( KFullPath, "c:\\Data" ); |
|
56 |
|
57 TInt err = KErrNone; |
|
58 TBool success = iFileMonitor->StartMonitoring( aObserver, aMdEClient, KFullPath, |
|
59 aHarvesterPluginFactory ); |
|
60 |
|
61 if( success ) |
|
62 { |
|
63 CHarvesterCenRepUtil* cenRepoUtil = NULL; |
|
64 TRAP( err, cenRepoUtil = CHarvesterCenRepUtil::NewL() ); |
|
65 if( cenRepoUtil ) |
|
66 { |
|
67 TRAP( err, cenRepoUtil->AddIgnorePathsToFspL( KDrive, KMonitorPath )); |
|
68 } |
|
69 delete cenRepoUtil; |
|
70 } |
|
71 return success && err == KErrNone; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CFileMonitorPlugin::StopMonitoring() |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 TBool CFileMonitorPlugin::StopMonitoring() |
|
79 { |
|
80 return iFileMonitor->StopMonitoring(); |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CFileMonitorPlugin::ResumeMonitoring() |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 TBool CFileMonitorPlugin::ResumeMonitoring( MMonitorPluginObserver& /*aObserver*/, |
|
88 CMdESession* /*aMdEClient*/, CContextEngine* /*aCtxEngine*/, |
|
89 CHarvesterPluginFactory* /*aHarvesterPluginFactory*/ ) |
|
90 { |
|
91 iFileMonitor->SetCachingStatus( EFalse ); |
|
92 return ETrue; |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // CFileMonitorPlugin::PauseMonitoring() |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 TBool CFileMonitorPlugin::PauseMonitoring() |
|
100 { |
|
101 iFileMonitor->SetCachingStatus( ETrue ); |
|
102 return ETrue; |
|
103 } |
|
104 |
|
105 // constructor support |
|
106 // don't export these, because used only by functions in this DLL, eg our NewLC() |
|
107 // --------------------------------------------------------------------------- |
|
108 // CFileMonitorPlugin::CFileMonitorPlugin() |
|
109 // first-phase C++ constructor |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 CFileMonitorPlugin::CFileMonitorPlugin() : iFileMonitor( NULL ) |
|
113 { |
|
114 // No implementation required |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CFileMonitorPlugin::ConstructL() |
|
119 // second-phase constructor |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 void CFileMonitorPlugin::ConstructL() |
|
123 { |
|
124 iFileMonitor = CFileMonitorAO::NewL(); |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // CFileMonitorPlugin::RegisterProcessOriginL() |
|
129 // Registers an origin mapping for a process |
|
130 // in file monitor CProcessOriginMapper. |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CFileMonitorPlugin::RegisterProcessL( const TUid& aProcessId, |
|
134 const TOrigin& aOrigin ) |
|
135 { |
|
136 iFileMonitor->Mapper().RegisterProcessL( aProcessId, aOrigin ); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CFileMonitorPlugin::UnregisterProcessOriginL() |
|
141 // Unregisters an origin mapping for a process. |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CFileMonitorPlugin::UnregisterProcessL( const TUid& aProcessId ) |
|
145 { |
|
146 iFileMonitor->Mapper().UnregisterProcessL( aProcessId ); |
|
147 } |
|
148 |