author | Sebastian Brannstrom <sebastianb@symbian.org> |
Sat, 13 Nov 2010 13:54:36 +0000 | |
branch | 3rded |
changeset 343 | 9c56bf585696 |
parent 176 | 1c8b56cb6409 |
child 390 | d7abecc9d189 |
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 |
||
343
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
307 |
DP1("Copy template DB from: %S", &dbTemplate); |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
308 |
DP1("Copy template DB to: %S", &dbFileName); |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
309 |
|
60 | 310 |
BaflUtils::CopyFile(iFsSession, dbTemplate,dbFileName); |
343
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
311 |
|
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
312 |
// important to set this file to not be read only if copying from Z: |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
313 |
iFsSession.SetAtt(dbFileName, 0, KEntryAttReadOnly); |
9c56bf585696
Catching up with 5th edition
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
176
diff
changeset
|
314 |
|
60 | 315 |
iIsFirstStartup = ETrue; |
316 |
DP("CPodcastModel::ResetDB END"); |
|
317 |
} |
|
318 |
||
319 |
||
320 |
void CPodcastModel::OpenDBL() |
|
321 |
{ |
|
322 |
DP("CPodcastModel::OpenDBL BEGIN"); |
|
323 |
||
324 |
if (iDB != NULL) |
|
325 |
{ |
|
326 |
sqlite3_close(iDB); |
|
327 |
iDB = NULL; |
|
328 |
} |
|
329 |
||
330 |
TFileName dbFileName; |
|
331 |
dbFileName.Copy(iSettingsEngine->PrivatePath()); |
|
332 |
dbFileName.Append(KDBFileName); |
|
333 |
||
334 |
if (!BaflUtils::FileExists(iFsSession, dbFileName)) |
|
335 |
{ |
|
336 |
User::Leave(KErrNotFound); |
|
337 |
} |
|
338 |
||
339 |
if (iDB == NULL) { |
|
340 |
// open DB |
|
341 |
TBuf8<KMaxFileName> filename8; |
|
342 |
filename8.Copy(dbFileName); |
|
343 |
int rc = sqlite3_open((const char*) filename8.PtrZ(), &iDB); |
|
344 |
if(rc != SQLITE_OK){ |
|
345 |
User::Leave(KErrCorrupt); |
|
346 |
} |
|
347 |
||
348 |
// do a test query |
|
349 |
sqlite3_stmt *st; |
|
350 |
rc = sqlite3_prepare_v2(iDB,"select count(*) from feeds" , -1, &st, (const char**) NULL); |
|
351 |
if( rc==SQLITE_OK ) |
|
352 |
{ |
|
353 |
Cleanup_sqlite3_finalize_PushL(st); |
|
354 |
rc = sqlite3_step(st); |
|
355 |
||
356 |
if (rc != SQLITE_ROW) |
|
357 |
{ |
|
358 |
User::Leave(KErrCorrupt); |
|
359 |
} |
|
360 |
CleanupStack::PopAndDestroy(); // st |
|
361 |
} |
|
362 |
else |
|
363 |
{ |
|
364 |
User::Leave(KErrCorrupt); |
|
365 |
} |
|
366 |
} |
|
367 |
||
368 |
DP("CPodcastModel::OpenDBL END"); |
|
369 |
} |
|
370 |
||
2 | 371 |
sqlite3* CPodcastModel::DB() |
372 |
{ |
|
373 |
return iDB; |
|
374 |
} |
|
375 |
||
376 |
void CPodcastModel::SetProxyUsageIfNeededL(RHTTPSession& aSession) |
|
377 |
{ |
|
378 |
TBool useProxy = EFalse; |
|
379 |
HBufC* serverName = NULL; |
|
380 |
TUint32 port = 0; |
|
381 |
||
382 |
TRAPD(err,GetProxyInformationForConnectionL(useProxy, serverName, port)); |
|
383 |
if (err == KErrNone && useProxy) |
|
384 |
{ |
|
385 |
CleanupStack::PushL(serverName); |
|
386 |
TBuf8<128> proxyAddr; |
|
387 |
proxyAddr.Append(*serverName); |
|
388 |
proxyAddr.Append(':'); |
|
389 |
proxyAddr.AppendNum(port); |
|
390 |
||
391 |
RStringF prxAddr = aSession.StringPool().OpenFStringL(proxyAddr); |
|
392 |
CleanupClosePushL(prxAddr); |
|
393 |
THTTPHdrVal prxUsage(aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); |
|
394 |
||
395 |
aSession.ConnectionInfo().SetPropertyL( |
|
396 |
aSession.StringPool().StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()), |
|
397 |
aSession.StringPool().StringF(HTTP::EUseProxy,RHTTPSession::GetTable())); |
|
398 |
||
399 |
aSession.ConnectionInfo().SetPropertyL(aSession.StringPool().StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()), prxAddr); |
|
400 |
||
401 |
CleanupStack::PopAndDestroy(&prxAddr); |
|
402 |
CleanupStack::PopAndDestroy(serverName); |
|
403 |
} |
|
404 |
} |
|
405 |
||
406 |
||
407 |
void CPodcastModel::GetProxyInformationForConnectionL(TBool& aIsUsed, HBufC*& aProxyServerName, TUint32& aPort) |
|
408 |
{ |
|
409 |
TInt iapId = GetIapId(); |
|
410 |
CCommsDbTableView* table = iCommDB->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID), iapId); |
|
411 |
||
412 |
TUint32 iapService; |
|
413 |
HBufC* iapServiceType; |
|
414 |
table->ReadUintL(TPtrC(IAP_SERVICE), iapService); |
|
415 |
iapServiceType = table->ReadLongTextLC(TPtrC(IAP_SERVICE_TYPE)); |
|
416 |
||
417 |
CCommsDbTableView* proxyTableView = iCommDB->OpenViewOnProxyRecordLC(iapService, *iapServiceType); |
|
418 |
TInt err = proxyTableView->GotoFirstRecord(); |
|
419 |
if( err != KErrNone) |
|
420 |
{ |
|
421 |
User::Leave(KErrNotFound); |
|
422 |
} |
|
423 |
||
424 |
proxyTableView->ReadBoolL(TPtrC(PROXY_USE_PROXY_SERVER), aIsUsed); |
|
425 |
if(aIsUsed) |
|
426 |
{ |
|
427 |
HBufC* serverName = proxyTableView->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME)); |
|
428 |
proxyTableView->ReadUintL(TPtrC(PROXY_PORT_NUMBER), aPort); |
|
429 |
aProxyServerName = serverName->AllocL(); |
|
430 |
CleanupStack::PopAndDestroy(serverName); |
|
431 |
} |
|
432 |
||
433 |
CleanupStack::PopAndDestroy(proxyTableView); |
|
434 |
CleanupStack::PopAndDestroy(iapServiceType); |
|
435 |
CleanupStack::PopAndDestroy(table); |
|
436 |
} |
|
437 |
||
438 |
TInt CPodcastModel::GetIapId() |
|
439 |
{ |
|
440 |
_LIT(KSetting, "IAP\\Id"); |
|
441 |
TUint32 iapId = 0; |
|
442 |
iConnectionEngine->Connection().GetIntSetting(KSetting, iapId); |
|
443 |
return iapId; |
|
444 |
} |
|
445 |
||
8 | 446 |
EXPORT_C void CPodcastModel::GetShowsDownloadingL() |
2 | 447 |
{ |
448 |
iActiveShowList.ResetAndDestroy(); |
|
8 | 449 |
iShowEngine->GetShowsDownloadingL(iActiveShowList); |
2 | 450 |
} |
451 |
||
8 | 452 |
EXPORT_C void CPodcastModel::GetShowsByFeedL(TUint aFeedUid) |
2 | 453 |
{ |
454 |
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
|
455 |
iShowEngine->DeleteOldShowsByFeedL(aFeedUid); |
60 | 456 |
iShowEngine->CheckForDeletedShows(aFeedUid); |
8 | 457 |
iShowEngine->GetShowsByFeedL(iActiveShowList, aFeedUid); |
2 | 458 |
} |
459 |
||
35
66c5303f3610
A ton of CodeScanner fixes (high issues) - but not all
Brendan Donegan <brendand@symbian.org>
parents:
8
diff
changeset
|
460 |
EXPORT_C void CPodcastModel::MarkSelectionPlayedL() |
2 | 461 |
{ |
462 |
for (int i=0;i<iActiveShowList.Count();i++) { |
|
463 |
if(iActiveShowList[i]->PlayState() != EPlayed) { |
|
464 |
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
|
465 |
iShowEngine->UpdateShowL(*iActiveShowList[i]); |
2 | 466 |
} |
467 |
} |
|
468 |
} |
|
469 |
||
470 |
TInt CPodcastModel::FindActiveShowByUid(TUint aUid) |
|
471 |
{ |
|
472 |
for (int i=0;i<iActiveShowList.Count();i++) { |
|
473 |
if (iActiveShowList[i]->Uid() == aUid) { |
|
474 |
return i; |
|
475 |
} |
|
476 |
} |
|
477 |
||
478 |
return KErrNotFound; |
|
479 |
} |
|
480 |
||
481 |
EXPORT_C TBool CPodcastModel::IsFirstStartup() |
|
482 |
{ |
|
483 |
return iIsFirstStartup; |
|
484 |
} |
|
485 |
||
486 |
||
60 | 487 |
void CPodcastModel::ImageOperationCompleteL(TInt /*aError*/, TUint /*aHandle*/, CPodcastModel& /*aPodcastModel*/) |
2 | 488 |
{ |
489 |
||
490 |
} |
|
491 |
||
492 |
EXPORT_C CImageHandler& CPodcastModel::ImageHandler() |
|
493 |
{ |
|
494 |
return *iImageHandler; |
|
495 |
} |
|
90
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
496 |
|
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
497 |
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
|
498 |
{ |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
499 |
//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
|
500 |
iDocHandler->SetExitObserver(this); |
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 |
TDataType emptyDataType = TDataType(); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
503 |
//Open a file embedded |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
504 |
iDocHandler->OpenFileEmbeddedL(aFilename, emptyDataType); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
505 |
} |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
506 |
|
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
507 |
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
|
508 |
{ |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
509 |
//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
|
510 |
MAknServerAppExitObserver::HandleServerAppExit(aReason); |
d0c0c3e6f7a1
Added support for launching music and video player when tapping on a downloaded show
teknolog
parents:
88
diff
changeset
|
511 |
} |
164
000f9fc147b2
Catch up with default branch; New v 27 SIS
Sebastian Brannstrom <sebastianb@symbian.org>
parents:
148
diff
changeset
|
512 |