|
1 /* |
|
2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "manager.h" |
|
20 #include "agentinterface.h" |
|
21 #include "agent.h" |
|
22 #include "agentinfo.h" |
|
23 #include "agentfactory.h" |
|
24 #include "attributeset.h" |
|
25 #include "caftypes.h" |
|
26 #include "caferr.h" |
|
27 #include "virtualpath.h" |
|
28 #include "dirstreamable.h" |
|
29 #include "rightsmanager.h" |
|
30 #include "cafpanic.h" |
|
31 #include "resolver.h" |
|
32 |
|
33 using namespace ContentAccess; |
|
34 |
|
35 EXPORT_C CManager* CManager::NewL() |
|
36 { |
|
37 CManager* self = CManager::NewLC(); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 |
|
42 EXPORT_C CManager* CManager::NewLC() |
|
43 { |
|
44 CManager* self = new (ELeave) CManager; |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 CManager::CManager() |
|
51 { |
|
52 } |
|
53 |
|
54 CManager::~CManager() |
|
55 { |
|
56 delete iResolver; |
|
57 } |
|
58 |
|
59 void CManager::ConstructL() |
|
60 { |
|
61 iResolver = CAgentResolver::NewL(EFalse); |
|
62 } |
|
63 |
|
64 EXPORT_C TInt CManager::DeleteFile(const TDesC &aFileName) const |
|
65 { |
|
66 TRAPD(err, DoDeleteFileL(aFileName)); |
|
67 return err; |
|
68 } |
|
69 |
|
70 void CManager::DoDeleteFileL(const TDesC &aFileName) const |
|
71 { |
|
72 TFileName actualFileName; |
|
73 |
|
74 // initalise a pointer to the relevant CAgentManager object |
|
75 // iResolver retains ownership of the pointer |
|
76 CAgentInfo& agentInfo = iResolver->ResolveFileL(aFileName, actualFileName, EContentShareReadOnly); |
|
77 |
|
78 User::LeaveIfError(agentInfo.AgentManagerL().DeleteFile(actualFileName)); |
|
79 } |
|
80 |
|
81 EXPORT_C TInt CManager::CopyFile(RFile& aSourceFile, const TDesC &aDestination) const |
|
82 { |
|
83 TRAPD(err, DoCopyFileL(aSourceFile, aDestination)); |
|
84 return err; |
|
85 } |
|
86 |
|
87 void CManager::DoCopyFileL(RFile& aSourceFile, const TDesC &aDestination) const |
|
88 { |
|
89 TFileName actualDestination; |
|
90 TBool thePrivateDir = EFalse; |
|
91 TUid agentUid = KNullUid; |
|
92 |
|
93 // Find out which agent owns the directory where the destination file lives |
|
94 TUid destinationAgentUid = iResolver->ResolveDirectory(aDestination, actualDestination, thePrivateDir); |
|
95 |
|
96 if(destinationAgentUid != iResolver->DefaultAgentUid()) |
|
97 { |
|
98 // Destination file is in an agent private directory |
|
99 // Use destination agent to copy |
|
100 agentUid = destinationAgentUid; |
|
101 } |
|
102 else |
|
103 { |
|
104 // Use RFile version of ResolveFileL to find the Agent Uid |
|
105 agentUid = iResolver->ResolveFileL(aSourceFile).Agent().ImplementationUid(); |
|
106 } |
|
107 |
|
108 // If creating the appropriate CAgentManager succeeded ask the agent to copy the file |
|
109 User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().CopyFile(aSourceFile, actualDestination)); |
|
110 } |
|
111 |
|
112 EXPORT_C TInt CManager::CopyFile(const TDesC &aSource, const TDesC &aDestination) const |
|
113 { |
|
114 TRAPD(err, DoCopyFileL(aSource, aDestination)); |
|
115 return err; |
|
116 } |
|
117 |
|
118 void CManager::DoCopyFileL(const TDesC &aSource, const TDesC &aDestination) const |
|
119 { |
|
120 TFileName actualSource; |
|
121 TFileName actualDestination; |
|
122 TBool thePrivateDir = EFalse; |
|
123 TUid agentUid = KNullUid; |
|
124 |
|
125 // Find out which agent owns the directory where the source file lives |
|
126 TUid sourceAgentUid = iResolver->ResolveDirectory(aSource, actualSource, thePrivateDir); |
|
127 |
|
128 // Find out which agent owns the directory where the destination file lives |
|
129 TUid destinationAgentUid = iResolver->ResolveDirectory(aDestination, actualDestination, thePrivateDir); |
|
130 |
|
131 if(sourceAgentUid != iResolver->DefaultAgentUid()) |
|
132 { |
|
133 // Source file is in an agent private directory |
|
134 // Use source agent to copy |
|
135 agentUid = sourceAgentUid; |
|
136 } |
|
137 else if(destinationAgentUid != iResolver->DefaultAgentUid()) |
|
138 { |
|
139 // Destination file is in an agent private directory |
|
140 // Use destination agent to copy |
|
141 agentUid = destinationAgentUid; |
|
142 } |
|
143 else |
|
144 { |
|
145 // Source and destination are in publicly accessable directories |
|
146 agentUid = iResolver->ResolveFileL(aSource, actualSource, EContentShareReadOnly).Agent().ImplementationUid(); |
|
147 } |
|
148 |
|
149 // If creating the appropriate CAgentManager succeeded ask the agent to copy the file |
|
150 User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().CopyFile(actualSource, actualDestination)); |
|
151 } |
|
152 |
|
153 EXPORT_C TInt CManager::RenameFile(const TDesC& aSource, const TDesC& aDestination) const |
|
154 { |
|
155 TRAPD(err, DoRenameFileL(aSource, aDestination)); |
|
156 return err; |
|
157 } |
|
158 |
|
159 void CManager::DoRenameFileL(const TDesC& aSource, const TDesC& aDestination) const |
|
160 { |
|
161 TFileName actualSource; |
|
162 TFileName actualDestination; |
|
163 TBool thePrivateDir = EFalse; |
|
164 TUid agentUid = KNullUid; |
|
165 |
|
166 // Find out which agent owns the directory where the source file lives |
|
167 TUid sourceAgentUid = iResolver->ResolveDirectory(aSource, actualSource, thePrivateDir); |
|
168 |
|
169 // Find out which agent owns the directory where the destination file lives |
|
170 TUid destinationAgentUid = iResolver->ResolveDirectory(aDestination, actualDestination, thePrivateDir); |
|
171 |
|
172 if(sourceAgentUid != iResolver->DefaultAgentUid()) |
|
173 { |
|
174 // Source file is in an agent private directory |
|
175 // Use source agent to copy |
|
176 agentUid = sourceAgentUid; |
|
177 } |
|
178 else if(destinationAgentUid != iResolver->DefaultAgentUid()) |
|
179 { |
|
180 // Destination file is in an agent private directory |
|
181 // Use destination agent to copy |
|
182 agentUid = destinationAgentUid; |
|
183 } |
|
184 else |
|
185 { |
|
186 // Source and destination are in publicly accessable directories |
|
187 agentUid = iResolver->ResolveFileL(aSource, actualSource, EContentShareReadOnly).Agent().ImplementationUid(); |
|
188 } |
|
189 |
|
190 // Ask the agent to move or rename the file |
|
191 User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().RenameFile(actualSource, actualDestination)); |
|
192 } |
|
193 |
|
194 EXPORT_C TInt CManager::MkDir(const TDesC &aPath) const |
|
195 { |
|
196 TRAPD(err, DoMkDirL(aPath)); |
|
197 |
|
198 return err; |
|
199 } |
|
200 |
|
201 void CManager::DoMkDirL(const TDesC &aPath) const |
|
202 { |
|
203 TBool isThePrivateDir = EFalse; |
|
204 TFileName actualPath; |
|
205 |
|
206 // Figure out which agent handles the directory |
|
207 TUid uid = iResolver->ResolveDirectory(aPath, actualPath, isThePrivateDir); |
|
208 |
|
209 User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().MkDir(actualPath)); |
|
210 } |
|
211 |
|
212 EXPORT_C TInt CManager::MkDirAll (const TDesC &aPath) const |
|
213 { |
|
214 TRAPD(err, DoMkDirAllL(aPath)); |
|
215 return err; |
|
216 } |
|
217 |
|
218 void CManager::DoMkDirAllL(const TDesC &aPath) const |
|
219 { |
|
220 TBool isThePrivateDir = EFalse; |
|
221 TFileName actualPath; |
|
222 |
|
223 // Figure out which agent handles the directory |
|
224 TUid uid = iResolver->ResolveDirectory(aPath, actualPath, isThePrivateDir); |
|
225 |
|
226 User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().MkDirAll(actualPath)); |
|
227 } |
|
228 |
|
229 EXPORT_C TInt CManager::RmDir(const TDesC &aPath) const |
|
230 { |
|
231 TRAPD(err, DoRmDirL(aPath)); |
|
232 return err; |
|
233 } |
|
234 |
|
235 void CManager::DoRmDirL(const TDesC &aPath) const |
|
236 { |
|
237 TBool isThePrivateDir = EFalse; |
|
238 TFileName actualPath; |
|
239 |
|
240 // Figure out which agent handles the directory |
|
241 TUid uid = iResolver->ResolveDirectory(aPath, actualPath, isThePrivateDir); |
|
242 |
|
243 if(isThePrivateDir) |
|
244 { |
|
245 User::Leave(KErrAccessDenied); |
|
246 } |
|
247 else |
|
248 { |
|
249 User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().RmDir(actualPath)); |
|
250 } |
|
251 } |
|
252 |
|
253 EXPORT_C TInt CManager::RenameDir(const TDesC& aOldName, const TDesC& aNewName) const |
|
254 { |
|
255 TRAPD(err, DoRenameDirL(aOldName, aNewName)); |
|
256 return err; |
|
257 } |
|
258 |
|
259 void CManager::DoRenameDirL(const TDesC &aOldName, const TDesC& aNewName) const |
|
260 { |
|
261 TPath actualSource; |
|
262 TPath actualDestination; |
|
263 TBool thePrivateDir = EFalse; |
|
264 TUid agentUid = iResolver->DefaultAgentUid(); |
|
265 |
|
266 // Find out which agent owns the directory where the source file lives |
|
267 TUid sourceAgentUid = iResolver->ResolveDirectory(aOldName, actualSource, thePrivateDir); |
|
268 |
|
269 // Find out which agent owns the directory where the destination file lives |
|
270 TUid destinationAgentUid = iResolver->ResolveDirectory(aNewName, actualDestination, thePrivateDir); |
|
271 |
|
272 if(sourceAgentUid != iResolver->DefaultAgentUid()) |
|
273 { |
|
274 // Source file is in an agent private directory |
|
275 // Use source agent to copy |
|
276 agentUid = sourceAgentUid; |
|
277 } |
|
278 else if(destinationAgentUid != iResolver->DefaultAgentUid()) |
|
279 { |
|
280 // Destination file is in an agent private directory |
|
281 // Use destination agent to copy |
|
282 agentUid = destinationAgentUid; |
|
283 } |
|
284 |
|
285 // Ask the agent to move or rename the file |
|
286 User::LeaveIfError(iResolver->AgentInfoL(agentUid).AgentManagerL().RenameDir(actualSource, actualDestination)); |
|
287 } |
|
288 |
|
289 |
|
290 EXPORT_C TInt CManager::GetDir(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList) const |
|
291 { |
|
292 TRAPD(err, DoGetDirL(aName, aEntryAttMask, aEntrySortKey, aEntryList)); |
|
293 return err; |
|
294 } |
|
295 |
|
296 void CManager::DoGetDirL(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList) const |
|
297 { |
|
298 TBool isThePrivateDir = EFalse; |
|
299 TFileName actualPath; |
|
300 |
|
301 // Figure out which agent handles the directory |
|
302 TUid uid = iResolver->ResolveDirectory(aName, actualPath, isThePrivateDir); |
|
303 |
|
304 if(isThePrivateDir) |
|
305 { |
|
306 // If we are doing GetDir of C:\\private\\ just create an empty CDirStreamable |
|
307 aEntryList = CDirStreamable::NewL(); |
|
308 } |
|
309 else |
|
310 { |
|
311 User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().GetDir(actualPath, aEntryAttMask, aEntrySortKey, aEntryList)); |
|
312 } |
|
313 } |
|
314 |
|
315 EXPORT_C TInt CManager::GetDir(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList, CDir *&aDirList) const |
|
316 { |
|
317 TRAPD(err, DoGetDirL(aName, aEntryAttMask, aEntrySortKey, aEntryList, aDirList)); |
|
318 return err; |
|
319 } |
|
320 |
|
321 void CManager::DoGetDirL(const TDesC &aName, TUint aEntryAttMask, TUint aEntrySortKey, CDir *&aEntryList, CDir *&aDirList) const |
|
322 { |
|
323 TBool isThePrivateDir = EFalse; |
|
324 TFileName actualPath; |
|
325 CDir* emptyDirList; |
|
326 |
|
327 // Figure out which agent handles the directory |
|
328 TUid uid = iResolver->ResolveDirectory(aName, actualPath, isThePrivateDir); |
|
329 |
|
330 if(isThePrivateDir) |
|
331 { |
|
332 // If we are doing GetDir of C:\\private\\ just create an empty entryList |
|
333 emptyDirList = CDirStreamable::NewL(); |
|
334 CleanupStack::PushL(emptyDirList); |
|
335 |
|
336 GetListOfAgentPrivateDirectoriesL(aDirList); |
|
337 |
|
338 CleanupStack::Pop(emptyDirList); |
|
339 aEntryList = emptyDirList; |
|
340 } |
|
341 else |
|
342 { |
|
343 User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().GetDir(actualPath, aEntryAttMask, aEntrySortKey, aEntryList, aDirList)); |
|
344 } |
|
345 } |
|
346 |
|
347 EXPORT_C TInt CManager::GetDir(const TDesC &aName, const TUidType &aEntryUid, TUint aEntrySortKey, CDir *&aFileList) const |
|
348 { |
|
349 TRAPD(err, DoGetDirL(aName, aEntryUid, aEntrySortKey, aFileList)); |
|
350 return err; |
|
351 } |
|
352 |
|
353 void CManager::DoGetDirL(const TDesC &aName, const TUidType &aEntryUid, TUint aEntrySortKey, CDir *&aFileList) const |
|
354 { |
|
355 TBool isThePrivateDir = EFalse; |
|
356 TFileName actualPath; |
|
357 |
|
358 // Figure out which agent handles the directory |
|
359 TUid uid = iResolver->ResolveDirectory(aName, actualPath, isThePrivateDir); |
|
360 |
|
361 if(isThePrivateDir) |
|
362 { |
|
363 // We've been asked to look at C:\\private\\ just return an empty CDirStreamable |
|
364 aFileList = CDirStreamable::NewL(); |
|
365 } |
|
366 else |
|
367 { |
|
368 User::LeaveIfError(iResolver->AgentInfoL(uid).AgentManagerL().GetDir(actualPath, aEntryUid, aEntrySortKey, aFileList)); |
|
369 } |
|
370 } |
|
371 |
|
372 EXPORT_C TInt CManager::GetAttribute(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath) const |
|
373 { |
|
374 TRAPD(err, DoGetAttributeL(aAttribute, aValue, aVirtualPath)); |
|
375 return err; |
|
376 } |
|
377 |
|
378 void CManager::DoGetAttributeL(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath) const |
|
379 { |
|
380 HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); |
|
381 TPtr uri = uriBuffer->Des(); |
|
382 |
|
383 // Find the agent who handles the file |
|
384 CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(),uri, EContentShareReadOnly); |
|
385 User::LeaveIfError(agentInfo.AgentManagerL().GetAttribute(aAttribute, aValue, TVirtualPathPtr(uri, aVirtualPath.UniqueId()))); |
|
386 CleanupStack::PopAndDestroy(uriBuffer); |
|
387 } |
|
388 |
|
389 EXPORT_C TInt CManager::GetStringAttribute(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath) const |
|
390 { |
|
391 TRAPD(err, DoGetStringAttributeL(aAttribute, aValue, aVirtualPath)); |
|
392 return err; |
|
393 } |
|
394 |
|
395 void CManager::DoGetStringAttributeL(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath) const |
|
396 { |
|
397 HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); |
|
398 TPtr uri = uriBuffer->Des(); |
|
399 |
|
400 |
|
401 // Find the agent who handles the file |
|
402 CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(), uri, EContentShareReadOnly); |
|
403 |
|
404 // find out the attribute |
|
405 User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttribute(aAttribute, aValue, TVirtualPathPtr(uri,aVirtualPath.UniqueId()))); |
|
406 CleanupStack::PopAndDestroy(uriBuffer); |
|
407 } |
|
408 |
|
409 EXPORT_C TInt CManager::GetAttributeSet(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath) const |
|
410 { |
|
411 TRAPD(err, DoGetAttributeSetL(aAttributeSet, aVirtualPath)); |
|
412 return err; |
|
413 } |
|
414 |
|
415 void CManager::DoGetAttributeSetL(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath) const |
|
416 { |
|
417 HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); |
|
418 TPtr uri = uriBuffer->Des(); |
|
419 |
|
420 // Find the agent who handles the file |
|
421 CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(), uri, EContentShareReadOnly); |
|
422 |
|
423 User::LeaveIfError(agentInfo.AgentManagerL().GetAttributeSet(aAttributeSet, TVirtualPathPtr(uri, aVirtualPath.UniqueId()))); |
|
424 CleanupStack::PopAndDestroy(uriBuffer); |
|
425 } |
|
426 |
|
427 EXPORT_C TInt CManager::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, const TVirtualPathPtr& aVirtualPath) const |
|
428 { |
|
429 TRAPD(err, DoGetStringAttributeSetL(aStringAttributeSet, aVirtualPath)); |
|
430 return err; |
|
431 } |
|
432 |
|
433 |
|
434 void CManager::DoGetStringAttributeSetL(RStringAttributeSet& aStringAttributeSet, const TVirtualPathPtr& aVirtualPath) const |
|
435 { |
|
436 HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); |
|
437 TPtr uri = uriBuffer->Des(); |
|
438 |
|
439 // Find the agent who handles the file |
|
440 CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(),uri, EContentShareReadOnly); |
|
441 |
|
442 // find out the array of attributes |
|
443 User::LeaveIfError(agentInfo.AgentManagerL().GetStringAttributeSet(aStringAttributeSet, TVirtualPathPtr(uri, aVirtualPath.UniqueId()))); |
|
444 CleanupStack::PopAndDestroy(uriBuffer); |
|
445 } |
|
446 |
|
447 EXPORT_C void CManager::NotifyStatusChange(const TDesC &aURI, TEventMask aMask, TRequestStatus &aStatus) |
|
448 { |
|
449 TRAPD(err, DoNotifyStatusChangeL(aURI, aMask, aStatus)); |
|
450 if(err != KErrNone) |
|
451 { |
|
452 // Must have failed before asking the agent for status |
|
453 TRequestStatus* status = &aStatus; |
|
454 User::RequestComplete(status, err); |
|
455 } |
|
456 |
|
457 } |
|
458 |
|
459 void CManager::DoNotifyStatusChangeL(const TDesC &aURI, TEventMask aMask, TRequestStatus &aStatus) |
|
460 { |
|
461 HBufC* uriBuffer = HBufC::NewLC(aURI.Length() + KMaxSIDLength); |
|
462 TPtr uri = uriBuffer->Des(); |
|
463 |
|
464 // Find the agent who handles the file |
|
465 CAgentInfo& agentInfo = iResolver->ResolveFileL(aURI, uri, EContentShareReadOnly); |
|
466 |
|
467 // Ask the agent to notifiy the client when the status of the given file changes |
|
468 agentInfo.AgentManagerL().NotifyStatusChange(uri, aMask, aStatus); |
|
469 CleanupStack::PopAndDestroy(uriBuffer); |
|
470 } |
|
471 |
|
472 EXPORT_C TInt CManager::CancelNotifyStatusChange (const TDesC &aURI, TRequestStatus &aStatus) |
|
473 { |
|
474 TRAPD(err, DoCancelNotifyStatusChangeL(aURI, aStatus)); |
|
475 return err; |
|
476 } |
|
477 |
|
478 void CManager::DoCancelNotifyStatusChangeL(const TDesC &aURI, TRequestStatus &aStatus) |
|
479 { |
|
480 HBufC* uriBuffer = HBufC::NewLC(aURI.Length() + KMaxSIDLength); |
|
481 TPtr uri = uriBuffer->Des(); |
|
482 |
|
483 // Find the agent who handles the file |
|
484 CAgentInfo& agentInfo = iResolver->ResolveFileL(aURI, uri, EContentShareReadOnly); |
|
485 |
|
486 // cancel the notification request |
|
487 User::LeaveIfError(agentInfo.AgentManagerL().CancelNotifyStatusChange(uri, aStatus)); |
|
488 CleanupStack::PopAndDestroy(uriBuffer); |
|
489 } |
|
490 |
|
491 EXPORT_C TInt CManager::SetProperty(TAgentProperty aProperty, TInt aValue) |
|
492 { |
|
493 TRAPD(err, DoSetPropertyL(aProperty, aValue)); |
|
494 return err; |
|
495 } |
|
496 |
|
497 void CManager::DoSetPropertyL(TAgentProperty aProperty, TInt aValue) |
|
498 { |
|
499 TInt err = KErrNone; |
|
500 TInt rVal = KErrNone; |
|
501 TInt i = 0; |
|
502 TInt count = iResolver->AgentInfoCount(); |
|
503 |
|
504 CAgentInfo &defaultAgentInfo = iResolver->AgentInfoL(iResolver->DefaultAgentUid()); |
|
505 err = defaultAgentInfo.AgentManagerL().SetProperty(aProperty, aValue); |
|
506 if(err == KErrNoMemory) |
|
507 { |
|
508 User::Leave(KErrNoMemory); |
|
509 } |
|
510 |
|
511 // Ignore F32 agent return code unless it's KErrNoMemory |
|
512 err= KErrNone; |
|
513 |
|
514 // Set the property in all the other agents |
|
515 for( i = 0; i < count; i++) |
|
516 { |
|
517 CAgentInfo& agentInfo = iResolver->AgentInfo(i); |
|
518 err = agentInfo.AgentManagerL().SetProperty(aProperty, aValue); |
|
519 if(err == KErrNoMemory) |
|
520 { |
|
521 User::Leave(KErrNoMemory); |
|
522 } |
|
523 |
|
524 // If an error occurred and no previous error has occured |
|
525 if(err != KErrNone && rVal == KErrNone) |
|
526 { |
|
527 rVal = err; |
|
528 } |
|
529 } |
|
530 |
|
531 // leave if an error occurred in any agent |
|
532 User::LeaveIfError(rVal); |
|
533 } |
|
534 |
|
535 EXPORT_C void CManager::DisplayInfoL(TDisplayInfo aInfo, const TVirtualPathPtr& aVirtualPath) |
|
536 { |
|
537 HBufC* uriBuffer = HBufC::NewLC(aVirtualPath.URI().Length() + KMaxSIDLength); |
|
538 TPtr uri = uriBuffer->Des(); |
|
539 |
|
540 // Find the agent who handles the file |
|
541 CAgentInfo& agentInfo = iResolver->ResolveFileL(aVirtualPath.URI(), uri, EContentShareReadOnly); |
|
542 |
|
543 // find out the attribute |
|
544 agentInfo.AgentManagerL().DisplayInfoL(aInfo, TVirtualPathPtr(uri, aVirtualPath.UniqueId())); |
|
545 CleanupStack::PopAndDestroy(uriBuffer); |
|
546 } |
|
547 |
|
548 |
|
549 EXPORT_C void CManager::ListAgentsL (RArray <TAgent>& aAgents) |
|
550 { |
|
551 TInt i = 0; |
|
552 TBuf <KMaxAgentNameLength> agentName; |
|
553 TInt count = iResolver->AgentInfoCount(); |
|
554 |
|
555 // build the array of pointers from CAgentResolver |
|
556 for(i = 0; i < count; i++) |
|
557 { |
|
558 TAgent agent = iResolver->AgentInfo(i).Agent(); |
|
559 User::LeaveIfError(aAgents.Append(agent)); |
|
560 } |
|
561 } |
|
562 |
|
563 EXPORT_C TInt CManager::AgentSpecificCommand (TAgent &aAgent, TInt aCommand, const TDesC8 &aInputBuffer, TDes8 &aOutputBuffer) |
|
564 { |
|
565 CAgentManager* manager = NULL; |
|
566 TInt err = KErrNone; |
|
567 TRAP(err, manager = &iResolver->AgentInfoL(aAgent.ImplementationUid()).AgentManagerL()); |
|
568 if(err == KErrNone) |
|
569 { |
|
570 err = manager->AgentSpecificCommand (aCommand, aInputBuffer, aOutputBuffer); |
|
571 } |
|
572 return err; |
|
573 } |
|
574 |
|
575 EXPORT_C void CManager::AgentSpecificCommand (TAgent &aAgent, TInt aCommand, const TDesC8 &aInputBuffer, TDes8 &aOutputBuffer, TRequestStatus &aStatus) |
|
576 { |
|
577 CAgentManager* manager = NULL; |
|
578 |
|
579 TRAPD(err, manager = &iResolver->AgentInfoL(aAgent.ImplementationUid()).AgentManagerL()); |
|
580 if(err == KErrNone) |
|
581 { |
|
582 manager->AgentSpecificCommand (aCommand, aInputBuffer, aOutputBuffer, aStatus); |
|
583 } |
|
584 else |
|
585 { |
|
586 TRequestStatus* status = &aStatus; |
|
587 User::RequestComplete(status, err); |
|
588 } |
|
589 } |
|
590 |
|
591 EXPORT_C void CManager::DisplayManagementInfoL(TAgent& aAgent) |
|
592 { |
|
593 CAgentInfo& agentInfo = iResolver->AgentInfoL(aAgent.ImplementationUid()); |
|
594 |
|
595 // Ask agent to display management info |
|
596 agentInfo.AgentManagerL().DisplayManagementInfoL(); |
|
597 } |
|
598 |
|
599 EXPORT_C CRightsManager* CManager::CreateRightsManagerL(TAgent& aAgent) const |
|
600 { |
|
601 // Create a rights manager |
|
602 return CRightsManager::NewL(aAgent.ImplementationUid()); |
|
603 } |
|
604 |
|
605 void CManager::GetListOfAgentPrivateDirectoriesL(CDir *&aDir) const |
|
606 { |
|
607 CDirStreamable *ptr = NULL; |
|
608 // fill in the agent directories under the \\private\\ directory |
|
609 TInt i = 0; |
|
610 TInt count = iResolver->AgentInfoCount(); |
|
611 |
|
612 TBuf <KMaxAgentNameLength> agentName; |
|
613 TPath privateDirectory; |
|
614 |
|
615 // Create CDirStreamable object |
|
616 ptr = CDirStreamable::NewL(); |
|
617 CleanupStack::PushL(ptr); |
|
618 |
|
619 // set aDir to point to the CDirStreamable we just created |
|
620 for(i = 0; i < count; i++) |
|
621 { |
|
622 // only fill in the agents that have a private directory that is not blank |
|
623 if(iResolver->AgentInfo(i).PrivateDirectoryName().Length() != 0) |
|
624 { |
|
625 TEntry aEntry; |
|
626 aEntry.iName = iResolver->AgentInfo(i).Agent().Name(); |
|
627 aEntry.iAtt = KEntryAttDir; |
|
628 aEntry.iType = TUidType(); |
|
629 aEntry.iSize = 0; |
|
630 ptr->AddL(aEntry); |
|
631 } |
|
632 } |
|
633 CleanupStack::Pop(ptr); |
|
634 aDir = ptr; |
|
635 } |
|
636 |
|
637 #ifndef REMOVE_CAF1 |
|
638 EXPORT_C void CManager::DeleteFileL(const TDesC &aFileName) |
|
639 { |
|
640 CManager *m = CManager::NewLC(); |
|
641 User::LeaveIfError(m->DeleteFile(aFileName)); |
|
642 CleanupStack::PopAndDestroy(m); |
|
643 } |
|
644 #endif // REMOVE_CAF1 |