1 /* |
|
2 * Copyright (c) 2007-2007 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: Meta data information wrapper |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // --------------------------------------------------------------------------- |
|
20 // Default two-phased constructor. |
|
21 // --------------------------------------------------------------------------- |
|
22 // |
|
23 inline CIRMetaData* CIRMetaData::NewL() |
|
24 { |
|
25 CIRMetaData* self = new ( ELeave ) CIRMetaData; |
|
26 CleanupStack::PushL( self ); |
|
27 self->ConstructL(); |
|
28 CleanupStack::Pop( self ); |
|
29 return self; |
|
30 } |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // Two-phased constructor for direct internalization. |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 inline CIRMetaData* CIRMetaData::NewL( const TDesC8& aData ) |
|
37 { |
|
38 CIRMetaData* self = new ( ELeave ) CIRMetaData; |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL( aData ); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Constructor. |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 inline CIRMetaData::CIRMetaData() |
|
50 { |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // Second-phase constructor. |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 inline void CIRMetaData::ConstructL() |
|
58 { |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // Second-phase constructor from binary data. |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 inline void CIRMetaData::ConstructL( const TDesC8& aData ) |
|
66 { |
|
67 RDesReadStream stream( aData ); |
|
68 CleanupClosePushL( stream ); |
|
69 InternalizeL( stream ); |
|
70 CleanupStack::PopAndDestroy( &stream ); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // Destructor. |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 inline CIRMetaData::~CIRMetaData() |
|
78 { |
|
79 iArtist.Close(); |
|
80 iSong.Close(); |
|
81 iStreamUrl.Close(); |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // Copies values from the supplied meta data object. |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 inline void CIRMetaData::SetL( const CIRMetaData& aMetaData ) |
|
89 { |
|
90 SetArtistL( aMetaData.Artist() ); |
|
91 SetSongL( aMetaData.Song() ); |
|
92 SetStreamUrlL( aMetaData.StreamUrl() ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // Sets the artist name. |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 inline void CIRMetaData::SetArtistL( const TDesC& aArtist ) |
|
100 { |
|
101 iArtist.Close(); |
|
102 iArtist.CreateL( aArtist ); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // Sets the song name. |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 inline void CIRMetaData::SetSongL( const TDesC& aSong ) |
|
110 { |
|
111 iSong.Close(); |
|
112 iSong.CreateL( aSong ); |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // Sets the stream URL. |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 inline void CIRMetaData::SetStreamUrlL( const TDesC& aStreamUrl ) |
|
120 { |
|
121 iStreamUrl.Close(); |
|
122 iStreamUrl.CreateL( aStreamUrl ); |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // Returns the artist name. |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 inline const TDesC& CIRMetaData::Artist() const |
|
130 { |
|
131 return iArtist; |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // Returns the song name. |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 inline const TDesC& CIRMetaData::Song() const |
|
139 { |
|
140 return iSong; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // Returns the stream URL. |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 inline const TDesC& CIRMetaData::StreamUrl() const |
|
148 { |
|
149 return iStreamUrl; |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // Internalizes the object from the supplied stream. |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 inline void CIRMetaData::InternalizeL( RReadStream& aStream ) |
|
157 { |
|
158 // The order of internalization must not be changed, nor can any of these |
|
159 // be removed. Futher data fields may be added. |
|
160 |
|
161 iArtist.Close(); |
|
162 iArtist.CreateL( aStream, KMaxTInt ); |
|
163 |
|
164 iSong.Close(); |
|
165 iSong.CreateL( aStream, KMaxTInt ); |
|
166 |
|
167 iStreamUrl.Close(); |
|
168 iStreamUrl.CreateL( aStream, KMaxTInt ); |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // Externalizes the object to the supplied stream. |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 inline void CIRMetaData::ExternalizeL( RWriteStream& aStream ) const |
|
176 { |
|
177 // The order of externalization must not be changed, nor can any of these |
|
178 // be removed. Futher data fields may be added. |
|
179 |
|
180 aStream << iArtist; |
|
181 aStream << iSong; |
|
182 aStream << iStreamUrl; |
|
183 |
|
184 aStream.CommitL(); |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // Equality comparison operator. |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 TBool CIRMetaData::operator==( const CIRMetaData& aMetaData ) const |
|
192 { |
|
193 TBool ret = EFalse; |
|
194 |
|
195 if ( iArtist == aMetaData.Artist() && iSong == aMetaData.Song() && iStreamUrl == aMetaData.StreamUrl() ) |
|
196 { |
|
197 ret = ETrue; |
|
198 } |
|
199 |
|
200 return ret; |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // Inequality comparison operator. |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 TBool CIRMetaData::operator!=( const CIRMetaData& aMetaData ) const |
|
208 { |
|
209 return !(*this == aMetaData); |
|
210 } |
|