sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <caf/cafpanic.h>
|
sl@0
|
20 |
#include <caf/virtualpathptr.h>
|
sl@0
|
21 |
#include <caf/dirstreamable.h>
|
sl@0
|
22 |
#include "f32agentmanager.h"
|
sl@0
|
23 |
#include "f32defaultattributes.h"
|
sl@0
|
24 |
#include <caf/f32agentui.h>
|
sl@0
|
25 |
|
sl@0
|
26 |
using namespace ContentAccess;
|
sl@0
|
27 |
|
sl@0
|
28 |
CF32AgentManager* CF32AgentManager::NewL()
|
sl@0
|
29 |
{
|
sl@0
|
30 |
CF32AgentManager* self=new(ELeave) CF32AgentManager();
|
sl@0
|
31 |
CleanupStack::PushL(self);
|
sl@0
|
32 |
self->ConstructL();
|
sl@0
|
33 |
CleanupStack::Pop(self);
|
sl@0
|
34 |
return self;
|
sl@0
|
35 |
}
|
sl@0
|
36 |
|
sl@0
|
37 |
CF32AgentManager::CF32AgentManager()
|
sl@0
|
38 |
{
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
CF32AgentManager::~CF32AgentManager()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
delete iFileMan;
|
sl@0
|
44 |
iFs.Close();
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
void CF32AgentManager::ConstructL()
|
sl@0
|
48 |
{
|
sl@0
|
49 |
User::LeaveIfError(iFs.Connect());
|
sl@0
|
50 |
iFileMan = CFileMan::NewL(iFs);
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
TBool CF32AgentManager::IsRecognizedL(const TDesC&, TContentShareMode) const
|
sl@0
|
54 |
{
|
sl@0
|
55 |
// F32 should be the default agent and should never be called here
|
sl@0
|
56 |
return EFalse;
|
sl@0
|
57 |
}
|
sl@0
|
58 |
|
sl@0
|
59 |
TBool CF32AgentManager::IsRecognizedL(RFile& ) const
|
sl@0
|
60 |
{
|
sl@0
|
61 |
return EFalse;
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
TBool CF32AgentManager::RecognizeFileL(const TDesC&, const TDesC8&, TDes8&, TDes8&) const
|
sl@0
|
65 |
{
|
sl@0
|
66 |
// F32 should be the default agent and should never be called here
|
sl@0
|
67 |
return EFalse;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
TInt CF32AgentManager::DeleteFile(const TDesC &aFileName)
|
sl@0
|
71 |
{
|
sl@0
|
72 |
TInt err = KErrNone;
|
sl@0
|
73 |
CF32AgentUi* ui = NULL;
|
sl@0
|
74 |
TBool enableDelete = ETrue;
|
sl@0
|
75 |
|
sl@0
|
76 |
// get a pointer to the UI
|
sl@0
|
77 |
TRAP(err, ui = &AgentUiL());
|
sl@0
|
78 |
if(err == KErrNone)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
// UI confirmation supported, see if user wants to delete
|
sl@0
|
81 |
TRAP(err, enableDelete = ui->ConfirmDeleteL(aFileName));
|
sl@0
|
82 |
if(err == KErrNone && enableDelete)
|
sl@0
|
83 |
{
|
sl@0
|
84 |
// User agrees to delete
|
sl@0
|
85 |
err = iFs.Delete(aFileName);
|
sl@0
|
86 |
}
|
sl@0
|
87 |
}
|
sl@0
|
88 |
else if(err == KErrCANotSupported)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
// UI is not supported, just delete it
|
sl@0
|
91 |
err = iFs.Delete(aFileName);
|
sl@0
|
92 |
}
|
sl@0
|
93 |
return err;
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
TInt CF32AgentManager::CopyFile(const TDesC& aSource, const TDesC& aDestination)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
return iFileMan->Copy(aSource, aDestination);
|
sl@0
|
99 |
}
|
sl@0
|
100 |
|
sl@0
|
101 |
TInt CF32AgentManager::CopyFile(RFile& aSource, const TDesC& aDestination)
|
sl@0
|
102 |
{
|
sl@0
|
103 |
return iFileMan->Copy(aSource, aDestination);
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
TInt CF32AgentManager::RenameFile(const TDesC& aSource, const TDesC& aDestination)
|
sl@0
|
107 |
{
|
sl@0
|
108 |
TInt result = iFileMan->Rename(aSource, aDestination);
|
sl@0
|
109 |
// If the files are on a different drive, Rename will fail
|
sl@0
|
110 |
// Therefore we simulate the Move by doing a Copy, followed by Delete
|
sl@0
|
111 |
if (result != KErrNone)
|
sl@0
|
112 |
{
|
sl@0
|
113 |
result = iFileMan->Copy(aSource,aDestination);
|
sl@0
|
114 |
if (result == KErrNone)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
// If the copy was successful try and delete the original
|
sl@0
|
117 |
result = iFileMan->Delete(aSource);
|
sl@0
|
118 |
if (result != KErrNone)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
// Delete failed so try to cleanup the destination file as we're going to exit with an error
|
sl@0
|
121 |
// We can safely ignore any error from this as the previous error is more important to propagate, since this is just cleanup
|
sl@0
|
122 |
iFileMan->Delete(aDestination);
|
sl@0
|
123 |
}
|
sl@0
|
124 |
}
|
sl@0
|
125 |
}
|
sl@0
|
126 |
return result;
|
sl@0
|
127 |
}
|
sl@0
|
128 |
|
sl@0
|
129 |
TInt CF32AgentManager::MkDir(const TDesC& aPath)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
return iFs.MkDir(aPath);
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
TInt CF32AgentManager::MkDirAll(const TDesC& aPath)
|
sl@0
|
135 |
{
|
sl@0
|
136 |
return iFs.MkDirAll(aPath);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
TInt CF32AgentManager::RmDir(const TDesC& aPath)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
return iFs.RmDir(aPath);
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
TInt CF32AgentManager::RenameDir(const TDesC& aOldName, const TDesC& aNewName)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
return iFs.Rename(aOldName, aNewName);
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
TInt CF32AgentManager::GetDir(const TDesC& aName,TUint aEntryAttMask,TUint aEntrySortKey, CDir*& aEntryList) const
|
sl@0
|
150 |
{
|
sl@0
|
151 |
return iFs.GetDir(aName, aEntryAttMask, aEntrySortKey, aEntryList);
|
sl@0
|
152 |
}
|
sl@0
|
153 |
|
sl@0
|
154 |
TInt CF32AgentManager::GetDir(const TDesC& aName,TUint aEntryAttMask,TUint aEntrySortKey, CDir*& aEntryList,CDir*& aDirList) const
|
sl@0
|
155 |
{
|
sl@0
|
156 |
return iFs.GetDir(aName, aEntryAttMask, aEntrySortKey, aEntryList, aDirList);
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
TInt CF32AgentManager::GetDir(const TDesC& aName,const TUidType& aEntryUid,TUint aEntrySortKey, CDir*& aFileList) const
|
sl@0
|
160 |
{
|
sl@0
|
161 |
return iFs.GetDir( aName, aEntryUid, aEntrySortKey, aFileList);
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
TInt CF32AgentManager::GetAttribute(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
// check that the virtual path exists
|
sl@0
|
167 |
if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone)
|
sl@0
|
168 |
{
|
sl@0
|
169 |
return KErrNotFound;
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
return TF32DefaultAttributes::GetAttribute(aAttribute, aValue, aVirtualPath.URI());
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
TInt CF32AgentManager::GetAttributeSet(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
// check that the virtual path exists
|
sl@0
|
178 |
if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone)
|
sl@0
|
179 |
{
|
sl@0
|
180 |
return KErrNotFound;
|
sl@0
|
181 |
}
|
sl@0
|
182 |
|
sl@0
|
183 |
return TF32DefaultAttributes::GetAttributeSet(aAttributeSet, aVirtualPath.URI());
|
sl@0
|
184 |
}
|
sl@0
|
185 |
|
sl@0
|
186 |
TInt CF32AgentManager::GetStringAttribute(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath)
|
sl@0
|
187 |
{
|
sl@0
|
188 |
// check that the virtual path exists
|
sl@0
|
189 |
if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone)
|
sl@0
|
190 |
{
|
sl@0
|
191 |
return KErrNotFound;
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
return TF32DefaultAttributes::GetStringAttribute(aAttribute, aValue, aVirtualPath.URI());
|
sl@0
|
195 |
}
|
sl@0
|
196 |
|
sl@0
|
197 |
TInt CF32AgentManager::GetStringAttributeSet(RStringAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath)
|
sl@0
|
198 |
{
|
sl@0
|
199 |
// check that the virtual path exists
|
sl@0
|
200 |
if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
return KErrNotFound;
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
return TF32DefaultAttributes::GetStringAttributeSet(aAttributeSet, aVirtualPath.URI());
|
sl@0
|
206 |
}
|
sl@0
|
207 |
|
sl@0
|
208 |
TInt CF32AgentManager::GetAttribute(TInt aAttribute, TInt& aValue, RFile& aFile, const TDesC& aUniqueId)
|
sl@0
|
209 |
{
|
sl@0
|
210 |
// Check that the client hasn't specified some incorrect UniqueId
|
sl@0
|
211 |
if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone)
|
sl@0
|
212 |
{
|
sl@0
|
213 |
return KErrNotFound;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
return TF32DefaultAttributes::GetAttribute(aAttribute, aValue, aFile);
|
sl@0
|
217 |
}
|
sl@0
|
218 |
|
sl@0
|
219 |
TInt CF32AgentManager::GetAttributeSet(RAttributeSet& aAttributeSet, RFile& aFile, const TDesC& aUniqueId)
|
sl@0
|
220 |
{
|
sl@0
|
221 |
// Check that the client hasn't specified some incorrect UniqueId
|
sl@0
|
222 |
if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone)
|
sl@0
|
223 |
{
|
sl@0
|
224 |
return KErrNotFound;
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
return TF32DefaultAttributes::GetAttributeSet(aAttributeSet, aFile);
|
sl@0
|
228 |
}
|
sl@0
|
229 |
|
sl@0
|
230 |
TInt CF32AgentManager::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, RFile& aFile, const TDesC& aUniqueId)
|
sl@0
|
231 |
{
|
sl@0
|
232 |
// Check that the client hasn't specified some incorrect UniqueId
|
sl@0
|
233 |
if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone)
|
sl@0
|
234 |
{
|
sl@0
|
235 |
return KErrNotFound;
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
return TF32DefaultAttributes::GetStringAttributeSet(aStringAttributeSet, aFile);
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
TInt CF32AgentManager::GetStringAttribute(TInt aAttribute, TDes& aValue, RFile& aFile, const TDesC& aUniqueId)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
// Check that the client hasn't specified some incorrect UniqueId
|
sl@0
|
244 |
if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone)
|
sl@0
|
245 |
{
|
sl@0
|
246 |
return KErrNotFound;
|
sl@0
|
247 |
}
|
sl@0
|
248 |
|
sl@0
|
249 |
return TF32DefaultAttributes::GetStringAttribute(aAttribute, aValue, aFile);
|
sl@0
|
250 |
}
|
sl@0
|
251 |
|
sl@0
|
252 |
|
sl@0
|
253 |
void CF32AgentManager::NotifyStatusChange(const TDesC& , TEventMask , TRequestStatus& aStatus)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
TRequestStatus* ptr = &aStatus;
|
sl@0
|
256 |
User::RequestComplete(ptr, KErrCANotSupported);
|
sl@0
|
257 |
}
|
sl@0
|
258 |
|
sl@0
|
259 |
TInt CF32AgentManager::CancelNotifyStatusChange(const TDesC& , TRequestStatus& )
|
sl@0
|
260 |
{
|
sl@0
|
261 |
return KErrCANotSupported;
|
sl@0
|
262 |
}
|
sl@0
|
263 |
|
sl@0
|
264 |
TInt CF32AgentManager::SetProperty(TAgentProperty aProperty, TInt aValue)
|
sl@0
|
265 |
{
|
sl@0
|
266 |
if(aProperty==EAgentPropertyAgentUI)
|
sl@0
|
267 |
// should only pass type EAgentPropertyAgentUI
|
sl@0
|
268 |
{
|
sl@0
|
269 |
|
sl@0
|
270 |
CF32AgentUi* ui = NULL;
|
sl@0
|
271 |
// get a pointer to the UI
|
sl@0
|
272 |
TRAPD(err, ui = &AgentUiL());
|
sl@0
|
273 |
if(err)
|
sl@0
|
274 |
{
|
sl@0
|
275 |
return err;
|
sl@0
|
276 |
}
|
sl@0
|
277 |
return ui->SetProperty(aProperty, aValue);
|
sl@0
|
278 |
}
|
sl@0
|
279 |
else
|
sl@0
|
280 |
{
|
sl@0
|
281 |
return KErrCANotSupported;
|
sl@0
|
282 |
}
|
sl@0
|
283 |
}
|
sl@0
|
284 |
|
sl@0
|
285 |
void CF32AgentManager::DisplayInfoL(TDisplayInfo aInfo, const TVirtualPathPtr& aVirtualPath)
|
sl@0
|
286 |
{
|
sl@0
|
287 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
288 |
RFile64 file;
|
sl@0
|
289 |
#else
|
sl@0
|
290 |
RFile file;
|
sl@0
|
291 |
#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
292 |
|
sl@0
|
293 |
// Check that the client hasn't specified some incorrect UniqueId
|
sl@0
|
294 |
User::LeaveIfError(TF32DefaultAttributes::CheckUniqueId(aVirtualPath.UniqueId()));
|
sl@0
|
295 |
|
sl@0
|
296 |
// Open the file as read only
|
sl@0
|
297 |
User::LeaveIfError(file.Open(iFs, aVirtualPath.URI(), EFileShareReadersOnly | EFileStream | EFileRead));
|
sl@0
|
298 |
CleanupClosePushL(file);
|
sl@0
|
299 |
AgentUiL().DisplayInfoL(aInfo, file);
|
sl@0
|
300 |
CleanupStack::PopAndDestroy(&file);
|
sl@0
|
301 |
}
|
sl@0
|
302 |
|
sl@0
|
303 |
void CF32AgentManager::DisplayInfoL(TDisplayInfo aInfo, RFile& aFile, const TDesC& aUniqueId)
|
sl@0
|
304 |
{
|
sl@0
|
305 |
// Check that the client hasn't specified some incorrect UniqueId
|
sl@0
|
306 |
User::LeaveIfError(TF32DefaultAttributes::CheckUniqueId(aUniqueId));
|
sl@0
|
307 |
|
sl@0
|
308 |
// Open the file as read only
|
sl@0
|
309 |
AgentUiL().DisplayInfoL(aInfo, aFile);
|
sl@0
|
310 |
}
|
sl@0
|
311 |
|
sl@0
|
312 |
|
sl@0
|
313 |
TInt CF32AgentManager::AgentSpecificCommand(TInt , const TDesC8& , TDes8& )
|
sl@0
|
314 |
{
|
sl@0
|
315 |
return KErrCANotSupported;
|
sl@0
|
316 |
}
|
sl@0
|
317 |
|
sl@0
|
318 |
void CF32AgentManager::AgentSpecificCommand(TInt , const TDesC8& , TDes8& , TRequestStatus& aStatus)
|
sl@0
|
319 |
{
|
sl@0
|
320 |
TRequestStatus* ptr = &aStatus;
|
sl@0
|
321 |
User::RequestComplete(ptr, KErrCANotSupported);
|
sl@0
|
322 |
}
|
sl@0
|
323 |
|
sl@0
|
324 |
void CF32AgentManager::DisplayManagementInfoL()
|
sl@0
|
325 |
{
|
sl@0
|
326 |
User::Panic(KCafPanicString, ECafPanicF32AgentManagementInfoNotSupported);
|
sl@0
|
327 |
}
|
sl@0
|
328 |
|
sl@0
|
329 |
CF32AgentUi& CF32AgentManager::AgentUiL()
|
sl@0
|
330 |
{
|
sl@0
|
331 |
if(!iAgentUi)
|
sl@0
|
332 |
{
|
sl@0
|
333 |
iAgentUi = TF32AgentUiFactory::CreateF32AgentUiL();
|
sl@0
|
334 |
}
|
sl@0
|
335 |
return *iAgentUi;
|
sl@0
|
336 |
}
|
sl@0
|
337 |
|
sl@0
|
338 |
void CF32AgentManager::PrepareHTTPRequestHeaders(RStringPool& /*aStringPool*/, RHTTPHeaders& /*aRequestHeaders*/) const
|
sl@0
|
339 |
{
|
sl@0
|
340 |
User::Panic(KCafPanicString, ECafPanicF32AgentPrepareHTTPHeadersNotSupported);
|
sl@0
|
341 |
}
|
sl@0
|
342 |
|
sl@0
|
343 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
344 |
|
sl@0
|
345 |
TBool CF32AgentManager::IsRecognizedL(const TDesC8& /*aHeaderData*/) const
|
sl@0
|
346 |
{
|
sl@0
|
347 |
// F32 should be the default agent and should never be called here
|
sl@0
|
348 |
return EFalse;
|
sl@0
|
349 |
}
|
sl@0
|
350 |
|
sl@0
|
351 |
TBool CF32AgentManager::RecognizeContentL(const TDesC8&, TDes8&, TDes8&) const
|
sl@0
|
352 |
{
|
sl@0
|
353 |
// F32 should be the default agent and should never be called here
|
sl@0
|
354 |
return EFalse;
|
sl@0
|
355 |
}
|
sl@0
|
356 |
|
sl@0
|
357 |
TInt CF32AgentManager::GetAttribute(const TDesC8& aHeaderData, TInt aAttribute, TInt& aValue)
|
sl@0
|
358 |
{
|
sl@0
|
359 |
return TF32DefaultAttributes::GetAttribute(aHeaderData, aAttribute, aValue);
|
sl@0
|
360 |
}
|
sl@0
|
361 |
|
sl@0
|
362 |
TInt CF32AgentManager::GetAttributeSet(const TDesC8& aHeaderData, RAttributeSet& aAttributeSet)
|
sl@0
|
363 |
{
|
sl@0
|
364 |
return TF32DefaultAttributes::GetAttributeSet(aHeaderData, aAttributeSet);
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
TInt CF32AgentManager::GetStringAttribute(const TDesC8& aHeaderData, TInt aAttribute, TDes& aValue)
|
sl@0
|
368 |
{
|
sl@0
|
369 |
return TF32DefaultAttributes::GetStringAttribute(aHeaderData, aAttribute, aValue);
|
sl@0
|
370 |
}
|
sl@0
|
371 |
|
sl@0
|
372 |
TInt CF32AgentManager::GetStringAttributeSet(const TDesC8& aHeaderData, RStringAttributeSet& aAttributeSet)
|
sl@0
|
373 |
{
|
sl@0
|
374 |
return TF32DefaultAttributes::GetStringAttributeSet(aHeaderData, aAttributeSet);
|
sl@0
|
375 |
}
|
sl@0
|
376 |
|
sl@0
|
377 |
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|