|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "DrmAsset.h" |
|
22 |
|
23 // EXTERNAL DATA STRUCTURES |
|
24 |
|
25 // EXTERNAL FUNCTION PROTOTYPES |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // LOCAL CONSTANTS AND MACROS |
|
32 |
|
33 // MODULE DATA STRUCTURES |
|
34 |
|
35 // LOCAL FUNCTION PROTOTYPES |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 |
|
39 // ============================= LOCAL FUNCTIONS =============================== |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 |
|
44 EXPORT_C CDRMAsset* CDRMAsset::NewL(void) |
|
45 { |
|
46 CDRMAsset* self; |
|
47 |
|
48 self = new (ELeave) CDRMAsset; |
|
49 return self; |
|
50 } |
|
51 |
|
52 EXPORT_C CDRMAsset* CDRMAsset::NewLC(void) |
|
53 { |
|
54 CDRMAsset* self; |
|
55 |
|
56 self = new (ELeave) CDRMAsset; |
|
57 CleanupStack::PushL(self); |
|
58 return self; |
|
59 } |
|
60 |
|
61 EXPORT_C CDRMAsset::~CDRMAsset(void) |
|
62 { |
|
63 delete iUid; |
|
64 delete iParentRights; |
|
65 } |
|
66 |
|
67 CDRMAsset::CDRMAsset(void): |
|
68 iUid(NULL), |
|
69 iParentRights(NULL) |
|
70 { |
|
71 } |
|
72 |
|
73 EXPORT_C void CDRMAsset::DuplicateL(CDRMAsset& aAsset) |
|
74 { |
|
75 delete iUid; |
|
76 iUid = NULL; |
|
77 if (aAsset.iUid != NULL) |
|
78 { |
|
79 iUid = aAsset.iUid->AllocL(); |
|
80 } |
|
81 |
|
82 delete iParentRights; |
|
83 iParentRights = NULL; |
|
84 if (aAsset.iParentRights != NULL) |
|
85 { |
|
86 iParentRights = aAsset.iParentRights->AllocL(); |
|
87 } |
|
88 |
|
89 iKey.Copy(aAsset.iKey); |
|
90 iProtectedKey.Copy(aAsset.iProtectedKey); |
|
91 iDigest.Copy(aAsset.iDigest); |
|
92 iAuthenticationSeed.Copy(aAsset.iAuthenticationSeed); |
|
93 iProtectedAuthSeed.Copy(aAsset.iProtectedAuthSeed); |
|
94 } |
|
95 |
|
96 EXPORT_C void CDRMAsset::ExternalizeL(RWriteStream& aStream) |
|
97 { |
|
98 if (iUid != NULL) |
|
99 { |
|
100 aStream.WriteInt32L(iUid->Length()); |
|
101 aStream.WriteL(*iUid); |
|
102 } |
|
103 else |
|
104 { |
|
105 aStream.WriteUint32L(0); |
|
106 } |
|
107 |
|
108 if (iParentRights != NULL) |
|
109 { |
|
110 aStream.WriteInt32L(iParentRights->Length()); |
|
111 aStream.WriteL(*iParentRights); |
|
112 } |
|
113 else |
|
114 { |
|
115 aStream.WriteUint32L(0); |
|
116 } |
|
117 |
|
118 aStream.WriteInt32L(iKey.Length()); |
|
119 aStream.WriteL(iKey); |
|
120 aStream.WriteInt32L(iProtectedKey.Length()); |
|
121 aStream.WriteL(iProtectedKey); |
|
122 aStream.WriteInt32L(iDigest.Length()); |
|
123 aStream.WriteL(iDigest); |
|
124 aStream.WriteInt32L(iAuthenticationSeed.Length()); |
|
125 aStream.WriteL(iAuthenticationSeed); |
|
126 aStream.WriteInt32L(iProtectedAuthSeed.Length()); |
|
127 aStream.WriteL(iProtectedAuthSeed); |
|
128 } |
|
129 |
|
130 EXPORT_C void CDRMAsset::InternalizeL(RReadStream& aStream) |
|
131 { |
|
132 TInt32 length; |
|
133 |
|
134 delete iUid; |
|
135 iUid = NULL; |
|
136 |
|
137 delete iParentRights; |
|
138 iParentRights = NULL; |
|
139 |
|
140 TPtr8 inRead(NULL,NULL); |
|
141 |
|
142 length = aStream.ReadInt32L(); |
|
143 if (length != 0) |
|
144 { |
|
145 iUid = HBufC8::NewMaxL(length); |
|
146 inRead.Set(const_cast<TUint8*>(iUid->Ptr()), 0, length); |
|
147 aStream.ReadL(inRead); |
|
148 } |
|
149 |
|
150 length = aStream.ReadInt32L(); |
|
151 if (length != 0) |
|
152 { |
|
153 iParentRights = HBufC8::NewMaxL(length); |
|
154 inRead.Set(const_cast<TUint8*>(iParentRights->Ptr()), 0, length); |
|
155 aStream.ReadL(inRead); |
|
156 } |
|
157 |
|
158 length = aStream.ReadInt32L(); |
|
159 iKey.SetLength(0); |
|
160 aStream.ReadL(iKey, length); |
|
161 |
|
162 length = aStream.ReadInt32L(); |
|
163 iProtectedKey.SetLength(0); |
|
164 aStream.ReadL(iProtectedKey, length); |
|
165 |
|
166 length = aStream.ReadInt32L(); |
|
167 iDigest.SetLength(0); |
|
168 aStream.ReadL(iDigest, length); |
|
169 |
|
170 length = aStream.ReadInt32L(); |
|
171 iAuthenticationSeed.SetLength(0); |
|
172 aStream.ReadL(iAuthenticationSeed, length); |
|
173 |
|
174 length = aStream.ReadInt32L(); |
|
175 iProtectedAuthSeed.SetLength(0); |
|
176 aStream.ReadL(iProtectedAuthSeed, length); |
|
177 |
|
178 } |
|
179 |
|
180 // End of file |