|
1 /* |
|
2 * Copyright (c) 2004-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 <apgcli.h> |
|
20 #include <f32file.h> |
|
21 #include <charconv.h> |
|
22 #include <e32cmn.h> |
|
23 #include <caf/attributeset.h> |
|
24 #include <caf/stringattributeset.h> |
|
25 #include <caf/virtualpath.h> |
|
26 #include <caf/caferr.h> |
|
27 #include "testagentattributes.h" |
|
28 |
|
29 |
|
30 using namespace ContentAccess; |
|
31 |
|
32 _LIT(KTestAgentPrivateDir, "c:\\private\\12345678\\"); |
|
33 _LIT(KDummyPrivateDir, "c:\\tcaf\\testdata\\TestAgentPrivateDir\\"); |
|
34 |
|
35 void TTestAgentAttributes::GetDummyFileName(const TDesC& aFileName, TDes& aDummyFileName) |
|
36 { |
|
37 if(aFileName.Left(KTestAgentPrivateDir().Length()) == KTestAgentPrivateDir) |
|
38 { |
|
39 aDummyFileName.Copy(KDummyPrivateDir()); |
|
40 aDummyFileName.Append(aFileName.Right(aFileName.Length() - KTestAgentPrivateDir().Length())); |
|
41 } |
|
42 else |
|
43 { |
|
44 aDummyFileName.Copy(aFileName); |
|
45 } |
|
46 } |
|
47 |
|
48 TInt TTestAgentAttributes::GetAttributeSet(CTestAgentFileInterface& aFile, RAttributeSet& aAttributeSet) |
|
49 { |
|
50 TInt i = 0; |
|
51 TInt attribute = 0; |
|
52 TInt value = 0; |
|
53 TInt err = KErrNone; |
|
54 TInt numAttributes = aAttributeSet.Count(); |
|
55 |
|
56 // loop through all the attriutes in the set and find their values |
|
57 for(i = 0; i < numAttributes; i++) |
|
58 { |
|
59 attribute = aAttributeSet[i]; |
|
60 err = aFile.GetAttribute(attribute, value); |
|
61 aAttributeSet.SetValue(attribute, value, err); |
|
62 } |
|
63 return KErrNone; |
|
64 } |
|
65 |
|
66 |
|
67 TInt TTestAgentAttributes::GetStringAttributeSet(CTestAgentFileInterface& aFile, RStringAttributeSet& aStringAttributeSet) |
|
68 { |
|
69 TInt i = 0; |
|
70 TInt attribute = 0; |
|
71 TInt err = KErrNone; |
|
72 |
|
73 // maybe this should be a CAF defined length |
|
74 TBuf <KMaxDataTypeLength> buf; |
|
75 |
|
76 TInt numAttributes = aStringAttributeSet.Count(); |
|
77 |
|
78 // loop through all the attriutes in the set and find their values |
|
79 for(i = 0; i < numAttributes; i++) |
|
80 { |
|
81 attribute = aStringAttributeSet[i]; |
|
82 err = aFile.GetStringAttribute(attribute, buf); |
|
83 err = aStringAttributeSet.SetValue(attribute, buf, err); |
|
84 if(err != KErrNone) |
|
85 { |
|
86 break; |
|
87 } |
|
88 } |
|
89 return err; |
|
90 } |
|
91 |
|
92 TInt TTestAgentAttributes::CheckUniqueId(const TDesC& aUniqueId) |
|
93 { |
|
94 // Allow the followig |
|
95 // a zero length descriptor which is the entire DCF file |
|
96 // or KDefaultContentObject which is the content object (OMA 1.0) |
|
97 // of the CID? |
|
98 if(aUniqueId.Length() == 0 || aUniqueId == KDefaultContentObject()) |
|
99 { |
|
100 return KErrNone; |
|
101 } |
|
102 else |
|
103 { |
|
104 return KErrNotFound; |
|
105 } |
|
106 } |
|
107 |
|
108 TInt TTestAgentAttributes::CheckVirtualPath(const TVirtualPathPtr& aVirtualPath) |
|
109 { |
|
110 // check the Unique Id |
|
111 TInt err = CheckUniqueId(aVirtualPath.UniqueId()); |
|
112 |
|
113 // check if the file exists |
|
114 |
|
115 |
|
116 return err; |
|
117 } |