os/security/contentmgmt/contentaccessfwfordrm/source/f32agent/f32agentmanager.cpp
First public contribution.
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include <caf/cafpanic.h>
20 #include <caf/virtualpathptr.h>
21 #include <caf/dirstreamable.h>
22 #include "f32agentmanager.h"
23 #include "f32defaultattributes.h"
24 #include <caf/f32agentui.h>
26 using namespace ContentAccess;
28 CF32AgentManager* CF32AgentManager::NewL()
30 CF32AgentManager* self=new(ELeave) CF32AgentManager();
31 CleanupStack::PushL(self);
33 CleanupStack::Pop(self);
37 CF32AgentManager::CF32AgentManager()
41 CF32AgentManager::~CF32AgentManager()
47 void CF32AgentManager::ConstructL()
49 User::LeaveIfError(iFs.Connect());
50 iFileMan = CFileMan::NewL(iFs);
53 TBool CF32AgentManager::IsRecognizedL(const TDesC&, TContentShareMode) const
55 // F32 should be the default agent and should never be called here
59 TBool CF32AgentManager::IsRecognizedL(RFile& ) const
64 TBool CF32AgentManager::RecognizeFileL(const TDesC&, const TDesC8&, TDes8&, TDes8&) const
66 // F32 should be the default agent and should never be called here
70 TInt CF32AgentManager::DeleteFile(const TDesC &aFileName)
73 CF32AgentUi* ui = NULL;
74 TBool enableDelete = ETrue;
76 // get a pointer to the UI
77 TRAP(err, ui = &AgentUiL());
80 // UI confirmation supported, see if user wants to delete
81 TRAP(err, enableDelete = ui->ConfirmDeleteL(aFileName));
82 if(err == KErrNone && enableDelete)
84 // User agrees to delete
85 err = iFs.Delete(aFileName);
88 else if(err == KErrCANotSupported)
90 // UI is not supported, just delete it
91 err = iFs.Delete(aFileName);
96 TInt CF32AgentManager::CopyFile(const TDesC& aSource, const TDesC& aDestination)
98 return iFileMan->Copy(aSource, aDestination);
101 TInt CF32AgentManager::CopyFile(RFile& aSource, const TDesC& aDestination)
103 return iFileMan->Copy(aSource, aDestination);
106 TInt CF32AgentManager::RenameFile(const TDesC& aSource, const TDesC& aDestination)
108 TInt result = iFileMan->Rename(aSource, aDestination);
109 // If the files are on a different drive, Rename will fail
110 // Therefore we simulate the Move by doing a Copy, followed by Delete
111 if (result != KErrNone)
113 result = iFileMan->Copy(aSource,aDestination);
114 if (result == KErrNone)
116 // If the copy was successful try and delete the original
117 result = iFileMan->Delete(aSource);
118 if (result != KErrNone)
120 // Delete failed so try to cleanup the destination file as we're going to exit with an error
121 // We can safely ignore any error from this as the previous error is more important to propagate, since this is just cleanup
122 iFileMan->Delete(aDestination);
129 TInt CF32AgentManager::MkDir(const TDesC& aPath)
131 return iFs.MkDir(aPath);
134 TInt CF32AgentManager::MkDirAll(const TDesC& aPath)
136 return iFs.MkDirAll(aPath);
139 TInt CF32AgentManager::RmDir(const TDesC& aPath)
141 return iFs.RmDir(aPath);
144 TInt CF32AgentManager::RenameDir(const TDesC& aOldName, const TDesC& aNewName)
146 return iFs.Rename(aOldName, aNewName);
149 TInt CF32AgentManager::GetDir(const TDesC& aName,TUint aEntryAttMask,TUint aEntrySortKey, CDir*& aEntryList) const
151 return iFs.GetDir(aName, aEntryAttMask, aEntrySortKey, aEntryList);
154 TInt CF32AgentManager::GetDir(const TDesC& aName,TUint aEntryAttMask,TUint aEntrySortKey, CDir*& aEntryList,CDir*& aDirList) const
156 return iFs.GetDir(aName, aEntryAttMask, aEntrySortKey, aEntryList, aDirList);
159 TInt CF32AgentManager::GetDir(const TDesC& aName,const TUidType& aEntryUid,TUint aEntrySortKey, CDir*& aFileList) const
161 return iFs.GetDir( aName, aEntryUid, aEntrySortKey, aFileList);
164 TInt CF32AgentManager::GetAttribute(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath)
166 // check that the virtual path exists
167 if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone)
172 return TF32DefaultAttributes::GetAttribute(aAttribute, aValue, aVirtualPath.URI());
175 TInt CF32AgentManager::GetAttributeSet(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath)
177 // check that the virtual path exists
178 if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone)
183 return TF32DefaultAttributes::GetAttributeSet(aAttributeSet, aVirtualPath.URI());
186 TInt CF32AgentManager::GetStringAttribute(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath)
188 // check that the virtual path exists
189 if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone)
194 return TF32DefaultAttributes::GetStringAttribute(aAttribute, aValue, aVirtualPath.URI());
197 TInt CF32AgentManager::GetStringAttributeSet(RStringAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath)
199 // check that the virtual path exists
200 if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone)
205 return TF32DefaultAttributes::GetStringAttributeSet(aAttributeSet, aVirtualPath.URI());
208 TInt CF32AgentManager::GetAttribute(TInt aAttribute, TInt& aValue, RFile& aFile, const TDesC& aUniqueId)
210 // Check that the client hasn't specified some incorrect UniqueId
211 if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone)
216 return TF32DefaultAttributes::GetAttribute(aAttribute, aValue, aFile);
219 TInt CF32AgentManager::GetAttributeSet(RAttributeSet& aAttributeSet, RFile& aFile, const TDesC& aUniqueId)
221 // Check that the client hasn't specified some incorrect UniqueId
222 if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone)
227 return TF32DefaultAttributes::GetAttributeSet(aAttributeSet, aFile);
230 TInt CF32AgentManager::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, RFile& aFile, const TDesC& aUniqueId)
232 // Check that the client hasn't specified some incorrect UniqueId
233 if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone)
238 return TF32DefaultAttributes::GetStringAttributeSet(aStringAttributeSet, aFile);
241 TInt CF32AgentManager::GetStringAttribute(TInt aAttribute, TDes& aValue, RFile& aFile, const TDesC& aUniqueId)
243 // Check that the client hasn't specified some incorrect UniqueId
244 if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone)
249 return TF32DefaultAttributes::GetStringAttribute(aAttribute, aValue, aFile);
253 void CF32AgentManager::NotifyStatusChange(const TDesC& , TEventMask , TRequestStatus& aStatus)
255 TRequestStatus* ptr = &aStatus;
256 User::RequestComplete(ptr, KErrCANotSupported);
259 TInt CF32AgentManager::CancelNotifyStatusChange(const TDesC& , TRequestStatus& )
261 return KErrCANotSupported;
264 TInt CF32AgentManager::SetProperty(TAgentProperty aProperty, TInt aValue)
266 if(aProperty==EAgentPropertyAgentUI)
267 // should only pass type EAgentPropertyAgentUI
270 CF32AgentUi* ui = NULL;
271 // get a pointer to the UI
272 TRAPD(err, ui = &AgentUiL());
277 return ui->SetProperty(aProperty, aValue);
281 return KErrCANotSupported;
285 void CF32AgentManager::DisplayInfoL(TDisplayInfo aInfo, const TVirtualPathPtr& aVirtualPath)
287 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
291 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
293 // Check that the client hasn't specified some incorrect UniqueId
294 User::LeaveIfError(TF32DefaultAttributes::CheckUniqueId(aVirtualPath.UniqueId()));
296 // Open the file as read only
297 User::LeaveIfError(file.Open(iFs, aVirtualPath.URI(), EFileShareReadersOnly | EFileStream | EFileRead));
298 CleanupClosePushL(file);
299 AgentUiL().DisplayInfoL(aInfo, file);
300 CleanupStack::PopAndDestroy(&file);
303 void CF32AgentManager::DisplayInfoL(TDisplayInfo aInfo, RFile& aFile, const TDesC& aUniqueId)
305 // Check that the client hasn't specified some incorrect UniqueId
306 User::LeaveIfError(TF32DefaultAttributes::CheckUniqueId(aUniqueId));
308 // Open the file as read only
309 AgentUiL().DisplayInfoL(aInfo, aFile);
313 TInt CF32AgentManager::AgentSpecificCommand(TInt , const TDesC8& , TDes8& )
315 return KErrCANotSupported;
318 void CF32AgentManager::AgentSpecificCommand(TInt , const TDesC8& , TDes8& , TRequestStatus& aStatus)
320 TRequestStatus* ptr = &aStatus;
321 User::RequestComplete(ptr, KErrCANotSupported);
324 void CF32AgentManager::DisplayManagementInfoL()
326 User::Panic(KCafPanicString, ECafPanicF32AgentManagementInfoNotSupported);
329 CF32AgentUi& CF32AgentManager::AgentUiL()
333 iAgentUi = TF32AgentUiFactory::CreateF32AgentUiL();
338 void CF32AgentManager::PrepareHTTPRequestHeaders(RStringPool& /*aStringPool*/, RHTTPHeaders& /*aRequestHeaders*/) const
340 User::Panic(KCafPanicString, ECafPanicF32AgentPrepareHTTPHeadersNotSupported);
343 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
345 TBool CF32AgentManager::IsRecognizedL(const TDesC8& /*aHeaderData*/) const
347 // F32 should be the default agent and should never be called here
351 TBool CF32AgentManager::RecognizeContentL(const TDesC8&, TDes8&, TDes8&) const
353 // F32 should be the default agent and should never be called here
357 TInt CF32AgentManager::GetAttribute(const TDesC8& aHeaderData, TInt aAttribute, TInt& aValue)
359 return TF32DefaultAttributes::GetAttribute(aHeaderData, aAttribute, aValue);
362 TInt CF32AgentManager::GetAttributeSet(const TDesC8& aHeaderData, RAttributeSet& aAttributeSet)
364 return TF32DefaultAttributes::GetAttributeSet(aHeaderData, aAttributeSet);
367 TInt CF32AgentManager::GetStringAttribute(const TDesC8& aHeaderData, TInt aAttribute, TDes& aValue)
369 return TF32DefaultAttributes::GetStringAttribute(aHeaderData, aAttribute, aValue);
372 TInt CF32AgentManager::GetStringAttributeSet(const TDesC8& aHeaderData, RStringAttributeSet& aAttributeSet)
374 return TF32DefaultAttributes::GetStringAttributeSet(aHeaderData, aAttributeSet);
377 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT