|
1 /* |
|
2 * Copyright (c) 2006-2008 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 "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: Implementation of CNcdDownloadInfo |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncddownloadinfo.h" |
|
20 #include "ncd_pp_entitydependency.h" |
|
21 #include "ncd_pp_download.h" |
|
22 #include "ncd_pp_descriptor.h" |
|
23 #include "ncd_pp_rights.h" |
|
24 #include "catalogsutils.h" |
|
25 #include "ncdpurchasedownloadinfo.h" |
|
26 |
|
27 |
|
28 CNcdDownloadInfo* CNcdDownloadInfo::NewL() |
|
29 { |
|
30 CNcdDownloadInfo* self = |
|
31 CNcdDownloadInfo::NewLC(); |
|
32 CleanupStack::Pop( self ); |
|
33 return self; |
|
34 } |
|
35 |
|
36 CNcdDownloadInfo* CNcdDownloadInfo::NewLC() |
|
37 { |
|
38 CNcdDownloadInfo* self = |
|
39 new (ELeave) CNcdDownloadInfo(); |
|
40 CleanupStack::PushL( self ); |
|
41 self->CNcdPurchaseDownloadInfo::ConstructL(); |
|
42 return self; |
|
43 } |
|
44 |
|
45 |
|
46 CNcdDownloadInfo* CNcdDownloadInfo::NewL( |
|
47 const MNcdPreminetProtocolEntityDependency& aProtocolDependency ) |
|
48 { |
|
49 CNcdDownloadInfo* self = |
|
50 CNcdDownloadInfo::NewLC( aProtocolDependency ); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 CNcdDownloadInfo* CNcdDownloadInfo::NewLC( |
|
56 const MNcdPreminetProtocolEntityDependency& aProtocolDependency ) |
|
57 { |
|
58 CNcdDownloadInfo* self = |
|
59 new (ELeave) CNcdDownloadInfo(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL( aProtocolDependency ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 |
|
66 CNcdDownloadInfo* CNcdDownloadInfo::NewLC( |
|
67 const MNcdPreminetProtocolDownload& aProtocolDownload ) |
|
68 { |
|
69 CNcdDownloadInfo* self = |
|
70 new (ELeave) CNcdDownloadInfo(); |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL( aProtocolDownload ); |
|
73 return self; |
|
74 } |
|
75 |
|
76 |
|
77 CNcdDownloadInfo* CNcdDownloadInfo::NewLC( |
|
78 const MNcdPurchaseDownloadInfo& aDownload, |
|
79 TUid aUid, |
|
80 const TDesC& aVersion ) |
|
81 { |
|
82 CNcdDownloadInfo* self = |
|
83 new (ELeave) CNcdDownloadInfo(); |
|
84 CleanupStack::PushL( self ); |
|
85 self->ConstructL( aDownload, aUid, aVersion ); |
|
86 return self; |
|
87 } |
|
88 |
|
89 |
|
90 |
|
91 void CNcdDownloadInfo::InternalizeL( RReadStream& aStream ) |
|
92 { |
|
93 DLTRACEIN(("")); |
|
94 CNcdPurchaseDownloadInfo::InternalizeL( aStream ); |
|
95 iUid.iUid = aStream.ReadInt32L(); |
|
96 InternalizeDesL( iVersion, aStream ); |
|
97 InternalizeEnumL( iDependencyState, aStream ); |
|
98 DLTRACEOUT(("Internalization successful")); |
|
99 } |
|
100 |
|
101 |
|
102 void CNcdDownloadInfo::ExternalizeL( RWriteStream& aStream ) |
|
103 { |
|
104 DLTRACEIN(("")); |
|
105 CNcdPurchaseDownloadInfo::ExternalizeL( aStream ); |
|
106 aStream.WriteInt32L( iUid.iUid ); |
|
107 ExternalizeDesL( *iVersion, aStream ); |
|
108 ExternalizeEnumL( iDependencyState, aStream ); |
|
109 DLTRACEOUT(("Externalization successful")); |
|
110 } |
|
111 |
|
112 |
|
113 |
|
114 const TDesC& CNcdDownloadInfo::ContentName() const |
|
115 { |
|
116 DLTRACEIN(("")); |
|
117 const TDesC* name = NULL; |
|
118 |
|
119 // Errors ignore, AttributeStringL leaves with KErrNotFound if |
|
120 // the attribute is not set but that doesn't matter |
|
121 TRAP_IGNORE( name = &AttributeStringL( |
|
122 MNcdPurchaseDownloadInfo::EDownloadAttributeDependencyName ) ); |
|
123 if ( name ) |
|
124 { |
|
125 return *name; |
|
126 } |
|
127 return KNullDesC; |
|
128 } |
|
129 |
|
130 |
|
131 TUid CNcdDownloadInfo::ContentId() const |
|
132 { |
|
133 return iUid; |
|
134 } |
|
135 |
|
136 |
|
137 const TDesC& CNcdDownloadInfo::ContentVersion() const |
|
138 { |
|
139 DASSERT( iVersion ); |
|
140 return *iVersion; |
|
141 } |
|
142 |
|
143 |
|
144 TNcdDependencyState CNcdDownloadInfo::DependencyState() const |
|
145 { |
|
146 return iDependencyState; |
|
147 } |
|
148 |
|
149 |
|
150 void CNcdDownloadInfo::SetDependencyState( TNcdDependencyState aState ) |
|
151 { |
|
152 iDependencyState = aState; |
|
153 } |
|
154 |
|
155 |
|
156 CNcdDownloadInfo::CNcdDownloadInfo() |
|
157 : CNcdPurchaseDownloadInfo(), |
|
158 iDependencyState( ENcdDependencyMissing ) |
|
159 { |
|
160 } |
|
161 |
|
162 |
|
163 void CNcdDownloadInfo::ConstructL( |
|
164 const MNcdPreminetProtocolEntityDependency& aProtocolDependency ) |
|
165 { |
|
166 DLTRACEIN(("")); |
|
167 // Just to be sure that everything will be initialized. |
|
168 // Notice, that this initializes everything. So, |
|
169 // most of the data is most likely unnecessarily created |
|
170 // here because they will be replaced later in this function. |
|
171 CNcdPurchaseDownloadInfo::ConstructL(); |
|
172 |
|
173 if ( aProtocolDependency.DownloadDetails() ) |
|
174 { |
|
175 ConstructDownloadL( *aProtocolDependency.DownloadDetails() ); |
|
176 } |
|
177 |
|
178 if ( aProtocolDependency.ContentId().Length() ) |
|
179 { |
|
180 TInt uid = 0; |
|
181 DLTRACE(( _L("Content ID: %S"), &aProtocolDependency.ContentId() )); |
|
182 |
|
183 TRAPD( err, uid = DesHexToIntL( aProtocolDependency.ContentId() ) ); |
|
184 if( err != KErrNone ) |
|
185 { |
|
186 DLERROR(( "DownloadableContent()->Id() was not valid hex" )); |
|
187 iUid.iUid = 0; |
|
188 } |
|
189 else |
|
190 { |
|
191 iUid.iUid = uid; |
|
192 } |
|
193 } |
|
194 |
|
195 iVersion = aProtocolDependency.ContentVersion().AllocL(); |
|
196 |
|
197 |
|
198 SetAttributeL( MNcdPurchaseDownloadInfo::EDownloadAttributeDependencyName, |
|
199 aProtocolDependency.Name() ); |
|
200 |
|
201 DLTRACEOUT(( _L("Content version: %S"), iVersion )); |
|
202 } |
|
203 |
|
204 |
|
205 void CNcdDownloadInfo::ConstructL( |
|
206 const MNcdPreminetProtocolDownload& aProtocolDownload ) |
|
207 { |
|
208 DLTRACEIN(("")); |
|
209 CNcdPurchaseDownloadInfo::ConstructL(); |
|
210 iVersion = KNullDesC().AllocL(); |
|
211 |
|
212 SetAttributeL( MNcdPurchaseDownloadInfo::EDownloadAttributeDependencyName, |
|
213 KNullDesC ); |
|
214 |
|
215 ConstructDownloadL( aProtocolDownload ); |
|
216 } |
|
217 |
|
218 |
|
219 void CNcdDownloadInfo::ConstructDownloadL( |
|
220 const MNcdPreminetProtocolDownload& aProtocolDownload ) |
|
221 { |
|
222 DLTRACEIN(("")); |
|
223 |
|
224 |
|
225 SetContentUriL( aProtocolDownload.Uri() ); |
|
226 SetLaunchable( aProtocolDownload.Launchable() ); |
|
227 SetContentMimeTypeL( aProtocolDownload.Mime() ); |
|
228 |
|
229 SetContentSize( aProtocolDownload.Size() ); |
|
230 |
|
231 SetInstallNotificationUriL( aProtocolDownload.InstallNotificationUri() ); |
|
232 |
|
233 // Set content usage |
|
234 if ( aProtocolDownload.Target() == EDownloadTargetConsumable ) |
|
235 { |
|
236 SetContentUsage( MNcdPurchaseDownloadInfo::EConsumable ); |
|
237 } |
|
238 else |
|
239 { |
|
240 DLINFO(("Setting as downloadable, was actually: %d", |
|
241 aProtocolDownload.Target())); |
|
242 SetContentUsage( MNcdPurchaseDownloadInfo::EDownloadable ); |
|
243 } |
|
244 |
|
245 if( aProtocolDownload.Descriptor() != NULL ) |
|
246 { |
|
247 SetDescriptorDataL( aProtocolDownload.Descriptor()->Data() ); |
|
248 SetDescriptorNameL( aProtocolDownload.Descriptor()->Name() ); |
|
249 SetDescriptorTypeL( aProtocolDownload.Descriptor()->Type() ); |
|
250 SetDescriptorUriL( aProtocolDownload.Descriptor()->Uri() ); |
|
251 } |
|
252 |
|
253 if( aProtocolDownload.Rights() ) |
|
254 { |
|
255 SetRightsTypeL( aProtocolDownload.Rights()->Type() ); |
|
256 SetRightsUriL( aProtocolDownload.Rights()->Uri() ); |
|
257 SetActivationKeyL( aProtocolDownload.Rights()->ActivationKey()); |
|
258 } |
|
259 |
|
260 SetContentValidityDelta( aProtocolDownload.ValidityDelta() ); |
|
261 |
|
262 DLTRACEOUT(("")); |
|
263 } |
|
264 |
|
265 |
|
266 void CNcdDownloadInfo::ConstructL( |
|
267 const MNcdPurchaseDownloadInfo& aDownload, |
|
268 TUid aUid, |
|
269 const TDesC& aVersion ) |
|
270 { |
|
271 DLTRACEIN(("")); |
|
272 CNcdPurchaseDownloadInfo::ConstructL( aDownload ); |
|
273 iVersion = aVersion.AllocL(); |
|
274 iUid = aUid; |
|
275 } |
|
276 |
|
277 |
|
278 CNcdDownloadInfo::~CNcdDownloadInfo() |
|
279 { |
|
280 delete iVersion; |
|
281 } |