Merge lp:~nik90/podbird/migrate-to-download-manager into lp:podbird/devel

Proposed by Nekhelesh Ramananthan
Status: Merged
Merged at revision: 133
Proposed branch: lp:~nik90/podbird/migrate-to-download-manager
Merge into: lp:podbird/devel
Diff against target: 414 lines (+138/-55)
6 files modified
app/podbird.qml (+30/-22)
app/podcasts.js (+2/-2)
app/ui/EpisodesPage.qml (+6/-2)
app/ui/EpisodesTab.qml (+66/-7)
app/ui/PodcastsTab.qml (+1/-1)
po/podbird.nik90.pot (+33/-21)
To merge this branch: bzr merge lp:~nik90/podbird/migrate-to-download-manager
Reviewer Review Type Date Requested Status
Podbird Developers Pending
Review via email: mp+289069@code.launchpad.net

Description of the change

- Migrated to DownloadManager to support truly multiple downloads while app is suspended.
- Integrated with the files indicator.
- Added "Downloads in Progress" to the Downloads view to keep track of all episodes that are being downloaded.

Screenshots -> http://imgur.com/a/gVnz0

To post a comment you must log in.
133. By Nekhelesh Ramananthan

Added Downloads in progress list in the downloaded view

134. By Nekhelesh Ramananthan

Added safety nets to ensure download manager doesn't crash podbird

135. By Nekhelesh Ramananthan

Renamed Downloaded to Downloads

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

@Mike, There was a critical bug where Podbird on crashing would send the DownloadManager to misbehave. It turns out that when you send an empty url to DownloadManager, it crashes the app and also causes the internal SingleDownload{} objects to not be destroyed until you restart the udm service.

I added a safety check to ensure we never send an empty url to DownloadManager which puts the critical bug to rest. I will nonetheless report this bug upstream against udm since it should handle this better imo.

136. By Nekhelesh Ramananthan

Added Download all button in the favourites view

137. By Nekhelesh Ramananthan

Log download errors when errorFound signal is fired

138. By Nekhelesh Ramananthan

Remove critical bug fixme since it was fixed

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

The critical bug that caused Podbird to crash has been reported at https://bugs.launchpad.net/ubuntu-download-manager/+bug/1557771.

139. By Nekhelesh Ramananthan

Merged lp:podbird/devel

140. By Nekhelesh Ramananthan

Updated all UDM imports to 1.2

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/podbird.qml'
2--- app/podbird.qml 2016-03-15 23:22:35 +0000
3+++ app/podbird.qml 2016-03-16 11:55:29 +0000
4@@ -18,13 +18,12 @@
5
6 import QtQuick 2.4
7 import Podbird 1.0
8-import UserMetrics 0.1
9 import QtMultimedia 5.6
10 import Ubuntu.Connectivity 1.0
11 import Qt.labs.settings 1.0
12 import Ubuntu.Components 1.3
13 import QtQuick.LocalStorage 2.0
14-import Ubuntu.DownloadManager 0.1
15+import Ubuntu.DownloadManager 1.2
16 import "ui"
17 import "themes" as Themes
18 import "podcasts.js" as Podcasts
19@@ -45,7 +44,6 @@
20
21 Component.onDestruction: {
22 console.log("[LOG]: Download cancelled");
23- downloader.cancel();
24 var db = Podcasts.init()
25 db.transaction(function (tx) {
26 tx.executeSql('UPDATE Episode SET queued=0 WHERE queued=1');
27@@ -139,32 +137,42 @@
28 }
29 }
30
31- SingleDownload {
32+ Component {
33+ id: singleDownloadComponent
34+ SingleDownload {
35+ id: singleDownloadObject
36+ property string image
37+ property string title
38+ property string guid
39+ metadata: Metadata {
40+ showInIndicator: true
41+ title: singleDownloadObject.title
42+ }
43+ }
44+ }
45+
46+ function downloadEpisode(image, title, guid, url) {
47+ var singleDownload = singleDownloadComponent.createObject(podbird, {"image": image, "title": title, "guid": guid})
48+ singleDownload.download(url)
49+ }
50+
51+ DownloadManager {
52 id: downloader
53- property var queue: []
54- property string downloadingGuid
55-
56- onFinished: {
57+
58+ property string downloadingGuid: downloads.length > 0 ? downloads[0].guid : "NULL"
59+ property int progress: downloads.length > 0 ? downloads[0].progress : 0
60+
61+ cleanDownloads: true
62+ onDownloadFinished: {
63 var db = Podcasts.init();
64 var finalLocation = fileManager.saveDownload(path);
65 db.transaction(function (tx) {
66- tx.executeSql("UPDATE Episode SET downloadedfile=?, queued=0 WHERE guid=?", [finalLocation, downloadingGuid]);
67- queue.shift();
68- if (queue.length > 0) {
69- downloadingGuid = queue[0][0];
70- download(queue[0][1]);
71- } else {
72- downloadingGuid = "";
73- }
74+ tx.executeSql("UPDATE Episode SET downloadedfile=?, queued=0 WHERE guid=?", [finalLocation, download.guid]);
75 });
76 }
77
78- function addDownload(guid, url) {
79- queue.push([guid, url]);
80- if (queue.length == 1) {
81- downloadingGuid = guid;
82- download(url);
83- }
84+ onErrorFound: {
85+ console.log("[ERROR]: " + download.errorMessage)
86 }
87 }
88
89
90=== modified file 'app/podcasts.js'
91--- app/podcasts.js 2016-03-14 00:16:15 +0000
92+++ app/podcasts.js 2016-03-16 11:55:29 +0000
93@@ -342,8 +342,8 @@
94 var rs2 = tx.executeSql("SELECT rowid, * FROM Episode WHERE podcast=? ORDER BY published DESC", [rs.rows.item(i).rowid]);
95 var loopCount = maxEpisodeDownload > rs2.rows.length ? rs2.rows.length : maxEpisodeDownload
96 for (var j=0; j < loopCount; j++) {
97- if (!rs2.rows.item(j).downloadedfile && !rs2.rows.item(j).listened) {
98- downloader.addDownload(rs2.rows.item(j).guid, rs2.rows.item(j).audiourl)
99+ if (!rs2.rows.item(j).downloadedfile && !rs2.rows.item(j).listened && rs2.rows.item(j).audiourl) {
100+ podbird.downloadEpisode(rs.rows.item(i).image, rs2.rows.item(j).name, rs2.rows.item(j).guid, rs2.rows.item(j).audiourl)
101 tx.executeSql("UPDATE Episode SET queued=1 WHERE guid = ?", [rs2.rows.item(j).guid]);
102 }
103 }
104
105=== modified file 'app/ui/EpisodesPage.qml'
106--- app/ui/EpisodesPage.qml 2016-03-14 23:06:06 +0000
107+++ app/ui/EpisodesPage.qml 2016-03-16 11:55:29 +0000
108@@ -20,7 +20,7 @@
109 import QtMultimedia 5.6
110 import Ubuntu.Components 1.3
111 import QtQuick.LocalStorage 2.0
112-import Ubuntu.DownloadManager 0.1
113+import Ubuntu.DownloadManager 1.2
114 import Ubuntu.Components.Popups 1.3
115 import "../podcasts.js" as Podcasts
116 import "../components"
117@@ -506,7 +506,11 @@
118 tx.executeSql("UPDATE Episode SET queued=1 WHERE guid = ?", [model.guid]);
119 });
120 episodeModel.setProperty(model.index, "queued", 1)
121- downloader.addDownload(model.guid, model.audiourl);
122+ if (model.audiourl) {
123+ podbird.downloadEpisode(model.image, model.name, model.guid, model.audiourl)
124+ } else {
125+ console.log("[ERROR]: Invalid download url: " + model.audiourl)
126+ }
127 }
128 }
129 },
130
131=== modified file 'app/ui/EpisodesTab.qml'
132--- app/ui/EpisodesTab.qml 2016-03-14 00:41:21 +0000
133+++ app/ui/EpisodesTab.qml 2016-03-16 11:55:29 +0000
134@@ -20,7 +20,7 @@
135 import QtMultimedia 5.6
136 import Ubuntu.Components 1.3
137 import QtQuick.LocalStorage 2.0
138-import Ubuntu.DownloadManager 0.1
139+import Ubuntu.DownloadManager 1.2
140 import Ubuntu.Components.Popups 1.3
141 import "../podcasts.js" as Podcasts
142 import "../components"
143@@ -83,7 +83,7 @@
144
145 Action {
146 iconName: "save"
147- visible: episodesPageHeaderSections.selectedIndex === 0
148+ visible: episodesPageHeaderSections.selectedIndex !== 1
149 text: i18n.tr("Download all")
150 onTriggered: {
151 var db = Podcasts.init();
152@@ -92,7 +92,11 @@
153 if (!episodesModel.get(i).downloadedfile) {
154 episodesModel.setProperty(i, "queued", 1)
155 tx.executeSql("UPDATE Episode SET queued=1 WHERE guid = ?", [episodesModel.get(i).guid]);
156- downloader.addDownload(episodesModel.get(i).guid, episodesModel.get(i).audiourl);
157+ if (episodesModel.get(i).audiourl) {
158+ podbird.downloadEpisode(episodesModel.get(i).image, episodesModel.get(i).name, episodesModel.get(i).guid, episodesModel.get(i).audiourl)
159+ } else {
160+ console.log("[ERROR]: Invalid download url: " + episodesModel.get(i).audiourl)
161+ }
162 }
163 }
164 });
165@@ -131,7 +135,7 @@
166 selectedSectionColor: podbird.appTheme.focusText
167 }
168
169- model: [i18n.tr("Recent"), i18n.tr("Downloaded"), i18n.tr("Favourites")]
170+ model: [i18n.tr("Recent"), i18n.tr("Downloads"), i18n.tr("Favourites")]
171 onSelectedIndexChanged: {
172 refreshModel();
173 }
174@@ -184,7 +188,7 @@
175 verticalCenterOffset: Qt.inputMethod.visible ? units.gu(4) : 0
176 }
177
178- sourceComponent: episodesModel.count === 0 || sortedEpisodeModel.count === 0 ? emptyStateComponent : undefined
179+ sourceComponent: (episodesModel.count === 0 || sortedEpisodeModel.count === 0) && downloader.downloads.length === 0 ? emptyStateComponent : undefined
180 }
181
182 Component {
183@@ -332,9 +336,60 @@
184
185 clip: true
186 model: sortedEpisodeModel
187+
188+ header: Column {
189+ width: episodeList.width
190+ visible: height !== 0
191+ height: downloader.downloads.length > 0 && episodesPageHeaderSections.selectedIndex === 1 ? childrenRect.height : 0
192+
193+ HeaderListItem {
194+ title.text: i18n.tr("Downloads in progress")
195+ }
196+
197+ Repeater {
198+ model: downloader.downloads
199+ delegate: ListItem {
200+ divider.visible: false
201+ height: inProgressLayout.height
202+ SlotsLayout {
203+ id: inProgressLayout
204+
205+ Image {
206+ height: width
207+ width: units.gu(6)
208+ source: modelData.image !== undefined ? modelData.image : Qt.resolvedUrl("../graphics/podbird.png")
209+ SlotsLayout.position: SlotsLayout.Leading
210+ sourceSize { width: width; height: height }
211+ }
212+
213+ mainSlot: Column {
214+ spacing: units.gu(0.5)
215+
216+ Label {
217+ text: modelData.title
218+ width: parent.width
219+ elide: Text.ElideRight
220+ }
221+
222+ CustomProgressBar {
223+ width: parent.width
224+ height: modelData.progress > 0 ? units.dp(5) : 0
225+ progress: modelData.progress
226+ indeterminateProgress: modelData.progress < 0 || modelData.progress > 100
227+ }
228+ }
229+ }
230+ }
231+ }
232+
233+ HeaderListItem {
234+ title.text: i18n.tr("Downloaded episodes")
235+ visible: sortedEpisodeModel.count !== 0 || episodesModel.count !== 0
236+ }
237+ }
238+
239 section.property: "diff"
240 section.labelPositioning: ViewSection.InlineLabels
241-
242 section.delegate: ListItem {
243 height: headerText.title.text !== "" ? headerText.height + divider.height : units.gu(0)
244 divider.anchors.leftMargin: units.gu(2)
245@@ -439,7 +494,11 @@
246 tx.executeSql("UPDATE Episode SET queued=1 WHERE guid = ?", [model.guid]);
247 });
248 episodesModel.setProperty(model.index, "queued", 1)
249- downloader.addDownload(model.guid, model.audiourl);
250+ if (model.audiourl) {
251+ podbird.downloadEpisode(model.image, model.name, model.guid, model.audiourl)
252+ } else {
253+ console.log("[ERROR]: Invalid download url: " + model.audiourl)
254+ }
255 }
256 }
257 },
258
259=== modified file 'app/ui/PodcastsTab.qml'
260--- app/ui/PodcastsTab.qml 2016-03-14 12:21:24 +0000
261+++ app/ui/PodcastsTab.qml 2016-03-16 11:55:29 +0000
262@@ -20,7 +20,7 @@
263 import QtMultimedia 5.6
264 import QtQuick.LocalStorage 2.0
265 import Ubuntu.Components 1.3
266-import Ubuntu.DownloadManager 0.1
267+import Ubuntu.DownloadManager 1.2
268 import Ubuntu.Components.Popups 1.0
269 import "../podcasts.js" as Podcasts
270 import "../components"
271
272=== modified file 'po/podbird.nik90.pot'
273--- po/podbird.nik90.pot 2016-03-15 23:22:35 +0000
274+++ po/podbird.nik90.pot 2016-03-16 11:55:29 +0000
275@@ -8,7 +8,7 @@
276 msgstr ""
277 "Project-Id-Version: \n"
278 "Report-Msgid-Bugs-To: \n"
279-"POT-Creation-Date: 2016-03-16 04:49+0530\n"
280+"POT-Creation-Date: 2016-03-16 04:57+0530\n"
281 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
282 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
283 "Language-Team: LANGUAGE <LL@li.org>\n"
284@@ -167,7 +167,7 @@
285 msgid "Unsubscribe"
286 msgstr ""
287
288-#: ../app/ui/EpisodesPage.qml:136 ../app/ui/EpisodesTab.qml:172
289+#: ../app/ui/EpisodesPage.qml:136 ../app/ui/EpisodesTab.qml:176
290 msgid "Search episode"
291 msgstr ""
292
293@@ -185,11 +185,11 @@
294 msgid "Cancel"
295 msgstr ""
296
297-#: ../app/ui/EpisodesPage.qml:223 ../app/ui/EpisodesTab.qml:294
298+#: ../app/ui/EpisodesPage.qml:223 ../app/ui/EpisodesTab.qml:298
299 msgid "Episode Description"
300 msgstr ""
301
302-#: ../app/ui/EpisodesPage.qml:235 ../app/ui/EpisodesTab.qml:306
303+#: ../app/ui/EpisodesPage.qml:235 ../app/ui/EpisodesTab.qml:310
304 #: ../app/ui/SearchPage.qml:170
305 msgid "Close"
306 msgstr ""
307@@ -210,7 +210,7 @@
308 msgid "Listened"
309 msgstr ""
310
311-#: ../app/ui/EpisodesPage.qml:414 ../app/ui/EpisodesTab.qml:134
312+#: ../app/ui/EpisodesPage.qml:414
313 msgid "Downloaded"
314 msgstr ""
315
316@@ -218,59 +218,71 @@
317 msgid "Download all"
318 msgstr ""
319
320-#: ../app/ui/EpisodesTab.qml:104
321+#: ../app/ui/EpisodesTab.qml:108
322 msgid "Delete all"
323 msgstr ""
324
325-#: ../app/ui/EpisodesTab.qml:134
326+#: ../app/ui/EpisodesTab.qml:138
327 msgid "Recent"
328 msgstr ""
329
330-#: ../app/ui/EpisodesTab.qml:134
331+#: ../app/ui/EpisodesTab.qml:138
332+msgid "Downloads"
333+msgstr ""
334+
335+#: ../app/ui/EpisodesTab.qml:138
336 msgid "Favourites"
337 msgstr ""
338
339-#: ../app/ui/EpisodesTab.qml:197
340+#: ../app/ui/EpisodesTab.qml:201
341 msgid "No New Episodes"
342 msgstr ""
343
344-#: ../app/ui/EpisodesTab.qml:199
345+#: ../app/ui/EpisodesTab.qml:203
346 msgid "No Downloaded Episodes"
347 msgstr ""
348
349-#: ../app/ui/EpisodesTab.qml:201
350+#: ../app/ui/EpisodesTab.qml:205
351 msgid "No Favourited Episodes"
352 msgstr ""
353
354-#: ../app/ui/EpisodesTab.qml:203
355+#: ../app/ui/EpisodesTab.qml:207
356 msgid "No Episodes Found"
357 msgstr ""
358
359-#: ../app/ui/EpisodesTab.qml:209
360+#: ../app/ui/EpisodesTab.qml:213
361 msgid "No more episodes to listen to!"
362 msgstr ""
363
364-#: ../app/ui/EpisodesTab.qml:211
365+#: ../app/ui/EpisodesTab.qml:215
366 msgid "No episodes have been downloaded for offline listening"
367 msgstr ""
368
369-#: ../app/ui/EpisodesTab.qml:213
370+#: ../app/ui/EpisodesTab.qml:217
371 msgid "No episodes have been favourited."
372 msgstr ""
373
374-#: ../app/ui/EpisodesTab.qml:215
375+#: ../app/ui/EpisodesTab.qml:219
376 msgid "No Episodes found matching the search term."
377 msgstr ""
378
379-#: ../app/ui/EpisodesTab.qml:347
380+#: ../app/ui/EpisodesTab.qml:346
381+msgid "Downloads in progress"
382+msgstr ""
383+
384+#: ../app/ui/EpisodesTab.qml:386
385+msgid "Downloaded episodes"
386+msgstr ""
387+
388+#: ../app/ui/EpisodesTab.qml:402
389 msgid "Today"
390 msgstr ""
391
392-#: ../app/ui/EpisodesTab.qml:351
393+#: ../app/ui/EpisodesTab.qml:406
394 msgid "Yesterday"
395 msgstr ""
396
397-#: ../app/ui/EpisodesTab.qml:355
398+#: ../app/ui/EpisodesTab.qml:410
399 msgid "Older"
400 msgstr ""
401
402@@ -527,10 +539,10 @@
403 msgid "Finish"
404 msgstr ""
405
406-#: /home/krnekhelesh/Development/fix-playlist-source-truncation-build/po/Podbird.desktop.in.h:1
407+#: /home/krnekhelesh/Development/add-download-manager-build/po/Podbird.desktop.in.h:1
408 msgid "The chirpiest podcast manager for Ubuntu"
409 msgstr ""
410
411-#: /home/krnekhelesh/Development/fix-playlist-source-truncation-build/po/Podbird.desktop.in.h:2
412+#: /home/krnekhelesh/Development/add-download-manager-build/po/Podbird.desktop.in.h:2
413 msgid "podcast;audio;itunes;broadcast;digital;stream;podcatcher;video;vodcast;"
414 msgstr ""

Subscribers

People subscribed via source and target branches