1 /* |
|
2 * Copyright (c) 2008 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 the License "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: CVcxNsChPublishableData class definition* |
|
15 */ |
|
16 |
|
17 |
|
18 #include <liwvariant.h> |
|
19 #include <e32hashtab.h> |
|
20 |
|
21 #include <videosuiteres.rsg> |
|
22 #include "videochpublishabledata.h" |
|
23 #include "videochpublishabledataitem.h" |
|
24 #include "iptvlastwatchedapi.h" |
|
25 |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // content type values for tvvideosuite |
|
30 // related data |
|
31 _LIT(KContentLastWatched, "lastwatchedcontent" ); |
|
32 _LIT(KContentIPTV, "iptvcontent" ); |
|
33 _LIT(KContentMyVideos, "myvideoscontent" ); |
|
34 _LIT(KContentVideoFeeds, "videofeedcontent" ); |
|
35 _LIT(KContentPreloaded, "preloadedcontent" ); |
|
36 _LIT(KContentService, "servicecontent"); |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CVcxNsChPublishableData::CVcxNsChPublishableData |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CVcxNsChPublishableData::CVcxNsChPublishableData() |
|
43 { |
|
44 // No implementation required |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CVcxNsChPublishableData::~CVcxNsChPublishableData |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CVcxNsChPublishableData::~CVcxNsChPublishableData() |
|
52 { |
|
53 |
|
54 delete iLastWatched; |
|
55 |
|
56 if( iData ) |
|
57 { |
|
58 THashMapIter< TInt, CVcxNsPublishableDataItem* > iter( *iData ); |
|
59 for( CVcxNsPublishableDataItem* const* iValue = iter.NextValue(); |
|
60 iValue; iValue = iter.NextValue() ) |
|
61 { |
|
62 delete *iValue; |
|
63 } |
|
64 |
|
65 iData->Close(); |
|
66 delete iData; |
|
67 } |
|
68 |
|
69 iFs.Close(); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CVcxNsChPublishableData::NewLC |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CVcxNsChPublishableData* CVcxNsChPublishableData::NewLC() |
|
77 { |
|
78 CVcxNsChPublishableData* self = new ( ELeave )CVcxNsChPublishableData(); |
|
79 CleanupStack::PushL( self ); |
|
80 self->ConstructL(); |
|
81 return self; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CVcxNsChPublishableData::NewL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 CVcxNsChPublishableData* CVcxNsChPublishableData::NewL() |
|
89 { |
|
90 CVcxNsChPublishableData* self = CVcxNsChPublishableData::NewLC(); |
|
91 CleanupStack::Pop( self ); // self; |
|
92 self->iFs.Connect(); |
|
93 return self; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CVcxNsChPublishableData::ConstructL |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CVcxNsChPublishableData::ConstructL() |
|
101 { |
|
102 iData = new( ELeave )RHashMap< TInt, CVcxNsPublishableDataItem* >; |
|
103 |
|
104 CVcxNsPublishableDataItem* item = NULL; |
|
105 |
|
106 // Generate default values |
|
107 // Last watched |
|
108 item = CVcxNsPublishableDataItem::NewLC( TPtrC( KContentLastWatched ) ); |
|
109 item->SetDataL( TPtrC8( KTvVideoName ), KNullDesC ); |
|
110 item->SetDataL( TPtrC8( KTvVideoPath ), KNullDesC ); |
|
111 item->SetDataL( TPtrC8( KTvVideoIconPath ), KNullDesC ); |
|
112 item->SetDataL( TPtrC8( KTvVideoLastWatchedType ), 0 ); |
|
113 // ownership transferred |
|
114 iData->InsertL( EVCxNsCPContentLastWatched, item ); |
|
115 CleanupStack::Pop( item ); |
|
116 |
|
117 // iptv |
|
118 item = CVcxNsPublishableDataItem::NewLC( TPtrC( KContentIPTV ) ); |
|
119 item->SetDataL( TPtrC8( KTvVideoCount ), 0 ); |
|
120 // ownership transferred |
|
121 iData->InsertL( EVCxNsCPContentIPTV, item ); |
|
122 CleanupStack::Pop( item ); |
|
123 |
|
124 // My videos |
|
125 item = CVcxNsPublishableDataItem::NewLC( TPtrC( KContentMyVideos ) ); |
|
126 item->SetDataL( TPtrC8( KTvVideoName ), KNullDesC ); |
|
127 item->SetDataL( TPtrC8( KTvVideoCount ), 0 ); |
|
128 item->SetDataL( TPtrC8( KTvVideoHasNewVideos ), 0 ); |
|
129 // ownership transferred |
|
130 iData->InsertL( EVCxNsCPContentMyVideos, item ); |
|
131 CleanupStack::Pop( item ); |
|
132 |
|
133 // video feeds |
|
134 item = CVcxNsPublishableDataItem::NewLC( TPtrC( KContentVideoFeeds ) ); |
|
135 item->SetDataL( TPtrC8( KTvVideoCount ), 0 ); |
|
136 // ownership transferred |
|
137 iData->InsertL( EVCxNsCPContentFeeds, item ); |
|
138 CleanupStack::Pop( item ); |
|
139 |
|
140 // preloaded video |
|
141 item = CVcxNsPublishableDataItem::NewLC( TPtrC( KContentPreloaded ) ); |
|
142 item->SetDataL( TPtrC8( KTvVideoName ), KNullDesC ); |
|
143 item->SetDataL( TPtrC8( KTvVideoPath ), KNullDesC ); |
|
144 item->SetDataL( TPtrC8( KTvVideoIconPath ), KNullDesC ); |
|
145 // ownership transferred |
|
146 iData->InsertL( EVCxNsCPContentPreloaded, item ); |
|
147 CleanupStack::Pop( item ); |
|
148 |
|
149 // preloaded service group |
|
150 item = CVcxNsPublishableDataItem::NewLC( TPtrC( KContentService ) ); |
|
151 item->SetDataL( TPtrC8( KTvVideoName ), KNullDesC ); |
|
152 item->SetDataL( TPtrC8( KTvVideoPath ), KNullDesC ); |
|
153 item->SetDataL( TPtrC8( KTvVideoId ), -1 ); |
|
154 item->SetDataL( TPtrC8( KTvVideoIconPath ), KNullDesC ); |
|
155 // ownership transferred |
|
156 iData->InsertL( EVCxNsCPContentServiceGroup, item ); |
|
157 CleanupStack::Pop( item ); |
|
158 |
|
159 iLastWatched = CIptvLastWatchedApi::NewL(); |
|
160 |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CVcxNsChPublishableData::GetItemL |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 CVcxNsPublishableDataItem* CVcxNsChPublishableData::GetItemL( TVCxNsCPContentType aContentType ) |
|
168 { |
|
169 CVcxNsPublishableDataItem** item = iData->Find( aContentType ); |
|
170 |
|
171 if( !item || !( *item ) ) |
|
172 { |
|
173 User::Leave( KErrNotFound ); |
|
174 } |
|
175 return *item; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CVcxNsChPublishableData::ItemContentTypeNameL |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 TPtrC CVcxNsChPublishableData::ItemContentTypeNameL( TVCxNsCPContentType aContentType ) |
|
183 { |
|
184 return GetItemL( aContentType )->ContentType(); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CVcxNsChPublishableData::SetDataL |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CVcxNsChPublishableData::SetDataL( |
|
192 TVCxNsCPContentType aContentType, |
|
193 TPtrC8 aValueKey, |
|
194 TInt aValue ) |
|
195 { |
|
196 GetItemL( aContentType )->SetDataL( aValueKey, aValue ); |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CVcxNsChPublishableData::SetDataL |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 void CVcxNsChPublishableData::SetDataL( |
|
204 TVCxNsCPContentType aContentType, |
|
205 TPtrC8 aValueKey, |
|
206 const TDesC& aValue ) |
|
207 { |
|
208 GetItemL( aContentType )->SetDataL( aValueKey, aValue ); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CVcxNsChPublishableData::GetIntDataL |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TInt CVcxNsChPublishableData::GetIntDataL( |
|
216 TVCxNsCPContentType aContentType, |
|
217 TPtrC8 aValueKey ) |
|
218 { |
|
219 return GetItemL( aContentType )->GetIntDataL( aValueKey ); |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CVcxNsChPublishableData::GetDesCDataL |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 const TDesC& CVcxNsChPublishableData::GetDesCDataL( |
|
227 TVCxNsCPContentType aContentType, |
|
228 TPtrC8 aValueKey ) |
|
229 { |
|
230 return GetItemL( aContentType )->GetDesCDataL( aValueKey ); |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CVcxNsChPublishableData::FillCPDataMapL |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void CVcxNsChPublishableData::FillCPDataMapL( TVCxNsCPContentType aContentType, |
|
238 CLiwDefaultMap& aDataMap ) |
|
239 { |
|
240 GetItemL( aContentType )->FillCPDataMapL( aDataMap ); |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CVcxNsChPublishableData::ReadCPDataMapL |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 void CVcxNsChPublishableData::ReadCPDataMapL( TVCxNsCPContentType aContentType, |
|
248 CLiwDefaultMap& aDataMap ) |
|
249 { |
|
250 GetItemL( aContentType )->ReadCPDataMapL( aDataMap ); |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CVcxNsChPublishableData::ClearData |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 void CVcxNsChPublishableData::ClearData( TVCxNsCPContentType aContentType ) |
|
258 { |
|
259 CVcxNsPublishableDataItem* item( 0 ); |
|
260 TRAPD( err, item = GetItemL( aContentType ) ); |
|
261 if( err == KErrNone && item ) |
|
262 { |
|
263 item->ClearData(); |
|
264 } |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CVcxNsChPublishableData::FileExists |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 TBool CVcxNsChPublishableData::FileExists( const TDesC& aFilePath ) |
|
272 { |
|
273 if( BaflUtils::FileExists( iFs, aFilePath ) ) |
|
274 { |
|
275 return ETrue; |
|
276 } |
|
277 return EFalse; |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CVcxNsChPublishableData::LastWatchedApi |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 CIptvLastWatchedApi& CVcxNsChPublishableData::LastWatchedApi() |
|
285 { |
|
286 return *iLastWatched; |
|
287 } |
|
288 |
|