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 "DriveC_plugin.h"
17 #include <f32pluginutils.h>
18 #include "plugincommon.h"
21 Leaving New function for the plugin
24 CDriveCPlugin* CDriveCPlugin::NewL()
26 CDriveCPlugin* self = new(ELeave) CDriveCPlugin;
27 CleanupStack::PushL(self);
35 Constructor for the plugin
38 CDriveCPlugin::CDriveCPlugin() : iInterceptsEnabled(EFalse),
44 void CDriveCPlugin::ConstructL()
49 The destructor for the plugin
52 CDriveCPlugin::~CDriveCPlugin()
58 Initialise the plugin.
61 void CDriveCPlugin::InitialiseL()
63 User::LeaveIfError(iFs.Connect());
64 CleanupClosePushL(iFs);
66 _LOG(_L("CDriveCPlugin InitialiseL"));
69 CleanupStack::Pop(); // iFs
73 Enable the plugin's intercepts.
76 void CDriveCPlugin::EnableInterceptsL()
78 if (iInterceptsEnabled) return;
80 User::LeaveIfError(RegisterIntercept(EFsFileRead, EPrePostIntercept));
81 User::LeaveIfError(RegisterIntercept(EFsFileWrite, EPrePostIntercept));
82 User::LeaveIfError(RegisterIntercept(EFsDirOpen, EPrePostIntercept));
83 User::LeaveIfError(RegisterIntercept(EFsFileLock, EPrePostIntercept));
84 User::LeaveIfError(RegisterIntercept(EFsFileUnLock, EPrePostIntercept));
85 User::LeaveIfError(RegisterIntercept(EFsFileSeek, EPrePostIntercept));
86 User::LeaveIfError(RegisterIntercept(EFsFileSize, EPrePostIntercept));
87 User::LeaveIfError(RegisterIntercept(EFsFileSetSize, EPrePostIntercept));
88 User::LeaveIfError(RegisterIntercept(EFsDirReadOne, EPrePostIntercept));
89 User::LeaveIfError(RegisterIntercept(EFsDirReadPacked, EPrePostIntercept));
90 User::LeaveIfError(RegisterIntercept(EFsFileOpen, EPrePostIntercept));
91 User::LeaveIfError(RegisterIntercept(EFsFileCreate, EPrePostIntercept));
92 User::LeaveIfError(RegisterIntercept(EFsFileReplace, EPrePostIntercept));
93 User::LeaveIfError(RegisterIntercept(EFsFileRename, EPrePostIntercept));
94 User::LeaveIfError(RegisterIntercept(EFsReadFileSection,EPrePostIntercept));
95 User::LeaveIfError(RegisterIntercept(EFsFileSubClose, EPrePostIntercept));
97 _LOG(_L("DriveC Plugin: Enabled intercepts."));
99 iInterceptsEnabled = ETrue;
103 Disable the plugin's intercepts.
106 void CDriveCPlugin::DisableInterceptsL()
108 if (!iInterceptsEnabled) return;
110 User::LeaveIfError(UnregisterIntercept(EFsFileRead, EPrePostIntercept));
111 User::LeaveIfError(UnregisterIntercept(EFsFileRename, EPrePostIntercept));
112 User::LeaveIfError(UnregisterIntercept(EFsFileWrite, EPrePostIntercept));
113 User::LeaveIfError(UnregisterIntercept(EFsDirOpen, EPrePostIntercept));
114 User::LeaveIfError(UnregisterIntercept(EFsFileLock, EPrePostIntercept));
115 User::LeaveIfError(UnregisterIntercept(EFsFileUnLock, EPrePostIntercept));
116 User::LeaveIfError(UnregisterIntercept(EFsFileSeek, EPrePostIntercept));
117 User::LeaveIfError(UnregisterIntercept(EFsFileSize, EPrePostIntercept));
118 User::LeaveIfError(UnregisterIntercept(EFsFileSetSize, EPrePostIntercept));
119 User::LeaveIfError(UnregisterIntercept(EFsFileCreate, EPrePostIntercept));
120 User::LeaveIfError(UnregisterIntercept(EFsFileOpen, EPrePostIntercept));
121 User::LeaveIfError(UnregisterIntercept(EFsFileReplace, EPrePostIntercept));
122 User::LeaveIfError(UnregisterIntercept(EFsFileSubClose, EPrePostIntercept));
123 User::LeaveIfError(UnregisterIntercept(EFsReadFileSection,EPrePostIntercept));
124 User::LeaveIfError(UnregisterIntercept(EFsDirReadOne, EPrePostIntercept));
125 User::LeaveIfError(UnregisterIntercept(EFsDirReadPacked,EPrePostIntercept));
128 _LOG(_L("DriveC Plugin: Disabled intercepts."));
130 iInterceptsEnabled = EFalse;
137 TInt CDriveCPlugin::DoRequestL(TFsPluginRequest& aRequest)
141 TInt function = aRequest.Function();
143 if(aRequest.DriveNumber() != 2)
145 iLineNumber=__LINE__;
146 iLastError=KErrNotSupported;
147 return KErrNotSupported;
150 if (aRequest.IsPostOperation())
152 _LOG2(_L("CDriveCPlugin post intercept for function %d"), function);
156 _LOG2(_L("CDriveCPlugin pre intercept for function %d"), function);
163 CFsPluginConn* CDriveCPlugin::NewPluginConnL()
165 return new(ELeave) CDriveCPluginConn();
169 //Synchronous RPlugin::DoControl
170 TInt CDriveCPlugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
174 //We can use this to set the drive
175 //We can store this as a member of this class.
176 TInt function = aRequest.Function();
177 TPckg<TInt> errCodeDes(iLastError);
178 TPckg<TInt> lineNumberDes(iLineNumber);
182 case KPluginGetError:
184 TRAP(err,aRequest.WriteParam1L(errCodeDes));
185 TRAP(err,aRequest.WriteParam2L(lineNumberDes));
196 TInt CDriveCPluginConn::DoControl(CFsPluginConnRequest& aRequest)
198 return ((CDriveCPlugin*)Plugin())->FsPluginDoControlL(aRequest);
201 void CDriveCPluginConn::DoRequest(CFsPluginConnRequest& aRequest)
206 void CDriveCPluginConn::DoCancel(TInt /*aReqMask*/)
212 class CDriveCPluginFactory : public CFsPluginFactory
215 CDriveCPluginFactory();
216 virtual TInt Install();
217 virtual CFsPlugin* NewPluginL();
218 virtual CFsPlugin* NewPluginConnL();
219 virtual TInt UniquePosition();
223 Constructor for the plugin factory
226 CDriveCPluginFactory::CDriveCPluginFactory()
231 Install function for the plugin factory
234 TInt CDriveCPluginFactory::Install()
236 SetSupportedDrives(1<<2);
237 //iSupportedDrives = 1<<2;
238 return(SetName(&KDriveCPluginName));
244 TInt CDriveCPluginFactory::UniquePosition()
250 Plugin factory function
253 CFsPlugin* CDriveCPluginFactory::NewPluginL()
256 return CDriveCPlugin::NewL();
260 Plugin factory function
263 CFsPlugin* CDriveCPluginFactory::NewPluginConnL()
266 return CDriveCPlugin::NewL();
275 EXPORT_C CFsPluginFactory* CreateFileSystem()
277 return(new CDriveCPluginFactory());