|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <caf/caf.h> |
|
17 #include "Reftestagentdata.h" |
|
18 #include "drmfiles.h" |
|
19 |
|
20 using namespace ContentAccess; |
|
21 |
|
22 CRefTestAgentData* CRefTestAgentData::NewL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode) |
|
23 { |
|
24 CRefTestAgentData* self = NewLC(aVirtualPath, aShareMode); |
|
25 CleanupStack::Pop(self); |
|
26 return self; |
|
27 } |
|
28 |
|
29 CRefTestAgentData* CRefTestAgentData::NewLC(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode) |
|
30 { |
|
31 CRefTestAgentData* self=new(ELeave) CRefTestAgentData(); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(aVirtualPath, aShareMode); |
|
34 return self; |
|
35 } |
|
36 |
|
37 CRefTestAgentData* CRefTestAgentData::NewL(RFile& aFile, const TDesC& aUniqueId) |
|
38 { |
|
39 CRefTestAgentData* self = NewLC(aFile, aUniqueId); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 CRefTestAgentData* CRefTestAgentData::NewLC(RFile& aFile, const TDesC& aUniqueId) |
|
45 { |
|
46 CRefTestAgentData* self=new(ELeave) CRefTestAgentData(); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(aFile, aUniqueId); |
|
49 return self; |
|
50 } |
|
51 |
|
52 CRefTestAgentData::CRefTestAgentData() |
|
53 { |
|
54 } |
|
55 |
|
56 CRefTestAgentData::~CRefTestAgentData() |
|
57 { |
|
58 iServer.Close(); |
|
59 } |
|
60 |
|
61 void CRefTestAgentData::ConstructL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode) |
|
62 { |
|
63 // default share mode of EFileShareReadersOnly |
|
64 TUint mode = EFileStream | EFileRead; |
|
65 |
|
66 if(aShareMode == EContentShareReadWrite) |
|
67 { |
|
68 mode |= EFileShareReadersOrWriters; |
|
69 } |
|
70 else if (aShareMode == EContentShareExclusive) |
|
71 { |
|
72 mode |= EFileShareExclusive; |
|
73 } |
|
74 else |
|
75 { |
|
76 mode |= EFileShareReadersOnly; |
|
77 } |
|
78 |
|
79 User::LeaveIfError(iServer.Open(aVirtualPath.URI(), aVirtualPath.UniqueId(), mode)); |
|
80 } |
|
81 |
|
82 |
|
83 void CRefTestAgentData::ConstructL(RFile& aFile, const TDesC& aUniqueId) |
|
84 { |
|
85 User::LeaveIfError(iServer.Open(aFile, aUniqueId)); |
|
86 } |
|
87 |
|
88 void CRefTestAgentData::DataSizeL(TInt &aSize) |
|
89 { |
|
90 User::LeaveIfError(iServer.DataSize(aSize)); |
|
91 } |
|
92 |
|
93 TInt CRefTestAgentData::EvaluateIntent(TIntent aIntent) |
|
94 { |
|
95 // Always allow EPeek |
|
96 TInt err = KErrNone; |
|
97 if(aIntent != EPeek) |
|
98 { |
|
99 TRAP(err, iServer.EvaluateIntentL(aIntent)); |
|
100 } |
|
101 return err; |
|
102 } |
|
103 |
|
104 TInt CRefTestAgentData::ExecuteIntent(TIntent aIntent) |
|
105 { |
|
106 // Always allow EPeek |
|
107 TInt err = KErrNone; |
|
108 if(aIntent != EPeek) |
|
109 { |
|
110 TRAP(err, iServer.ExecuteIntentL(aIntent)); |
|
111 } |
|
112 return err; |
|
113 } |
|
114 |
|
115 TInt CRefTestAgentData::Read(TDes8& aDes) |
|
116 { |
|
117 return iServer.Read(aDes, aDes.MaxLength()); |
|
118 } |
|
119 |
|
120 TInt CRefTestAgentData::Read(TDes8& aDes,TInt aLength) |
|
121 { |
|
122 return iServer.Read(aDes, aLength); |
|
123 } |
|
124 |
|
125 void CRefTestAgentData::Read(TDes8& aDes,TRequestStatus& aStatus) |
|
126 { |
|
127 TInt err = Read(aDes); |
|
128 TRequestStatus* status = &aStatus; |
|
129 User::RequestComplete(status, err); |
|
130 } |
|
131 |
|
132 void CRefTestAgentData::Read(TDes8& aDes, |
|
133 TInt aLength, |
|
134 TRequestStatus& aStatus) |
|
135 { |
|
136 TInt err = Read(aDes, aLength); |
|
137 TRequestStatus* status = &aStatus; |
|
138 User::RequestComplete(status, err); |
|
139 } |
|
140 |
|
141 TInt CRefTestAgentData::Seek(TSeek aMode, TInt& aPos) |
|
142 { |
|
143 return iServer.Seek(aMode, aPos); |
|
144 } |
|
145 |
|
146 TInt CRefTestAgentData::SetProperty(TAgentProperty /*aProperty*/, TInt /*aValue*/) |
|
147 { |
|
148 return KErrCANotSupported; |
|
149 } |
|
150 |
|
151 TInt CRefTestAgentData::GetAttribute(TInt aAttribute, TInt& aValue) |
|
152 { |
|
153 return iServer.GetAttribute(aAttribute, aValue); |
|
154 } |
|
155 |
|
156 TInt CRefTestAgentData::GetAttributeSet(RAttributeSet& aAttributeSet) |
|
157 { |
|
158 TInt ret=KErrNone; |
|
159 TRAPD(err,ret=iServer.GetAttributeSetL(aAttributeSet)); |
|
160 if(err==KErrNone) |
|
161 return ret; |
|
162 else |
|
163 return err; |
|
164 } |
|
165 |
|
166 TInt CRefTestAgentData::GetStringAttribute(TInt aAttribute, TDes& aValue) |
|
167 { |
|
168 return iServer.GetStringAttribute(aAttribute, aValue); |
|
169 } |
|
170 |
|
171 TInt CRefTestAgentData::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet) |
|
172 { |
|
173 TInt ret=KErrNone; |
|
174 TRAPD(err,ret=iServer.GetStringAttributeSetL(aStringAttributeSet)); |
|
175 if(err==KErrNone) |
|
176 return ret; |
|
177 else |
|
178 return err; |
|
179 } |
|
180 TInt CRefTestAgentData::Read(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus) |
|
181 { |
|
182 TInt err = iServer.Read(aPos, aDes, aLength); |
|
183 TRequestStatus* status = &aStatus; |
|
184 User::RequestComplete(status, err); |
|
185 return KErrNone; |
|
186 } |
|
187 |