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