author | Sebastian Brannstrom <sebastianb@symbian.org> |
Sat, 23 Oct 2010 17:09:23 +0100 | |
branch | 3rded |
changeset 277 | 03ad04f315db |
parent 176 | 1c8b56cb6409 |
child 343 | 9c56bf585696 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright (c) 2007-2010 Sebastian Brannstrom, Lars Persson, EmbedDev AB |
|
3 |
* |
|
4 |
* All rights reserved. |
|
5 |
* This component and the accompanying materials are made available |
|
6 |
* under the terms of the License "Eclipse Public License v1.0" |
|
7 |
* which accompanies this distribution, and is available |
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 |
* |
|
10 |
* Initial Contributors: |
|
11 |
* EmbedDev AB - initial contribution. |
|
12 |
* |
|
13 |
* Contributors: |
|
14 |
* |
|
15 |
* Description: |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
#include <commdb.h> |
|
20 |
#include "PodcastModel.h" |
|
21 |
#include "FeedEngine.h" |
|
22 |
#include "SettingsEngine.h" |
|
23 |
#include "ShowEngine.h" |
|
24 |
#include "connectionengine.h" |
|
60 | 25 |
#include "podcastutils.h" |
26 |
#include "Podcatcher.pan" |
|
2 | 27 |
#include <bautils.h> |
90
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
28 |
#include <aknserverapp.h> // MAknServerAppExitObserver |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
29 |
#include <DocumentHandler.h> |
2 | 30 |
|
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
148
diff
changeset
|
31 |
|
2 | 32 |
const TInt KDefaultGranu = 5; |
33 |
_LIT(KDBFileName, "podcatcher.sqlite"); |
|
34 |
_LIT(KDBTemplateFileName, "podcatcher.sqlite.template"); |
|
35 |
||
36 |
EXPORT_C CPodcastModel* CPodcastModel::NewL() |
|
37 |
{ |
|
38 |
CPodcastModel* self = new (ELeave) CPodcastModel; |
|
39 |
CleanupStack::PushL(self); |
|
40 |
self->ConstructL(); |
|
41 |
CleanupStack::Pop(self); |
|
42 |
return self; |
|
43 |
} |
|
44 |
||
45 |
CPodcastModel::~CPodcastModel() |
|
46 |
{ |
|
47 |
||
48 |
delete iFeedEngine; |
|
49 |
delete iSettingsEngine; |
|
50 |
delete iShowEngine; |
|
51 |
||
52 |
delete iIapNameArray; |
|
53 |
iIapIdArray.Close(); |
|
54 |
||
55 |
delete iSNAPNameArray; |
|
56 |
iSNAPIdArray.Close(); |
|
57 |
delete iCommDB; |
|
58 |
sqlite3_close(iDB); |
|
59 |
iFsSession.Close(); |
|
60 |
iActiveShowList.ResetAndDestroy(); |
|
61 |
iActiveShowList.Close(); |
|
62 |
delete iConnectionEngine; |
|
63 |
delete iImageHandler; |
|
90
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
64 |
delete iDocHandler; |
2 | 65 |
} |
66 |
||
67 |
CPodcastModel::CPodcastModel() |
|
68 |
{ |
|
69 |
} |
|
70 |
||
71 |
void CPodcastModel::ConstructL() |
|
72 |
{ |
|
73 |
DP("CPodcastModel::ConstructL BEGIN"); |
|
74 |
User::LeaveIfError(iFsSession.Connect()); |
|
75 |
iCommDB = CCommsDatabase::NewL (EDatabaseTypeUnspecified); |
|
76 |
iIapNameArray = new (ELeave) CDesCArrayFlat(KDefaultGranu); |
|
77 |
iSNAPNameArray = new (ELeave) CDesCArrayFlat(KDefaultGranu); |
|
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
148
diff
changeset
|
78 |
|
60 | 79 |
iImageHandler = CImageHandler::NewL(FsSession(), *this); |
90
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
80 |
iDocHandler = CDocumentHandler::NewL(CEikonEnv::Static()->Process()); |
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
148
diff
changeset
|
81 |
|
176
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
82 |
UpdateIAPListL(); |
2 | 83 |
|
84 |
iSettingsEngine = CSettingsEngine::NewL(*this); |
|
85 |
iConnectionEngine = CConnectionEngine::NewL(*this); |
|
86 |
||
176
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
87 |
TRAPD(err, OpenDBL()); |
60 | 88 |
|
89 |
if (err != KErrNone) |
|
90 |
{ |
|
91 |
ResetDB(); |
|
92 |
||
93 |
TRAP(err, OpenDBL()); |
|
94 |
||
95 |
if (err != KErrNone) |
|
96 |
{ |
|
97 |
Panic(EPodcatcherPanicDB); |
|
98 |
} |
|
99 |
||
100 |
} |
|
101 |
||
2 | 102 |
iFeedEngine = CFeedEngine::NewL(*this); |
103 |
iShowEngine = CShowEngine::NewL(*this); |
|
104 |
||
105 |
DP("CPodcastModel::ConstructL END"); |
|
106 |
} |
|
107 |
||
108 |
||
109 |
||
110 |
EXPORT_C void CPodcastModel::UpdateIAPListL() |
|
111 |
{ |
|
112 |
iIapNameArray->Reset(); |
|
113 |
iIapIdArray.Reset(); |
|
114 |
||
115 |
CCommsDbTableView* table = iCommDB->OpenTableLC (TPtrC (IAP)); |
|
116 |
TInt ret = table->GotoFirstRecord (); |
|
117 |
TPodcastIAPItem IAPItem; |
|
118 |
TBuf <KCommsDbSvrMaxFieldLength> bufName; |
|
119 |
while (ret == KErrNone) // There was a first record |
|
120 |
{ |
|
121 |
table->ReadUintL(TPtrC(COMMDB_ID), IAPItem.iIapId); |
|
122 |
table->ReadTextL (TPtrC(COMMDB_NAME), bufName); |
|
123 |
table->ReadTextL (TPtrC(IAP_BEARER_TYPE), IAPItem.iBearerType); |
|
124 |
table->ReadTextL (TPtrC(IAP_SERVICE_TYPE), IAPItem.iServiceType); |
|
125 |
||
126 |
iIapIdArray.Append(IAPItem); |
|
127 |
iIapNameArray->AppendL(bufName); |
|
128 |
ret = table->GotoNextRecord(); |
|
129 |
} |
|
130 |
CleanupStack::PopAndDestroy(); // Close table |
|
131 |
} |
|
132 |
||
133 |
EXPORT_C void CPodcastModel::UpdateSNAPListL() |
|
134 |
{ |
|
176
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
135 |
// DP("CPodcastModel::UpdateSNAPListL BEGIN"); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
136 |
// iSNAPNameArray->Reset(); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
137 |
// iSNAPIdArray.Reset(); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
138 |
// |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
139 |
// RCmDestination destination; |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
140 |
// TPodcastIAPItem IAPItem; |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
141 |
// |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
142 |
// RArray<TUint32> destArray; |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
143 |
// CleanupClosePushL(destArray); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
144 |
// iCmManager.AllDestinationsL(destArray); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
145 |
// |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
146 |
// TInt cnt = destArray.Count(); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
147 |
// DP1("destArray.Count==%d", cnt); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
148 |
// for(TInt loop = 0;loop<cnt;loop++) |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
149 |
// { |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
150 |
// destination = iCmManager.DestinationL (destArray[loop]); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
151 |
// CleanupClosePushL(destination); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
152 |
// if(!destination.IsHidden()) |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
153 |
// { |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
154 |
// IAPItem.iIapId = destArray[loop]; |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
155 |
// HBufC* name = destination.NameLC(); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
156 |
// DP1(" destination.NameLC==%S", name); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
157 |
// iSNAPNameArray->AppendL(*name); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
158 |
// CleanupStack::PopAndDestroy(name); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
159 |
// iSNAPIdArray.Append(IAPItem); |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
160 |
// } |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
161 |
// CleanupStack::PopAndDestroy();//close destination |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
162 |
// } |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
163 |
// CleanupStack::PopAndDestroy();// close destArray |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
164 |
// |
1c8b56cb6409
Now compiles for 3rd ed, but does not launch due to malloc error in SQLite
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
164
diff
changeset
|
165 |
// DP("CPodcastModel::UpdateSNAPListL END"); |
2 | 166 |
} |
167 |
||
168 |
EXPORT_C CDesCArrayFlat* CPodcastModel::IAPNames() |
|
169 |
{ |
|
170 |
return iIapNameArray; |
|
171 |
} |
|
172 |
||
173 |
EXPORT_C RArray<TPodcastIAPItem>& CPodcastModel::IAPIds() |
|
174 |
{ |
|
175 |
return iIapIdArray; |
|
176 |
} |
|
177 |
||
178 |
EXPORT_C CDesCArrayFlat* CPodcastModel::SNAPNames() |
|
179 |
{ |
|
180 |
return iSNAPNameArray; |
|
181 |
} |
|
182 |
||
183 |
EXPORT_C RArray<TPodcastIAPItem>& CPodcastModel::SNAPIds() |
|
184 |
{ |
|
185 |
return iSNAPIdArray; |
|
186 |
} |
|
187 |
||
188 |
||
189 |
RFs& CPodcastModel::FsSession() |
|
190 |
{ |
|
191 |
return iFsSession; |
|
192 |
} |
|
193 |
||
194 |
EXPORT_C void CPodcastModel::SetPlayingPodcast(CShowInfo* aPodcast) |
|
195 |
{ |
|
196 |
iPlayingPodcast = aPodcast; |
|
197 |
} |
|
198 |
||
199 |
EXPORT_C CShowInfo* CPodcastModel::PlayingPodcast() |
|
200 |
{ |
|
201 |
return iPlayingPodcast; |
|
202 |
} |
|
203 |
||
204 |
EXPORT_C CFeedEngine& CPodcastModel::FeedEngine() |
|
205 |
{ |
|
206 |
return *iFeedEngine; |
|
207 |
} |
|
208 |
||
209 |
EXPORT_C CShowEngine& CPodcastModel::ShowEngine() |
|
210 |
{ |
|
211 |
return *iShowEngine; |
|
212 |
} |
|
213 |
||
214 |
EXPORT_C CSettingsEngine& CPodcastModel::SettingsEngine() |
|
215 |
{ |
|
216 |
return *iSettingsEngine; |
|
217 |
} |
|
218 |
||
219 |
EXPORT_C CConnectionEngine& CPodcastModel::ConnectionEngine() |
|
220 |
{ |
|
221 |
return *iConnectionEngine; |
|
222 |
} |
|
223 |
||
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
148
diff
changeset
|
224 |
EXPORT_C void CPodcastModel::PlayPausePodcastL(CShowInfo* aPodcast, TBool /* aPlayOnInit */) |
2 | 225 |
{ |
136
cee38af14bcf
Merged show playback error handling from S^3 branch
teknolog
parents:
90
diff
changeset
|
226 |
DP("CPodcastModel::PlayPausePodcastL BEGIN"); |
90
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
227 |
TRAPD(err, LaunchFileEmbeddedL(aPodcast->FileName())); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
228 |
|
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
229 |
if (err == KErrNone) |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
230 |
{ |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
231 |
aPodcast->SetPlayState(EPlayed); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
232 |
iShowEngine->UpdateShowL(*aPodcast); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
233 |
} |
136
cee38af14bcf
Merged show playback error handling from S^3 branch
teknolog
parents:
90
diff
changeset
|
234 |
else |
cee38af14bcf
Merged show playback error handling from S^3 branch
teknolog
parents:
90
diff
changeset
|
235 |
{ |
cee38af14bcf
Merged show playback error handling from S^3 branch
teknolog
parents:
90
diff
changeset
|
236 |
User::Leave(err); |
cee38af14bcf
Merged show playback error handling from S^3 branch
teknolog
parents:
90
diff
changeset
|
237 |
} |
cee38af14bcf
Merged show playback error handling from S^3 branch
teknolog
parents:
90
diff
changeset
|
238 |
DP("CPodcastModel::PlayPausePodcastL END"); |
2 | 239 |
} |
240 |
||
241 |
EXPORT_C CFeedInfo* CPodcastModel::ActiveFeedInfo() |
|
242 |
{ |
|
243 |
return iActiveFeed; |
|
244 |
} |
|
245 |
||
246 |
EXPORT_C void CPodcastModel::SetActiveFeedInfo(CFeedInfo* aFeedInfo) |
|
247 |
{ |
|
248 |
iActiveFeed = aFeedInfo; |
|
249 |
} |
|
250 |
||
251 |
EXPORT_C RShowInfoArray& CPodcastModel::ActiveShowList() |
|
252 |
{ |
|
253 |
return iActiveShowList; |
|
254 |
} |
|
255 |
||
256 |
void CPodcastModel::SetActiveShowList(RShowInfoArray& aShowArray) |
|
257 |
{ |
|
258 |
iActiveShowList.ResetAndDestroy(); |
|
259 |
TInt cnt = aShowArray.Count(); |
|
260 |
||
261 |
for(TInt loop = 0;loop < cnt; loop++) |
|
262 |
{ |
|
263 |
iActiveShowList.Append(aShowArray[loop]); |
|
264 |
} |
|
265 |
} |
|
266 |
||
60 | 267 |
EXPORT_C void CPodcastModel::DropDB() |
268 |
{ |
|
269 |
if (iDB != NULL) |
|
270 |
{ |
|
271 |
sqlite3_close(iDB); |
|
272 |
iDB = NULL; |
|
273 |
} |
|
274 |
||
275 |
TFileName dbFileName; |
|
276 |
dbFileName.Copy(iSettingsEngine->PrivatePath()); |
|
277 |
dbFileName.Append(KDBFileName); |
|
278 |
||
279 |
// remove the old DB file |
|
280 |
if (BaflUtils::FileExists(iFsSession, dbFileName)) |
|
281 |
{ |
|
282 |
BaflUtils::DeleteFile(iFsSession, dbFileName); |
|
283 |
} |
|
284 |
} |
|
285 |
||
286 |
void CPodcastModel::ResetDB() |
|
287 |
{ |
|
288 |
DP("CPodcastModel::ResetDB BEGIN"); |
|
289 |
||
290 |
DropDB(); |
|
291 |
||
292 |
TFileName dbFileName; |
|
293 |
dbFileName.Copy(iSettingsEngine->PrivatePath()); |
|
294 |
dbFileName.Append(KDBFileName); |
|
295 |
||
296 |
// remove the old DB file |
|
297 |
if (BaflUtils::FileExists(iFsSession, dbFileName)) |
|
298 |
{ |
|
299 |
BaflUtils::DeleteFile(iFsSession, dbFileName); |
|
300 |
} |
|
301 |
||
302 |
// copy template to new DB |
|
303 |
TFileName dbTemplate; |
|
304 |
dbTemplate.Copy(iSettingsEngine->PrivatePath()); |
|
305 |
dbTemplate.Append(KDBTemplateFileName); |
|
306 |
||
307 |
BaflUtils::CopyFile(iFsSession, dbTemplate,dbFileName); |
|
308 |
iIsFirstStartup = ETrue; |
|
309 |
DP("CPodcastModel::ResetDB END"); |
|
310 |
} |
|
311 |
||
312 |
||
313 |
void CPodcastModel::OpenDBL() |
|
314 |
{ |
|
315 |
DP("CPodcastModel::OpenDBL BEGIN"); |
|
316 |
||
317 |
if (iDB != NULL) |
|
318 |
{ |
|
319 |
sqlite3_close(iDB); |
|
320 |
iDB = NULL; |
|
321 |
} |
|
322 |
||
323 |
TFileName dbFileName; |
|
324 |
dbFileName.Copy(iSettingsEngine->PrivatePath()); |
|
325 |
dbFileName.Append(KDBFileName); |
|
326 |
||
327 |
if (!BaflUtils::FileExists(iFsSession, dbFileName)) |
|
328 |
{ |
|
329 |
User::Leave(KErrNotFound); |
|
330 |
} |
|
331 |
||
332 |
if (iDB == NULL) { |
|
333 |
// open DB |
|
334 |
TBuf8<KMaxFileName> filename8; |
|
335 |
filename8.Copy(dbFileName); |
|
336 |
int rc = sqlite3_open((const char*) filename8.PtrZ(), &iDB); |
|
337 |
if(rc != SQLITE_OK){ |
|
338 |
User::Leave(KErrCorrupt); |
|
339 |
} |
|
340 |
||
341 |
// do a test query |
|
342 |
sqlite3_stmt *st; |
|
343 |
rc = sqlite3_prepare_v2(iDB,"select count(*) from feeds" , -1, &st, (const char**) NULL); |
|
344 |
if( rc==SQLITE_OK ) |
|
345 |
{ |
|
346 |
Cleanup_sqlite3_finalize_PushL(st); |
|
347 |
rc = sqlite3_step(st); |
|
348 |
||
349 |
if (rc != SQLITE_ROW) |
|
350 |
{ |
|
351 |
User::Leave(KErrCorrupt); |
|
352 |
} |
|
353 |
CleanupStack::PopAndDestroy(); // st |
|
354 |
} |
|
355 |
else |
|
356 |
{ |
|
357 |
User::Leave(KErrCorrupt); |
|
358 |
} |
|
359 |
} |
|
360 |
||
361 |
DP("CPodcastModel::OpenDBL END"); |
|
362 |
} |
|
363 |
||
2 | 364 |
sqlite3* CPodcastModel::DB() |
365 |
{ |
|
366 |
return iDB; |
|
367 |
} |
|
368 |
||
369 |
void CPodcastModel::SetProxyUsageIfNeededL(RHTTPSession& aSession) |
|
370 |
{ |
|
371 |
TBool useProxy = EFalse; |
|
372 |
HBufC* serverName = NULL; |
|
373 |
TUint32 port = 0; |
|
374 |
||
375 |
TRAPD(err,GetProxyInformationForConnectionL(useProxy, serverName, port)); |
|
376 |
if (err == KErrNone && useProxy) |
|
377 |
{ |
|
378 |
CleanupStack::PushL(serverName); |
|
379 |
TBuf8<128> proxyAddr; |
|
380 |
proxyAddr.Append(*serverName); |
|
381 |
proxyAddr.Append(':'); |
|
382 |
proxyAddr.AppendNum(port); |
|
383 |
||
384 |
RStringF prxAddr = aSession.StringPool().OpenFStringL(proxyAddr); |
|
385 |
CleanupClosePushL(prxAddr); |
|
386 |
THTTPHdrVal prxUsage(aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); |
|
387 |
||
388 |
aSession.ConnectionInfo().SetPropertyL( |
|
389 |
aSession.StringPool().StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()), |
|
390 |
aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); |
|
391 |
||
392 |
aSession.ConnectionInfo().SetPropertyL(aSession.StringPool().StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), prxAddr); |
|
393 |
||
394 |
CleanupStack::PopAndDestroy(&prxAddr); |
|
395 |
CleanupStack::PopAndDestroy(serverName); |
|
396 |
} |
|
397 |
} |
|
398 |
||
399 |
||
400 |
void CPodcastModel::GetProxyInformationForConnectionL(TBool& aIsUsed, HBufC*& aProxyServerName, TUint32& aPort) |
|
401 |
{ |
|
402 |
TInt iapId = GetIapId(); |
|
403 |
CCommsDbTableView* table = iCommDB->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID), iapId); |
|
404 |
||
405 |
TUint32 iapService; |
|
406 |
HBufC* iapServiceType; |
|
407 |
table->ReadUintL(TPtrC(IAP_SERVICE), iapService); |
|
408 |
iapServiceType = table->ReadLongTextLC(TPtrC(IAP_SERVICE_TYPE)); |
|
409 |
||
410 |
CCommsDbTableView* proxyTableView = iCommDB->OpenViewOnProxyRecordLC(iapService, *iapServiceType); |
|
411 |
TInt err = proxyTableView->GotoFirstRecord(); |
|
412 |
if( err != KErrNone) |
|
413 |
{ |
|
414 |
User::Leave(KErrNotFound); |
|
415 |
} |
|
416 |
||
417 |
proxyTableView->ReadBoolL(TPtrC(PROXY_USE_PROXY_SERVER), aIsUsed); |
|
418 |
if(aIsUsed) |
|
419 |
{ |
|
420 |
HBufC* serverName = proxyTableView->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME)); |
|
421 |
proxyTableView->ReadUintL(TPtrC(PROXY_PORT_NUMBER), aPort); |
|
422 |
aProxyServerName = serverName->AllocL(); |
|
423 |
CleanupStack::PopAndDestroy(serverName); |
|
424 |
} |
|
425 |
||
426 |
CleanupStack::PopAndDestroy(proxyTableView); |
|
427 |
CleanupStack::PopAndDestroy(iapServiceType); |
|
428 |
CleanupStack::PopAndDestroy(table); |
|
429 |
} |
|
430 |
||
431 |
TInt CPodcastModel::GetIapId() |
|
432 |
{ |
|
433 |
_LIT(KSetting, "IAP\\Id"); |
|
434 |
TUint32 iapId = 0; |
|
435 |
iConnectionEngine->Connection().GetIntSetting(KSetting, iapId); |
|
436 |
return iapId; |
|
437 |
} |
|
438 |
||
8 | 439 |
EXPORT_C void CPodcastModel::GetShowsDownloadingL() |
2 | 440 |
{ |
441 |
iActiveShowList.ResetAndDestroy(); |
|
8 | 442 |
iShowEngine->GetShowsDownloadingL(iActiveShowList); |
2 | 443 |
} |
444 |
||
8 | 445 |
EXPORT_C void CPodcastModel::GetShowsByFeedL(TUint aFeedUid) |
2 | 446 |
{ |
447 |
iActiveShowList.ResetAndDestroy(); |
|
88
f4b512d870e8
Moved call to DeleteOldShowsByFeedL to when a feed is listed. This prevents a race condition which likely caused
teknolog
parents:
67
diff
changeset
|
448 |
iShowEngine->DeleteOldShowsByFeedL(aFeedUid); |
60 | 449 |
iShowEngine->CheckForDeletedShows(aFeedUid); |
8 | 450 |
iShowEngine->GetShowsByFeedL(iActiveShowList, aFeedUid); |
2 | 451 |
} |
452 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
453 |
EXPORT_C void CPodcastModel::MarkSelectionPlayedL() |
2 | 454 |
{ |
455 |
for (int i=0;i<iActiveShowList.Count();i++) { |
|
456 |
if(iActiveShowList[i]->PlayState() != EPlayed) { |
|
457 |
iActiveShowList[i]->SetPlayState(EPlayed); |
|
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
458 |
iShowEngine->UpdateShowL(*iActiveShowList[i]); |
2 | 459 |
} |
460 |
} |
|
461 |
} |
|
462 |
||
463 |
TInt CPodcastModel::FindActiveShowByUid(TUint aUid) |
|
464 |
{ |
|
465 |
for (int i=0;i<iActiveShowList.Count();i++) { |
|
466 |
if (iActiveShowList[i]->Uid() == aUid) { |
|
467 |
return i; |
|
468 |
} |
|
469 |
} |
|
470 |
||
471 |
return KErrNotFound; |
|
472 |
} |
|
473 |
||
474 |
EXPORT_C TBool CPodcastModel::IsFirstStartup() |
|
475 |
{ |
|
476 |
return iIsFirstStartup; |
|
477 |
} |
|
478 |
||
479 |
||
60 | 480 |
void CPodcastModel::ImageOperationCompleteL(TInt /*aError*/, TUint /*aHandle*/, CPodcastModel& /*aPodcastModel*/) |
2 | 481 |
{ |
482 |
||
483 |
} |
|
484 |
||
485 |
EXPORT_C CImageHandler& CPodcastModel::ImageHandler() |
|
486 |
{ |
|
487 |
return *iImageHandler; |
|
488 |
} |
|
90
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
489 |
|
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
490 |
void CPodcastModel::LaunchFileEmbeddedL(const TDesC& aFilename) |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
491 |
{ |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
492 |
//Set the exit observer so HandleServerAppExit will be called |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
493 |
iDocHandler->SetExitObserver(this); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
494 |
|
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
495 |
TDataType emptyDataType = TDataType(); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
496 |
//Open a file embedded |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
497 |
iDocHandler->OpenFileEmbeddedL(aFilename, emptyDataType); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
498 |
} |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
499 |
|
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
500 |
void CPodcastModel::HandleServerAppExit(TInt aReason) |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
501 |
{ |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
502 |
//Handle closing the handler application |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
503 |
MAknServerAppExitObserver::HandleServerAppExit(aReason); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
504 |
} |
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
148
diff
changeset
|
505 |