|
1 /* |
|
2 * Copyright (c) 2004 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: M-Mms-Element-Descriptor header |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <msvstore.h> |
|
23 |
|
24 #include "mmselementdescriptor.h" |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // LOCAL CONSTANTS AND MACROS |
|
35 |
|
36 // MODULE DATA STRUCTURES |
|
37 |
|
38 // LOCAL FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 // ============================= LOCAL FUNCTIONS =============================== |
|
43 |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMmsElementDescriptor::CMmsElementDescriptor |
|
49 // C++ default constructor can NOT contain any code, that |
|
50 // might leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CMmsElementDescriptor::CMmsElementDescriptor() |
|
54 { |
|
55 // everything is initailized to 0 by CBase |
|
56 } |
|
57 |
|
58 // Destructor |
|
59 CMmsElementDescriptor::~CMmsElementDescriptor() |
|
60 { |
|
61 delete iContentReference; |
|
62 delete iContentType; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CMmsElementDescriptor::Externalize |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CMmsElementDescriptor::ExternalizeL( RMsvWriteStream& aStream ) const |
|
70 { |
|
71 TInt32 length = 0; |
|
72 length = ContentReference().Length(); |
|
73 aStream.WriteInt32L( length ); |
|
74 if ( length > 0 ) |
|
75 { |
|
76 aStream << ContentReference(); |
|
77 } |
|
78 |
|
79 length = 0; |
|
80 length = ContentType().Length(); |
|
81 aStream.WriteInt32L( length ); |
|
82 if ( length > 0 ) |
|
83 { |
|
84 aStream << ContentType(); |
|
85 } |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CMmsElementDescriptor::InternalizeL |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CMmsElementDescriptor::InternalizeL( RMsvReadStream& aStream ) |
|
93 { |
|
94 delete iContentReference; |
|
95 iContentReference = NULL; |
|
96 delete iContentType; |
|
97 iContentType = NULL; |
|
98 TInt32 length = 0; |
|
99 length = aStream.ReadInt32L(); |
|
100 |
|
101 if ( length > 0 ) |
|
102 { |
|
103 iContentReference = HBufC::NewL( aStream, length ); |
|
104 } |
|
105 |
|
106 length = aStream.ReadInt32L(); |
|
107 if ( length > 0 ) |
|
108 { |
|
109 iContentType = HBufC8::NewL( aStream, length ); |
|
110 } |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CMmsElementDescriptor::Size |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 TInt CMmsElementDescriptor::Size() const |
|
118 { |
|
119 TInt size = 0; |
|
120 size += sizeof( TInt32 ); |
|
121 // use size to net number of bytes, not characters |
|
122 size += ContentReference().Size(); |
|
123 size += sizeof( TInt32 ); |
|
124 size += ContentType().Size(); |
|
125 return size; |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CMmsElementDescriptor::ContentReference |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C TPtrC CMmsElementDescriptor::ContentReference() const |
|
133 { |
|
134 return iContentReference ? TPtrC( *iContentReference ) : TPtrC(); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CMmsElementDescriptor::SetContentReferenceL |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 EXPORT_C void CMmsElementDescriptor::SetContentReferenceL( const TDesC& aContentReference ) |
|
142 { |
|
143 delete iContentReference; |
|
144 iContentReference = NULL; |
|
145 iContentReference = aContentReference.AllocL(); |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CMmsElementDescriptor::ContentType |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C TPtrC8 CMmsElementDescriptor::ContentType() const |
|
153 { |
|
154 return iContentType ? TPtrC8( *iContentType ) : TPtrC8(); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CMmsElementDescriptor::SetContentTypeL |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 EXPORT_C void CMmsElementDescriptor::SetContentTypeL( const TDesC8& aContentType ) |
|
162 { |
|
163 delete iContentType; |
|
164 iContentType = NULL; |
|
165 iContentType = aContentType.AllocL(); |
|
166 } |
|
167 |
|
168 |
|
169 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
170 |
|
171 // End of File |