Update contrib.
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 "template_plugin.h"
17 #include <f32pluginutils.h>
20 Leaving New function for the plugin
23 CTemplatePlugin* CTemplatePlugin::NewL()
25 CTemplatePlugin* self = new(ELeave) CTemplatePlugin;
26 CleanupStack::PushL(self);
34 Constructor for the plugin
37 CTemplatePlugin::CTemplatePlugin() : iInterceptsEnabled(EFalse),
43 void CTemplatePlugin::ConstructL()
48 The destructor for the plugin
51 CTemplatePlugin::~CTemplatePlugin()
57 Initialise the plugin.
60 void CTemplatePlugin::InitialiseL()
62 User::LeaveIfError(iFs.Connect());
63 CleanupClosePushL(iFs);
65 _LOG(_L("CTemplatePlugin InitialiseL"));
68 CleanupStack::Pop(); // iFs
72 Enable the plugin's intercepts.
75 void CTemplatePlugin::EnableInterceptsL()
77 if (iInterceptsEnabled) return;
79 User::LeaveIfError(RegisterIntercept(EFsFileRead, EPrePostIntercept));
80 User::LeaveIfError(RegisterIntercept(EFsFileWrite, EPrePostIntercept));
81 User::LeaveIfError(RegisterIntercept(EFsDirOpen, EPrePostIntercept));
82 User::LeaveIfError(RegisterIntercept(EFsFileLock, EPrePostIntercept));
83 User::LeaveIfError(RegisterIntercept(EFsFileUnLock, EPrePostIntercept));
84 User::LeaveIfError(RegisterIntercept(EFsFileSeek, EPrePostIntercept));
85 User::LeaveIfError(RegisterIntercept(EFsFileSize, EPrePostIntercept));
86 User::LeaveIfError(RegisterIntercept(EFsFileSetSize, EPrePostIntercept));
87 User::LeaveIfError(RegisterIntercept(EFsDirReadOne, EPrePostIntercept));
88 User::LeaveIfError(RegisterIntercept(EFsDirReadPacked, EPrePostIntercept));
89 User::LeaveIfError(RegisterIntercept(EFsFileOpen, EPrePostIntercept));
90 User::LeaveIfError(RegisterIntercept(EFsFileCreate, EPrePostIntercept));
91 User::LeaveIfError(RegisterIntercept(EFsFileReplace,EPrePostIntercept));
92 User::LeaveIfError(RegisterIntercept(EFsFileRename, EPrePostIntercept));
93 User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept));
94 User::LeaveIfError(RegisterIntercept(EFsFileSubClose, EPrePostIntercept));
96 _LOG(_L("Template Plugin: Enabled intercepts."));
98 iInterceptsEnabled = ETrue;
102 Disable the plugin's intercepts.
105 void CTemplatePlugin::DisableInterceptsL()
107 if (!iInterceptsEnabled) return;
109 User::LeaveIfError(UnregisterIntercept(EFsFileRead, EPrePostIntercept));
110 User::LeaveIfError(UnregisterIntercept(EFsFileRename, EPrePostIntercept));
111 User::LeaveIfError(UnregisterIntercept(EFsFileWrite, EPrePostIntercept));
112 User::LeaveIfError(UnregisterIntercept(EFsDirOpen, EPrePostIntercept));
113 User::LeaveIfError(UnregisterIntercept(EFsFileLock, EPrePostIntercept));
114 User::LeaveIfError(UnregisterIntercept(EFsFileUnLock, EPrePostIntercept));
115 User::LeaveIfError(UnregisterIntercept(EFsFileSeek, EPrePostIntercept));
116 User::LeaveIfError(UnregisterIntercept(EFsFileSize, EPrePostIntercept));
117 User::LeaveIfError(UnregisterIntercept(EFsFileSetSize, EPrePostIntercept));
118 User::LeaveIfError(UnregisterIntercept(EFsFileCreate, EPrePostIntercept));
119 User::LeaveIfError(UnregisterIntercept(EFsFileOpen, EPrePostIntercept));
120 User::LeaveIfError(UnregisterIntercept(EFsFileReplace, EPrePostIntercept));
121 User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, EPrePostIntercept));
122 User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,EPrePostIntercept));
123 User::LeaveIfError(UnregisterIntercept(EFsDirReadOne, EPrePostIntercept));
124 User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,EPrePostIntercept));
127 _LOG(_L("Template Plugin: Disabled intercepts."));
129 iInterceptsEnabled = EFalse;
136 TInt CTemplatePlugin::DoRequestL(TFsPluginRequest& aRequest)
140 TInt function = aRequest.Function();
142 if (aRequest.IsPostOperation())
144 _LOG2(_L("CTemplatePlugin post intercept for function %d"), function);
148 _LOG2(_L("CTemplatePlugin pre intercept for function %d"), function);
155 CFsPluginConn* CTemplatePlugin::NewPluginConnL()
157 return new(ELeave) CTemplatePluginConn();
160 //Synchronous RPlugin::DoControl
161 TInt CTemplatePlugin::FsPluginDoControlL(CFsPluginConnRequest& /*aRequest*/)
163 /*TInt function = aRequest.Function();
175 TInt CTemplatePluginConn::DoControl(CFsPluginConnRequest& aRequest)
177 return ((CTemplatePlugin*)Plugin())->FsPluginDoControlL(aRequest);
180 void CTemplatePluginConn::DoRequest(CFsPluginConnRequest& aRequest)
185 void CTemplatePluginConn::DoCancel(TInt /*aReqMask*/)
195 class CTemplatePluginFactory : public CFsPluginFactory
198 CTemplatePluginFactory();
199 virtual TInt Install();
200 virtual CFsPlugin* NewPluginL();
201 virtual CFsPlugin* NewPluginConnL();
202 virtual TInt UniquePosition();
206 Constructor for the plugin factory
209 CTemplatePluginFactory::CTemplatePluginFactory()
214 Install function for the plugin factory
217 TInt CTemplatePluginFactory::Install()
219 SetSupportedDrives(KPluginSupportAllDrives);
220 return(SetName(&KTemplatePluginName));
226 TInt CTemplatePluginFactory::UniquePosition()
228 return(KTemplatePos);
232 Plugin factory function
235 CFsPlugin* CTemplatePluginFactory::NewPluginL()
238 return CTemplatePlugin::NewL();
242 Plugin factory function
245 CFsPlugin* CTemplatePluginFactory::NewPluginConnL()
248 return CTemplatePlugin::NewL();
257 EXPORT_C CFsPluginFactory* CreateFileSystem()
259 return(new CTemplatePluginFactory());