First public contribution.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "t_notify_plugin.h"
17 #include <f32pluginutils.h>
22 Leaving New function for the plugin
25 CNotifyPlugin* CNotifyPlugin::NewL()
27 CNotifyPlugin* self = new(ELeave) CNotifyPlugin;
28 CleanupStack::PushL(self);
36 Constructor for the plugin
39 CNotifyPlugin::CNotifyPlugin() : iInterceptsEnabled(EFalse),
45 void CNotifyPlugin::ConstructL()
50 The destructor for the plugin
53 CNotifyPlugin::~CNotifyPlugin()
59 Initialise the plugin.
62 void CNotifyPlugin::InitialiseL()
64 User::LeaveIfError(iFs.Connect());
65 CleanupClosePushL(iFs);
67 _LOG(_L("CNotifyPlugin InitialiseL"));
70 CleanupStack::Pop(); // iFs
74 Enable the plugin's intercepts.
77 void CNotifyPlugin::EnableInterceptsL()
79 if (iInterceptsEnabled) return;
81 User::LeaveIfError(RegisterIntercept(EFsFileRead, EPrePostIntercept));
82 User::LeaveIfError(RegisterIntercept(EFsFileWrite, EPrePostIntercept));
83 User::LeaveIfError(RegisterIntercept(EFsDirOpen, EPrePostIntercept));
84 User::LeaveIfError(RegisterIntercept(EFsFileLock, EPrePostIntercept));
85 User::LeaveIfError(RegisterIntercept(EFsFileUnLock, EPrePostIntercept));
86 User::LeaveIfError(RegisterIntercept(EFsFileSeek, EPrePostIntercept));
87 User::LeaveIfError(RegisterIntercept(EFsFileSize, EPrePostIntercept));
88 User::LeaveIfError(RegisterIntercept(EFsFileSetSize, EPrePostIntercept));
89 User::LeaveIfError(RegisterIntercept(EFsDirReadOne, EPrePostIntercept));
90 User::LeaveIfError(RegisterIntercept(EFsDirReadPacked, EPrePostIntercept));
91 User::LeaveIfError(RegisterIntercept(EFsFileOpen, EPrePostIntercept));
92 User::LeaveIfError(RegisterIntercept(EFsFileCreate, EPrePostIntercept));
93 User::LeaveIfError(RegisterIntercept(EFsFileReplace,EPrePostIntercept));
94 User::LeaveIfError(RegisterIntercept(EFsFileRename, EPrePostIntercept));
95 User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept));
96 User::LeaveIfError(RegisterIntercept(EFsFileSubClose, EPrePostIntercept));
98 _LOG(_L("Notify Plugin: Enabled intercepts."));
100 iInterceptsEnabled = ETrue;
104 Disable the plugin's intercepts.
107 void CNotifyPlugin::DisableInterceptsL()
109 if (!iInterceptsEnabled) return;
111 User::LeaveIfError(UnregisterIntercept(EFsFileRead, EPrePostIntercept));
112 User::LeaveIfError(UnregisterIntercept(EFsFileRename, EPrePostIntercept));
113 User::LeaveIfError(UnregisterIntercept(EFsFileWrite, EPrePostIntercept));
114 User::LeaveIfError(UnregisterIntercept(EFsDirOpen, EPrePostIntercept));
115 User::LeaveIfError(UnregisterIntercept(EFsFileLock, EPrePostIntercept));
116 User::LeaveIfError(UnregisterIntercept(EFsFileUnLock, EPrePostIntercept));
117 User::LeaveIfError(UnregisterIntercept(EFsFileSeek, EPrePostIntercept));
118 User::LeaveIfError(UnregisterIntercept(EFsFileSize, EPrePostIntercept));
119 User::LeaveIfError(UnregisterIntercept(EFsFileSetSize, EPrePostIntercept));
120 User::LeaveIfError(UnregisterIntercept(EFsFileCreate, EPrePostIntercept));
121 User::LeaveIfError(UnregisterIntercept(EFsFileOpen, EPrePostIntercept));
122 User::LeaveIfError(UnregisterIntercept(EFsFileReplace, EPrePostIntercept));
123 User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, EPrePostIntercept));
124 User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,EPrePostIntercept));
125 User::LeaveIfError(UnregisterIntercept(EFsDirReadOne, EPrePostIntercept));
126 User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,EPrePostIntercept));
129 _LOG(_L("Notify Plugin: Disabled intercepts."));
131 iInterceptsEnabled = EFalse;
138 TInt CNotifyPlugin::DoRequestL(TFsPluginRequest& aRequest)
142 TInt function = aRequest.Function();
144 if (aRequest.IsPostOperation())
146 _LOG2(_L("CNotifyPlugin post intercept for function %d"), function);
148 else if(function==EFsFileCreate)
150 _LOG2(_L("CNotifyPlugin pre intercept for function %d"), function);
153 basepath.Append(gDriveToTest);
154 basepath.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); //len=22
157 path1.Copy(basepath);
158 path1.Append(_L("plugin.create"));
160 RFilePlugin file(aRequest);
161 //Wrong file - should not notify
162 file.Replace(path1,EFileWrite);
166 path2.Copy(basepath);
167 path2.Append(_L("simple.create"));
169 //Correct file, Should notify?
170 RFilePlugin fileplugin(aRequest);
171 TInt r = fileplugin.Create(path2,EFileWrite);
172 r = fileplugin.TransferToClient();
175 return KErrCompletion;
182 CFsPluginConn* CNotifyPlugin::NewPluginConnL()
184 return new(ELeave) CNotifyPluginConn();
187 //Synchronous RPlugin::DoControl
188 TInt CNotifyPlugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
190 TInt function = aRequest.Function();
194 case KPluginSetDrive:
196 TPckg<TChar> drive(gDriveToTest);
197 TRAPD(err,aRequest.ReadParam1L(drive));
210 TInt CNotifyPluginConn::DoControl(CFsPluginConnRequest& aRequest)
212 return ((CNotifyPlugin*)Plugin())->FsPluginDoControlL(aRequest);
215 void CNotifyPluginConn::DoRequest(CFsPluginConnRequest& aRequest)
220 void CNotifyPluginConn::DoCancel(TInt /*aReqMask*/)
230 class CNotifyPluginFactory : public CFsPluginFactory
233 CNotifyPluginFactory();
234 virtual TInt Install();
235 virtual CFsPlugin* NewPluginL();
236 virtual CFsPlugin* NewPluginConnL();
237 virtual TInt UniquePosition();
241 Constructor for the plugin factory
244 CNotifyPluginFactory::CNotifyPluginFactory()
249 Install function for the plugin factory
252 TInt CNotifyPluginFactory::Install()
254 SetSupportedDrives(KPluginSupportAllDrives);
255 return(SetName(&KNotifyPluginName));
261 TInt CNotifyPluginFactory::UniquePosition()
267 Plugin factory function
270 CFsPlugin* CNotifyPluginFactory::NewPluginL()
273 return CNotifyPlugin::NewL();
277 Plugin factory function
280 CFsPlugin* CNotifyPluginFactory::NewPluginConnL()
283 return CNotifyPlugin::NewL();
292 EXPORT_C CFsPluginFactory* CreateFileSystem()
294 return(new CNotifyPluginFactory());