|
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: This class implements the interface specified in CMetaDataSource |
|
15 * when audio source is from a descriptor. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "MetaDataSourceDescriptor.h" |
|
23 #ifdef _DEBUG |
|
24 #include <e32svr.h> |
|
25 #endif |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CMetaDataSourceDescriptor::CMetaDataSourceDescriptor |
|
31 // C++ default constructor can NOT contain any code, that |
|
32 // might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CMetaDataSourceDescriptor::CMetaDataSourceDescriptor() |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMetaDataSourceDescriptor::ConstructL |
|
41 // Symbian 2nd phase constructor can leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 void CMetaDataSourceDescriptor::ConstructL( |
|
45 const TDesC8& aDes ) |
|
46 { |
|
47 iSource.Set(aDes); |
|
48 iLength = iSource.Length(); |
|
49 #ifdef _DEBUG |
|
50 RDebug::Print(_L("CMetaDataSourceDescriptor::ConstructL - Done")); |
|
51 #endif |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CMetaDataSourceDescriptor::NewL |
|
56 // Two-phased constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CMetaDataSourceDescriptor* CMetaDataSourceDescriptor::NewL( |
|
60 const TDesC8& aDes ) |
|
61 { |
|
62 #ifdef _DEBUG |
|
63 RDebug::Print(_L("CMetaDataSourceDescriptor::NewL")); |
|
64 #endif |
|
65 CMetaDataSourceDescriptor* self = new( ELeave ) CMetaDataSourceDescriptor; |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL( aDes ); |
|
68 CleanupStack::Pop(); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // Destructor |
|
73 CMetaDataSourceDescriptor::~CMetaDataSourceDescriptor() |
|
74 { |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CMetaDataSourceDescriptor::ReadL |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CMetaDataSourceDescriptor::ReadL( |
|
82 TDes8& aDes ) |
|
83 { |
|
84 if ( aDes.Length() >= iLength ) |
|
85 { |
|
86 aDes.Copy(iSource); |
|
87 } |
|
88 else |
|
89 { |
|
90 aDes.Copy(iSource.Ptr(), aDes.MaxLength()); |
|
91 } |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CMetaDataSourceDescriptor::ReadL |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CMetaDataSourceDescriptor::ReadL( |
|
99 TDes8& aDes, |
|
100 TInt aLength ) |
|
101 { |
|
102 if(aLength > aDes.MaxLength()) |
|
103 { |
|
104 aLength = aDes.MaxLength(); |
|
105 } |
|
106 aDes.Copy(iSource.Ptr(), aLength); |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CMetaDataSourceDescriptor::ReadL |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CMetaDataSourceDescriptor::ReadL( |
|
114 TInt aPos, |
|
115 TDes8& aDes ) |
|
116 { |
|
117 if(aPos + aDes.MaxLength() > iLength) |
|
118 { |
|
119 aDes.FillZ(aDes.MaxLength()); |
|
120 return; |
|
121 } |
|
122 aDes.Copy(iSource.Mid(aPos, aDes.MaxLength())); |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CMetaDataSourceDescriptor::ReadL |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CMetaDataSourceDescriptor::ReadL( |
|
130 TInt aPos, |
|
131 TDes8& aDes, |
|
132 TInt aLength ) |
|
133 { |
|
134 if(aPos + aLength > iLength) |
|
135 { |
|
136 aDes.FillZ(aDes.MaxLength()); |
|
137 return; |
|
138 } |
|
139 if(aLength > aDes.MaxLength()) |
|
140 { |
|
141 aLength = aDes.MaxLength(); |
|
142 } |
|
143 aDes.Copy(iSource.Mid(aPos, aLength)); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CMetaDataSourceDescriptor::Size |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 TInt CMetaDataSourceDescriptor::Size( |
|
151 TInt& aSize ) const |
|
152 { |
|
153 aSize = iLength; |
|
154 return KErrNone; |
|
155 } |
|
156 |
|
157 // End of File |