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.
14 // Template_plugin.cpp
18 #include "unremovable_plugin.h"
19 #include "plugincommon.h"
20 #include <f32pluginutils.h>
23 Leaving New function for the plugin
26 CUnremovablePlugin* CUnremovablePlugin::NewL()
28 CUnremovablePlugin* self = new(ELeave) CUnremovablePlugin;
29 CleanupStack::PushL(self);
37 Constructor for the plugin
40 CUnremovablePlugin::CUnremovablePlugin() : iInterceptsEnabled(EFalse),
46 void CUnremovablePlugin::ConstructL()
52 The destructor for the plugin
55 CUnremovablePlugin::~CUnremovablePlugin()
61 Initialise the plugin.
64 void CUnremovablePlugin::InitialiseL()
66 User::LeaveIfError(iFs.Connect());
67 CleanupClosePushL(iFs);
69 _LOG(_L("CUnremovablePlugin InitialiseL"));
72 CleanupStack::Pop(); // iFs
76 Enable the plugin's intercepts.
79 void CUnremovablePlugin::EnableInterceptsL()
81 if (iInterceptsEnabled) return;
83 User::LeaveIfError(RegisterIntercept(EFsDismountPlugin,EPreIntercept));
85 _LOG(_L("CUnremovablePlugin : Enabled intercepts."));
87 iInterceptsEnabled = ETrue;
91 Disable the plugin's intercepts.
94 void CUnremovablePlugin::DisableInterceptsL()
96 if (!iInterceptsEnabled) return;
98 User::LeaveIfError(UnregisterIntercept(EFsDismountPlugin,EPreIntercept));
100 _LOG(_L("CUnremovablePlugin : Disabled intercepts."));
102 iInterceptsEnabled = EFalse;
106 Handle requests to Dismount the plugin only.
107 This plugin is designed such that its removal is not allowed.
110 TInt CUnremovablePlugin::DoRequestL(TFsPluginRequest& aRequest)
114 TInt function = aRequest.Function();
116 if (aRequest.IsPostOperation())
118 _LOG2(_L("CUnremovablePlugin post intercept for function %d"), function);
119 //We should never get here
120 //Is it even correct to post-intercept a EFsDismountPlugin ??
125 _LOG2(_L("CUnremovablePlugin pre intercept for function %d"), function);
127 //If a user is trying to dismount this plugin and this plugin doesn't want
128 //to be dismounted then we should eb able to intecept this and return KErrAccessDenied or some
129 //appropriate error code.
137 return KErrPermissionDenied;
146 CFsPluginConn* CUnremovablePlugin::NewPluginConnL()
148 return new(ELeave) CUnremovablePluginConn();
152 //Synchronous RPlugin::DoControl
153 TInt CUnremovablePlugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest)
157 //We can use this to set the drive
158 //We can store this as a member of this class.
159 TInt function = aRequest.Function();
160 TPckg<TInt> removableDes(iRemovable);
164 //case KPluginGetError:
166 // TPckg<TInt> errCodeDes(iLastError);
167 // TPckg<TInt> errMsgDes(iMessage);
168 // TRAP(err,aRequest.WriteParam1L(errCodeDes));
169 // TRAP(err,aRequest.WriteParam2L(errMsgDes));
172 case KPluginSetRemovable:
174 TRAP(err,aRequest.ReadParam1L(removableDes));
184 TInt CUnremovablePluginConn::DoControl(CFsPluginConnRequest& aRequest)
186 return ((CUnremovablePlugin*)Plugin())->FsPluginDoControlL(aRequest);
189 void CUnremovablePluginConn::DoRequest(CFsPluginConnRequest& aRequest)
194 void CUnremovablePluginConn::DoCancel(TInt /*aReqMask*/)
201 class CUnremovablePluginFactory : public CFsPluginFactory
204 CUnremovablePluginFactory();
205 virtual TInt Install();
206 virtual CFsPlugin* NewPluginL();
207 virtual CFsPlugin* NewPluginConnL();
208 virtual TInt UniquePosition();
212 Constructor for the plugin factory
215 CUnremovablePluginFactory::CUnremovablePluginFactory()
220 Install function for the plugin factory
223 TInt CUnremovablePluginFactory::Install()
225 iSupportedDrives = KPluginAutoAttach;
226 return(SetName(&KUnremovablePluginName));
232 TInt CUnremovablePluginFactory::UniquePosition()
234 return(KUnremovablePos);
238 Plugin factory function
241 CFsPlugin* CUnremovablePluginFactory::NewPluginL()
244 return CUnremovablePlugin::NewL();
248 Plugin factory function
251 CFsPlugin* CUnremovablePluginFactory::NewPluginConnL()
254 return CUnremovablePlugin::NewL();
263 EXPORT_C CFsPluginFactory* CreateFileSystem()
265 return(new CUnremovablePluginFactory());