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 "agentinfo.h" sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "resolver.h" sl@0: sl@0: using namespace ContentAccess; sl@0: sl@0: EXPORT_C CManager* CManager::NewL() sl@0: { sl@0: CManager* self = CManager::NewLC(); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: EXPORT_C CManager* CManager::NewLC() sl@0: { sl@0: CManager* self = new (ELeave) CManager; sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(); sl@0: return self; sl@0: } sl@0: sl@0: CManager::CManager() sl@0: { sl@0: } sl@0: sl@0: CManager::~CManager() sl@0: { sl@0: delete iResolver; sl@0: } sl@0: sl@0: void CManager::ConstructL() sl@0: { sl@0: iResolver = CAgentResolver::NewL(EFalse); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::DeleteFile(const TDesC &aFileName) const sl@0: { sl@0: TRAPD(err, DoDeleteFileL(aFileName)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoDeleteFileL(const TDesC &aFileName) const sl@0: { sl@0: TFileName actualFileName; sl@0: sl@0: // initalise a pointer to the relevant CAgentManager object sl@0: // iResolver retains ownership of the pointer sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aFileName, actualFileName, EContentShareReadOnly); sl@0: sl@0: User::LeaveIfError(agentInfo.AgentManagerL().DeleteFile(actualFileName)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::CopyFile(RFile& aSourceFile, const TDesC &aDestination) const sl@0: { sl@0: TRAPD(err, DoCopyFileL(aSourceFile, aDestination)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoCopyFileL(RFile& aSourceFile, const TDesC &aDestination) const sl@0: { sl@0: TFileName actualDestination; sl@0: TBool thePrivateDir = EFalse; sl@0: TUid agentUid = KNullUid; sl@0: sl@0: // Find out which agent owns the directory where the destination file lives sl@0: TUid destinationAgentUid = iResolver->ResolveDirectory(aDestination, actualDestination, thePrivateDir); sl@0: sl@0: if(destinationAgentUid != iResolver->DefaultAgentUid()) sl@0: { sl@0: // Destination file is in an agent private directory sl@0: // Use destination agent to copy sl@0: agentUid = destinationAgentUid; sl@0: } sl@0: else sl@0: { sl@0: // Use RFile version of ResolveFileL to find the Agent Uid sl@0: agentUid = iResolver->ResolveFileL(aSourceFile).Agent().ImplementationUid(); sl@0: } sl@0: sl@0: // If creating the appropriate CAgentManager succeeded ask the agent to copy the file sl@0: User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().CopyFile(aSourceFile, actualDestination)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::CopyFile(const TDesC &aSource, const TDesC &aDestination) const sl@0: { sl@0: TRAPD(err, DoCopyFileL(aSource, aDestination)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoCopyFileL(const TDesC &aSource, const TDesC &aDestination) const sl@0: { sl@0: TFileName actualSource; sl@0: TFileName actualDestination; sl@0: TBool thePrivateDir = EFalse; sl@0: TUid agentUid = KNullUid; sl@0: sl@0: // Find out which agent owns the directory where the source file lives sl@0: TUid sourceAgentUid = iResolver->ResolveDirectory(aSource, actualSource, thePrivateDir); sl@0: sl@0: // Find out which agent owns the directory where the destination file lives sl@0: TUid destinationAgentUid = iResolver->ResolveDirectory(aDestination, actualDestination, thePrivateDir); sl@0: sl@0: if(sourceAgentUid != iResolver->DefaultAgentUid()) sl@0: { sl@0: // Source file is in an agent private directory sl@0: // Use source agent to copy sl@0: agentUid = sourceAgentUid; sl@0: } sl@0: else if(destinationAgentUid != iResolver->DefaultAgentUid()) sl@0: { sl@0: // Destination file is in an agent private directory sl@0: // Use destination agent to copy sl@0: agentUid = destinationAgentUid; sl@0: } sl@0: else sl@0: { sl@0: // Source and destination are in publicly accessable directories sl@0: agentUid = iResolver->ResolveFileL(aSource, actualSource, EContentShareReadOnly).Agent().ImplementationUid(); sl@0: } sl@0: sl@0: // If creating the appropriate CAgentManager succeeded ask the agent to copy the file sl@0: User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().CopyFile(actualSource, actualDestination)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::RenameFile(const TDesC& aSource, const TDesC& aDestination) const sl@0: { sl@0: TRAPD(err, DoRenameFileL(aSource, aDestination)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoRenameFileL(const TDesC& aSource, const TDesC& aDestination) const sl@0: { sl@0: TFileName actualSource; sl@0: TFileName actualDestination; sl@0: TBool thePrivateDir = EFalse; sl@0: TUid agentUid = KNullUid; sl@0: sl@0: // Find out which agent owns the directory where the source file lives sl@0: TUid sourceAgentUid = iResolver->ResolveDirectory(aSource, actualSource, thePrivateDir); sl@0: sl@0: // Find out which agent owns the directory where the destination file lives sl@0: TUid destinationAgentUid = iResolver->ResolveDirectory(aDestination, actualDestination, thePrivateDir); sl@0: sl@0: if(sourceAgentUid != iResolver->DefaultAgentUid()) sl@0: { sl@0: // Source file is in an agent private directory sl@0: // Use source agent to copy sl@0: agentUid = sourceAgentUid; sl@0: } sl@0: else if(destinationAgentUid != iResolver->DefaultAgentUid()) sl@0: { sl@0: // Destination file is in an agent private directory sl@0: // Use destination agent to copy sl@0: agentUid = destinationAgentUid; sl@0: } sl@0: else sl@0: { sl@0: // Source and destination are in publicly accessable directories sl@0: agentUid = iResolver->ResolveFileL(aSource, actualSource, EContentShareReadOnly).Agent().ImplementationUid(); sl@0: } sl@0: sl@0: // Ask the agent to move or rename the file sl@0: User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().RenameFile(actualSource, actualDestination)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::MkDir(const TDesC &aPath) const sl@0: { sl@0: TRAPD(err, DoMkDirL(aPath)); sl@0: sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoMkDirL(const TDesC &aPath) const sl@0: { sl@0: TBool isThePrivateDir = EFalse; sl@0: TFileName actualPath; sl@0: sl@0: // Figure out which agent handles the directory sl@0: TUid uid = iResolver->ResolveDirectory(aPath, actualPath, isThePrivateDir); sl@0: sl@0: User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().MkDir(actualPath)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::MkDirAll (const TDesC &aPath) const sl@0: { sl@0: TRAPD(err, DoMkDirAllL(aPath)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoMkDirAllL(const TDesC &aPath) const sl@0: { sl@0: TBool isThePrivateDir = EFalse; sl@0: TFileName actualPath; sl@0: sl@0: // Figure out which agent handles the directory sl@0: TUid uid = iResolver->ResolveDirectory(aPath, actualPath, isThePrivateDir); sl@0: sl@0: User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().MkDirAll(actualPath)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::RmDir(const TDesC &aPath) const sl@0: { sl@0: TRAPD(err, DoRmDirL(aPath)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoRmDirL(const TDesC &aPath) const sl@0: { sl@0: TBool isThePrivateDir = EFalse; sl@0: TFileName actualPath; sl@0: sl@0: // Figure out which agent handles the directory sl@0: TUid uid = iResolver->ResolveDirectory(aPath, actualPath, isThePrivateDir); sl@0: sl@0: if(isThePrivateDir) sl@0: { sl@0: User::Leave(KErrAccessDenied); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().RmDir(actualPath)); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::RenameDir(const TDesC& aOldName, const TDesC& aNewName) const sl@0: { sl@0: TRAPD(err, DoRenameDirL(aOldName, aNewName)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoRenameDirL(const TDesC &aOldName, const TDesC& aNewName) const sl@0: { sl@0: TPath actualSource; sl@0: TPath actualDestination; sl@0: TBool thePrivateDir = EFalse; sl@0: TUid agentUid = iResolver->DefaultAgentUid(); sl@0: sl@0: // Find out which agent owns the directory where the source file lives sl@0: TUid sourceAgentUid = iResolver->ResolveDirectory(aOldName, actualSource, thePrivateDir); sl@0: sl@0: // Find out which agent owns the directory where the destination file lives sl@0: TUid destinationAgentUid = iResolver->ResolveDirectory(aNewName, actualDestination, thePrivateDir); sl@0: sl@0: if(sourceAgentUid != iResolver->DefaultAgentUid()) sl@0: { sl@0: // Source file is in an agent private directory sl@0: // Use source agent to copy sl@0: agentUid = sourceAgentUid; sl@0: } sl@0: else if(destinationAgentUid != iResolver->DefaultAgentUid()) sl@0: { sl@0: // Destination file is in an agent private directory sl@0: // Use destination agent to copy sl@0: agentUid = destinationAgentUid; sl@0: } sl@0: sl@0: // Ask the agent to move or rename the file sl@0: User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().RenameDir(actualSource, actualDestination)); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TInt CManager::GetDir(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList) const sl@0: { sl@0: TRAPD(err, DoGetDirL(aName, aEntryAttMask, aEntrySortKey, aEntryList)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetDirL(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList) const sl@0: { sl@0: TBool isThePrivateDir = EFalse; sl@0: TFileName actualPath; sl@0: sl@0: // Figure out which agent handles the directory sl@0: TUid uid = iResolver->ResolveDirectory(aName, actualPath, isThePrivateDir); sl@0: sl@0: if(isThePrivateDir) sl@0: { sl@0: // If we are doing GetDir of C:\\private\\ just create an empty CDirStreamable sl@0: aEntryList = CDirStreamable::NewL(); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().GetDir(actualPath, aEntryAttMask, aEntrySortKey, aEntryList)); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetDir(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList, CDir *&aDirList) const sl@0: { sl@0: TRAPD(err, DoGetDirL(aName, aEntryAttMask, aEntrySortKey, aEntryList, aDirList)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetDirL(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList, CDir *&aDirList) const sl@0: { sl@0: TBool isThePrivateDir = EFalse; sl@0: TFileName actualPath; sl@0: CDir* emptyDirList; sl@0: sl@0: // Figure out which agent handles the directory sl@0: TUid uid = iResolver->ResolveDirectory(aName, actualPath, isThePrivateDir); sl@0: sl@0: if(isThePrivateDir) sl@0: { sl@0: // If we are doing GetDir of C:\\private\\ just create an empty entryList sl@0: emptyDirList = CDirStreamable::NewL(); sl@0: CleanupStack::PushL(emptyDirList); sl@0: sl@0: GetListOfAgentPrivateDirectoriesL(aDirList); sl@0: sl@0: CleanupStack::Pop(emptyDirList); sl@0: aEntryList = emptyDirList; sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().GetDir(actualPath, aEntryAttMask, aEntrySortKey, aEntryList, aDirList)); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetDir(const TDesC &aName, const TUidType &aEntryUid, TUint aEntrySortKey, CDir *&aFileList) const sl@0: { sl@0: TRAPD(err, DoGetDirL(aName, aEntryUid, aEntrySortKey, aFileList)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetDirL(const TDesC &aName, const TUidType &aEntryUid, TUint aEntrySortKey, CDir *&aFileList) const sl@0: { sl@0: TBool isThePrivateDir = EFalse; sl@0: TFileName actualPath; sl@0: sl@0: // Figure out which agent handles the directory sl@0: TUid uid = iResolver->ResolveDirectory(aName, actualPath, isThePrivateDir); sl@0: sl@0: if(isThePrivateDir) sl@0: { sl@0: // We've been asked to look at C:\\private\\ just return an empty CDirStreamable sl@0: aFileList = CDirStreamable::NewL(); sl@0: } sl@0: else sl@0: { sl@0: User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().GetDir(actualPath, aEntryUid, aEntrySortKey, aFileList)); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetAttribute(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath) const sl@0: { sl@0: TRAPD(err, DoGetAttributeL(aAttribute, aValue, aVirtualPath)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetAttributeL(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath) const sl@0: { sl@0: HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); sl@0: TPtr uri = uriBuffer->Des(); sl@0: sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(),uri, EContentShareReadOnly); sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetAttribute(aAttribute, aValue, TVirtualPathPtr(uri, aVirtualPath.UniqueId()))); sl@0: CleanupStack::PopAndDestroy(uriBuffer); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetAttribute(TInt aAttribute, TInt& aValue, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: TRAPD(err, DoGetAttributeL(aAttribute, aValue, aFile, aUniqueId)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetAttributeL(TInt aAttribute, TInt& aValue, RFile& aFile, const TDesC& aUniqueId) const sl@0: { sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile); sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetAttribute(aAttribute, aValue, aFile, aUniqueId)); sl@0: } sl@0: sl@0: sl@0: EXPORT_C TInt CManager::GetStringAttribute(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath) const sl@0: { sl@0: TRAPD(err, DoGetStringAttributeL(aAttribute, aValue, aVirtualPath)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetStringAttributeL(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath) const sl@0: { sl@0: HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); sl@0: TPtr uri = uriBuffer->Des(); sl@0: sl@0: sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(), uri, EContentShareReadOnly); sl@0: sl@0: // find out the attribute sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttribute(aAttribute, aValue, TVirtualPathPtr(uri,aVirtualPath.UniqueId()))); sl@0: CleanupStack::PopAndDestroy(uriBuffer); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetStringAttribute (TInt aAttribute, TDes& aValue, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: TRAPD(err, DoGetStringAttributeL(aAttribute, aValue, aFile, aUniqueId)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetStringAttributeL(TInt aAttribute, TDes& aValue, RFile& aFile, const TDesC& aUniqueId) const sl@0: { sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile); sl@0: // find out the attribute sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttribute(aAttribute, aValue, aFile, aUniqueId)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetAttributeSet(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath) const sl@0: { sl@0: TRAPD(err, DoGetAttributeSetL(aAttributeSet, aVirtualPath)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetAttributeSetL(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath) const sl@0: { sl@0: HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); sl@0: TPtr uri = uriBuffer->Des(); sl@0: sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(), uri, EContentShareReadOnly); sl@0: sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetAttributeSet(aAttributeSet, TVirtualPathPtr(uri, aVirtualPath.UniqueId()))); sl@0: CleanupStack::PopAndDestroy(uriBuffer); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetAttributeSet (RAttributeSet& aAttributeSet, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: TRAPD(err, DoGetAttributeSetL(aAttributeSet, aFile, aUniqueId)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetAttributeSetL(RAttributeSet& aAttributeSet, RFile& aFile, const TDesC& aUniqueId) const sl@0: { sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile); sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetAttributeSet(aAttributeSet, aFile, aUniqueId)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, const TVirtualPathPtr& aVirtualPath) const sl@0: { sl@0: TRAPD(err, DoGetStringAttributeSetL(aStringAttributeSet, aVirtualPath)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetStringAttributeSetL(RStringAttributeSet& aStringAttributeSet, const TVirtualPathPtr& aVirtualPath) const sl@0: { sl@0: HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); sl@0: TPtr uri = uriBuffer->Des(); sl@0: sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(),uri, EContentShareReadOnly); sl@0: sl@0: // find out the array of attributes sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttributeSet(aStringAttributeSet, TVirtualPathPtr(uri, aVirtualPath.UniqueId()))); sl@0: CleanupStack::PopAndDestroy(uriBuffer); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: TRAPD(err, DoGetStringAttributeSetL(aStringAttributeSet, aFile, aUniqueId)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetStringAttributeSetL(RStringAttributeSet& aStringAttributeSet, RFile& aFile, const TDesC& aUniqueId) const sl@0: { sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile); sl@0: // find out the array of attributes sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttributeSet(aStringAttributeSet, aFile, aUniqueId)); sl@0: } sl@0: sl@0: EXPORT_C void CManager::NotifyStatusChange(const TDesC &aURI, TEventMask aMask, TRequestStatus &aStatus) sl@0: { sl@0: TRAPD(err, DoNotifyStatusChangeL(aURI, aMask, aStatus)); sl@0: if(err != KErrNone) sl@0: { sl@0: // Must have failed before asking the agent for status sl@0: TRequestStatus* status = &aStatus; sl@0: User::RequestComplete(status, err); sl@0: } sl@0: } sl@0: sl@0: void CManager::DoNotifyStatusChangeL(const TDesC &aURI, TEventMask aMask, TRequestStatus &aStatus) sl@0: { sl@0: HBufC* uriBuffer = HBufC::NewLC(aURI.Length() + KMaxSIDLength); sl@0: TPtr uri = uriBuffer->Des(); sl@0: sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aURI, uri, EContentShareReadOnly); sl@0: sl@0: // Ask the agent to notifiy the client when the status of the given file changes sl@0: agentInfo.AgentManagerL().NotifyStatusChange(uri, aMask, aStatus); sl@0: CleanupStack::PopAndDestroy(uriBuffer); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::CancelNotifyStatusChange (const TDesC &aURI, TRequestStatus &aStatus) sl@0: { sl@0: TRAPD(err, DoCancelNotifyStatusChangeL(aURI, aStatus)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoCancelNotifyStatusChangeL(const TDesC &aURI, TRequestStatus &aStatus) sl@0: { sl@0: HBufC* uriBuffer = HBufC::NewLC(aURI.Length() + KMaxSIDLength); sl@0: TPtr uri = uriBuffer->Des(); sl@0: sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aURI, uri, EContentShareReadOnly); sl@0: sl@0: // cancel the notification request sl@0: User::LeaveIfError(agentInfo.AgentManagerL().CancelNotifyStatusChange(uri, aStatus)); sl@0: CleanupStack::PopAndDestroy(uriBuffer); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::SetProperty(TAgentProperty aProperty, TInt aValue) sl@0: { sl@0: TRAPD(err, DoSetPropertyL(aProperty, aValue)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoSetPropertyL(TAgentProperty aProperty, TInt aValue) sl@0: { sl@0: TInt err = KErrNone; sl@0: TInt rVal = KErrNone; sl@0: TInt i = 0; sl@0: TInt count = iResolver->AgentInfoCount(); sl@0: sl@0: CAgentInfo &defaultAgentInfo = iResolver->AgentInfoL(iResolver->DefaultAgentUid()); sl@0: err = defaultAgentInfo.AgentManagerL().SetProperty(aProperty, aValue); sl@0: if(err == KErrNoMemory) sl@0: { sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: // Ignore F32 agent return code unless it's KErrNoMemory sl@0: err= KErrNone; sl@0: sl@0: // Set the property in all the other agents sl@0: for( i = 0; i < count; i++) sl@0: { sl@0: CAgentInfo& agentInfo = iResolver->AgentInfo(i); sl@0: err = agentInfo.AgentManagerL().SetProperty(aProperty, aValue); sl@0: if(err == KErrNoMemory) sl@0: { sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: // If an error occurred and no previous error has occured sl@0: if(err != KErrNone && rVal == KErrNone) sl@0: { sl@0: rVal = err; sl@0: } sl@0: } sl@0: sl@0: // leave if an error occurred in any agent sl@0: User::LeaveIfError(rVal); sl@0: } sl@0: sl@0: EXPORT_C void CManager::DisplayInfoL(TDisplayInfo aInfo, const TVirtualPathPtr& aVirtualPath) sl@0: { sl@0: HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); sl@0: TPtr uri = uriBuffer->Des(); sl@0: sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(), uri, EContentShareReadOnly); sl@0: sl@0: // find out the attribute sl@0: agentInfo.AgentManagerL().DisplayInfoL(aInfo, TVirtualPathPtr(uri, aVirtualPath.UniqueId())); sl@0: CleanupStack::PopAndDestroy(uriBuffer); sl@0: } sl@0: sl@0: EXPORT_C void CManager::DisplayInfoL(TDisplayInfo aInfo, RFile& aFile, const TDesC& aUniqueId) sl@0: { sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile); sl@0: // find out the attribute sl@0: agentInfo.AgentManagerL().DisplayInfoL(aInfo, aFile, aUniqueId); sl@0: } sl@0: sl@0: EXPORT_C void CManager::ListAgentsL (RArray & aAgents) sl@0: { sl@0: TInt i = 0; sl@0: TBuf agentName; sl@0: TInt count = iResolver->AgentInfoCount(); sl@0: sl@0: // build the array of pointers from CAgentResolver sl@0: for(i = 0; i < count; i++) sl@0: { sl@0: TAgent agent = iResolver->AgentInfo(i).Agent(); sl@0: User::LeaveIfError(aAgents.Append(agent)); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::AgentSpecificCommand (TAgent &aAgent, TInt aCommand, const TDesC8 &aInputBuffer, TDes8 &aOutputBuffer) sl@0: { sl@0: CAgentManager* manager = NULL; sl@0: TInt err = KErrNone; sl@0: TRAP(err, manager = &iResolver->AgentInfoL(aAgent.ImplementationUid()).AgentManagerL()); sl@0: if(err == KErrNone) sl@0: { sl@0: err = manager->AgentSpecificCommand (aCommand, aInputBuffer, aOutputBuffer); sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: EXPORT_C void CManager::AgentSpecificCommand (TAgent &aAgent, TInt aCommand, const TDesC8 &aInputBuffer, TDes8 &aOutputBuffer, TRequestStatus &aStatus) sl@0: { sl@0: CAgentManager* manager = NULL; sl@0: sl@0: TRAPD(err, manager = &iResolver->AgentInfoL(aAgent.ImplementationUid()).AgentManagerL()); sl@0: if(err == KErrNone) sl@0: { sl@0: manager->AgentSpecificCommand (aCommand, aInputBuffer, aOutputBuffer, aStatus); sl@0: } sl@0: else sl@0: { sl@0: TRequestStatus* status = &aStatus; sl@0: User::RequestComplete(status, err); sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void CManager::DisplayManagementInfoL(TAgent& aAgent) sl@0: { sl@0: CAgentInfo& agentInfo = iResolver->AgentInfoL(aAgent.ImplementationUid()); sl@0: sl@0: // Ask agent to display management info sl@0: agentInfo.AgentManagerL().DisplayManagementInfoL(); sl@0: } sl@0: sl@0: EXPORT_C CRightsManager* CManager::CreateRightsManagerL(TAgent& aAgent) const sl@0: { sl@0: // Create a rights manager sl@0: return CRightsManager::NewL(aAgent.ImplementationUid()); sl@0: } sl@0: sl@0: void CManager::GetListOfAgentPrivateDirectoriesL(CDir *&aDir) const sl@0: { sl@0: CDirStreamable *ptr = NULL; sl@0: // fill in the agent directories under the \\private\\ directory sl@0: TInt i = 0; sl@0: TInt count = iResolver->AgentInfoCount(); sl@0: sl@0: TBuf agentName; sl@0: TPath privateDirectory; sl@0: sl@0: // Create CDirStreamable object sl@0: ptr = CDirStreamable::NewL(); sl@0: CleanupStack::PushL(ptr); sl@0: sl@0: // set aDir to point to the CDirStreamable we just created sl@0: for(i = 0; i < count; i++) sl@0: { sl@0: // only fill in the agents that have a private directory that is not blank sl@0: if(iResolver->AgentInfo(i).PrivateDirectoryName().Length() != 0) sl@0: { sl@0: TEntry aEntry; sl@0: aEntry.iName = iResolver->AgentInfo(i).Agent().Name(); sl@0: aEntry.iAtt = KEntryAttDir; sl@0: aEntry.iType = TUidType(); sl@0: aEntry.iSize = 0; sl@0: ptr->AddL(aEntry); sl@0: } sl@0: } sl@0: CleanupStack::Pop(ptr); sl@0: aDir = ptr; sl@0: } sl@0: sl@0: #ifndef REMOVE_CAF1 sl@0: EXPORT_C void CManager::DeleteFileL(const TDesC &aFileName) sl@0: { sl@0: CManager *m = CManager::NewLC(); sl@0: User::LeaveIfError(m->DeleteFile(aFileName)); sl@0: CleanupStack::PopAndDestroy(m); sl@0: } sl@0: #endif // REMOVE_CAF1 sl@0: sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: EXPORT_C TInt CManager::GetAttribute(const TDesC8& aHeaderData, TInt aAttribute, TInt& aValue) const sl@0: { sl@0: TRAPD(err, DoGetAttributeL(aHeaderData, aAttribute, aValue)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetAttributeL(const TDesC8& aHeaderData, TInt aAttribute, TInt& aValue) const sl@0: { sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aHeaderData); sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetAttribute(aHeaderData, aAttribute, aValue)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetAttributeSet(const TDesC8& aHeaderData, RAttributeSet& aAttributeSet) const sl@0: { sl@0: TRAPD(err, DoGetAttributeSetL(aHeaderData, aAttributeSet)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetAttributeSetL(const TDesC8& aHeaderData, RAttributeSet& aAttributeSet) const sl@0: { sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aHeaderData); sl@0: sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetAttributeSet(aHeaderData, aAttributeSet)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetStringAttribute(const TDesC8& aHeaderData, TInt aAttribute, TDes& aValue) const sl@0: { sl@0: TRAPD(err, DoGetStringAttributeL(aHeaderData, aAttribute, aValue)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetStringAttributeL(const TDesC8& aHeaderData, TInt aAttribute, TDes& aValue) const sl@0: { sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aHeaderData); sl@0: sl@0: // find out the attribute sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttribute(aHeaderData, aAttribute, aValue)); sl@0: } sl@0: sl@0: EXPORT_C TInt CManager::GetStringAttributeSet(const TDesC8& aHeaderData, RStringAttributeSet& aStringAttributeSet) const sl@0: { sl@0: TRAPD(err, DoGetStringAttributeSetL(aHeaderData, aStringAttributeSet)); sl@0: return err; sl@0: } sl@0: sl@0: void CManager::DoGetStringAttributeSetL(const TDesC8& aHeaderData, RStringAttributeSet& aStringAttributeSet) const sl@0: { sl@0: // Find the agent who handles the file sl@0: CAgentInfo& agentInfo = iResolver->ResolveFileL(aHeaderData); sl@0: sl@0: // find out the array of attributes sl@0: User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttributeSet(aHeaderData, aStringAttributeSet)); sl@0: } sl@0: sl@0: #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT