0
|
1 |
// Copyright (c) 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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// f32test\plugins\format\t_formathook.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include "t_formathook.h"
|
|
19 |
#include <f32pluginutils.h>
|
|
20 |
|
|
21 |
_LIT(KFormatPluginName, "This is a test format plugin");
|
|
22 |
|
|
23 |
|
|
24 |
/**
|
|
25 |
@internalComponent
|
|
26 |
*/
|
|
27 |
CFormatHook* CFormatHook::NewL()
|
|
28 |
{
|
|
29 |
return new(ELeave) CFormatHook;
|
|
30 |
}
|
|
31 |
|
|
32 |
|
|
33 |
/**
|
|
34 |
Constructor for the plugin
|
|
35 |
@internalComponent
|
|
36 |
*/
|
|
37 |
CFormatHook::CFormatHook() : iFormatInterceptTestStage(ETestNotStarted)
|
|
38 |
{
|
|
39 |
}
|
|
40 |
|
|
41 |
/**
|
|
42 |
@internalComponent
|
|
43 |
*/
|
|
44 |
CFormatHook::~CFormatHook()
|
|
45 |
{
|
|
46 |
// If this assert fails then the pre- and/or post- intercept
|
|
47 |
// of the IPC below has not been received when RFormat::Close()
|
|
48 |
// was called by the client.
|
|
49 |
ASSERT(iFormatInterceptTestStage == EPostFormatSubClose);
|
|
50 |
}
|
|
51 |
|
|
52 |
/**
|
|
53 |
Initialise the format intercept plugin.
|
|
54 |
@internalComponent
|
|
55 |
*/
|
|
56 |
void CFormatHook::InitialiseL()
|
|
57 |
{
|
|
58 |
User::LeaveIfError(RegisterIntercept(EFsFormatOpen, EPrePostIntercept));
|
|
59 |
User::LeaveIfError(RegisterIntercept(EFsFormatNext, EPrePostIntercept));
|
|
60 |
User::LeaveIfError(RegisterIntercept(EFsFormatSubClose, EPrePostIntercept));
|
|
61 |
}
|
|
62 |
|
|
63 |
/**
|
|
64 |
@internalComponent
|
|
65 |
*/
|
|
66 |
TInt CFormatHook::DoRequestL(TFsPluginRequest& aRequest)
|
|
67 |
{
|
|
68 |
//RDebug::Printf("CFormatHook::DoRequestL aRequest.Function() = %d, IsPostOperation() = %d", aRequest.Function(), aRequest.IsPostOperation());
|
|
69 |
TInt err = KErrNotSupported;
|
|
70 |
|
|
71 |
TInt function = aRequest.Function();
|
|
72 |
|
|
73 |
switch(function)
|
|
74 |
{
|
|
75 |
case EFsFormatOpen:
|
|
76 |
err = VsDriveFormatOpen(aRequest);
|
|
77 |
break;
|
|
78 |
|
|
79 |
case EFsFormatNext:
|
|
80 |
err = VsDriveFormatNext(aRequest);
|
|
81 |
break;
|
|
82 |
|
|
83 |
case EFsFormatSubClose:
|
|
84 |
err = VsDriveFormatClose(aRequest);
|
|
85 |
break;
|
|
86 |
|
|
87 |
default:
|
|
88 |
break;
|
|
89 |
}
|
|
90 |
|
|
91 |
return err;
|
|
92 |
}
|
|
93 |
|
|
94 |
/**
|
|
95 |
Handle pre- and post- format of RFormat::Open() - EFsFormatOpen IPC
|
|
96 |
*/
|
|
97 |
TInt CFormatHook::VsDriveFormatOpen(TFsPluginRequest& aRequest)
|
|
98 |
{
|
|
99 |
//RDebug::Printf("CFormatHook::VsDriveFormatOpen aRequest.Function() = %d, IsPostOperation() = %d", aRequest.Function(), aRequest.IsPostOperation());
|
|
100 |
(void)aRequest;
|
|
101 |
ASSERT(aRequest.Function() == EFsFormatOpen);
|
|
102 |
|
|
103 |
if (iFormatInterceptTestStage == ETestNotStarted)
|
|
104 |
{
|
|
105 |
// If the test has just started, the first
|
|
106 |
// operation should be preintercept of EFsFormatOpen
|
|
107 |
ASSERT(!aRequest.IsPostOperation());
|
|
108 |
iFormatInterceptTestStage = EPreFormatOpen;
|
|
109 |
}
|
|
110 |
else
|
|
111 |
{
|
|
112 |
ASSERT(iFormatInterceptTestStage == EPreFormatOpen);
|
|
113 |
ASSERT(aRequest.IsPostOperation()); // Should be postintercept of EFsFormatOpen
|
|
114 |
iFormatInterceptTestStage = EPostFormatOpen;
|
|
115 |
}
|
|
116 |
return KErrNone;
|
|
117 |
}
|
|
118 |
|
|
119 |
/**
|
|
120 |
Handle pre- and post- format of RFormat::Next() - EFsFormatNext IPC
|
|
121 |
*/
|
|
122 |
TInt CFormatHook::VsDriveFormatNext(TFsPluginRequest& aRequest)
|
|
123 |
{
|
|
124 |
//RDebug::Printf("CFormatHook::VsDriveFormatNext aRequest.Function() = %d, IsPostOperation() = %d", aRequest.Function(), aRequest.IsPostOperation());
|
|
125 |
(void)aRequest;
|
|
126 |
ASSERT(aRequest.Function() == EFsFormatNext);
|
|
127 |
|
|
128 |
if (iFormatInterceptTestStage == EPostFormatOpen)
|
|
129 |
{
|
|
130 |
ASSERT(!aRequest.IsPostOperation());
|
|
131 |
iFormatInterceptTestStage = EPreFormatNext;
|
|
132 |
}
|
|
133 |
else
|
|
134 |
{
|
|
135 |
ASSERT(iFormatInterceptTestStage == EPreFormatNext);
|
|
136 |
ASSERT(aRequest.IsPostOperation());
|
|
137 |
iFormatInterceptTestStage = EPostFormatNext;
|
|
138 |
}
|
|
139 |
return KErrNone;
|
|
140 |
}
|
|
141 |
|
|
142 |
/**
|
|
143 |
Handle pre- and post- format of RFormat::Close() - EFsFormatSubClose IPC
|
|
144 |
*/
|
|
145 |
TInt CFormatHook::VsDriveFormatClose(TFsPluginRequest& aRequest)
|
|
146 |
{
|
|
147 |
//RDebug::Printf("CFormatHook::VsDriveFormatsubClose aRequest.Function() = %d, IsPostOperation() = %d", aRequest.Function(), aRequest.IsPostOperation());
|
|
148 |
(void)aRequest;
|
|
149 |
ASSERT(aRequest.Function() == EFsFormatSubClose);
|
|
150 |
|
|
151 |
if (iFormatInterceptTestStage == EPostFormatNext)
|
|
152 |
{
|
|
153 |
ASSERT(!aRequest.IsPostOperation());
|
|
154 |
iFormatInterceptTestStage = EPreFormatSubClose;
|
|
155 |
}
|
|
156 |
else
|
|
157 |
{
|
|
158 |
ASSERT(iFormatInterceptTestStage == EPreFormatSubClose);
|
|
159 |
ASSERT(aRequest.IsPostOperation());
|
|
160 |
iFormatInterceptTestStage = EPostFormatSubClose;
|
|
161 |
}
|
|
162 |
return KErrNone;
|
|
163 |
}
|
|
164 |
|
|
165 |
/**
|
|
166 |
@internalComponent
|
|
167 |
*/
|
|
168 |
TInt CFormatHook::FormatPluginName(TDes& aName)
|
|
169 |
{
|
|
170 |
aName = KFormatPluginName;
|
|
171 |
return KErrNone;
|
|
172 |
}
|
|
173 |
|
|
174 |
//
|
|
175 |
// Plugin Factory
|
|
176 |
//
|
|
177 |
|
|
178 |
class CFormatHookFactory : public CFsPluginFactory
|
|
179 |
{
|
|
180 |
public:
|
|
181 |
CFormatHookFactory();
|
|
182 |
virtual TInt Install();
|
|
183 |
virtual CFsPlugin* NewPluginL();
|
|
184 |
virtual CFsPlugin* NewPluginConnL();
|
|
185 |
virtual TInt UniquePosition();
|
|
186 |
};
|
|
187 |
|
|
188 |
/**
|
|
189 |
Constructor for the plugin factory
|
|
190 |
@internalComponent
|
|
191 |
*/
|
|
192 |
CFormatHookFactory::CFormatHookFactory()
|
|
193 |
{
|
|
194 |
}
|
|
195 |
|
|
196 |
/**
|
|
197 |
Install function for the plugin factory
|
|
198 |
@internalComponent
|
|
199 |
*/
|
|
200 |
TInt CFormatHookFactory::Install()
|
|
201 |
{
|
|
202 |
iSupportedDrives = KPluginAutoAttach;
|
|
203 |
|
|
204 |
_LIT(KFormatHookName,"FormatHook");
|
|
205 |
return(SetName(&KFormatHookName));
|
|
206 |
}
|
|
207 |
|
|
208 |
/**
|
|
209 |
@internalComponent
|
|
210 |
*/
|
|
211 |
TInt CFormatHookFactory::UniquePosition()
|
|
212 |
{
|
|
213 |
return(0x4CC);
|
|
214 |
}
|
|
215 |
|
|
216 |
/**
|
|
217 |
Plugin factory function
|
|
218 |
@internalComponent
|
|
219 |
*/
|
|
220 |
CFsPlugin* CFormatHookFactory::NewPluginL()
|
|
221 |
{
|
|
222 |
return CFormatHook::NewL();
|
|
223 |
}
|
|
224 |
|
|
225 |
/**
|
|
226 |
Plugin factory function
|
|
227 |
@internalComponent
|
|
228 |
*/
|
|
229 |
CFsPlugin* CFormatHookFactory::NewPluginConnL()
|
|
230 |
|
|
231 |
{
|
|
232 |
return CFormatHook::NewL();
|
|
233 |
}
|
|
234 |
|
|
235 |
/**
|
|
236 |
Create a new format plugin
|
|
237 |
@internalComponent
|
|
238 |
*/
|
|
239 |
extern "C" {
|
|
240 |
|
|
241 |
EXPORT_C CFsPluginFactory* CreateFileSystem()
|
|
242 |
{
|
|
243 |
return(new CFormatHookFactory());
|
|
244 |
}
|
|
245 |
}
|
|
246 |
|