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