|
1 /* |
|
2 * ============================================================================= |
|
3 * Name : CMSRPReport.cpp |
|
4 * Part of : MSRP API |
|
5 * Version : %version: 1 % << Don't touch! Updated by Synergy at check-out. |
|
6 * |
|
7 * Copyright © 2009 Nokia. All rights reserved. |
|
8 * This material, including documentation and any related |
|
9 * computer programs, is protected by copyright controlled by |
|
10 * Nokia Corporation. All rights are reserved. Copying, |
|
11 * including reproducing, storing, adapting or translating, any |
|
12 * or all of this material requires the prior written consent of |
|
13 * Nokia Corporation. This material also contains confidential |
|
14 * information which may not be disclosed to others without the |
|
15 * prior written consent of Nokia Corporation. |
|
16 * ============================================================================= |
|
17 */ |
|
18 |
|
19 // CLASS HEADER |
|
20 #include "CMSRPReport.h" |
|
21 |
|
22 // EXTERNAL INCLUDES |
|
23 //#include <e32base.h> |
|
24 #include <MsrpStrConsts.h> |
|
25 |
|
26 // INTERNAL INCLUDES |
|
27 #include "MsrpCommon.h" |
|
28 #include "CMSRPFromPathHeader.h" |
|
29 #include "CMSRPToPathHeader.h" |
|
30 #include "CMSRPMessageIdHeader.h" |
|
31 #include "CMSRPByteRangeHeader.h" |
|
32 #include "CMSRPContentTypeHeader.h" |
|
33 #include "CMSRPFailureReportHeader.h" |
|
34 #include "CMSRPSuccessReportHeader.h" |
|
35 #include "CMSRPStatusHeader.h" |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CMSRPReport::CMSRPReport |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CMSRPReport::CMSRPReport() |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CMSRPReport::~CMSRPReport |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 EXPORT_C CMSRPReport::~CMSRPReport() |
|
50 { |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CMSRPReport::InternalizeL |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CMSRPReport* CMSRPReport::InternalizeL( RReadStream& aReadStream ) |
|
58 { |
|
59 CMSRPReport* self = new (ELeave) CMSRPReport(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->DoInternalizeL( aReadStream ); |
|
62 CleanupStack::Pop( self ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CMSRPReport::DoInternalizeL |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CMSRPReport::DoInternalizeL( RReadStream& aReadStream ) |
|
71 { |
|
72 TUint8 dataType( 0 ); |
|
73 |
|
74 // read the identifier |
|
75 if ( aReadStream.ReadUint8L() != 102 ) |
|
76 { |
|
77 User::Leave( KErrArgument ); |
|
78 } |
|
79 |
|
80 do |
|
81 { |
|
82 dataType = aReadStream.ReadUint8L(); |
|
83 |
|
84 switch( dataType ) |
|
85 { |
|
86 case 1: // from path |
|
87 { |
|
88 iFromPath = CMSRPFromPathHeader::InternalizeValueL( aReadStream ); |
|
89 break; |
|
90 } |
|
91 case 2: // to path |
|
92 { |
|
93 iToPath = CMSRPToPathHeader::InternalizeValueL( aReadStream ); |
|
94 break; |
|
95 } |
|
96 case 3: // message id |
|
97 { |
|
98 iMessageId = CMSRPMessageIdHeader::InternalizeValueL( aReadStream ); |
|
99 break; |
|
100 } |
|
101 case 4: // byte range |
|
102 { |
|
103 iByteRange = CMSRPByteRangeHeader::InternalizeValueL( aReadStream ); |
|
104 break; |
|
105 } |
|
106 case 5: // content type |
|
107 { |
|
108 iContentType = CMSRPContentTypeHeader::InternalizeValueL( aReadStream ); |
|
109 break; |
|
110 } |
|
111 case 6: // failure report |
|
112 { |
|
113 iFailureReport = CMSRPFailureReportHeader::InternalizeValueL( aReadStream ); |
|
114 break; |
|
115 } |
|
116 case 7: // success report |
|
117 { |
|
118 iSuccessReport = CMSRPSuccessReportHeader::InternalizeValueL( aReadStream ); |
|
119 break; |
|
120 } |
|
121 case 8: // status |
|
122 { |
|
123 iStatusHeader = CMSRPStatusHeader::InternalizeValueL( aReadStream ); |
|
124 break; |
|
125 } |
|
126 |
|
127 default: |
|
128 { |
|
129 // nothing to do |
|
130 break; |
|
131 } |
|
132 } |
|
133 |
|
134 } while( dataType ); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CMSRPReport::ExternalizeL |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 EXPORT_C void CMSRPReport::ExternalizeL( RWriteStream& aWriteStream ) |
|
142 { |
|
143 // first add the MSRP Message identifier |
|
144 aWriteStream.WriteUint8L( 102 ); // MSRP Report identifier |
|
145 |
|
146 if( iFromPath ) |
|
147 { |
|
148 aWriteStream.WriteUint8L(1); // more headers in the stream flag |
|
149 iFromPath->ExternalizeValueL( aWriteStream ); |
|
150 } |
|
151 if( iToPath ) |
|
152 { |
|
153 aWriteStream.WriteUint8L(2); // more headers in the stream flag |
|
154 iToPath->ExternalizeValueL( aWriteStream ); |
|
155 } |
|
156 if ( iMessageId ) |
|
157 { |
|
158 aWriteStream.WriteUint8L(3); // more headers in the stream flag |
|
159 iMessageId->ExternalizeValueL( aWriteStream ); |
|
160 } |
|
161 if( iByteRange ) |
|
162 { |
|
163 aWriteStream.WriteUint8L(4); // more headers in the stream flag |
|
164 iByteRange->ExternalizeValueL( aWriteStream ); |
|
165 } |
|
166 if( iContentType ) |
|
167 { |
|
168 aWriteStream.WriteUint8L(5); // more headers in the stream flag |
|
169 iContentType->ExternalizeValueL( aWriteStream ); |
|
170 } |
|
171 if( iFailureReport ) |
|
172 { |
|
173 aWriteStream.WriteUint8L(6); // more headers in the stream flag |
|
174 iFailureReport->ExternalizeValueL( aWriteStream ); |
|
175 } |
|
176 if( iSuccessReport ) |
|
177 { |
|
178 aWriteStream.WriteUint8L(7); // more headers in the stream flag |
|
179 iSuccessReport->ExternalizeValueL( aWriteStream ); |
|
180 } |
|
181 if ( iStatusHeader ) |
|
182 { |
|
183 aWriteStream.WriteUint8L( 8 ); |
|
184 iStatusHeader->ExternalizeValueL( aWriteStream ); |
|
185 } |
|
186 |
|
187 aWriteStream.WriteUint8L(0); // no more headers in the stream flag |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CMSRPReport::IsReport |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 EXPORT_C TBool CMSRPReport::IsReport( const TDesC8& aBuffer ) |
|
195 { |
|
196 if ( aBuffer.Length() ) |
|
197 { |
|
198 if ( aBuffer[ 0 ] == 102 ) |
|
199 { |
|
200 return ETrue; |
|
201 } |
|
202 } |
|
203 |
|
204 return EFalse; |
|
205 } |
|
206 |
|
207 // End of File |