sl@0
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include "t_notify_plugin.h"
|
sl@0
|
17 |
#include <f32pluginutils.h>
|
sl@0
|
18 |
|
sl@0
|
19 |
TChar gDriveToTest;
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
Leaving New function for the plugin
|
sl@0
|
23 |
@internalComponent
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
CNotifyPlugin* CNotifyPlugin::NewL()
|
sl@0
|
26 |
{
|
sl@0
|
27 |
CNotifyPlugin* self = new(ELeave) CNotifyPlugin;
|
sl@0
|
28 |
CleanupStack::PushL(self);
|
sl@0
|
29 |
self->ConstructL();
|
sl@0
|
30 |
CleanupStack::Pop();
|
sl@0
|
31 |
return self;
|
sl@0
|
32 |
}
|
sl@0
|
33 |
|
sl@0
|
34 |
|
sl@0
|
35 |
/**
|
sl@0
|
36 |
Constructor for the plugin
|
sl@0
|
37 |
@internalComponent
|
sl@0
|
38 |
*/
|
sl@0
|
39 |
CNotifyPlugin::CNotifyPlugin() : iInterceptsEnabled(EFalse),
|
sl@0
|
40 |
iLogging(ETrue)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
|
sl@0
|
45 |
void CNotifyPlugin::ConstructL()
|
sl@0
|
46 |
{
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
/**
|
sl@0
|
50 |
The destructor for the plugin
|
sl@0
|
51 |
@internalComponent
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
CNotifyPlugin::~CNotifyPlugin()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
iFs.Close();
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
/**
|
sl@0
|
59 |
Initialise the plugin.
|
sl@0
|
60 |
@internalComponent
|
sl@0
|
61 |
*/
|
sl@0
|
62 |
void CNotifyPlugin::InitialiseL()
|
sl@0
|
63 |
{
|
sl@0
|
64 |
User::LeaveIfError(iFs.Connect());
|
sl@0
|
65 |
CleanupClosePushL(iFs);
|
sl@0
|
66 |
|
sl@0
|
67 |
_LOG(_L("CNotifyPlugin InitialiseL"));
|
sl@0
|
68 |
EnableInterceptsL();
|
sl@0
|
69 |
|
sl@0
|
70 |
CleanupStack::Pop(); // iFs
|
sl@0
|
71 |
}
|
sl@0
|
72 |
|
sl@0
|
73 |
/**
|
sl@0
|
74 |
Enable the plugin's intercepts.
|
sl@0
|
75 |
@internalComponent
|
sl@0
|
76 |
*/
|
sl@0
|
77 |
void CNotifyPlugin::EnableInterceptsL()
|
sl@0
|
78 |
{
|
sl@0
|
79 |
if (iInterceptsEnabled) return;
|
sl@0
|
80 |
|
sl@0
|
81 |
User::LeaveIfError(RegisterIntercept(EFsFileRead, EPrePostIntercept));
|
sl@0
|
82 |
User::LeaveIfError(RegisterIntercept(EFsFileWrite, EPrePostIntercept));
|
sl@0
|
83 |
User::LeaveIfError(RegisterIntercept(EFsDirOpen, EPrePostIntercept));
|
sl@0
|
84 |
User::LeaveIfError(RegisterIntercept(EFsFileLock, EPrePostIntercept));
|
sl@0
|
85 |
User::LeaveIfError(RegisterIntercept(EFsFileUnLock, EPrePostIntercept));
|
sl@0
|
86 |
User::LeaveIfError(RegisterIntercept(EFsFileSeek, EPrePostIntercept));
|
sl@0
|
87 |
User::LeaveIfError(RegisterIntercept(EFsFileSize, EPrePostIntercept));
|
sl@0
|
88 |
User::LeaveIfError(RegisterIntercept(EFsFileSetSize, EPrePostIntercept));
|
sl@0
|
89 |
User::LeaveIfError(RegisterIntercept(EFsDirReadOne, EPrePostIntercept));
|
sl@0
|
90 |
User::LeaveIfError(RegisterIntercept(EFsDirReadPacked, EPrePostIntercept));
|
sl@0
|
91 |
User::LeaveIfError(RegisterIntercept(EFsFileOpen, EPrePostIntercept));
|
sl@0
|
92 |
User::LeaveIfError(RegisterIntercept(EFsFileCreate, EPrePostIntercept));
|
sl@0
|
93 |
User::LeaveIfError(RegisterIntercept(EFsFileReplace,EPrePostIntercept));
|
sl@0
|
94 |
User::LeaveIfError(RegisterIntercept(EFsFileRename, EPrePostIntercept));
|
sl@0
|
95 |
User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept));
|
sl@0
|
96 |
User::LeaveIfError(RegisterIntercept(EFsFileSubClose, EPrePostIntercept));
|
sl@0
|
97 |
|
sl@0
|
98 |
_LOG(_L("Notify Plugin: Enabled intercepts."));
|
sl@0
|
99 |
|
sl@0
|
100 |
iInterceptsEnabled = ETrue;
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
/**
|
sl@0
|
104 |
Disable the plugin's intercepts.
|
sl@0
|
105 |
@internalComponent
|
sl@0
|
106 |
*/
|
sl@0
|
107 |
void CNotifyPlugin::DisableInterceptsL()
|
sl@0
|
108 |
{
|
sl@0
|
109 |
if (!iInterceptsEnabled) return;
|
sl@0
|
110 |
|
sl@0
|
111 |
User::LeaveIfError(UnregisterIntercept(EFsFileRead, EPrePostIntercept));
|
sl@0
|
112 |
User::LeaveIfError(UnregisterIntercept(EFsFileRename, EPrePostIntercept));
|
sl@0
|
113 |
User::LeaveIfError(UnregisterIntercept(EFsFileWrite, EPrePostIntercept));
|
sl@0
|
114 |
User::LeaveIfError(UnregisterIntercept(EFsDirOpen, EPrePostIntercept));
|
sl@0
|
115 |
User::LeaveIfError(UnregisterIntercept(EFsFileLock, EPrePostIntercept));
|
sl@0
|
116 |
User::LeaveIfError(UnregisterIntercept(EFsFileUnLock, EPrePostIntercept));
|
sl@0
|
117 |
User::LeaveIfError(UnregisterIntercept(EFsFileSeek, EPrePostIntercept));
|
sl@0
|
118 |
User::LeaveIfError(UnregisterIntercept(EFsFileSize, EPrePostIntercept));
|
sl@0
|
119 |
User::LeaveIfError(UnregisterIntercept(EFsFileSetSize, EPrePostIntercept));
|
sl@0
|
120 |
User::LeaveIfError(UnregisterIntercept(EFsFileCreate, EPrePostIntercept));
|
sl@0
|
121 |
User::LeaveIfError(UnregisterIntercept(EFsFileOpen, EPrePostIntercept));
|
sl@0
|
122 |
User::LeaveIfError(UnregisterIntercept(EFsFileReplace, EPrePostIntercept));
|
sl@0
|
123 |
User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, EPrePostIntercept));
|
sl@0
|
124 |
User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,EPrePostIntercept));
|
sl@0
|
125 |
User::LeaveIfError(UnregisterIntercept(EFsDirReadOne, EPrePostIntercept));
|
sl@0
|
126 |
User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,EPrePostIntercept));
|
sl@0
|
127 |
|
sl@0
|
128 |
|
sl@0
|
129 |
_LOG(_L("Notify Plugin: Disabled intercepts."));
|
sl@0
|
130 |
|
sl@0
|
131 |
iInterceptsEnabled = EFalse;
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
/**
|
sl@0
|
135 |
Handle requests
|
sl@0
|
136 |
@internalComponent
|
sl@0
|
137 |
*/
|
sl@0
|
138 |
TInt CNotifyPlugin::DoRequestL(TFsPluginRequest& aRequest)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
TInt err = KErrNone;
|
sl@0
|
141 |
|
sl@0
|
142 |
TInt function = aRequest.Function();
|
sl@0
|
143 |
|
sl@0
|
144 |
if (aRequest.IsPostOperation())
|
sl@0
|
145 |
{
|
sl@0
|
146 |
_LOG2(_L("CNotifyPlugin post intercept for function %d"), function);
|
sl@0
|
147 |
}
|
sl@0
|
148 |
else if(function==EFsFileCreate)
|
sl@0
|
149 |
{
|
sl@0
|
150 |
_LOG2(_L("CNotifyPlugin pre intercept for function %d"), function);
|
sl@0
|
151 |
|
sl@0
|
152 |
TBuf<40> basepath;
|
sl@0
|
153 |
basepath.Append(gDriveToTest);
|
sl@0
|
154 |
basepath.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); //len=22
|
sl@0
|
155 |
|
sl@0
|
156 |
TBuf<40> path1;
|
sl@0
|
157 |
path1.Copy(basepath);
|
sl@0
|
158 |
path1.Append(_L("plugin.create"));
|
sl@0
|
159 |
|
sl@0
|
160 |
RFilePlugin file(aRequest);
|
sl@0
|
161 |
//Wrong file - should not notify
|
sl@0
|
162 |
file.Replace(path1,EFileWrite);
|
sl@0
|
163 |
file.Close();
|
sl@0
|
164 |
|
sl@0
|
165 |
TBuf<40> path2;
|
sl@0
|
166 |
path2.Copy(basepath);
|
sl@0
|
167 |
path2.Append(_L("simple.create"));
|
sl@0
|
168 |
|
sl@0
|
169 |
//Correct file, Should notify?
|
sl@0
|
170 |
RFilePlugin fileplugin(aRequest);
|
sl@0
|
171 |
TInt r = fileplugin.Create(path2,EFileWrite);
|
sl@0
|
172 |
r = fileplugin.TransferToClient();
|
sl@0
|
173 |
fileplugin.Close();
|
sl@0
|
174 |
|
sl@0
|
175 |
return KErrCompletion;
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
return err;
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
|
sl@0
|
182 |
CFsPluginConn* CNotifyPlugin::NewPluginConnL()
|
sl@0
|
183 |
{
|
sl@0
|
184 |
return new(ELeave) CNotifyPluginConn();
|
sl@0
|
185 |
}
|
sl@0
|
186 |
|
sl@0
|
187 |
//Synchronous RPlugin::DoControl
|
sl@0
|
188 |
TInt CNotifyPlugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
TInt function = aRequest.Function();
|
sl@0
|
191 |
|
sl@0
|
192 |
switch(function)
|
sl@0
|
193 |
{
|
sl@0
|
194 |
case KPluginSetDrive:
|
sl@0
|
195 |
{
|
sl@0
|
196 |
TPckg<TChar> drive(gDriveToTest);
|
sl@0
|
197 |
TRAPD(err,aRequest.ReadParam1L(drive));
|
sl@0
|
198 |
if(err != KErrNone)
|
sl@0
|
199 |
return err;
|
sl@0
|
200 |
break;
|
sl@0
|
201 |
}
|
sl@0
|
202 |
default:
|
sl@0
|
203 |
break;
|
sl@0
|
204 |
}
|
sl@0
|
205 |
|
sl@0
|
206 |
return KErrNone;
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
|
sl@0
|
210 |
TInt CNotifyPluginConn::DoControl(CFsPluginConnRequest& aRequest)
|
sl@0
|
211 |
{
|
sl@0
|
212 |
return ((CNotifyPlugin*)Plugin())->FsPluginDoControlL(aRequest);
|
sl@0
|
213 |
}
|
sl@0
|
214 |
|
sl@0
|
215 |
void CNotifyPluginConn::DoRequest(CFsPluginConnRequest& aRequest)
|
sl@0
|
216 |
{
|
sl@0
|
217 |
DoControl(aRequest);
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
void CNotifyPluginConn::DoCancel(TInt /*aReqMask*/)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
}
|
sl@0
|
223 |
|
sl@0
|
224 |
|
sl@0
|
225 |
|
sl@0
|
226 |
|
sl@0
|
227 |
|
sl@0
|
228 |
//factory functions
|
sl@0
|
229 |
|
sl@0
|
230 |
class CNotifyPluginFactory : public CFsPluginFactory
|
sl@0
|
231 |
{
|
sl@0
|
232 |
public:
|
sl@0
|
233 |
CNotifyPluginFactory();
|
sl@0
|
234 |
virtual TInt Install();
|
sl@0
|
235 |
virtual CFsPlugin* NewPluginL();
|
sl@0
|
236 |
virtual CFsPlugin* NewPluginConnL();
|
sl@0
|
237 |
virtual TInt UniquePosition();
|
sl@0
|
238 |
};
|
sl@0
|
239 |
|
sl@0
|
240 |
/**
|
sl@0
|
241 |
Constructor for the plugin factory
|
sl@0
|
242 |
@internalComponent
|
sl@0
|
243 |
*/
|
sl@0
|
244 |
CNotifyPluginFactory::CNotifyPluginFactory()
|
sl@0
|
245 |
{
|
sl@0
|
246 |
}
|
sl@0
|
247 |
|
sl@0
|
248 |
/**
|
sl@0
|
249 |
Install function for the plugin factory
|
sl@0
|
250 |
@internalComponent
|
sl@0
|
251 |
*/
|
sl@0
|
252 |
TInt CNotifyPluginFactory::Install()
|
sl@0
|
253 |
{
|
sl@0
|
254 |
SetSupportedDrives(KPluginSupportAllDrives);
|
sl@0
|
255 |
return(SetName(&KNotifyPluginName));
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
/**
|
sl@0
|
259 |
@internalComponent
|
sl@0
|
260 |
*/
|
sl@0
|
261 |
TInt CNotifyPluginFactory::UniquePosition()
|
sl@0
|
262 |
{
|
sl@0
|
263 |
return(KNotifyPos);
|
sl@0
|
264 |
}
|
sl@0
|
265 |
|
sl@0
|
266 |
/**
|
sl@0
|
267 |
Plugin factory function
|
sl@0
|
268 |
@internalComponent
|
sl@0
|
269 |
*/
|
sl@0
|
270 |
CFsPlugin* CNotifyPluginFactory::NewPluginL()
|
sl@0
|
271 |
|
sl@0
|
272 |
{
|
sl@0
|
273 |
return CNotifyPlugin::NewL();
|
sl@0
|
274 |
}
|
sl@0
|
275 |
|
sl@0
|
276 |
/**
|
sl@0
|
277 |
Plugin factory function
|
sl@0
|
278 |
@internalComponent
|
sl@0
|
279 |
*/
|
sl@0
|
280 |
CFsPlugin* CNotifyPluginFactory::NewPluginConnL()
|
sl@0
|
281 |
|
sl@0
|
282 |
{
|
sl@0
|
283 |
return CNotifyPlugin::NewL();
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
/**
|
sl@0
|
287 |
Create a new Plugin
|
sl@0
|
288 |
@internalComponent
|
sl@0
|
289 |
*/
|
sl@0
|
290 |
extern "C" {
|
sl@0
|
291 |
|
sl@0
|
292 |
EXPORT_C CFsPluginFactory* CreateFileSystem()
|
sl@0
|
293 |
{
|
sl@0
|
294 |
return(new CNotifyPluginFactory());
|
sl@0
|
295 |
}
|
sl@0
|
296 |
}
|
sl@0
|
297 |
|