1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/contentmgmt/contentaccessfwfordrm/source/caf/manager.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,765 @@
1.4 +/*
1.5 +* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +#include <caf/manager.h>
1.23 +#include <caf/agentinterface.h>
1.24 +#include <caf/agent.h>
1.25 +#include "agentinfo.h"
1.26 +#include <caf/agentfactory.h>
1.27 +#include <caf/attributeset.h>
1.28 +#include <caf/caftypes.h>
1.29 +#include <caf/caferr.h>
1.30 +#include <caf/virtualpath.h>
1.31 +#include <caf/dirstreamable.h>
1.32 +#include <caf/rightsmanager.h>
1.33 +#include <caf/cafpanic.h>
1.34 +#include "resolver.h"
1.35 +
1.36 +using namespace ContentAccess;
1.37 +
1.38 +EXPORT_C CManager* CManager::NewL()
1.39 + {
1.40 + CManager* self = CManager::NewLC();
1.41 + CleanupStack::Pop(self);
1.42 + return self;
1.43 + }
1.44 +
1.45 +EXPORT_C CManager* CManager::NewLC()
1.46 + {
1.47 + CManager* self = new (ELeave) CManager;
1.48 + CleanupStack::PushL(self);
1.49 + self->ConstructL();
1.50 + return self;
1.51 + }
1.52 +
1.53 +CManager::CManager()
1.54 + {
1.55 + }
1.56 +
1.57 +CManager::~CManager()
1.58 + {
1.59 + delete iResolver;
1.60 + }
1.61 +
1.62 +void CManager::ConstructL()
1.63 + {
1.64 + iResolver = CAgentResolver::NewL(EFalse);
1.65 + }
1.66 +
1.67 +EXPORT_C TInt CManager::DeleteFile(const TDesC &aFileName) const
1.68 + {
1.69 + TRAPD(err, DoDeleteFileL(aFileName));
1.70 + return err;
1.71 + }
1.72 +
1.73 +void CManager::DoDeleteFileL(const TDesC &aFileName) const
1.74 + {
1.75 + TFileName actualFileName;
1.76 +
1.77 + // initalise a pointer to the relevant CAgentManager object
1.78 + // iResolver retains ownership of the pointer
1.79 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aFileName, actualFileName, EContentShareReadOnly);
1.80 +
1.81 + User::LeaveIfError(agentInfo.AgentManagerL().DeleteFile(actualFileName));
1.82 + }
1.83 +
1.84 +EXPORT_C TInt CManager::CopyFile(RFile& aSourceFile, const TDesC &aDestination) const
1.85 + {
1.86 + TRAPD(err, DoCopyFileL(aSourceFile, aDestination));
1.87 + return err;
1.88 + }
1.89 +
1.90 +void CManager::DoCopyFileL(RFile& aSourceFile, const TDesC &aDestination) const
1.91 + {
1.92 + TFileName actualDestination;
1.93 + TBool thePrivateDir = EFalse;
1.94 + TUid agentUid = KNullUid;
1.95 +
1.96 + // Find out which agent owns the directory where the destination file lives
1.97 + TUid destinationAgentUid = iResolver->ResolveDirectory(aDestination, actualDestination, thePrivateDir);
1.98 +
1.99 + if(destinationAgentUid != iResolver->DefaultAgentUid())
1.100 + {
1.101 + // Destination file is in an agent private directory
1.102 + // Use destination agent to copy
1.103 + agentUid = destinationAgentUid;
1.104 + }
1.105 + else
1.106 + {
1.107 + // Use RFile version of ResolveFileL to find the Agent Uid
1.108 + agentUid = iResolver->ResolveFileL(aSourceFile).Agent().ImplementationUid();
1.109 + }
1.110 +
1.111 + // If creating the appropriate CAgentManager succeeded ask the agent to copy the file
1.112 + User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().CopyFile(aSourceFile, actualDestination));
1.113 + }
1.114 +
1.115 +EXPORT_C TInt CManager::CopyFile(const TDesC &aSource, const TDesC &aDestination) const
1.116 + {
1.117 + TRAPD(err, DoCopyFileL(aSource, aDestination));
1.118 + return err;
1.119 + }
1.120 +
1.121 +void CManager::DoCopyFileL(const TDesC &aSource, const TDesC &aDestination) const
1.122 + {
1.123 + TFileName actualSource;
1.124 + TFileName actualDestination;
1.125 + TBool thePrivateDir = EFalse;
1.126 + TUid agentUid = KNullUid;
1.127 +
1.128 + // Find out which agent owns the directory where the source file lives
1.129 + TUid sourceAgentUid = iResolver->ResolveDirectory(aSource, actualSource, thePrivateDir);
1.130 +
1.131 + // Find out which agent owns the directory where the destination file lives
1.132 + TUid destinationAgentUid = iResolver->ResolveDirectory(aDestination, actualDestination, thePrivateDir);
1.133 +
1.134 + if(sourceAgentUid != iResolver->DefaultAgentUid())
1.135 + {
1.136 + // Source file is in an agent private directory
1.137 + // Use source agent to copy
1.138 + agentUid = sourceAgentUid;
1.139 + }
1.140 + else if(destinationAgentUid != iResolver->DefaultAgentUid())
1.141 + {
1.142 + // Destination file is in an agent private directory
1.143 + // Use destination agent to copy
1.144 + agentUid = destinationAgentUid;
1.145 + }
1.146 + else
1.147 + {
1.148 + // Source and destination are in publicly accessable directories
1.149 + agentUid = iResolver->ResolveFileL(aSource, actualSource, EContentShareReadOnly).Agent().ImplementationUid();
1.150 + }
1.151 +
1.152 + // If creating the appropriate CAgentManager succeeded ask the agent to copy the file
1.153 + User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().CopyFile(actualSource, actualDestination));
1.154 + }
1.155 +
1.156 +EXPORT_C TInt CManager::RenameFile(const TDesC& aSource, const TDesC& aDestination) const
1.157 + {
1.158 + TRAPD(err, DoRenameFileL(aSource, aDestination));
1.159 + return err;
1.160 + }
1.161 +
1.162 +void CManager::DoRenameFileL(const TDesC& aSource, const TDesC& aDestination) const
1.163 + {
1.164 + TFileName actualSource;
1.165 + TFileName actualDestination;
1.166 + TBool thePrivateDir = EFalse;
1.167 + TUid agentUid = KNullUid;
1.168 +
1.169 + // Find out which agent owns the directory where the source file lives
1.170 + TUid sourceAgentUid = iResolver->ResolveDirectory(aSource, actualSource, thePrivateDir);
1.171 +
1.172 + // Find out which agent owns the directory where the destination file lives
1.173 + TUid destinationAgentUid = iResolver->ResolveDirectory(aDestination, actualDestination, thePrivateDir);
1.174 +
1.175 + if(sourceAgentUid != iResolver->DefaultAgentUid())
1.176 + {
1.177 + // Source file is in an agent private directory
1.178 + // Use source agent to copy
1.179 + agentUid = sourceAgentUid;
1.180 + }
1.181 + else if(destinationAgentUid != iResolver->DefaultAgentUid())
1.182 + {
1.183 + // Destination file is in an agent private directory
1.184 + // Use destination agent to copy
1.185 + agentUid = destinationAgentUid;
1.186 + }
1.187 + else
1.188 + {
1.189 + // Source and destination are in publicly accessable directories
1.190 + agentUid = iResolver->ResolveFileL(aSource, actualSource, EContentShareReadOnly).Agent().ImplementationUid();
1.191 + }
1.192 +
1.193 + // Ask the agent to move or rename the file
1.194 + User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().RenameFile(actualSource, actualDestination));
1.195 + }
1.196 +
1.197 +EXPORT_C TInt CManager::MkDir(const TDesC &aPath) const
1.198 + {
1.199 + TRAPD(err, DoMkDirL(aPath));
1.200 +
1.201 + return err;
1.202 + }
1.203 +
1.204 +void CManager::DoMkDirL(const TDesC &aPath) const
1.205 + {
1.206 + TBool isThePrivateDir = EFalse;
1.207 + TFileName actualPath;
1.208 +
1.209 + // Figure out which agent handles the directory
1.210 + TUid uid = iResolver->ResolveDirectory(aPath, actualPath, isThePrivateDir);
1.211 +
1.212 + User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().MkDir(actualPath));
1.213 + }
1.214 +
1.215 +EXPORT_C TInt CManager::MkDirAll (const TDesC &aPath) const
1.216 + {
1.217 + TRAPD(err, DoMkDirAllL(aPath));
1.218 + return err;
1.219 + }
1.220 +
1.221 +void CManager::DoMkDirAllL(const TDesC &aPath) const
1.222 + {
1.223 + TBool isThePrivateDir = EFalse;
1.224 + TFileName actualPath;
1.225 +
1.226 + // Figure out which agent handles the directory
1.227 + TUid uid = iResolver->ResolveDirectory(aPath, actualPath, isThePrivateDir);
1.228 +
1.229 + User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().MkDirAll(actualPath));
1.230 + }
1.231 +
1.232 +EXPORT_C TInt CManager::RmDir(const TDesC &aPath) const
1.233 + {
1.234 + TRAPD(err, DoRmDirL(aPath));
1.235 + return err;
1.236 + }
1.237 +
1.238 +void CManager::DoRmDirL(const TDesC &aPath) const
1.239 + {
1.240 + TBool isThePrivateDir = EFalse;
1.241 + TFileName actualPath;
1.242 +
1.243 + // Figure out which agent handles the directory
1.244 + TUid uid = iResolver->ResolveDirectory(aPath, actualPath, isThePrivateDir);
1.245 +
1.246 + if(isThePrivateDir)
1.247 + {
1.248 + User::Leave(KErrAccessDenied);
1.249 + }
1.250 + else
1.251 + {
1.252 + User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().RmDir(actualPath));
1.253 + }
1.254 + }
1.255 +
1.256 +EXPORT_C TInt CManager::RenameDir(const TDesC& aOldName, const TDesC& aNewName) const
1.257 + {
1.258 + TRAPD(err, DoRenameDirL(aOldName, aNewName));
1.259 + return err;
1.260 + }
1.261 +
1.262 +void CManager::DoRenameDirL(const TDesC &aOldName, const TDesC& aNewName) const
1.263 + {
1.264 + TPath actualSource;
1.265 + TPath actualDestination;
1.266 + TBool thePrivateDir = EFalse;
1.267 + TUid agentUid = iResolver->DefaultAgentUid();
1.268 +
1.269 + // Find out which agent owns the directory where the source file lives
1.270 + TUid sourceAgentUid = iResolver->ResolveDirectory(aOldName, actualSource, thePrivateDir);
1.271 +
1.272 + // Find out which agent owns the directory where the destination file lives
1.273 + TUid destinationAgentUid = iResolver->ResolveDirectory(aNewName, actualDestination, thePrivateDir);
1.274 +
1.275 + if(sourceAgentUid != iResolver->DefaultAgentUid())
1.276 + {
1.277 + // Source file is in an agent private directory
1.278 + // Use source agent to copy
1.279 + agentUid = sourceAgentUid;
1.280 + }
1.281 + else if(destinationAgentUid != iResolver->DefaultAgentUid())
1.282 + {
1.283 + // Destination file is in an agent private directory
1.284 + // Use destination agent to copy
1.285 + agentUid = destinationAgentUid;
1.286 + }
1.287 +
1.288 + // Ask the agent to move or rename the file
1.289 + User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().RenameDir(actualSource, actualDestination));
1.290 + }
1.291 +
1.292 +
1.293 +EXPORT_C TInt CManager::GetDir(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList) const
1.294 + {
1.295 + TRAPD(err, DoGetDirL(aName, aEntryAttMask, aEntrySortKey, aEntryList));
1.296 + return err;
1.297 + }
1.298 +
1.299 +void CManager::DoGetDirL(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList) const
1.300 + {
1.301 + TBool isThePrivateDir = EFalse;
1.302 + TFileName actualPath;
1.303 +
1.304 + // Figure out which agent handles the directory
1.305 + TUid uid = iResolver->ResolveDirectory(aName, actualPath, isThePrivateDir);
1.306 +
1.307 + if(isThePrivateDir)
1.308 + {
1.309 + // If we are doing GetDir of C:\\private\\ just create an empty CDirStreamable
1.310 + aEntryList = CDirStreamable::NewL();
1.311 + }
1.312 + else
1.313 + {
1.314 + User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().GetDir(actualPath, aEntryAttMask, aEntrySortKey, aEntryList));
1.315 + }
1.316 + }
1.317 +
1.318 +EXPORT_C TInt CManager::GetDir(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList, CDir *&aDirList) const
1.319 + {
1.320 + TRAPD(err, DoGetDirL(aName, aEntryAttMask, aEntrySortKey, aEntryList, aDirList));
1.321 + return err;
1.322 + }
1.323 +
1.324 +void CManager::DoGetDirL(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList, CDir *&aDirList) const
1.325 + {
1.326 + TBool isThePrivateDir = EFalse;
1.327 + TFileName actualPath;
1.328 + CDir* emptyDirList;
1.329 +
1.330 + // Figure out which agent handles the directory
1.331 + TUid uid = iResolver->ResolveDirectory(aName, actualPath, isThePrivateDir);
1.332 +
1.333 + if(isThePrivateDir)
1.334 + {
1.335 + // If we are doing GetDir of C:\\private\\ just create an empty entryList
1.336 + emptyDirList = CDirStreamable::NewL();
1.337 + CleanupStack::PushL(emptyDirList);
1.338 +
1.339 + GetListOfAgentPrivateDirectoriesL(aDirList);
1.340 +
1.341 + CleanupStack::Pop(emptyDirList);
1.342 + aEntryList = emptyDirList;
1.343 + }
1.344 + else
1.345 + {
1.346 + User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().GetDir(actualPath, aEntryAttMask, aEntrySortKey, aEntryList, aDirList));
1.347 + }
1.348 + }
1.349 +
1.350 +EXPORT_C TInt CManager::GetDir(const TDesC &aName, const TUidType &aEntryUid, TUint aEntrySortKey, CDir *&aFileList) const
1.351 + {
1.352 + TRAPD(err, DoGetDirL(aName, aEntryUid, aEntrySortKey, aFileList));
1.353 + return err;
1.354 + }
1.355 +
1.356 +void CManager::DoGetDirL(const TDesC &aName, const TUidType &aEntryUid, TUint aEntrySortKey, CDir *&aFileList) const
1.357 + {
1.358 + TBool isThePrivateDir = EFalse;
1.359 + TFileName actualPath;
1.360 +
1.361 + // Figure out which agent handles the directory
1.362 + TUid uid = iResolver->ResolveDirectory(aName, actualPath, isThePrivateDir);
1.363 +
1.364 + if(isThePrivateDir)
1.365 + {
1.366 + // We've been asked to look at C:\\private\\ just return an empty CDirStreamable
1.367 + aFileList = CDirStreamable::NewL();
1.368 + }
1.369 + else
1.370 + {
1.371 + User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().GetDir(actualPath, aEntryUid, aEntrySortKey, aFileList));
1.372 + }
1.373 + }
1.374 +
1.375 +EXPORT_C TInt CManager::GetAttribute(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath) const
1.376 + {
1.377 + TRAPD(err, DoGetAttributeL(aAttribute, aValue, aVirtualPath));
1.378 + return err;
1.379 + }
1.380 +
1.381 +void CManager::DoGetAttributeL(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath) const
1.382 + {
1.383 + HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength);
1.384 + TPtr uri = uriBuffer->Des();
1.385 +
1.386 + // Find the agent who handles the file
1.387 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(),uri, EContentShareReadOnly);
1.388 + User::LeaveIfError(agentInfo.AgentManagerL().GetAttribute(aAttribute, aValue, TVirtualPathPtr(uri, aVirtualPath.UniqueId())));
1.389 + CleanupStack::PopAndDestroy(uriBuffer);
1.390 + }
1.391 +
1.392 +EXPORT_C TInt CManager::GetAttribute(TInt aAttribute, TInt& aValue, RFile& aFile, const TDesC& aUniqueId)
1.393 + {
1.394 + TRAPD(err, DoGetAttributeL(aAttribute, aValue, aFile, aUniqueId));
1.395 + return err;
1.396 + }
1.397 +
1.398 +void CManager::DoGetAttributeL(TInt aAttribute, TInt& aValue, RFile& aFile, const TDesC& aUniqueId) const
1.399 + {
1.400 + // Find the agent who handles the file
1.401 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile);
1.402 + User::LeaveIfError(agentInfo.AgentManagerL().GetAttribute(aAttribute, aValue, aFile, aUniqueId));
1.403 + }
1.404 +
1.405 +
1.406 +EXPORT_C TInt CManager::GetStringAttribute(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath) const
1.407 + {
1.408 + TRAPD(err, DoGetStringAttributeL(aAttribute, aValue, aVirtualPath));
1.409 + return err;
1.410 + }
1.411 +
1.412 +void CManager::DoGetStringAttributeL(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath) const
1.413 + {
1.414 + HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength);
1.415 + TPtr uri = uriBuffer->Des();
1.416 +
1.417 +
1.418 + // Find the agent who handles the file
1.419 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(), uri, EContentShareReadOnly);
1.420 +
1.421 + // find out the attribute
1.422 + User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttribute(aAttribute, aValue, TVirtualPathPtr(uri,aVirtualPath.UniqueId())));
1.423 + CleanupStack::PopAndDestroy(uriBuffer);
1.424 + }
1.425 +
1.426 +EXPORT_C TInt CManager::GetStringAttribute (TInt aAttribute, TDes& aValue, RFile& aFile, const TDesC& aUniqueId)
1.427 + {
1.428 + TRAPD(err, DoGetStringAttributeL(aAttribute, aValue, aFile, aUniqueId));
1.429 + return err;
1.430 + }
1.431 +
1.432 +void CManager::DoGetStringAttributeL(TInt aAttribute, TDes& aValue, RFile& aFile, const TDesC& aUniqueId) const
1.433 + {
1.434 + // Find the agent who handles the file
1.435 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile);
1.436 + // find out the attribute
1.437 + User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttribute(aAttribute, aValue, aFile, aUniqueId));
1.438 + }
1.439 +
1.440 +EXPORT_C TInt CManager::GetAttributeSet(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath) const
1.441 + {
1.442 + TRAPD(err, DoGetAttributeSetL(aAttributeSet, aVirtualPath));
1.443 + return err;
1.444 + }
1.445 +
1.446 +void CManager::DoGetAttributeSetL(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath) const
1.447 + {
1.448 + HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength);
1.449 + TPtr uri = uriBuffer->Des();
1.450 +
1.451 + // Find the agent who handles the file
1.452 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(), uri, EContentShareReadOnly);
1.453 +
1.454 + User::LeaveIfError(agentInfo.AgentManagerL().GetAttributeSet(aAttributeSet, TVirtualPathPtr(uri, aVirtualPath.UniqueId())));
1.455 + CleanupStack::PopAndDestroy(uriBuffer);
1.456 + }
1.457 +
1.458 +EXPORT_C TInt CManager::GetAttributeSet (RAttributeSet& aAttributeSet, RFile& aFile, const TDesC& aUniqueId)
1.459 + {
1.460 + TRAPD(err, DoGetAttributeSetL(aAttributeSet, aFile, aUniqueId));
1.461 + return err;
1.462 + }
1.463 +
1.464 +void CManager::DoGetAttributeSetL(RAttributeSet& aAttributeSet, RFile& aFile, const TDesC& aUniqueId) const
1.465 + {
1.466 + // Find the agent who handles the file
1.467 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile);
1.468 + User::LeaveIfError(agentInfo.AgentManagerL().GetAttributeSet(aAttributeSet, aFile, aUniqueId));
1.469 + }
1.470 +
1.471 +EXPORT_C TInt CManager::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, const TVirtualPathPtr& aVirtualPath) const
1.472 + {
1.473 + TRAPD(err, DoGetStringAttributeSetL(aStringAttributeSet, aVirtualPath));
1.474 + return err;
1.475 + }
1.476 +
1.477 +void CManager::DoGetStringAttributeSetL(RStringAttributeSet& aStringAttributeSet, const TVirtualPathPtr& aVirtualPath) const
1.478 + {
1.479 + HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength);
1.480 + TPtr uri = uriBuffer->Des();
1.481 +
1.482 + // Find the agent who handles the file
1.483 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(),uri, EContentShareReadOnly);
1.484 +
1.485 + // find out the array of attributes
1.486 + User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttributeSet(aStringAttributeSet, TVirtualPathPtr(uri, aVirtualPath.UniqueId())));
1.487 + CleanupStack::PopAndDestroy(uriBuffer);
1.488 + }
1.489 +
1.490 +EXPORT_C TInt CManager::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, RFile& aFile, const TDesC& aUniqueId)
1.491 + {
1.492 + TRAPD(err, DoGetStringAttributeSetL(aStringAttributeSet, aFile, aUniqueId));
1.493 + return err;
1.494 + }
1.495 +
1.496 +void CManager::DoGetStringAttributeSetL(RStringAttributeSet& aStringAttributeSet, RFile& aFile, const TDesC& aUniqueId) const
1.497 + {
1.498 + // Find the agent who handles the file
1.499 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile);
1.500 + // find out the array of attributes
1.501 + User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttributeSet(aStringAttributeSet, aFile, aUniqueId));
1.502 + }
1.503 +
1.504 +EXPORT_C void CManager::NotifyStatusChange(const TDesC &aURI, TEventMask aMask, TRequestStatus &aStatus)
1.505 + {
1.506 + TRAPD(err, DoNotifyStatusChangeL(aURI, aMask, aStatus));
1.507 + if(err != KErrNone)
1.508 + {
1.509 + // Must have failed before asking the agent for status
1.510 + TRequestStatus* status = &aStatus;
1.511 + User::RequestComplete(status, err);
1.512 + }
1.513 + }
1.514 +
1.515 +void CManager::DoNotifyStatusChangeL(const TDesC &aURI, TEventMask aMask, TRequestStatus &aStatus)
1.516 + {
1.517 + HBufC* uriBuffer = HBufC::NewLC(aURI.Length() + KMaxSIDLength);
1.518 + TPtr uri = uriBuffer->Des();
1.519 +
1.520 + // Find the agent who handles the file
1.521 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aURI, uri, EContentShareReadOnly);
1.522 +
1.523 + // Ask the agent to notifiy the client when the status of the given file changes
1.524 + agentInfo.AgentManagerL().NotifyStatusChange(uri, aMask, aStatus);
1.525 + CleanupStack::PopAndDestroy(uriBuffer);
1.526 + }
1.527 +
1.528 +EXPORT_C TInt CManager::CancelNotifyStatusChange (const TDesC &aURI, TRequestStatus &aStatus)
1.529 + {
1.530 + TRAPD(err, DoCancelNotifyStatusChangeL(aURI, aStatus));
1.531 + return err;
1.532 + }
1.533 +
1.534 +void CManager::DoCancelNotifyStatusChangeL(const TDesC &aURI, TRequestStatus &aStatus)
1.535 + {
1.536 + HBufC* uriBuffer = HBufC::NewLC(aURI.Length() + KMaxSIDLength);
1.537 + TPtr uri = uriBuffer->Des();
1.538 +
1.539 + // Find the agent who handles the file
1.540 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aURI, uri, EContentShareReadOnly);
1.541 +
1.542 + // cancel the notification request
1.543 + User::LeaveIfError(agentInfo.AgentManagerL().CancelNotifyStatusChange(uri, aStatus));
1.544 + CleanupStack::PopAndDestroy(uriBuffer);
1.545 + }
1.546 +
1.547 +EXPORT_C TInt CManager::SetProperty(TAgentProperty aProperty, TInt aValue)
1.548 + {
1.549 + TRAPD(err, DoSetPropertyL(aProperty, aValue));
1.550 + return err;
1.551 + }
1.552 +
1.553 +void CManager::DoSetPropertyL(TAgentProperty aProperty, TInt aValue)
1.554 + {
1.555 + TInt err = KErrNone;
1.556 + TInt rVal = KErrNone;
1.557 + TInt i = 0;
1.558 + TInt count = iResolver->AgentInfoCount();
1.559 +
1.560 + CAgentInfo &defaultAgentInfo = iResolver->AgentInfoL(iResolver->DefaultAgentUid());
1.561 + err = defaultAgentInfo.AgentManagerL().SetProperty(aProperty, aValue);
1.562 + if(err == KErrNoMemory)
1.563 + {
1.564 + User::Leave(KErrNoMemory);
1.565 + }
1.566 +
1.567 + // Ignore F32 agent return code unless it's KErrNoMemory
1.568 + err= KErrNone;
1.569 +
1.570 + // Set the property in all the other agents
1.571 + for( i = 0; i < count; i++)
1.572 + {
1.573 + CAgentInfo& agentInfo = iResolver->AgentInfo(i);
1.574 + err = agentInfo.AgentManagerL().SetProperty(aProperty, aValue);
1.575 + if(err == KErrNoMemory)
1.576 + {
1.577 + User::Leave(KErrNoMemory);
1.578 + }
1.579 +
1.580 + // If an error occurred and no previous error has occured
1.581 + if(err != KErrNone && rVal == KErrNone)
1.582 + {
1.583 + rVal = err;
1.584 + }
1.585 + }
1.586 +
1.587 + // leave if an error occurred in any agent
1.588 + User::LeaveIfError(rVal);
1.589 + }
1.590 +
1.591 +EXPORT_C void CManager::DisplayInfoL(TDisplayInfo aInfo, const TVirtualPathPtr& aVirtualPath)
1.592 + {
1.593 + HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength);
1.594 + TPtr uri = uriBuffer->Des();
1.595 +
1.596 + // Find the agent who handles the file
1.597 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(), uri, EContentShareReadOnly);
1.598 +
1.599 + // find out the attribute
1.600 + agentInfo.AgentManagerL().DisplayInfoL(aInfo, TVirtualPathPtr(uri, aVirtualPath.UniqueId()));
1.601 + CleanupStack::PopAndDestroy(uriBuffer);
1.602 + }
1.603 +
1.604 +EXPORT_C void CManager::DisplayInfoL(TDisplayInfo aInfo, RFile& aFile, const TDesC& aUniqueId)
1.605 + {
1.606 + // Find the agent who handles the file
1.607 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aFile);
1.608 + // find out the attribute
1.609 + agentInfo.AgentManagerL().DisplayInfoL(aInfo, aFile, aUniqueId);
1.610 + }
1.611 +
1.612 +EXPORT_C void CManager::ListAgentsL (RArray <TAgent>& aAgents)
1.613 + {
1.614 + TInt i = 0;
1.615 + TBuf <KMaxAgentNameLength> agentName;
1.616 + TInt count = iResolver->AgentInfoCount();
1.617 +
1.618 + // build the array of pointers from CAgentResolver
1.619 + for(i = 0; i < count; i++)
1.620 + {
1.621 + TAgent agent = iResolver->AgentInfo(i).Agent();
1.622 + User::LeaveIfError(aAgents.Append(agent));
1.623 + }
1.624 + }
1.625 +
1.626 +EXPORT_C TInt CManager::AgentSpecificCommand (TAgent &aAgent, TInt aCommand, const TDesC8 &aInputBuffer, TDes8 &aOutputBuffer)
1.627 + {
1.628 + CAgentManager* manager = NULL;
1.629 + TInt err = KErrNone;
1.630 + TRAP(err, manager = &iResolver->AgentInfoL(aAgent.ImplementationUid()).AgentManagerL());
1.631 + if(err == KErrNone)
1.632 + {
1.633 + err = manager->AgentSpecificCommand (aCommand, aInputBuffer, aOutputBuffer);
1.634 + }
1.635 + return err;
1.636 + }
1.637 +
1.638 +EXPORT_C void CManager::AgentSpecificCommand (TAgent &aAgent, TInt aCommand, const TDesC8 &aInputBuffer, TDes8 &aOutputBuffer, TRequestStatus &aStatus)
1.639 + {
1.640 + CAgentManager* manager = NULL;
1.641 +
1.642 + TRAPD(err, manager = &iResolver->AgentInfoL(aAgent.ImplementationUid()).AgentManagerL());
1.643 + if(err == KErrNone)
1.644 + {
1.645 + manager->AgentSpecificCommand (aCommand, aInputBuffer, aOutputBuffer, aStatus);
1.646 + }
1.647 + else
1.648 + {
1.649 + TRequestStatus* status = &aStatus;
1.650 + User::RequestComplete(status, err);
1.651 + }
1.652 + }
1.653 +
1.654 +EXPORT_C void CManager::DisplayManagementInfoL(TAgent& aAgent)
1.655 + {
1.656 + CAgentInfo& agentInfo = iResolver->AgentInfoL(aAgent.ImplementationUid());
1.657 +
1.658 + // Ask agent to display management info
1.659 + agentInfo.AgentManagerL().DisplayManagementInfoL();
1.660 + }
1.661 +
1.662 +EXPORT_C CRightsManager* CManager::CreateRightsManagerL(TAgent& aAgent) const
1.663 + {
1.664 + // Create a rights manager
1.665 + return CRightsManager::NewL(aAgent.ImplementationUid());
1.666 + }
1.667 +
1.668 +void CManager::GetListOfAgentPrivateDirectoriesL(CDir *&aDir) const
1.669 + {
1.670 + CDirStreamable *ptr = NULL;
1.671 + // fill in the agent directories under the \\private\\ directory
1.672 + TInt i = 0;
1.673 + TInt count = iResolver->AgentInfoCount();
1.674 +
1.675 + TBuf <KMaxAgentNameLength> agentName;
1.676 + TPath privateDirectory;
1.677 +
1.678 + // Create CDirStreamable object
1.679 + ptr = CDirStreamable::NewL();
1.680 + CleanupStack::PushL(ptr);
1.681 +
1.682 + // set aDir to point to the CDirStreamable we just created
1.683 + for(i = 0; i < count; i++)
1.684 + {
1.685 + // only fill in the agents that have a private directory that is not blank
1.686 + if(iResolver->AgentInfo(i).PrivateDirectoryName().Length() != 0)
1.687 + {
1.688 + TEntry aEntry;
1.689 + aEntry.iName = iResolver->AgentInfo(i).Agent().Name();
1.690 + aEntry.iAtt = KEntryAttDir;
1.691 + aEntry.iType = TUidType();
1.692 + aEntry.iSize = 0;
1.693 + ptr->AddL(aEntry);
1.694 + }
1.695 + }
1.696 + CleanupStack::Pop(ptr);
1.697 + aDir = ptr;
1.698 + }
1.699 +
1.700 +#ifndef REMOVE_CAF1
1.701 +EXPORT_C void CManager::DeleteFileL(const TDesC &aFileName)
1.702 + {
1.703 + CManager *m = CManager::NewLC();
1.704 + User::LeaveIfError(m->DeleteFile(aFileName));
1.705 + CleanupStack::PopAndDestroy(m);
1.706 + }
1.707 +#endif // REMOVE_CAF1
1.708 +
1.709 +#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
1.710 +
1.711 +EXPORT_C TInt CManager::GetAttribute(const TDesC8& aHeaderData, TInt aAttribute, TInt& aValue) const
1.712 + {
1.713 + TRAPD(err, DoGetAttributeL(aHeaderData, aAttribute, aValue));
1.714 + return err;
1.715 + }
1.716 +
1.717 +void CManager::DoGetAttributeL(const TDesC8& aHeaderData, TInt aAttribute, TInt& aValue) const
1.718 + {
1.719 + // Find the agent who handles the file
1.720 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aHeaderData);
1.721 + User::LeaveIfError(agentInfo.AgentManagerL().GetAttribute(aHeaderData, aAttribute, aValue));
1.722 + }
1.723 +
1.724 +EXPORT_C TInt CManager::GetAttributeSet(const TDesC8& aHeaderData, RAttributeSet& aAttributeSet) const
1.725 + {
1.726 + TRAPD(err, DoGetAttributeSetL(aHeaderData, aAttributeSet));
1.727 + return err;
1.728 + }
1.729 +
1.730 +void CManager::DoGetAttributeSetL(const TDesC8& aHeaderData, RAttributeSet& aAttributeSet) const
1.731 + {
1.732 + // Find the agent who handles the file
1.733 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aHeaderData);
1.734 +
1.735 + User::LeaveIfError(agentInfo.AgentManagerL().GetAttributeSet(aHeaderData, aAttributeSet));
1.736 + }
1.737 +
1.738 +EXPORT_C TInt CManager::GetStringAttribute(const TDesC8& aHeaderData, TInt aAttribute, TDes& aValue) const
1.739 + {
1.740 + TRAPD(err, DoGetStringAttributeL(aHeaderData, aAttribute, aValue));
1.741 + return err;
1.742 + }
1.743 +
1.744 +void CManager::DoGetStringAttributeL(const TDesC8& aHeaderData, TInt aAttribute, TDes& aValue) const
1.745 + {
1.746 + // Find the agent who handles the file
1.747 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aHeaderData);
1.748 +
1.749 + // find out the attribute
1.750 + User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttribute(aHeaderData, aAttribute, aValue));
1.751 + }
1.752 +
1.753 +EXPORT_C TInt CManager::GetStringAttributeSet(const TDesC8& aHeaderData, RStringAttributeSet& aStringAttributeSet) const
1.754 + {
1.755 + TRAPD(err, DoGetStringAttributeSetL(aHeaderData, aStringAttributeSet));
1.756 + return err;
1.757 + }
1.758 +
1.759 +void CManager::DoGetStringAttributeSetL(const TDesC8& aHeaderData, RStringAttributeSet& aStringAttributeSet) const
1.760 + {
1.761 + // Find the agent who handles the file
1.762 + CAgentInfo& agentInfo = iResolver->ResolveFileL(aHeaderData);
1.763 +
1.764 + // find out the array of attributes
1.765 + User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttributeSet(aHeaderData, aStringAttributeSet));
1.766 + }
1.767 +
1.768 +#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT