author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 02:35:35 +0300 | |
changeset 281 | 13fbfa31d2ba |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
281
13fbfa31d2ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// |
|
15 |
||
281
13fbfa31d2ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
16 |
#include "drivec_plugin.h" |
0 | 17 |
#include <f32pluginutils.h> |
18 |
#include "plugincommon.h" |
|
19 |
||
20 |
/** |
|
21 |
Leaving New function for the plugin |
|
22 |
@internalComponent |
|
23 |
*/ |
|
24 |
CDriveCPlugin* CDriveCPlugin::NewL() |
|
25 |
{ |
|
26 |
CDriveCPlugin* self = new(ELeave) CDriveCPlugin; |
|
27 |
CleanupStack::PushL(self); |
|
28 |
self->ConstructL(); |
|
29 |
CleanupStack::Pop(); |
|
30 |
return self; |
|
31 |
} |
|
32 |
||
33 |
||
34 |
/** |
|
35 |
Constructor for the plugin |
|
36 |
@internalComponent |
|
37 |
*/ |
|
38 |
CDriveCPlugin::CDriveCPlugin() : iInterceptsEnabled(EFalse), |
|
39 |
iLogging(ETrue) |
|
40 |
{ |
|
41 |
} |
|
42 |
||
43 |
||
44 |
void CDriveCPlugin::ConstructL() |
|
45 |
{ |
|
46 |
} |
|
47 |
||
48 |
/** |
|
49 |
The destructor for the plugin |
|
50 |
@internalComponent |
|
51 |
*/ |
|
52 |
CDriveCPlugin::~CDriveCPlugin() |
|
53 |
{ |
|
54 |
iFs.Close(); |
|
55 |
} |
|
56 |
||
57 |
/** |
|
58 |
Initialise the plugin. |
|
59 |
@internalComponent |
|
60 |
*/ |
|
61 |
void CDriveCPlugin::InitialiseL() |
|
62 |
{ |
|
63 |
User::LeaveIfError(iFs.Connect()); |
|
64 |
CleanupClosePushL(iFs); |
|
65 |
||
66 |
_LOG(_L("CDriveCPlugin InitialiseL")); |
|
67 |
EnableInterceptsL(); |
|
68 |
||
69 |
CleanupStack::Pop(); // iFs |
|
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
Enable the plugin's intercepts. |
|
74 |
@internalComponent |
|
75 |
*/ |
|
76 |
void CDriveCPlugin::EnableInterceptsL() |
|
77 |
{ |
|
78 |
if (iInterceptsEnabled) return; |
|
79 |
||
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)); |
|
96 |
||
97 |
_LOG(_L("DriveC Plugin: Enabled intercepts.")); |
|
98 |
||
99 |
iInterceptsEnabled = ETrue; |
|
100 |
} |
|
101 |
||
102 |
/** |
|
103 |
Disable the plugin's intercepts. |
|
104 |
@internalComponent |
|
105 |
*/ |
|
106 |
void CDriveCPlugin::DisableInterceptsL() |
|
107 |
{ |
|
108 |
if (!iInterceptsEnabled) return; |
|
109 |
||
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)); |
|
126 |
||
127 |
||
128 |
_LOG(_L("DriveC Plugin: Disabled intercepts.")); |
|
129 |
||
130 |
iInterceptsEnabled = EFalse; |
|
131 |
} |
|
132 |
||
133 |
/** |
|
134 |
Handle requests |
|
135 |
@internalComponent |
|
136 |
*/ |
|
137 |
TInt CDriveCPlugin::DoRequestL(TFsPluginRequest& aRequest) |
|
138 |
{ |
|
139 |
TInt err = KErrNone; |
|
140 |
||
141 |
TInt function = aRequest.Function(); |
|
142 |
||
143 |
if(aRequest.DriveNumber() != 2) |
|
144 |
{ |
|
145 |
iLineNumber=__LINE__; |
|
146 |
iLastError=KErrNotSupported; |
|
147 |
return KErrNotSupported; |
|
148 |
} |
|
149 |
||
150 |
if (aRequest.IsPostOperation()) |
|
151 |
{ |
|
152 |
_LOG2(_L("CDriveCPlugin post intercept for function %d"), function); |
|
153 |
} |
|
154 |
else |
|
155 |
{ |
|
156 |
_LOG2(_L("CDriveCPlugin pre intercept for function %d"), function); |
|
157 |
} |
|
158 |
||
159 |
return err; |
|
160 |
} |
|
161 |
||
162 |
||
163 |
CFsPluginConn* CDriveCPlugin::NewPluginConnL() |
|
164 |
{ |
|
165 |
return new(ELeave) CDriveCPluginConn(); |
|
166 |
} |
|
167 |
||
168 |
||
169 |
//Synchronous RPlugin::DoControl |
|
170 |
TInt CDriveCPlugin::FsPluginDoControlL(CFsPluginConnRequest& aRequest) |
|
171 |
{ |
|
172 |
TInt err = KErrNone; |
|
173 |
||
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); |
|
179 |
||
180 |
switch(function) |
|
181 |
{ |
|
182 |
case KPluginGetError: |
|
183 |
{ |
|
184 |
TRAP(err,aRequest.WriteParam1L(errCodeDes)); |
|
185 |
TRAP(err,aRequest.WriteParam2L(lineNumberDes)); |
|
186 |
break; |
|
187 |
} |
|
188 |
default: |
|
189 |
break; |
|
190 |
} |
|
191 |
||
192 |
return err; |
|
193 |
} |
|
194 |
||
195 |
||
196 |
TInt CDriveCPluginConn::DoControl(CFsPluginConnRequest& aRequest) |
|
197 |
{ |
|
198 |
return ((CDriveCPlugin*)Plugin())->FsPluginDoControlL(aRequest); |
|
199 |
} |
|
200 |
||
201 |
void CDriveCPluginConn::DoRequest(CFsPluginConnRequest& aRequest) |
|
202 |
{ |
|
203 |
DoControl(aRequest); |
|
204 |
} |
|
205 |
||
206 |
void CDriveCPluginConn::DoCancel(TInt /*aReqMask*/) |
|
207 |
{ |
|
208 |
} |
|
209 |
||
210 |
//factory functions |
|
211 |
||
212 |
class CDriveCPluginFactory : public CFsPluginFactory |
|
213 |
{ |
|
214 |
public: |
|
215 |
CDriveCPluginFactory(); |
|
216 |
virtual TInt Install(); |
|
217 |
virtual CFsPlugin* NewPluginL(); |
|
218 |
virtual CFsPlugin* NewPluginConnL(); |
|
219 |
virtual TInt UniquePosition(); |
|
220 |
}; |
|
221 |
||
222 |
/** |
|
223 |
Constructor for the plugin factory |
|
224 |
@internalComponent |
|
225 |
*/ |
|
226 |
CDriveCPluginFactory::CDriveCPluginFactory() |
|
227 |
{ |
|
228 |
} |
|
229 |
||
230 |
/** |
|
231 |
Install function for the plugin factory |
|
232 |
@internalComponent |
|
233 |
*/ |
|
234 |
TInt CDriveCPluginFactory::Install() |
|
235 |
{ |
|
236 |
SetSupportedDrives(1<<2); |
|
237 |
//iSupportedDrives = 1<<2; |
|
238 |
return(SetName(&KDriveCPluginName)); |
|
239 |
} |
|
240 |
||
241 |
/** |
|
242 |
@internalComponent |
|
243 |
*/ |
|
244 |
TInt CDriveCPluginFactory::UniquePosition() |
|
245 |
{ |
|
246 |
return(KDriveCPos); |
|
247 |
} |
|
248 |
||
249 |
/** |
|
250 |
Plugin factory function |
|
251 |
@internalComponent |
|
252 |
*/ |
|
253 |
CFsPlugin* CDriveCPluginFactory::NewPluginL() |
|
254 |
||
255 |
{ |
|
256 |
return CDriveCPlugin::NewL(); |
|
257 |
} |
|
258 |
||
259 |
/** |
|
260 |
Plugin factory function |
|
261 |
@internalComponent |
|
262 |
*/ |
|
263 |
CFsPlugin* CDriveCPluginFactory::NewPluginConnL() |
|
264 |
||
265 |
{ |
|
266 |
return CDriveCPlugin::NewL(); |
|
267 |
} |
|
268 |
||
269 |
/** |
|
270 |
Create a new Plugin |
|
271 |
@internalComponent |
|
272 |
*/ |
|
273 |
extern "C" { |
|
274 |
||
275 |
EXPORT_C CFsPluginFactory* CreateFileSystem() |
|
276 |
{ |
|
277 |
return(new CDriveCPluginFactory()); |
|
278 |
} |
|
279 |
} |
|
280 |