sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "f32agentmanager.h" sl@0: #include "f32defaultattributes.h" sl@0: #include sl@0: sl@0: using namespace ContentAccess; sl@0: sl@0: CF32AgentManager* CF32AgentManager::NewL() sl@0: { sl@0: CF32AgentManager* self=new(ELeave) CF32AgentManager(); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CF32AgentManager::CF32AgentManager() sl@0: { sl@0: } sl@0: sl@0: CF32AgentManager::~CF32AgentManager() sl@0: { sl@0: delete iFileMan; sl@0: iFs.Close(); sl@0: } sl@0: sl@0: void CF32AgentManager::ConstructL() sl@0: { sl@0: User::LeaveIfError(iFs.Connect()); sl@0: iFileMan = CFileMan::NewL(iFs); sl@0: } sl@0: sl@0: TBool CF32AgentManager::IsRecognizedL(const TDesC&, TContentShareMode) const sl@0: { sl@0: // F32 should be the default agent and should never be called here sl@0: return EFalse; sl@0: } sl@0: sl@0: TBool CF32AgentManager::IsRecognizedL(RFile& ) const sl@0: { sl@0: return EFalse; sl@0: } sl@0: sl@0: TBool CF32AgentManager::RecognizeFileL(const TDesC&, const TDesC8&, TDes8&, TDes8&) const sl@0: { sl@0: // F32 should be the default agent and should never be called here sl@0: return EFalse; sl@0: } sl@0: sl@0: TInt CF32AgentManager::DeleteFile(const TDesC &aFileName) sl@0: { sl@0: TInt err = KErrNone; sl@0: CF32AgentUi* ui = NULL; sl@0: TBool enableDelete = ETrue; sl@0: sl@0: // get a pointer to the UI sl@0: TRAP(err, ui = &AgentUiL()); sl@0: if(err == KErrNone) sl@0: { sl@0: // UI confirmation supported, see if user wants to delete sl@0: TRAP(err, enableDelete = ui->ConfirmDeleteL(aFileName)); sl@0: if(err == KErrNone && enableDelete) sl@0: { sl@0: // User agrees to delete sl@0: err = iFs.Delete(aFileName); sl@0: } sl@0: } sl@0: else if(err == KErrCANotSupported) sl@0: { sl@0: // UI is not supported, just delete it sl@0: err = iFs.Delete(aFileName); sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: TInt CF32AgentManager::CopyFile(const TDesC& aSource, const TDesC& aDestination) sl@0: { sl@0: return iFileMan->Copy(aSource, aDestination); sl@0: } sl@0: sl@0: TInt CF32AgentManager::CopyFile(RFile& aSource, const TDesC& aDestination) sl@0: { sl@0: return iFileMan->Copy(aSource, aDestination); sl@0: } sl@0: sl@0: TInt CF32AgentManager::RenameFile(const TDesC& aSource, const TDesC& aDestination) sl@0: { sl@0: TInt result = iFileMan->Rename(aSource, aDestination); sl@0: // If the files are on a different drive, Rename will fail sl@0: // Therefore we simulate the Move by doing a Copy, followed by Delete sl@0: if (result != KErrNone) sl@0: { sl@0: result = iFileMan->Copy(aSource,aDestination); sl@0: if (result == KErrNone) sl@0: { sl@0: // If the copy was successful try and delete the original sl@0: result = iFileMan->Delete(aSource); sl@0: if (result != KErrNone) sl@0: { sl@0: // Delete failed so try to cleanup the destination file as we're going to exit with an error sl@0: // We can safely ignore any error from this as the previous error is more important to propagate, since this is just cleanup sl@0: iFileMan->Delete(aDestination); sl@0: } sl@0: } sl@0: } sl@0: return result; sl@0: } sl@0: sl@0: TInt CF32AgentManager::MkDir(const TDesC& aPath) sl@0: { sl@0: return iFs.MkDir(aPath); sl@0: } sl@0: sl@0: TInt CF32AgentManager::MkDirAll(const TDesC& aPath) sl@0: { sl@0: return iFs.MkDirAll(aPath); sl@0: } sl@0: sl@0: TInt CF32AgentManager::RmDir(const TDesC& aPath) sl@0: { sl@0: return iFs.RmDir(aPath); sl@0: } sl@0: sl@0: TInt CF32AgentManager::RenameDir(const TDesC& aOldName, const TDesC& aNewName) sl@0: { sl@0: return iFs.Rename(aOldName, aNewName); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetDir(const TDesC& aName,TUint aEntryAttMask,TUint aEntrySortKey, CDir*& aEntryList) const sl@0: { sl@0: return iFs.GetDir(aName, aEntryAttMask, aEntrySortKey, aEntryList); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetDir(const TDesC& aName,TUint aEntryAttMask,TUint aEntrySortKey, CDir*& aEntryList,CDir*& aDirList) const sl@0: { sl@0: return iFs.GetDir(aName, aEntryAttMask, aEntrySortKey, aEntryList, aDirList); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetDir(const TDesC& aName,const TUidType& aEntryUid,TUint aEntrySortKey, CDir*& aFileList) const sl@0: { sl@0: return iFs.GetDir( aName, aEntryUid, aEntrySortKey, aFileList); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetAttribute(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath) sl@0: { sl@0: // check that the virtual path exists sl@0: if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone) sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: return TF32DefaultAttributes::GetAttribute(aAttribute, aValue, aVirtualPath.URI()); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetAttributeSet(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath) sl@0: { sl@0: // check that the virtual path exists sl@0: if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone) sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: return TF32DefaultAttributes::GetAttributeSet(aAttributeSet, aVirtualPath.URI()); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetStringAttribute(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath) sl@0: { sl@0: // check that the virtual path exists sl@0: if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone) sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: return TF32DefaultAttributes::GetStringAttribute(aAttribute, aValue, aVirtualPath.URI()); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetStringAttributeSet(RStringAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath) sl@0: { sl@0: // check that the virtual path exists sl@0: if(TF32DefaultAttributes::CheckVirtualPath(aVirtualPath) != KErrNone) sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: return TF32DefaultAttributes::GetStringAttributeSet(aAttributeSet, aVirtualPath.URI()); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetAttribute(TInt aAttribute, TInt& aValue, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: // Check that the client hasn't specified some incorrect UniqueId sl@0: if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone) sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: return TF32DefaultAttributes::GetAttribute(aAttribute, aValue, aFile); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetAttributeSet(RAttributeSet& aAttributeSet, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: // Check that the client hasn't specified some incorrect UniqueId sl@0: if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone) sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: return TF32DefaultAttributes::GetAttributeSet(aAttributeSet, aFile); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: // Check that the client hasn't specified some incorrect UniqueId sl@0: if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone) sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: return TF32DefaultAttributes::GetStringAttributeSet(aStringAttributeSet, aFile); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetStringAttribute(TInt aAttribute, TDes& aValue, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: // Check that the client hasn't specified some incorrect UniqueId sl@0: if(TF32DefaultAttributes::CheckUniqueId(aUniqueId) != KErrNone) sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: sl@0: return TF32DefaultAttributes::GetStringAttribute(aAttribute, aValue, aFile); sl@0: } sl@0: sl@0: sl@0: void CF32AgentManager::NotifyStatusChange(const TDesC& , TEventMask , TRequestStatus& aStatus) sl@0: { sl@0: TRequestStatus* ptr = &aStatus; sl@0: User::RequestComplete(ptr, KErrCANotSupported); sl@0: } sl@0: sl@0: TInt CF32AgentManager::CancelNotifyStatusChange(const TDesC& , TRequestStatus& ) sl@0: { sl@0: return KErrCANotSupported; sl@0: } sl@0: sl@0: TInt CF32AgentManager::SetProperty(TAgentProperty aProperty, TInt aValue) sl@0: { sl@0: if(aProperty==EAgentPropertyAgentUI) sl@0: // should only pass type EAgentPropertyAgentUI sl@0: { sl@0: sl@0: CF32AgentUi* ui = NULL; sl@0: // get a pointer to the UI sl@0: TRAPD(err, ui = &AgentUiL()); sl@0: if(err) sl@0: { sl@0: return err; sl@0: } sl@0: return ui->SetProperty(aProperty, aValue); sl@0: } sl@0: else sl@0: { sl@0: return KErrCANotSupported; sl@0: } sl@0: } sl@0: sl@0: void CF32AgentManager::DisplayInfoL(TDisplayInfo aInfo, const TVirtualPathPtr& aVirtualPath) sl@0: { sl@0: #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: RFile64 file; sl@0: #else sl@0: RFile file; sl@0: #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API sl@0: sl@0: // Check that the client hasn't specified some incorrect UniqueId sl@0: User::LeaveIfError(TF32DefaultAttributes::CheckUniqueId(aVirtualPath.UniqueId())); sl@0: sl@0: // Open the file as read only sl@0: User::LeaveIfError(file.Open(iFs, aVirtualPath.URI(), EFileShareReadersOnly | EFileStream | EFileRead)); sl@0: CleanupClosePushL(file); sl@0: AgentUiL().DisplayInfoL(aInfo, file); sl@0: CleanupStack::PopAndDestroy(&file); sl@0: } sl@0: sl@0: void CF32AgentManager::DisplayInfoL(TDisplayInfo aInfo, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: // Check that the client hasn't specified some incorrect UniqueId sl@0: User::LeaveIfError(TF32DefaultAttributes::CheckUniqueId(aUniqueId)); sl@0: sl@0: // Open the file as read only sl@0: AgentUiL().DisplayInfoL(aInfo, aFile); sl@0: } sl@0: sl@0: sl@0: TInt CF32AgentManager::AgentSpecificCommand(TInt , const TDesC8& , TDes8& ) sl@0: { sl@0: return KErrCANotSupported; sl@0: } sl@0: sl@0: void CF32AgentManager::AgentSpecificCommand(TInt , const TDesC8& , TDes8& , TRequestStatus& aStatus) sl@0: { sl@0: TRequestStatus* ptr = &aStatus; sl@0: User::RequestComplete(ptr, KErrCANotSupported); sl@0: } sl@0: sl@0: void CF32AgentManager::DisplayManagementInfoL() sl@0: { sl@0: User::Panic(KCafPanicString, ECafPanicF32AgentManagementInfoNotSupported); sl@0: } sl@0: sl@0: CF32AgentUi& CF32AgentManager::AgentUiL() sl@0: { sl@0: if(!iAgentUi) sl@0: { sl@0: iAgentUi = TF32AgentUiFactory::CreateF32AgentUiL(); sl@0: } sl@0: return *iAgentUi; sl@0: } sl@0: sl@0: void CF32AgentManager::PrepareHTTPRequestHeaders(RStringPool& /*aStringPool*/, RHTTPHeaders& /*aRequestHeaders*/) const sl@0: { sl@0: User::Panic(KCafPanicString, ECafPanicF32AgentPrepareHTTPHeadersNotSupported); sl@0: } sl@0: sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: TBool CF32AgentManager::IsRecognizedL(const TDesC8& /*aHeaderData*/) const sl@0: { sl@0: // F32 should be the default agent and should never be called here sl@0: return EFalse; sl@0: } sl@0: sl@0: TBool CF32AgentManager::RecognizeContentL(const TDesC8&, TDes8&, TDes8&) const sl@0: { sl@0: // F32 should be the default agent and should never be called here sl@0: return EFalse; sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetAttribute(const TDesC8& aHeaderData, TInt aAttribute, TInt& aValue) sl@0: { sl@0: return TF32DefaultAttributes::GetAttribute(aHeaderData, aAttribute, aValue); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetAttributeSet(const TDesC8& aHeaderData, RAttributeSet& aAttributeSet) sl@0: { sl@0: return TF32DefaultAttributes::GetAttributeSet(aHeaderData, aAttributeSet); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetStringAttribute(const TDesC8& aHeaderData, TInt aAttribute, TDes& aValue) sl@0: { sl@0: return TF32DefaultAttributes::GetStringAttribute(aHeaderData, aAttribute, aValue); sl@0: } sl@0: sl@0: TInt CF32AgentManager::GetStringAttributeSet(const TDesC8& aHeaderData, RStringAttributeSet& aAttributeSet) sl@0: { sl@0: return TF32DefaultAttributes::GetStringAttributeSet(aHeaderData, aAttributeSet); sl@0: } sl@0: sl@0: #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT