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 "DriveZ_plugin.h"
17 #include <f32pluginutils.h>
18 #include "plugincommon.h"
21 Leaving New function for the plugin
24 CDriveZPlugin* CDriveZPlugin::NewL()
26 CDriveZPlugin* self = new(ELeave) CDriveZPlugin;
27 CleanupStack::PushL(self);
35 Constructor for the plugin
38 CDriveZPlugin::CDriveZPlugin() : iInterceptsEnabled(EFalse),
44 void CDriveZPlugin::ConstructL()
49 The destructor for the plugin
52 CDriveZPlugin::~CDriveZPlugin()
58 Initialise the plugin.
61 void CDriveZPlugin::InitialiseL()
63 User::LeaveIfError(iFs.Connect());
64 CleanupClosePushL(iFs);
66 _LOG(_L("CDriveZPlugin InitialiseL"));
69 CleanupStack::Pop(); // iFs
73 Enable the plugin's intercepts.
76 void CDriveZPlugin::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("DriveZ Plugin: Enabled intercepts."));
99 iInterceptsEnabled = ETrue;
103 Disable the plugin's intercepts.
106 void CDriveZPlugin::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("DriveZ Plugin: Disabled intercepts."));
130 iInterceptsEnabled = EFalse;
137 TInt CDriveZPlugin::DoRequestL(TFsPluginRequest& aRequest)
141 TInt function = aRequest.Function();
143 if(aRequest.DriveNumber() != 25)
145 iLineNumber=__LINE__;
146 iLastError=KErrNotSupported;
147 return KErrNotSupported;
151 if (aRequest.IsPostOperation())
153 _LOG2(_L("CDriveZPlugin post intercept for function %d"), function);
157 _LOG2(_L("CDriveZPlugin pre intercept for function %d"), function);
164 CFsPluginConn* CDriveZPlugin::NewPluginConnL()
166 return new(ELeave) CDriveZPluginConn();
170 //Synchronous RPlugin::DoControl
171 TInt CDriveZPlugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
175 //We can use this to set the drive
176 //We can store this as a member of this class.
177 TInt function = aRequest.Function();
178 TPckg<TInt> errCodeDes(iLastError);
179 TPckg<TInt> lineNumberDes(iLineNumber);
183 case KPluginGetError:
185 TRAP(err,aRequest.WriteParam1L(errCodeDes));
186 TRAP(err,aRequest.WriteParam2L(lineNumberDes));
197 TInt CDriveZPluginConn::DoControl(CFsPluginConnRequest& aRequest)
199 return ((CDriveZPlugin*)Plugin())->FsPluginDoControlL(aRequest);
202 void CDriveZPluginConn::DoRequest(CFsPluginConnRequest& aRequest)
207 void CDriveZPluginConn::DoCancel(TInt /*aReqMask*/)
214 class CDriveZPluginFactory : public CFsPluginFactory
217 CDriveZPluginFactory();
218 virtual TInt Install();
219 virtual CFsPlugin* NewPluginL();
220 virtual CFsPlugin* NewPluginConnL();
221 virtual TInt UniquePosition();
225 Constructor for the plugin factory
228 CDriveZPluginFactory::CDriveZPluginFactory()
233 Install function for the plugin factory
236 TInt CDriveZPluginFactory::Install()
238 SetSupportedDrives(1<<EDriveZ);
239 //iSupportedDrives = 1<<25;
240 return(SetName(&KDriveZPluginName));
246 TInt CDriveZPluginFactory::UniquePosition()
252 Plugin factory function
255 CFsPlugin* CDriveZPluginFactory::NewPluginL()
258 return CDriveZPlugin::NewL();
262 Plugin factory function
265 CFsPlugin* CDriveZPluginFactory::NewPluginConnL()
268 return CDriveZPlugin::NewL();
277 EXPORT_C CFsPluginFactory* CreateFileSystem()
279 return(new CDriveZPluginFactory());