Merge lp:~victored/beat-box/threads into lp:beat-box
- threads
- Merge into trunk
Proposed by
Victor Martinez
Status: | Merged |
---|---|
Merged at revision: | 654 |
Proposed branch: | lp:~victored/beat-box/threads |
Merge into: | lp:beat-box |
Diff against target: |
3303 lines (+751/-811) (has conflicts) 31 files modified
src/BeatBox.vala (+9/-9) src/CMakeLists.txt (+2/-2) src/Core/FileOperator.vala (+36/-27) src/Core/LibraryManager.vala (+340/-211) src/Core/LibraryWindow.vala (+15/-15) src/Core/PodcastManager.vala (+17/-17) src/DataBase/DataBaseUpdater.vala (+69/-84) src/Devices/CDRomDevice.vala (+3/-3) src/Devices/DeviceManager.vala (+20/-14) src/Devices/iPodDevice.vala (+15/-15) src/Lastfm/LastFM.vala (+116/-133) src/Lastfm/SimilarMedia.vala (+5/-7) src/Lastfm/TopArtistAlbums.vala (+12/-10) src/Lastfm/TopArtistSongs.vala (+8/-10) src/Lists/GenericList.vala (+3/-3) src/Media/LyricFetcher.vala (+7/-7) src/Store/Widgets/AlbumView.vala (+12/-11) src/Store/Widgets/ArtistView.vala (+9/-9) src/Store/Widgets/HomeView.vala (+15/-13) src/Store/Widgets/StoreView.vala (+8/-8) src/Views/SimilarMediaView.vala (+5/-5) src/Widgets/EmbeddedAlert.vala (+3/-9) src/Widgets/SearchSuggester.vala (+3/-3) src/Widgets/StatusBar.vala (+1/-66) src/Widgets/StyledWidgets/StyledArtistImages.vala (+5/-6) src/Widgets/WarningLabel.vala (+0/-99) src/Windows/AddPodcastWindow.vala (+3/-3) src/Windows/RemoveDuplicatesDialog.vala (+3/-3) src/Wrappers/PodcastViewWrapper.vala (+4/-4) src/Wrappers/StationViewWrapper.vala (+3/-3) src/Wrappers/ViewWrapper.vala (+0/-2) Text conflict in src/Devices/DeviceManager.vala Text conflict in src/Lastfm/TopArtistAlbums.vala |
To merge this branch: | bzr merge lp:~victored/beat-box/threads |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Scott Ringwelski | Approve | ||
Review via email: mp+113161@code.launchpad.net |
Commit message
Description of the change
Port to GLib 2.32 thread API
To post a comment you must log in.
lp:~victored/beat-box/threads
updated
- 642. By Victor Martinez
-
Don't use compact class for AZLyrics fetcher and make LibraryManager:
:recheck_ files_not_ found_async( ) actually async
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/BeatBox.vala' | |||
2 | --- src/BeatBox.vala 2012-06-19 22:50:13 +0000 | |||
3 | +++ src/BeatBox.vala 2012-07-03 06:49:24 +0000 | |||
4 | @@ -46,13 +46,7 @@ | |||
5 | 46 | warning ("Error parsing arguments: %s\n", err.message); | 46 | warning ("Error parsing arguments: %s\n", err.message); |
6 | 47 | } | 47 | } |
7 | 48 | 48 | ||
8 | 49 | Gdk.threads_init(); | ||
9 | 50 | Gdk.threads_enter(); | ||
10 | 51 | Gtk.init(ref args); | 49 | Gtk.init(ref args); |
11 | 52 | Gdk.threads_leave(); | ||
12 | 53 | |||
13 | 54 | Notify.init("beatbox"); | ||
14 | 55 | GLib.Environment.set_prgname("beatbox"); | ||
15 | 56 | 50 | ||
16 | 57 | try { | 51 | try { |
17 | 58 | Gst.init_check (ref args); | 52 | Gst.init_check (ref args); |
18 | @@ -146,7 +140,7 @@ | |||
19 | 146 | } | 140 | } |
20 | 147 | } | 141 | } |
21 | 148 | 142 | ||
23 | 149 | //library_manager.play_files (to_play); | 143 | //library_manager.play_files (to_play); |
24 | 150 | } | 144 | } |
25 | 151 | 145 | ||
26 | 152 | protected override void activate () { | 146 | protected override void activate () { |
27 | @@ -171,10 +165,16 @@ | |||
28 | 171 | //plugins.hook_new_window (library_window); | 165 | //plugins.hook_new_window (library_window); |
29 | 172 | } | 166 | } |
30 | 173 | 167 | ||
31 | 168 | // FIXME: mounting the music folder and accessing the files shold | ||
32 | 169 | // not be done on separate threads. recheck_files_not_found() should | ||
33 | 170 | // be called using an Idle.add (Priority.LOW, ...) instead. Same for | ||
34 | 171 | // podcast checking and album art download. | ||
35 | 172 | |||
36 | 174 | // In 10 seconds, check for missing songs. This gives enought time | 173 | // In 10 seconds, check for missing songs. This gives enought time |
37 | 175 | // to automount the music folder | 174 | // to automount the music folder |
40 | 176 | Timeout.add(10000, () => { | 175 | // FIXME: This code is race-condition-prone |
41 | 177 | library_manager.recheck_files_not_found(); | 176 | Timeout.add(10000, () => { |
42 | 177 | library_manager.recheck_files_not_found_async (); | ||
43 | 178 | 178 | ||
44 | 179 | return false; | 179 | return false; |
45 | 180 | }); | 180 | }); |
46 | 181 | 181 | ||
47 | === modified file 'src/CMakeLists.txt' | |||
48 | --- src/CMakeLists.txt 2012-07-02 01:40:25 +0000 | |||
49 | +++ src/CMakeLists.txt 2012-07-03 06:49:24 +0000 | |||
50 | @@ -52,7 +52,6 @@ | |||
51 | 52 | Playlists/SmartQuery.vala | 52 | Playlists/SmartQuery.vala |
52 | 53 | Playlists/SmartPlaylist.vala | 53 | Playlists/SmartPlaylist.vala |
53 | 54 | Widgets/TopDisplay.vala | 54 | Widgets/TopDisplay.vala |
54 | 55 | Widgets/WarningLabel.vala | ||
55 | 56 | Widgets/SimpleOptionChooser.vala | 55 | Widgets/SimpleOptionChooser.vala |
56 | 57 | Widgets/PresetList.vala | 56 | Widgets/PresetList.vala |
57 | 58 | Widgets/SideBar.vala | 57 | Widgets/SideBar.vala |
58 | @@ -61,7 +60,7 @@ | |||
59 | 61 | Widgets/StatusBar.vala | 60 | Widgets/StatusBar.vala |
60 | 62 | Widgets/SearchSuggester.vala | 61 | Widgets/SearchSuggester.vala |
61 | 63 | Widgets/TaggingArea.vala | 62 | Widgets/TaggingArea.vala |
63 | 64 | Widgets/InfoPanel.vala | 63 | # Widgets/InfoPanel.vala |
64 | 65 | Widgets/VolumeWidget.vala | 64 | Widgets/VolumeWidget.vala |
65 | 66 | Widgets/NavigationArrows.vala | 65 | Widgets/NavigationArrows.vala |
66 | 67 | Widgets/EmbeddedAlert.vala | 66 | Widgets/EmbeddedAlert.vala |
67 | @@ -177,6 +176,7 @@ | |||
68 | 177 | OPTIONS | 176 | OPTIONS |
69 | 178 | --vapidir=${CMAKE_SOURCE_DIR}/vapi | 177 | --vapidir=${CMAKE_SOURCE_DIR}/vapi |
70 | 179 | --vapidir=${CMAKE_BINARY_DIR}/core/ | 178 | --vapidir=${CMAKE_BINARY_DIR}/core/ |
71 | 179 | --target-glib=2.32 | ||
72 | 180 | ${ADD_OPTIONS} | 180 | ${ADD_OPTIONS} |
73 | 181 | GENERATE_VAPI | 181 | GENERATE_VAPI |
74 | 182 | beatbox | 182 | beatbox |
75 | 183 | 183 | ||
76 | === modified file 'src/Core/FileOperator.vala' | |||
77 | --- src/Core/FileOperator.vala 2012-06-13 23:54:06 +0000 | |||
78 | +++ src/Core/FileOperator.vala 2012-07-03 06:49:24 +0000 | |||
79 | @@ -86,7 +86,7 @@ | |||
80 | 86 | album_art_folder.make_directory_with_parents(null); | 86 | album_art_folder.make_directory_with_parents(null); |
81 | 87 | } | 87 | } |
82 | 88 | catch(GLib.Error err) { | 88 | catch(GLib.Error err) { |
84 | 89 | warning ("Could not create folder in cache directory: %s\n", err.message); | 89 | warning ("Could not create folder in cache directory: %s", err.message); |
85 | 90 | } | 90 | } |
86 | 91 | } | 91 | } |
87 | 92 | } | 92 | } |
88 | @@ -133,14 +133,23 @@ | |||
89 | 133 | } | 133 | } |
90 | 134 | } | 134 | } |
91 | 135 | catch(GLib.Error err) { | 135 | catch(GLib.Error err) { |
93 | 136 | warning("Could not pre-scan music folder. Progress percentage may be off: %s\n", err.message); | 136 | warning("Could not pre-scan music folder. Progress percentage may be off: %s", err.message); |
94 | 137 | } | 137 | } |
95 | 138 | 138 | ||
96 | 139 | return index; | 139 | return index; |
97 | 140 | } | 140 | } |
101 | 141 | 141 | ||
102 | 142 | public void* queue_music_files_bootstrap_thread() { | 142 | public async void queue_music_files_bootstrap_async () { |
103 | 143 | queue_music_files(import_file); | 143 | try { |
104 | 144 | new Thread<void*>.try (null, queue_music_files_bootstrap_thread); | ||
105 | 145 | } | ||
106 | 146 | catch (Error err) { | ||
107 | 147 | warning ("Could not create thread for queue_music_files_bootstrap: %s", err.message); | ||
108 | 148 | } | ||
109 | 149 | } | ||
110 | 150 | |||
111 | 151 | private void* queue_music_files_bootstrap_thread () { | ||
112 | 152 | queue_music_files (import_file); | ||
113 | 144 | 153 | ||
114 | 145 | return null; | 154 | return null; |
115 | 146 | } | 155 | } |
116 | @@ -163,7 +172,7 @@ | |||
117 | 163 | } | 172 | } |
118 | 164 | } | 173 | } |
119 | 165 | catch(GLib.Error err) { | 174 | catch(GLib.Error err) { |
121 | 166 | warning("Could not pre-scan music folder. Progress percentage may be off: %s\n", err.message); | 175 | warning("Could not pre-scan music folder. Progress percentage may be off: %s", err.message); |
122 | 167 | } | 176 | } |
123 | 168 | 177 | ||
124 | 169 | // Let it be known that all files are queued and may now finish import | 178 | // Let it be known that all files are queued and may now finish import |
125 | @@ -254,7 +263,7 @@ | |||
126 | 254 | if(success) { | 263 | if(success) { |
127 | 255 | foreach(int i in lm.media_ids()) { | 264 | foreach(int i in lm.media_ids()) { |
128 | 256 | if(lm.media_from_id(i).album_artist == m.album_artist && lm.media_from_id(i).album == m.album) { | 265 | if(lm.media_from_id(i).album_artist == m.album_artist && lm.media_from_id(i).album == m.album) { |
130 | 257 | debug("setting album art for %s by %s\n", lm.media_from_id(i).title, lm.media_from_id(i).artist); | 266 | debug("setting album art for %s by %s", lm.media_from_id(i).title, lm.media_from_id(i).artist); |
131 | 258 | lm.media_from_id(i).setAlbumArtPath(uri); | 267 | lm.media_from_id(i).setAlbumArtPath(uri); |
132 | 259 | } | 268 | } |
133 | 260 | } | 269 | } |
134 | @@ -294,10 +303,10 @@ | |||
135 | 294 | if(!inThread && lm.lw.initializationFinished) { | 303 | if(!inThread && lm.lw.initializationFinished) { |
136 | 295 | try { | 304 | try { |
137 | 296 | inThread = true; | 305 | inThread = true; |
139 | 297 | Thread.create<void*>(save_media_thread, false); | 306 | new Thread<void*>.try (null, save_media_thread); |
140 | 298 | } | 307 | } |
143 | 299 | catch(GLib.Error err) { | 308 | catch (Error err) { |
144 | 300 | warning ("Could not create thread to rescan music folder: %s\n", err.message); | 309 | warning ("Could not create thread to rescan music folder: %s", err.message); |
145 | 301 | } | 310 | } |
146 | 302 | } | 311 | } |
147 | 303 | } | 312 | } |
148 | @@ -332,7 +341,7 @@ | |||
149 | 332 | } | 341 | } |
150 | 333 | } | 342 | } |
151 | 334 | else { | 343 | else { |
153 | 335 | debug ("Could not save %s.\n", s.uri); | 344 | debug ("Could not save %s.", s.uri); |
154 | 336 | } | 345 | } |
155 | 337 | } | 346 | } |
156 | 338 | 347 | ||
157 | @@ -357,7 +366,7 @@ | |||
158 | 357 | dest = GLib.File.new_for_path(Path.build_path("/", settings.getMusicFolder(), s.artist.replace("/", "_"), s.album.replace("/", "_"), s.track.to_string() + " " + s.title.replace("/", "_") + ext)); | 366 | dest = GLib.File.new_for_path(Path.build_path("/", settings.getMusicFolder(), s.artist.replace("/", "_"), s.album.replace("/", "_"), s.track.to_string() + " " + s.title.replace("/", "_") + ext)); |
159 | 358 | 367 | ||
160 | 359 | if(original.get_path() == dest.get_path()) { | 368 | if(original.get_path() == dest.get_path()) { |
162 | 360 | debug("File is already in correct location\n"); | 369 | debug("File is already in correct location"); |
163 | 361 | return null; | 370 | return null; |
164 | 362 | } | 371 | } |
165 | 363 | 372 | ||
166 | @@ -371,7 +380,7 @@ | |||
167 | 371 | dest.get_parent().make_directory_with_parents(null); | 380 | dest.get_parent().make_directory_with_parents(null); |
168 | 372 | } | 381 | } |
169 | 373 | catch(GLib.Error err) { | 382 | catch(GLib.Error err) { |
171 | 374 | debug("Could not find new destination!: %s\n", err.message); | 383 | debug("Could not find new destination!: %s", err.message); |
172 | 375 | } | 384 | } |
173 | 376 | 385 | ||
174 | 377 | return dest; | 386 | return dest; |
175 | @@ -389,17 +398,17 @@ | |||
176 | 389 | 398 | ||
177 | 390 | /* copy the file over */ | 399 | /* copy the file over */ |
178 | 391 | if(!delete_old) { | 400 | if(!delete_old) { |
180 | 392 | debug("Copying %s to %s\n", s.uri, dest.get_uri()); | 401 | debug("Copying %s to %s", s.uri, dest.get_uri()); |
181 | 393 | success = original.copy(dest, FileCopyFlags.NONE, null, null); | 402 | success = original.copy(dest, FileCopyFlags.NONE, null, null); |
182 | 394 | } | 403 | } |
183 | 395 | else { | 404 | else { |
185 | 396 | debug("Moving %s to %s\n", s.uri, dest.get_uri()); | 405 | debug("Moving %s to %s", s.uri, dest.get_uri()); |
186 | 397 | success = original.move(dest, FileCopyFlags.NONE, null, null); | 406 | success = original.move(dest, FileCopyFlags.NONE, null, null); |
187 | 398 | } | 407 | } |
188 | 399 | 408 | ||
189 | 400 | if(success || dest.query_exists()) { | 409 | if(success || dest.query_exists()) { |
190 | 401 | success = true; | 410 | success = true; |
192 | 402 | debug("success copying file\n"); | 411 | debug("success copying file"); |
193 | 403 | s.uri = dest.get_uri(); | 412 | s.uri = dest.get_uri(); |
194 | 404 | 413 | ||
195 | 405 | // Save the uri change in the database | 414 | // Save the uri change in the database |
196 | @@ -415,13 +424,13 @@ | |||
197 | 415 | 424 | ||
198 | 416 | if(!GLib.File.new_for_path(albumArtDest).query_exists() && mediaFile.query_exists() && | 425 | if(!GLib.File.new_for_path(albumArtDest).query_exists() && mediaFile.query_exists() && |
199 | 417 | mediaFile.copy(GLib.File.new_for_path(albumArtDest), FileCopyFlags.NONE, null, null)) { | 426 | mediaFile.copy(GLib.File.new_for_path(albumArtDest), FileCopyFlags.NONE, null, null)) { |
201 | 418 | debug("Copying album art to %s\n", albumArtDest); | 427 | debug("Copying album art to %s", albumArtDest); |
202 | 419 | s.setAlbumArtPath(albumArtDest); | 428 | s.setAlbumArtPath(albumArtDest); |
203 | 420 | } | 429 | } |
204 | 421 | } | 430 | } |
205 | 422 | } | 431 | } |
206 | 423 | else | 432 | else |
208 | 424 | warning("Failure: Could not copy imported media %s to media folder %s\n", s.uri, dest.get_path()); | 433 | warning("Failure: Could not copy imported media %s to media folder %s", s.uri, dest.get_path()); |
209 | 425 | 434 | ||
210 | 426 | /* if we are supposed to delete the old, make sure there are no items left in folder if we do */ | 435 | /* if we are supposed to delete the old, make sure there are no items left in folder if we do */ |
211 | 427 | if(delete_old) { | 436 | if(delete_old) { |
212 | @@ -430,13 +439,13 @@ | |||
213 | 430 | // must check for .jpg's as well. | 439 | // must check for .jpg's as well. |
214 | 431 | 440 | ||
215 | 432 | if(old_folder_items == 0) { | 441 | if(old_folder_items == 0) { |
217 | 433 | debug("going to delete %s because no files are in it\n", original.get_parent().get_path()); | 442 | debug("going to delete %s because no files are in it", original.get_parent().get_path()); |
218 | 434 | original.get_parent().delete(); | 443 | original.get_parent().delete(); |
219 | 435 | } | 444 | } |
220 | 436 | } | 445 | } |
221 | 437 | } | 446 | } |
222 | 438 | catch(GLib.Error err) { | 447 | catch(GLib.Error err) { |
224 | 439 | warning("Could not copy imported media %s to media folder: %s\n", s.uri, err.message); | 448 | warning("Could not copy imported media %s to media folder: %s", s.uri, err.message); |
225 | 440 | } | 449 | } |
226 | 441 | 450 | ||
227 | 442 | return success; | 451 | return success; |
228 | @@ -453,18 +462,18 @@ | |||
229 | 453 | 462 | ||
230 | 454 | //TODO: COPY ALBUM AND IMAGE ARTWORK | 463 | //TODO: COPY ALBUM AND IMAGE ARTWORK |
231 | 455 | if(old_folder_items == 0) { | 464 | if(old_folder_items == 0) { |
233 | 456 | debug("going to delete %s because no files are in it\n", file.get_parent().get_path()); | 465 | debug("going to delete %s because no files are in it", file.get_parent().get_path()); |
234 | 457 | //original.get_parent().delete(); | 466 | //original.get_parent().delete(); |
235 | 458 | 467 | ||
236 | 459 | var old_folder_parent_items = count_music_files(file.get_parent().get_parent(), ref dummy_list); | 468 | var old_folder_parent_items = count_music_files(file.get_parent().get_parent(), ref dummy_list); |
237 | 460 | 469 | ||
238 | 461 | if(old_folder_parent_items == 0) { | 470 | if(old_folder_parent_items == 0) { |
240 | 462 | debug("going to delete %s because no files are in it\n", file.get_parent().get_parent().get_path()); | 471 | debug("going to delete %s because no files are in it", file.get_parent().get_parent().get_path()); |
241 | 463 | } | 472 | } |
242 | 464 | } | 473 | } |
243 | 465 | } | 474 | } |
244 | 466 | catch(GLib.Error err) { | 475 | catch(GLib.Error err) { |
246 | 467 | warning("Could not move file %s to trash: %s (you could be using a file system which is not supported)\n", s, err.message); | 476 | warning("Could not move file %s to trash: %s (you could be using a file system which is not supported)", s, err.message); |
247 | 468 | 477 | ||
248 | 469 | //tell the user the file could not be moved and ask if they'd like to delete permanently instead. | 478 | //tell the user the file could not be moved and ask if they'd like to delete permanently instead. |
249 | 470 | //Gtk.MessageDialog md = new Gtk.MessageDialog(lm.lw, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, "Could not trash file %s, would you like to permanently delete it? You cannot undo these changes.", s); | 479 | //Gtk.MessageDialog md = new Gtk.MessageDialog(lm.lw, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, "Could not trash file %s, would you like to permanently delete it? You cannot undo these changes.", s); |
250 | @@ -491,7 +500,7 @@ | |||
251 | 491 | } | 500 | } |
252 | 492 | } | 501 | } |
253 | 493 | catch(GLib.Error err) { | 502 | catch(GLib.Error err) { |
255 | 494 | message("Could not guess content types: %s\n", err.message); | 503 | message("Could not guess content types: %s", err.message); |
256 | 495 | } | 504 | } |
257 | 496 | }*/ | 505 | }*/ |
258 | 497 | 506 | ||
259 | @@ -608,10 +617,10 @@ | |||
260 | 608 | fo_progress(_("<b>Copying</b> files to <b>Music Folder</b>..."), 0.0); | 617 | fo_progress(_("<b>Copying</b> files to <b>Music Folder</b>..."), 0.0); |
261 | 609 | 618 | ||
262 | 610 | try { | 619 | try { |
264 | 611 | Thread.create<void*>(copy_imports_thread, false); | 620 | new Thread<void*>.try (null, copy_imports_thread); |
265 | 612 | } | 621 | } |
268 | 613 | catch(GLib.Error err) { | 622 | catch (Error err) { |
269 | 614 | warning("Could not create thread to rescan music folder: %s\n", err.message); | 623 | warning ("Could not create thread to rescan music folder: %s", err.message); |
270 | 615 | } | 624 | } |
271 | 616 | } | 625 | } |
272 | 617 | else { | 626 | else { |
273 | 618 | 627 | ||
274 | === modified file 'src/Core/LibraryManager.vala' | |||
275 | --- src/Core/LibraryManager.vala 2012-07-02 23:17:27 +0000 | |||
276 | +++ src/Core/LibraryManager.vala 2012-07-03 06:49:24 +0000 | |||
277 | @@ -29,7 +29,15 @@ | |||
278 | 29 | */ | 29 | */ |
279 | 30 | public class BeatBox.LibraryManager : /*BeatBox.LibraryModel,*/ GLib.Object { | 30 | public class BeatBox.LibraryManager : /*BeatBox.LibraryModel,*/ GLib.Object { |
280 | 31 | public static const int PREVIEW_MEDIA_ID = -2; | 31 | public static const int PREVIEW_MEDIA_ID = -2; |
282 | 32 | public BeatBox.LibraryWindow lw; | 32 | |
283 | 33 | // FIXME (BeatBox 0.7+) | ||
284 | 34 | // At this point, a signal should be emmited | ||
285 | 35 | // to let LibraryWindow know what's happening | ||
286 | 36 | // under the hood. | ||
287 | 37 | // UI code doesn't belong here. | ||
288 | 38 | public BeatBox.LibraryWindow lw; // Drop this reference | ||
289 | 39 | |||
290 | 40 | |||
291 | 33 | public BeatBox.Settings settings; | 41 | public BeatBox.Settings settings; |
292 | 34 | public BeatBox.DataBaseManager dbm; | 42 | public BeatBox.DataBaseManager dbm; |
293 | 35 | public BeatBox.DataBaseUpdater dbu; | 43 | public BeatBox.DataBaseUpdater dbu; |
294 | @@ -38,13 +46,6 @@ | |||
295 | 38 | public BeatBox.DeviceManager device_manager; | 46 | public BeatBox.DeviceManager device_manager; |
296 | 39 | public BeatBox.PodcastManager pm; | 47 | public BeatBox.PodcastManager pm; |
297 | 40 | 48 | ||
298 | 41 | Mutex _media_lock; // lock for _media. use this around _media, _songs | ||
299 | 42 | Mutex _songs_lock; | ||
300 | 43 | Mutex _podcasts_lock; | ||
301 | 44 | Mutex _audiobooks_lock; | ||
302 | 45 | Mutex _stations_lock; | ||
303 | 46 | Mutex _playlists_lock; // lock for _playlists | ||
304 | 47 | Mutex _smart_playlists_lock; // lock for _smart_playlists | ||
305 | 48 | HashMap<int, SmartPlaylist> _smart_playlists; // rowid, smart playlist | 49 | HashMap<int, SmartPlaylist> _smart_playlists; // rowid, smart playlist |
306 | 49 | HashMap<int, Playlist> _playlists; // rowid, playlist of all playlists | 50 | HashMap<int, Playlist> _playlists; // rowid, playlist of all playlists |
307 | 50 | HashMap<int, Media> _media; // rowid, media of all medias | 51 | HashMap<int, Media> _media; // rowid, media of all medias |
308 | @@ -126,9 +127,12 @@ | |||
309 | 126 | public signal void media_queued(Media m); | 127 | public signal void media_queued(Media m); |
310 | 127 | public signal void media_played(Media id, Media? old_id); | 128 | public signal void media_played(Media id, Media? old_id); |
311 | 128 | public signal void playback_stopped(int was_playing); | 129 | public signal void playback_stopped(int was_playing); |
313 | 129 | 130 | ||
314 | 131 | // FIXME (BeatBox 0.7+) | ||
315 | 132 | // Drop reference to LibraryWindow | ||
316 | 130 | public LibraryManager(BeatBox.Settings sett, BeatBox.LibraryWindow lww) { | 133 | public LibraryManager(BeatBox.Settings sett, BeatBox.LibraryWindow lww) { |
317 | 131 | this.lw = lww; | 134 | this.lw = lww; |
318 | 135 | |||
319 | 132 | this.settings = sett; | 136 | this.settings = sett; |
320 | 133 | this.player = new Streamer(this, lw); | 137 | this.player = new Streamer(this, lw); |
321 | 134 | 138 | ||
322 | @@ -139,14 +143,7 @@ | |||
323 | 139 | 143 | ||
324 | 140 | fo.fo_progress.connect(dbProgress); | 144 | fo.fo_progress.connect(dbProgress); |
325 | 141 | dbm.db_progress.connect(dbProgress); | 145 | dbm.db_progress.connect(dbProgress); |
334 | 142 | 146 | ||
327 | 143 | _smart_playlists_lock = new Mutex(); | ||
328 | 144 | _playlists_lock = new Mutex(); | ||
329 | 145 | _media_lock = new Mutex(); | ||
330 | 146 | _songs_lock = new Mutex(); | ||
331 | 147 | _podcasts_lock = new Mutex(); | ||
332 | 148 | _audiobooks_lock = new Mutex(); | ||
333 | 149 | _stations_lock = new Mutex(); | ||
335 | 150 | 147 | ||
336 | 151 | _smart_playlists = new HashMap<int, SmartPlaylist>(); | 148 | _smart_playlists = new HashMap<int, SmartPlaylist>(); |
337 | 152 | _playlists = new HashMap<int, Playlist>(); | 149 | _playlists = new HashMap<int, Playlist>(); |
338 | @@ -195,51 +192,73 @@ | |||
339 | 195 | album_list_setup = new TreeViewSetup(MusicList.MusicColumn.TRACK, Gtk.SortType.ASCENDING, ViewWrapper.Hint.ALBUM_LIST); | 192 | album_list_setup = new TreeViewSetup(MusicList.MusicColumn.TRACK, Gtk.SortType.ASCENDING, ViewWrapper.Hint.ALBUM_LIST); |
340 | 196 | 193 | ||
341 | 197 | //load all medias from db | 194 | //load all medias from db |
342 | 198 | _media_lock.lock (); | ||
343 | 199 | foreach(Media s in dbm.load_medias()) { | 195 | foreach(Media s in dbm.load_medias()) { |
345 | 200 | _media.set(s.rowid, s); | 196 | lock (_media) { |
346 | 197 | _media.set (s.rowid, s); | ||
347 | 198 | } | ||
348 | 201 | 199 | ||
366 | 202 | if(s.mediatype == MediaType.SONG) | 200 | if (s.mediatype == MediaType.SONG) { |
367 | 203 | _songs.set(s.rowid, s); | 201 | lock (_songs) { |
368 | 204 | else if(s.mediatype == MediaType.PODCAST) | 202 | _songs.set(s.rowid, s); |
369 | 205 | _podcasts.set(s.rowid, s); | 203 | } |
370 | 206 | else if(s.mediatype == MediaType.AUDIOBOOK) | 204 | } |
371 | 207 | _audiobooks.set(s.rowid, s); | 205 | else if (s.mediatype == MediaType.PODCAST) { |
372 | 208 | else if(s.mediatype == MediaType.STATION) | 206 | lock (_podcasts) { |
373 | 209 | _stations.set(s.rowid, s); | 207 | _podcasts.set(s.rowid, s); |
374 | 210 | } | 208 | } |
375 | 211 | _media_lock.unlock(); | 209 | } |
376 | 212 | 210 | else if (s.mediatype == MediaType.AUDIOBOOK) { | |
377 | 213 | _smart_playlists_lock.lock(); | 211 | lock (_audiobooks) { |
378 | 214 | foreach(SmartPlaylist p in dbm.load_smart_playlists()) { | 212 | _audiobooks.set(s.rowid, s); |
379 | 215 | _smart_playlists.set(p.get_rowid(), p); | 213 | } |
380 | 216 | } | 214 | } |
381 | 217 | _smart_playlists_lock.unlock(); | 215 | else if(s.mediatype == MediaType.STATION) { |
382 | 218 | 216 | lock (_stations) { | |
383 | 217 | _stations.set(s.rowid, s); | ||
384 | 218 | } | ||
385 | 219 | } | ||
386 | 220 | } | ||
387 | 221 | |||
388 | 222 | lock (_smart_playlists) { | ||
389 | 223 | foreach (SmartPlaylist p in dbm.load_smart_playlists()) { | ||
390 | 224 | _smart_playlists.set (p.get_rowid(), p); | ||
391 | 225 | } | ||
392 | 226 | } | ||
393 | 227 | |||
394 | 219 | //load all playlists from db | 228 | //load all playlists from db |
395 | 220 | _playlists_lock.lock(); | ||
396 | 221 | var playlists_added = new LinkedList<string>(); | 229 | var playlists_added = new LinkedList<string>(); |
397 | 222 | foreach(Playlist p in dbm.load_playlists()) { | 230 | foreach(Playlist p in dbm.load_playlists()) { |
398 | 223 | if(!playlists_added.contains(p.get_name())) { // sometimes we get duplicates. don't add duplicates | 231 | if(!playlists_added.contains(p.get_name())) { // sometimes we get duplicates. don't add duplicates |
400 | 224 | _playlists.set(p.get_rowid(), p); | 232 | lock (_playlists) { |
401 | 233 | _playlists.set(p.get_rowid(), p); | ||
402 | 234 | } | ||
403 | 225 | 235 | ||
404 | 226 | if(p.get_name() == "autosaved_music") { | 236 | if(p.get_name() == "autosaved_music") { |
405 | 227 | music_setup = p.tvs; | 237 | music_setup = p.tvs; |
406 | 228 | music_setup.set_hint(ViewWrapper.Hint.MUSIC); | 238 | music_setup.set_hint(ViewWrapper.Hint.MUSIC); |
408 | 229 | _playlists.unset(p.get_rowid()); | 239 | |
409 | 240 | lock (_playlists) { | ||
410 | 241 | _playlists.unset (p.get_rowid()); | ||
411 | 242 | } | ||
412 | 230 | } | 243 | } |
413 | 231 | else if(p.get_name() == "autosaved_podcast") { | 244 | else if(p.get_name() == "autosaved_podcast") { |
414 | 232 | podcast_setup = p.tvs; | 245 | podcast_setup = p.tvs; |
416 | 233 | _playlists.unset(p.get_rowid()); | 246 | lock (_playlists) { |
417 | 247 | _playlists.unset (p.get_rowid()); | ||
418 | 248 | } | ||
419 | 234 | } | 249 | } |
420 | 235 | else if(p.get_name() == "autosaved_station") { | 250 | else if(p.get_name() == "autosaved_station") { |
421 | 236 | station_setup = p.tvs; | 251 | station_setup = p.tvs; |
423 | 237 | _playlists.unset(p.get_rowid()); | 252 | lock (_playlists) { |
424 | 253 | _playlists.unset (p.get_rowid()); | ||
425 | 254 | } | ||
426 | 238 | } | 255 | } |
427 | 239 | else if(p.get_name() == "autosaved_similar") { | 256 | else if(p.get_name() == "autosaved_similar") { |
428 | 240 | similar_setup = p.tvs; | 257 | similar_setup = p.tvs; |
429 | 241 | similar_setup.set_hint(ViewWrapper.Hint.SIMILAR); | 258 | similar_setup.set_hint(ViewWrapper.Hint.SIMILAR); |
431 | 242 | _playlists.unset(p.get_rowid()); | 259 | lock (_playlists) { |
432 | 260 | _playlists.unset (p.get_rowid()); | ||
433 | 261 | } | ||
434 | 243 | } | 262 | } |
435 | 244 | else if(p.get_name() == "autosaved_queue") { | 263 | else if(p.get_name() == "autosaved_queue") { |
436 | 245 | foreach(var m in medias_from_playlist(p.get_rowid())) { | 264 | foreach(var m in medias_from_playlist(p.get_rowid())) { |
437 | @@ -248,27 +267,26 @@ | |||
438 | 248 | 267 | ||
439 | 249 | queue_setup = p.tvs; | 268 | queue_setup = p.tvs; |
440 | 250 | queue_setup.set_hint(ViewWrapper.Hint.QUEUE); | 269 | queue_setup.set_hint(ViewWrapper.Hint.QUEUE); |
442 | 251 | _playlists.unset(p.get_rowid()); | 270 | lock (_playlists) { |
443 | 271 | _playlists.unset (p.get_rowid()); | ||
444 | 272 | } | ||
445 | 252 | } | 273 | } |
446 | 253 | else if(p.get_name() == "autosaved_history") { | 274 | else if(p.get_name() == "autosaved_history") { |
447 | 254 | history_setup = p.tvs; | 275 | history_setup = p.tvs; |
448 | 255 | history_setup.set_hint(ViewWrapper.Hint.HISTORY); | 276 | history_setup.set_hint(ViewWrapper.Hint.HISTORY); |
450 | 256 | _playlists.unset(p.get_rowid()); | 277 | lock (_playlists) { |
451 | 278 | _playlists.unset (p.get_rowid()); | ||
452 | 279 | } | ||
453 | 257 | } | 280 | } |
454 | 258 | 281 | ||
455 | 259 | playlists_added.add(p.get_name()); | 282 | playlists_added.add(p.get_name()); |
456 | 260 | } | 283 | } |
457 | 261 | } | 284 | } |
458 | 262 | _playlists_lock.unlock(); | ||
459 | 263 | 285 | ||
460 | 264 | device_manager = new DeviceManager(this); | 286 | device_manager = new DeviceManager(this); |
461 | 265 | 287 | ||
462 | 266 | // start thread to load all the medias pixbuf's | 288 | // start thread to load all the medias pixbuf's |
468 | 267 | try { | 289 | fetch_image_cache_async (); |
464 | 268 | Thread.create<void*>(fetch_thread_function, false); | ||
465 | 269 | } catch(GLib.ThreadError err) { | ||
466 | 270 | warning("Could not create thread to load media pixbuf's: %s \n", err.message); | ||
467 | 271 | } | ||
469 | 272 | } | 290 | } |
470 | 273 | 291 | ||
471 | 274 | /***************************************** | 292 | /***************************************** |
472 | @@ -289,6 +307,12 @@ | |||
473 | 289 | 307 | ||
474 | 290 | public bool doProgressNotificationWithTimeout() { | 308 | public bool doProgressNotificationWithTimeout() { |
475 | 291 | if(_doing_file_operations) { | 309 | if(_doing_file_operations) { |
476 | 310 | |||
477 | 311 | // FIXME (BeatBox 0.7+) | ||
478 | 312 | // At this point, a signal should be emmited | ||
479 | 313 | // to let LibraryWindow know what's happening | ||
480 | 314 | // under the hood. | ||
481 | 315 | // UI code doesn't belong here. | ||
482 | 292 | Gdk.threads_enter(); | 316 | Gdk.threads_enter(); |
483 | 293 | progress_notification(null, (double)((double)fo.index)/((double)fo.item_count)); | 317 | progress_notification(null, (double)((double)fo.index)/((double)fo.item_count)); |
484 | 294 | Gdk.threads_leave(); | 318 | Gdk.threads_leave(); |
485 | @@ -303,13 +327,24 @@ | |||
486 | 303 | 327 | ||
487 | 304 | public void set_music_folder(string folder) { | 328 | public void set_music_folder(string folder) { |
488 | 305 | if(start_file_operations(_("Importing music from %s...").printf("<b>" + Markup.escape_text(folder) + "</b>"))) { | 329 | if(start_file_operations(_("Importing music from %s...").printf("<b>" + Markup.escape_text(folder) + "</b>"))) { |
489 | 330 | |||
490 | 331 | // FIXME (BeatBox 0.7+) | ||
491 | 332 | // At this point, a signal should be emmited | ||
492 | 333 | // to let LibraryWindow know what's happening | ||
493 | 334 | // under the hood. | ||
494 | 335 | // UI code doesn't belong here. | ||
495 | 306 | lw.resetSideTree(true); | 336 | lw.resetSideTree(true); |
496 | 307 | lw.sideTree.removeAllStaticPlaylists(); | 337 | lw.sideTree.removeAllStaticPlaylists(); |
497 | 308 | 338 | ||
498 | 309 | clear_medias(); | 339 | clear_medias(); |
499 | 310 | _queue.clear(); | 340 | _queue.clear(); |
500 | 311 | _already_played.clear(); | 341 | _already_played.clear(); |
502 | 312 | 342 | ||
503 | 343 | // FIXME (BeatBox 0.7+) | ||
504 | 344 | // At this point, a signal should be emmited | ||
505 | 345 | // to let LibraryWindow know what's happening | ||
506 | 346 | // under the hood. | ||
507 | 347 | // UI code doesn't belong here. | ||
508 | 313 | lw.resetSideTree(false); | 348 | lw.resetSideTree(false); |
509 | 314 | lw.update_sensitivities(); | 349 | lw.update_sensitivities(); |
510 | 315 | stopPlayback(); | 350 | stopPlayback(); |
511 | @@ -317,49 +352,58 @@ | |||
512 | 317 | settings.setMusicMountName(""); | 352 | settings.setMusicMountName(""); |
513 | 318 | settings.setMusicFolder(folder); | 353 | settings.setMusicFolder(folder); |
514 | 319 | 354 | ||
521 | 320 | try { | 355 | set_music_folder_async (); |
522 | 321 | Thread.create<void*>(set_music_thread_function, false); | 356 | } |
523 | 322 | } | 357 | } |
524 | 323 | catch(GLib.Error err) { | 358 | |
525 | 324 | warning("Could not create thread to set music folder: %s\n", err.message); | 359 | public async void set_music_folder_async () { |
526 | 325 | } | 360 | try { |
527 | 361 | new Thread<void*>.try (null, set_music_thread_function); | ||
528 | 362 | } | ||
529 | 363 | catch(Error err) { | ||
530 | 364 | warning("Could not create thread to set music folder: %s", err.message); | ||
531 | 326 | } | 365 | } |
532 | 327 | } | 366 | } |
533 | 328 | 367 | ||
535 | 329 | public void* set_music_thread_function () { | 368 | private void* set_music_thread_function () { |
536 | 330 | var music_folder = GLib.File.new_for_path(settings.getMusicFolder()); | 369 | var music_folder = GLib.File.new_for_path(settings.getMusicFolder()); |
537 | 331 | 370 | ||
538 | 332 | fo.resetProgress(0); | 371 | fo.resetProgress(0); |
539 | 333 | fo.start_import(FileOperator.ImportType.SET); | 372 | fo.start_import(FileOperator.ImportType.SET); |
540 | 334 | fo.import_file = music_folder; | 373 | fo.import_file = music_folder; |
542 | 335 | Thread.create<void*>(fo.queue_music_files_bootstrap_thread, false); | 374 | |
543 | 375 | fo.queue_music_files_bootstrap_async (); | ||
544 | 376 | |||
545 | 336 | Timeout.add(100, doProgressNotificationWithTimeout); | 377 | Timeout.add(100, doProgressNotificationWithTimeout); |
546 | 337 | 378 | ||
547 | 338 | return null; | 379 | return null; |
548 | 339 | } | 380 | } |
549 | 340 | 381 | ||
551 | 341 | public void add_files_to_library(LinkedList<string> files) { | 382 | public async void add_files_to_library_async (LinkedList<string> files) { |
552 | 342 | if(start_file_operations(_("Adding files to library...")) && files.size > 0) { | 383 | if(start_file_operations(_("Adding files to library...")) && files.size > 0) { |
553 | 343 | temp_add_files = files; | 384 | temp_add_files = files; |
554 | 344 | 385 | ||
555 | 345 | try { | 386 | try { |
557 | 346 | Thread.create<void*>(add_files_to_library_thread, false); | 387 | new Thread<void*>.try (null, add_files_to_library_thread); |
558 | 347 | } | 388 | } |
561 | 348 | catch(GLib.Error err) { | 389 | catch (Error err) { |
562 | 349 | warning ("Could not create thread to add music files: %s\n", err.message); | 390 | warning ("Could not create thread to add music files: %s", err.message); |
563 | 350 | } | 391 | } |
564 | 351 | } | 392 | } |
565 | 352 | } | 393 | } |
568 | 353 | 394 | ||
569 | 354 | public void* add_files_to_library_thread () { | 395 | private void* add_files_to_library_thread () { |
570 | 396 | // FIXME: we need a better API for doing this kind of stuff. | ||
571 | 397 | // FileOperator could emit some signals, and we could | ||
572 | 398 | // track them here. | ||
573 | 355 | fo.resetProgress(temp_add_files.size - 1); | 399 | fo.resetProgress(temp_add_files.size - 1); |
574 | 356 | Timeout.add(100, doProgressNotificationWithTimeout); | 400 | Timeout.add(100, doProgressNotificationWithTimeout); |
575 | 357 | fo.import_files(temp_add_files, FileOperator.ImportType.IMPORT); | 401 | fo.import_files(temp_add_files, FileOperator.ImportType.IMPORT); |
577 | 358 | 402 | ||
578 | 359 | return null; | 403 | return null; |
579 | 360 | } | 404 | } |
580 | 361 | 405 | ||
582 | 362 | public void add_folder_to_library(LinkedList<File> folders) { | 406 | public async void add_folder_to_library_async (LinkedList<File> folders) { |
583 | 363 | string oper = ""; | 407 | string oper = ""; |
584 | 364 | if(folders.size == 1) { | 408 | if(folders.size == 1) { |
585 | 365 | oper = _("Adding music from %s to library...").printf("<b>" + Markup.escape_text(folders.get(0).get_path()) + "</b>"); | 409 | oper = _("Adding music from %s to library...").printf("<b>" + Markup.escape_text(folders.get(0).get_path()) + "</b>"); |
586 | @@ -372,15 +416,15 @@ | |||
587 | 372 | temp_add_folders = folders; | 416 | temp_add_folders = folders; |
588 | 373 | 417 | ||
589 | 374 | try { | 418 | try { |
591 | 375 | Thread.create<void*>(add_folder_to_library_thread, false); | 419 | new Thread<void*>.try (null, add_folder_to_library_thread); |
592 | 376 | } | 420 | } |
595 | 377 | catch(GLib.Error err) { | 421 | catch (Error err) { |
596 | 378 | warning ("Could not create thread to add music folder: %s\n", err.message); | 422 | warning ("Could not create thread to add music folder: %s", err.message); |
597 | 379 | } | 423 | } |
598 | 380 | } | 424 | } |
599 | 381 | } | 425 | } |
600 | 382 | 426 | ||
602 | 383 | public void* add_folder_to_library_thread () { | 427 | private void* add_folder_to_library_thread () { |
603 | 384 | var files = new LinkedList<string>(); | 428 | var files = new LinkedList<string>(); |
604 | 385 | int items = 0; | 429 | int items = 0; |
605 | 386 | 430 | ||
606 | @@ -395,18 +439,18 @@ | |||
607 | 395 | return null; | 439 | return null; |
608 | 396 | } | 440 | } |
609 | 397 | 441 | ||
611 | 398 | public void rescan_music_folder() { | 442 | public async void rescan_music_folder_async () { |
612 | 399 | if(start_file_operations(_("Rescanning music folder for changes..."))) { | 443 | if(start_file_operations(_("Rescanning music folder for changes..."))) { |
613 | 400 | try { | 444 | try { |
615 | 401 | Thread.create<void*>(rescan_music_thread_function, false); | 445 | new Thread<void*>.try (null, rescan_music_thread_function); |
616 | 402 | } | 446 | } |
619 | 403 | catch(GLib.Error err) { | 447 | catch (Error err) { |
620 | 404 | warning ("Could not create thread to rescan music folder: %s\n", err.message); | 448 | warning ("Could not create thread to rescan music folder: %s", err.message); |
621 | 405 | } | 449 | } |
622 | 406 | } | 450 | } |
623 | 407 | } | 451 | } |
626 | 408 | 452 | ||
627 | 409 | public void* rescan_music_thread_function () { | 453 | private void* rescan_music_thread_function () { |
628 | 410 | HashMap<string, Media> paths = new HashMap<string, Media>(); | 454 | HashMap<string, Media> paths = new HashMap<string, Media>(); |
629 | 411 | LinkedList<Media> to_remove = new LinkedList<Media>(); | 455 | LinkedList<Media> to_remove = new LinkedList<Media>(); |
630 | 412 | LinkedList<string> to_import = new LinkedList<string>(); | 456 | LinkedList<string> to_import = new LinkedList<string>(); |
631 | @@ -456,30 +500,35 @@ | |||
632 | 456 | return null; | 500 | return null; |
633 | 457 | } | 501 | } |
634 | 458 | 502 | ||
636 | 459 | public void recheck_files_not_found() { | 503 | public void recheck_files_not_found_async () { |
637 | 460 | try { | 504 | try { |
639 | 461 | Thread.create<void*>(recheck_files_not_found_thread, false); | 505 | new Thread<void*>.try (null, recheck_files_not_found_thread); |
640 | 462 | } | 506 | } |
643 | 463 | catch(GLib.Error err) { | 507 | catch (Error err) { |
644 | 464 | warning ("Could not create thread to check file locations: %s\n", err.message); | 508 | warning ("Could not create thread to check file locations: %s", err.message); |
645 | 465 | } | 509 | } |
646 | 466 | } | 510 | } |
649 | 467 | 511 | ||
650 | 468 | public void* recheck_files_not_found_thread () { | 512 | private void* recheck_files_not_found_thread () { |
651 | 469 | Media[] cache_media; | 513 | Media[] cache_media; |
652 | 470 | var not_found = new LinkedList<Media>(); | 514 | var not_found = new LinkedList<Media>(); |
653 | 471 | var found = new LinkedList<Media>(); // files that location were unknown but now are found | 515 | var found = new LinkedList<Media>(); // files that location were unknown but now are found |
654 | 516 | |||
655 | 517 | // FIXME (BeatBox 0.7+) | ||
656 | 518 | // At this point, a signal should be emmited | ||
657 | 519 | // to let LibraryWindow know what's happening | ||
658 | 520 | // under the hood. | ||
659 | 521 | // UI code doesn't belong here. | ||
660 | 472 | var not_found_pix = Icons.PROCESS_ERROR.render(IconSize.MENU, ((ViewWrapper)lw.sideTree.getWidget(lw.sideTree.library_music_iter)).list_view.get_style_context()); | 522 | var not_found_pix = Icons.PROCESS_ERROR.render(IconSize.MENU, ((ViewWrapper)lw.sideTree.getWidget(lw.sideTree.library_music_iter)).list_view.get_style_context()); |
663 | 473 | 523 | ||
662 | 474 | _media_lock.lock(); | ||
664 | 475 | cache_media = _media.values.to_array(); | 524 | cache_media = _media.values.to_array(); |
665 | 476 | _media_lock.unlock(); | ||
666 | 477 | 525 | ||
667 | 478 | for(int i = 0; i < cache_media.length; ++i) { | 526 | for(int i = 0; i < cache_media.length; ++i) { |
668 | 479 | var m = cache_media[i]; | 527 | var m = cache_media[i]; |
669 | 480 | if(m.mediatype == MediaType.STATION || | 528 | if(m.mediatype == MediaType.STATION || |
670 | 481 | (m.mediatype == MediaType.PODCAST && m.uri.has_prefix("http:/"))) { | 529 | (m.mediatype == MediaType.PODCAST && m.uri.has_prefix("http:/"))) { |
671 | 482 | // don't try to find this | 530 | // don't try to find this |
672 | 531 | warning ("Found station or podcast with uri prefix 'http:/'"); | ||
673 | 483 | } | 532 | } |
674 | 484 | else { | 533 | else { |
675 | 485 | if(File.new_for_uri(m.uri).query_exists() && m.location_unknown) { | 534 | if(File.new_for_uri(m.uri).query_exists() && m.location_unknown) { |
676 | @@ -499,6 +548,12 @@ | |||
677 | 499 | if(not_found.size > 0) { | 548 | if(not_found.size > 0) { |
678 | 500 | warning("Some media files could not be found and are being marked as such.\n"); | 549 | warning("Some media files could not be found and are being marked as such.\n"); |
679 | 501 | update_medias(not_found, false, false, true); | 550 | update_medias(not_found, false, false, true); |
680 | 551 | |||
681 | 552 | // FIXME (BeatBox 0.7+) | ||
682 | 553 | // At this point, a signal should be emmited | ||
683 | 554 | // to let LibraryWindow know what's happening | ||
684 | 555 | // under the hood. | ||
685 | 556 | // UI code doesn't belong here. | ||
686 | 502 | foreach(var m in not_found) { | 557 | foreach(var m in not_found) { |
687 | 503 | lw.media_not_found(m.rowid); | 558 | lw.media_not_found(m.rowid); |
688 | 504 | } | 559 | } |
689 | @@ -506,6 +561,12 @@ | |||
690 | 506 | if(found.size > 0) { | 561 | if(found.size > 0) { |
691 | 507 | warning("Some media files whose location were unknown were found.\n"); | 562 | warning("Some media files whose location were unknown were found.\n"); |
692 | 508 | update_medias(found, false, false, true); | 563 | update_medias(found, false, false, true); |
693 | 564 | |||
694 | 565 | // FIXME (BeatBox 0.7+) | ||
695 | 566 | // At this point, a signal should be emmited | ||
696 | 567 | // to let LibraryWindow know what's happening | ||
697 | 568 | // under the hood. | ||
698 | 569 | // UI code doesn't belong here. | ||
699 | 509 | foreach(var m in found) { | 570 | foreach(var m in found) { |
700 | 510 | lw.media_found(m.rowid); | 571 | lw.media_found(m.rowid); |
701 | 511 | } | 572 | } |
702 | @@ -536,15 +597,13 @@ | |||
703 | 536 | 597 | ||
704 | 537 | public Playlist? playlist_from_name(string name) { | 598 | public Playlist? playlist_from_name(string name) { |
705 | 538 | Playlist? rv = null; | 599 | Playlist? rv = null; |
708 | 539 | 600 | ||
707 | 540 | _playlists_lock.lock(); | ||
709 | 541 | foreach(var p in _playlists.values) { | 601 | foreach(var p in _playlists.values) { |
710 | 542 | if(p.get_name() == name) { | 602 | if(p.get_name() == name) { |
711 | 543 | rv = p; | 603 | rv = p; |
712 | 544 | break; | 604 | break; |
713 | 545 | } | 605 | } |
714 | 546 | } | 606 | } |
715 | 547 | _playlists_lock.unlock(); | ||
716 | 548 | 607 | ||
717 | 549 | return rv; | 608 | return rv; |
718 | 550 | } | 609 | } |
719 | @@ -556,10 +615,10 @@ | |||
720 | 556 | top_index = i; | 615 | top_index = i; |
721 | 557 | } | 616 | } |
722 | 558 | 617 | ||
727 | 559 | _playlists_lock.lock(); | 618 | lock (_playlists) { |
728 | 560 | p.set_rowid(top_index + 1); | 619 | p.set_rowid(top_index + 1); |
729 | 561 | _playlists.set(p.get_rowid(), p); | 620 | _playlists.set(p.get_rowid(), p); |
730 | 562 | _playlists_lock.unlock(); | 621 | } |
731 | 563 | 622 | ||
732 | 564 | playlist_added(p); | 623 | playlist_added(p); |
733 | 565 | dbm.add_playlist(p); | 624 | dbm.add_playlist(p); |
734 | @@ -570,9 +629,9 @@ | |||
735 | 570 | public void remove_playlist(int id) { | 629 | public void remove_playlist(int id) { |
736 | 571 | Playlist removed; | 630 | Playlist removed; |
737 | 572 | 631 | ||
741 | 573 | _playlists_lock.lock(); | 632 | lock (_playlists) { |
742 | 574 | _playlists.unset(id, out removed); | 633 | _playlists.unset(id, out removed); |
743 | 575 | _playlists_lock.unlock(); | 634 | } |
744 | 576 | 635 | ||
745 | 577 | playlist_removed(removed); | 636 | playlist_removed(removed); |
746 | 578 | dbu.removeItem(removed); | 637 | dbu.removeItem(removed); |
747 | @@ -598,29 +657,29 @@ | |||
748 | 598 | public SmartPlaylist? smart_playlist_from_name(string name) { | 657 | public SmartPlaylist? smart_playlist_from_name(string name) { |
749 | 599 | SmartPlaylist? rv = null; | 658 | SmartPlaylist? rv = null; |
750 | 600 | 659 | ||
757 | 601 | _smart_playlists_lock.lock(); | 660 | lock (_smart_playlists) { |
758 | 602 | foreach(var p in _smart_playlists.values) { | 661 | foreach(var p in _smart_playlists.values) { |
759 | 603 | if(p.get_name() == name) { | 662 | if(p.get_name() == name) { |
760 | 604 | rv = p; | 663 | rv = p; |
761 | 605 | break; | 664 | break; |
762 | 606 | } | 665 | } |
763 | 666 | } | ||
764 | 607 | } | 667 | } |
767 | 608 | _smart_playlists_lock.unlock(); | 668 | |
766 | 609 | |||
768 | 610 | return rv; | 669 | return rv; |
769 | 611 | } | 670 | } |
770 | 612 | 671 | ||
771 | 613 | public void save_smart_playlists() { | 672 | public void save_smart_playlists() { |
772 | 614 | try { | 673 | try { |
777 | 615 | Thread.create<void*>( () => { | 674 | new Thread<void*>.try (null, () => { |
778 | 616 | _smart_playlists_lock.lock(); | 675 | lock (_smart_playlists) { |
779 | 617 | dbm.save_smart_playlists(_smart_playlists.values); | 676 | dbm.save_smart_playlists(_smart_playlists.values); |
780 | 618 | _smart_playlists_lock.unlock(); | 677 | } |
781 | 619 | 678 | ||
782 | 620 | return null; | 679 | return null; |
784 | 621 | }, false); | 680 | }); |
785 | 622 | } | 681 | } |
787 | 623 | catch(GLib.Error err) { | 682 | catch(Error err) { |
788 | 624 | warning ("Could not create thread to save smart playlists: %s\n", err.message); | 683 | warning ("Could not create thread to save smart playlists: %s\n", err.message); |
789 | 625 | } | 684 | } |
790 | 626 | } | 685 | } |
791 | @@ -632,10 +691,10 @@ | |||
792 | 632 | top_index = i; | 691 | top_index = i; |
793 | 633 | } | 692 | } |
794 | 634 | 693 | ||
799 | 635 | _smart_playlists_lock.lock(); | 694 | lock (_smart_playlists) { |
800 | 636 | p.set_rowid(top_index + 1);// + 1 for 1-based db | 695 | p.set_rowid(top_index + 1);// + 1 for 1-based db |
801 | 637 | _smart_playlists.set(p.get_rowid(), p); | 696 | _smart_playlists.set(p.get_rowid(), p); |
802 | 638 | _smart_playlists_lock.unlock(); | 697 | } |
803 | 639 | 698 | ||
804 | 640 | playlist_added(p); | 699 | playlist_added(p); |
805 | 641 | save_smart_playlists(); | 700 | save_smart_playlists(); |
806 | @@ -646,9 +705,9 @@ | |||
807 | 646 | public void remove_smart_playlist(int id) { | 705 | public void remove_smart_playlist(int id) { |
808 | 647 | SmartPlaylist removed; | 706 | SmartPlaylist removed; |
809 | 648 | 707 | ||
813 | 649 | _smart_playlists_lock.lock(); | 708 | lock (_smart_playlists) { |
814 | 650 | _smart_playlists.unset(id, out removed); | 709 | _smart_playlists.unset(id, out removed); |
815 | 651 | _smart_playlists_lock.unlock(); | 710 | } |
816 | 652 | 711 | ||
817 | 653 | playlist_removed(removed); | 712 | playlist_removed(removed); |
818 | 654 | dbu.removeItem(removed); | 713 | dbu.removeItem(removed); |
819 | @@ -660,7 +719,6 @@ | |||
820 | 660 | 719 | ||
821 | 661 | // We really only want to clear the songs that are permanent and on the file system | 720 | // We really only want to clear the songs that are permanent and on the file system |
822 | 662 | // Dont clear podcasts that link to a url, device media, temporary media, previews, songs | 721 | // Dont clear podcasts that link to a url, device media, temporary media, previews, songs |
823 | 663 | _media_lock.lock(); | ||
824 | 664 | var unset = new LinkedList<Media>();//HashMap<int, Media>(); | 722 | var unset = new LinkedList<Media>();//HashMap<int, Media>(); |
825 | 665 | var unset_ids = new LinkedList<int>(); | 723 | var unset_ids = new LinkedList<int>(); |
826 | 666 | foreach(int i in _media.keys) { | 724 | foreach(int i in _media.keys) { |
827 | @@ -676,26 +734,39 @@ | |||
828 | 676 | } | 734 | } |
829 | 677 | } | 735 | } |
830 | 678 | } | 736 | } |
851 | 679 | 737 | ||
852 | 680 | foreach(Media s in unset) { | 738 | lock (_media) { |
853 | 681 | _media.unset(s.rowid); | 739 | foreach(Media s in unset) { |
854 | 682 | 740 | _media.unset(s.rowid); | |
855 | 683 | if(s.mediatype == MediaType.SONG) | 741 | |
856 | 684 | _songs.unset(s.rowid); | 742 | if(s.mediatype == MediaType.SONG) { |
857 | 685 | else if(s.mediatype == MediaType.PODCAST) | 743 | lock (_songs) { |
858 | 686 | _podcasts.unset(s.rowid); | 744 | _songs.unset (s.rowid); |
859 | 687 | else if(s.mediatype == MediaType.AUDIOBOOK) | 745 | } |
860 | 688 | _audiobooks.unset(s.rowid); | 746 | } |
861 | 689 | else if(s.mediatype == MediaType.STATION) | 747 | else if(s.mediatype == MediaType.PODCAST) { |
862 | 690 | _stations.unset(s.rowid); | 748 | lock (_podcasts) { |
863 | 691 | } | 749 | _podcasts.unset (s.rowid); |
864 | 692 | _media_lock.unlock(); | 750 | } |
865 | 693 | 751 | } | |
866 | 694 | _playlists_lock.lock(); | 752 | else if(s.mediatype == MediaType.AUDIOBOOK) { |
867 | 695 | foreach(var p in _playlists.values) { | 753 | lock (_audiobooks) { |
868 | 696 | p.removeMedias(unset_ids); | 754 | _audiobooks.unset(s.rowid); |
869 | 697 | } | 755 | } |
870 | 698 | _playlists_lock.unlock(); | 756 | } |
871 | 757 | else if(s.mediatype == MediaType.STATION) { | ||
872 | 758 | lock (_stations) { | ||
873 | 759 | _stations.unset(s.rowid); | ||
874 | 760 | } | ||
875 | 761 | } | ||
876 | 762 | } | ||
877 | 763 | } | ||
878 | 764 | |||
879 | 765 | lock (_playlists) { | ||
880 | 766 | foreach(var p in _playlists.values) { | ||
881 | 767 | p.removeMedias(unset_ids); | ||
882 | 768 | } | ||
883 | 769 | } | ||
884 | 699 | 770 | ||
885 | 700 | dbm.clear_medias(); | 771 | dbm.clear_medias(); |
886 | 701 | dbm.add_medias(_media.values); | 772 | dbm.add_medias(_media.values); |
887 | @@ -790,17 +861,17 @@ | |||
888 | 790 | dbu.update_medias(updates); | 861 | dbu.update_medias(updates); |
889 | 791 | } | 862 | } |
890 | 792 | 863 | ||
892 | 793 | public void save_media() { | 864 | public async void save_media_async () { |
893 | 794 | try { | 865 | try { |
898 | 795 | Thread.create<void*>( () => { | 866 | new Thread<void*>.try (null, () => { |
899 | 796 | _media_lock.lock(); | 867 | lock (_media) { |
900 | 797 | dbm.update_medias(_media.values); | 868 | dbm.update_medias (_media.values); |
901 | 798 | _media_lock.unlock(); | 869 | } |
902 | 799 | 870 | ||
903 | 800 | return null; | 871 | return null; |
905 | 801 | }, false); | 872 | }); |
906 | 802 | } | 873 | } |
908 | 803 | catch(GLib.Error err) { | 874 | catch(Error err) { |
909 | 804 | warning ("Could not create thread to save media: %s\n", err.message); | 875 | warning ("Could not create thread to save media: %s\n", err.message); |
910 | 805 | } | 876 | } |
911 | 806 | } | 877 | } |
912 | @@ -816,13 +887,13 @@ | |||
913 | 816 | public Media? match_media_to_list(Media m, Collection<Media> to_match) { | 887 | public Media? match_media_to_list(Media m, Collection<Media> to_match) { |
914 | 817 | Media? rv = null; | 888 | Media? rv = null; |
915 | 818 | 889 | ||
920 | 819 | _media_lock.lock(); | 890 | lock (_media) { |
921 | 820 | foreach(var test in to_match) { | 891 | foreach(var test in to_match) { |
922 | 821 | if(!test.isTemporary && test != m && test.title.down() == m.title.down() && test.artist.down() == m.artist.down()) { | 892 | if(!test.isTemporary && test != m && test.title.down() == m.title.down() && test.artist.down() == m.artist.down()) { |
923 | 822 | rv = test; | 893 | rv = test; |
924 | 894 | } | ||
925 | 823 | } | 895 | } |
926 | 824 | } | 896 | } |
927 | 825 | _media_lock.unlock(); | ||
928 | 826 | 897 | ||
929 | 827 | return rv; | 898 | return rv; |
930 | 828 | } | 899 | } |
931 | @@ -832,10 +903,8 @@ | |||
932 | 832 | rv.title = title; | 903 | rv.title = title; |
933 | 833 | rv.artist = artist; | 904 | rv.artist = artist; |
934 | 834 | Media[] searchable; | 905 | Media[] searchable; |
937 | 835 | 906 | ||
936 | 836 | _media_lock.lock(); | ||
938 | 837 | searchable = _media.values.to_array(); | 907 | searchable = _media.values.to_array(); |
939 | 838 | _media_lock.unlock(); | ||
940 | 839 | 908 | ||
941 | 840 | for(int i = 0; i < searchable.length; ++i) { | 909 | for(int i = 0; i < searchable.length; ++i) { |
942 | 841 | Media s = searchable[i]; | 910 | Media s = searchable[i]; |
943 | @@ -848,10 +917,8 @@ | |||
944 | 848 | 917 | ||
945 | 849 | public void medias_from_name(Collection<Media> tests, ref LinkedList<int> found, ref LinkedList<Media> not_found) { | 918 | public void medias_from_name(Collection<Media> tests, ref LinkedList<int> found, ref LinkedList<Media> not_found) { |
946 | 850 | Media[] searchable; | 919 | Media[] searchable; |
949 | 851 | 920 | ||
948 | 852 | _media_lock.lock(); | ||
950 | 853 | searchable = _media.values.to_array(); | 921 | searchable = _media.values.to_array(); |
951 | 854 | _media_lock.unlock(); | ||
952 | 855 | 922 | ||
953 | 856 | foreach(Media test in tests) { | 923 | foreach(Media test in tests) { |
954 | 857 | bool found_match = false; | 924 | bool found_match = false; |
955 | @@ -872,15 +939,13 @@ | |||
956 | 872 | public Media? media_from_file(string uri) { | 939 | public Media? media_from_file(string uri) { |
957 | 873 | Media? rv = null; | 940 | Media? rv = null; |
958 | 874 | 941 | ||
959 | 875 | _media_lock.lock(); | ||
960 | 876 | foreach(Media s in _media.values) { | 942 | foreach(Media s in _media.values) { |
961 | 877 | if(s.uri == uri) { | 943 | if(s.uri == uri) { |
962 | 878 | rv = s; | 944 | rv = s; |
963 | 879 | break; | 945 | break; |
964 | 880 | } | 946 | } |
965 | 881 | } | 947 | } |
968 | 882 | _media_lock.unlock(); | 948 | |
967 | 883 | |||
969 | 884 | return rv; | 949 | return rv; |
970 | 885 | } | 950 | } |
971 | 886 | 951 | ||
972 | @@ -997,31 +1062,44 @@ | |||
973 | 997 | return; | 1062 | return; |
974 | 998 | 1063 | ||
975 | 999 | int top_index = 0; | 1064 | int top_index = 0; |
977 | 1000 | _media_lock.lock(); | 1065 | |
978 | 1001 | foreach(int i in _media.keys) { | 1066 | foreach(int i in _media.keys) { |
979 | 1002 | if(i > top_index) | 1067 | if(i > top_index) |
980 | 1003 | top_index = i; | 1068 | top_index = i; |
981 | 1004 | } | 1069 | } |
982 | 1005 | 1070 | ||
983 | 1006 | var added = new LinkedList<int>(); | 1071 | var added = new LinkedList<int>(); |
1000 | 1007 | foreach(var s in new_media) { | 1072 | lock (_media) { |
1001 | 1008 | if(s.rowid == 0) | 1073 | foreach(var s in new_media) { |
1002 | 1009 | s.rowid = ++top_index; | 1074 | if(s.rowid == 0) |
1003 | 1010 | 1075 | s.rowid = ++top_index; | |
1004 | 1011 | added.add(s.rowid); | 1076 | |
1005 | 1012 | 1077 | added.add(s.rowid); | |
1006 | 1013 | _media.set(s.rowid, s); | 1078 | |
1007 | 1014 | 1079 | _media.set(s.rowid, s); | |
1008 | 1015 | if(s.mediatype == MediaType.SONG) | 1080 | |
1009 | 1016 | _songs.set(s.rowid, s); | 1081 | if(s.mediatype == MediaType.SONG) { |
1010 | 1017 | else if(s.mediatype == MediaType.PODCAST) | 1082 | lock (_songs) { |
1011 | 1018 | _podcasts.set(s.rowid, s); | 1083 | _audiobooks.set (s.rowid, s); |
1012 | 1019 | else if(s.mediatype == MediaType.AUDIOBOOK) | 1084 | } |
1013 | 1020 | _audiobooks.set(s.rowid, s); | 1085 | } |
1014 | 1021 | else if(s.mediatype == MediaType.STATION) | 1086 | else if(s.mediatype == MediaType.PODCAST) { |
1015 | 1022 | _stations.set(s.rowid, s); | 1087 | lock (_podcasts) { |
1016 | 1088 | _podcasts.set (s.rowid, s); | ||
1017 | 1089 | } | ||
1018 | 1090 | } | ||
1019 | 1091 | else if(s.mediatype == MediaType.AUDIOBOOK) { | ||
1020 | 1092 | lock (_audiobooks) { | ||
1021 | 1093 | _audiobooks.set (s.rowid, s); | ||
1022 | 1094 | } | ||
1023 | 1095 | } | ||
1024 | 1096 | else if(s.mediatype == MediaType.STATION) { | ||
1025 | 1097 | lock (_stations) { | ||
1026 | 1098 | _stations.set (s.rowid, s); | ||
1027 | 1099 | } | ||
1028 | 1100 | } | ||
1029 | 1101 | } | ||
1030 | 1023 | } | 1102 | } |
1031 | 1024 | _media_lock.unlock(); | ||
1032 | 1025 | 1103 | ||
1033 | 1026 | if(new_media.size > 0) { | 1104 | if(new_media.size > 0) { |
1034 | 1027 | dbm.add_medias(new_media); | 1105 | dbm.add_medias(new_media); |
1035 | @@ -1055,30 +1133,45 @@ | |||
1036 | 1055 | // call now so that lm.media_from_id() still works | 1133 | // call now so that lm.media_from_id() still works |
1037 | 1056 | medias_removed(removedIds); | 1134 | medias_removed(removedIds); |
1038 | 1057 | 1135 | ||
1051 | 1058 | _media_lock.lock(); | 1136 | lock (_media) { |
1052 | 1059 | foreach(Media s in toRemove) { | 1137 | foreach(Media s in toRemove) { |
1053 | 1060 | _media.unset(s.rowid); | 1138 | _media.unset(s.rowid); |
1054 | 1061 | 1139 | ||
1055 | 1062 | if(s.mediatype == MediaType.SONG) | 1140 | if(s.mediatype == MediaType.SONG) { |
1056 | 1063 | _songs.unset(s.rowid); | 1141 | lock (_songs) { |
1057 | 1064 | else if(s.mediatype == MediaType.PODCAST) | 1142 | _songs.unset (s.rowid); |
1058 | 1065 | _podcasts.unset(s.rowid); | 1143 | } |
1059 | 1066 | else if(s.mediatype == MediaType.AUDIOBOOK) | 1144 | } |
1060 | 1067 | _audiobooks.unset(s.rowid); | 1145 | else if(s.mediatype == MediaType.PODCAST) { |
1061 | 1068 | else if(s.mediatype == MediaType.STATION) | 1146 | lock (_podcasts) { |
1062 | 1069 | _stations.unset(s.rowid); | 1147 | _podcasts.unset (s.rowid); |
1063 | 1148 | } | ||
1064 | 1149 | } | ||
1065 | 1150 | else if(s.mediatype == MediaType.AUDIOBOOK) { | ||
1066 | 1151 | lock (_audiobooks) { | ||
1067 | 1152 | _audiobooks.unset(s.rowid); | ||
1068 | 1153 | } | ||
1069 | 1154 | } | ||
1070 | 1155 | else if(s.mediatype == MediaType.STATION) { | ||
1071 | 1156 | lock (_stations) { | ||
1072 | 1157 | _stations.unset(s.rowid); | ||
1073 | 1158 | } | ||
1074 | 1159 | } | ||
1075 | 1160 | } | ||
1076 | 1070 | } | 1161 | } |
1080 | 1071 | _media_lock.unlock(); | 1162 | |
1078 | 1072 | |||
1079 | 1073 | _playlists_lock.lock(); | ||
1081 | 1074 | foreach(var p in _playlists.values) { | 1163 | foreach(var p in _playlists.values) { |
1082 | 1075 | p.removeMedias(toRemove); | 1164 | p.removeMedias(toRemove); |
1083 | 1076 | } | 1165 | } |
1084 | 1077 | _playlists_lock.unlock(); | ||
1085 | 1078 | 1166 | ||
1086 | 1079 | if(_media.size == 0) | 1167 | if(_media.size == 0) |
1087 | 1080 | settings.setMusicFolder(Environment.get_user_special_dir(UserDirectory.MUSIC)); | 1168 | settings.setMusicFolder(Environment.get_user_special_dir(UserDirectory.MUSIC)); |
1089 | 1081 | 1169 | ||
1090 | 1170 | // FIXME (BeatBox 0.7+) | ||
1091 | 1171 | // At this point, a signal should be emmited | ||
1092 | 1172 | // to let LibraryWindow know what's happening | ||
1093 | 1173 | // under the hood. | ||
1094 | 1174 | // UI code doesn't belong here. | ||
1095 | 1082 | lw.update_sensitivities(); | 1175 | lw.update_sensitivities(); |
1096 | 1083 | } | 1176 | } |
1097 | 1084 | 1177 | ||
1098 | @@ -1340,6 +1433,12 @@ | |||
1099 | 1340 | if(File.new_for_uri(m.uri).query_exists()) { // we did not know location, but it has re-appearred | 1433 | if(File.new_for_uri(m.uri).query_exists()) { // we did not know location, but it has re-appearred |
1100 | 1341 | m.location_unknown = false; | 1434 | m.location_unknown = false; |
1101 | 1342 | m.unique_status_image = null; | 1435 | m.unique_status_image = null; |
1102 | 1436 | |||
1103 | 1437 | // FIXME (BeatBox 0.7+) | ||
1104 | 1438 | // At this point, a signal should be emmited | ||
1105 | 1439 | // to let LibraryWindow know what's happening | ||
1106 | 1440 | // under the hood. | ||
1107 | 1441 | // UI code doesn't belong here. | ||
1108 | 1343 | lw.media_found(m.rowid); | 1442 | lw.media_found(m.rowid); |
1109 | 1344 | } | 1443 | } |
1110 | 1345 | else { // to avoid infinite loop with repeat on, don't try to play next again | 1444 | else { // to avoid infinite loop with repeat on, don't try to play next again |
1111 | @@ -1351,9 +1450,16 @@ | |||
1112 | 1351 | // check that the file exists | 1450 | // check that the file exists |
1113 | 1352 | var music_folder_uri = File.new_for_path(settings.getMusicFolder()).get_uri(); | 1451 | var music_folder_uri = File.new_for_path(settings.getMusicFolder()).get_uri(); |
1114 | 1353 | if((settings.getMusicFolder() != "" && m.uri.has_prefix(music_folder_uri) && !GLib.File.new_for_uri(m.uri).query_exists())) { | 1452 | if((settings.getMusicFolder() != "" && m.uri.has_prefix(music_folder_uri) && !GLib.File.new_for_uri(m.uri).query_exists())) { |
1115 | 1453 | |||
1116 | 1454 | // FIXME (BeatBox 0.7+) | ||
1117 | 1455 | // At this point, a signal should be emmited | ||
1118 | 1456 | // to let LibraryWindow know what's happening | ||
1119 | 1457 | // under the hood. | ||
1120 | 1458 | // UI code doesn't belong here. | ||
1121 | 1354 | m.unique_status_image = Icons.PROCESS_ERROR.render(IconSize.MENU, ((ViewWrapper)lw.sideTree.getWidget(lw.sideTree.library_music_iter)).list_view.get_style_context()); | 1459 | m.unique_status_image = Icons.PROCESS_ERROR.render(IconSize.MENU, ((ViewWrapper)lw.sideTree.getWidget(lw.sideTree.library_music_iter)).list_view.get_style_context()); |
1122 | 1355 | m.location_unknown = true; | 1460 | m.location_unknown = true; |
1123 | 1356 | lw.media_not_found(id); | 1461 | lw.media_not_found(id); |
1124 | 1462 | |||
1125 | 1357 | getNext(true); | 1463 | getNext(true); |
1126 | 1358 | return; | 1464 | return; |
1127 | 1359 | } | 1465 | } |
1128 | @@ -1392,10 +1498,11 @@ | |||
1129 | 1392 | */ | 1498 | */ |
1130 | 1393 | Timeout.add(1000, () => { | 1499 | Timeout.add(1000, () => { |
1131 | 1394 | if(media_info.media == m) { | 1500 | if(media_info.media == m) { |
1132 | 1501 | // FIXME (BeatBox 0.7+) : Move to playback manager | ||
1133 | 1395 | try { | 1502 | try { |
1135 | 1396 | Thread.create<void*>(change_gains_thread, false); | 1503 | new Thread<void*>.try (null, change_gains_thread); |
1136 | 1397 | } | 1504 | } |
1138 | 1398 | catch(GLib.Error err) { | 1505 | catch(Error err) { |
1139 | 1399 | warning("Could not create thread to change gains: %s\n", err.message); | 1506 | warning("Could not create thread to change gains: %s\n", err.message); |
1140 | 1400 | } | 1507 | } |
1141 | 1401 | 1508 | ||
1142 | @@ -1417,6 +1524,9 @@ | |||
1143 | 1417 | } | 1524 | } |
1144 | 1418 | 1525 | ||
1145 | 1419 | // FIXME: Slow. Don't read eq. presets from settings. | 1526 | // FIXME: Slow. Don't read eq. presets from settings. |
1146 | 1527 | // FIXME (BeatBox 0.7+) | ||
1147 | 1528 | // Deprecate in favor of PlaybackManager. Currently, this is public | ||
1148 | 1529 | // because EqualizerWindow needs it | ||
1149 | 1420 | public void* change_gains_thread () { | 1530 | public void* change_gains_thread () { |
1150 | 1421 | if(settings.getEqualizerEnabled()) { | 1531 | if(settings.getEqualizerEnabled()) { |
1151 | 1422 | bool automatic_enabled = settings.getAutoSwitchPreset(); | 1532 | bool automatic_enabled = settings.getAutoSwitchPreset(); |
1152 | @@ -1479,7 +1589,12 @@ | |||
1153 | 1479 | temps.add(s); | 1589 | temps.add(s); |
1154 | 1480 | 1590 | ||
1155 | 1481 | playMedia(s, false); | 1591 | playMedia(s, false); |
1157 | 1482 | 1592 | ||
1158 | 1593 | // FIXME (BeatBox 0.7+) | ||
1159 | 1594 | // At this point, a signal should be emmited | ||
1160 | 1595 | // to let LibraryWindow know what's happening | ||
1161 | 1596 | // under the hood. | ||
1162 | 1597 | // UI code doesn't belong here. | ||
1163 | 1483 | if(!playing) { | 1598 | if(!playing) { |
1164 | 1484 | lw.playClicked(); | 1599 | lw.playClicked(); |
1165 | 1485 | } | 1600 | } |
1166 | @@ -1526,19 +1641,26 @@ | |||
1167 | 1526 | set_album_art(_media.get(id), pix, emit); | 1641 | set_album_art(_media.get(id), pix, emit); |
1168 | 1527 | } | 1642 | } |
1169 | 1528 | } | 1643 | } |
1171 | 1529 | 1644 | ||
1172 | 1645 | public async void fetch_image_cache_async () { | ||
1173 | 1646 | try { | ||
1174 | 1647 | new Thread<void*>.try (null, fetch_image_thread_function); | ||
1175 | 1648 | } catch(Error err) { | ||
1176 | 1649 | warning ("Could not create thread to load media pixbuf's: %s \n", err.message); | ||
1177 | 1650 | } | ||
1178 | 1651 | } | ||
1179 | 1652 | |||
1180 | 1530 | /* at the start, load all the pixbufs */ | 1653 | /* at the start, load all the pixbufs */ |
1182 | 1531 | public void* fetch_thread_function () { | 1654 | private void* fetch_image_thread_function () { |
1183 | 1532 | if(in_fetch_thread) | 1655 | if(in_fetch_thread) |
1184 | 1533 | return null; | 1656 | return null; |
1186 | 1534 | 1657 | ||
1187 | 1535 | in_fetch_thread = true; | 1658 | in_fetch_thread = true; |
1188 | 1536 | //GStreamerTagger tagger = new GStreamerTagger(this); | 1659 | //GStreamerTagger tagger = new GStreamerTagger(this); |
1189 | 1537 | LinkedList<Media> medias = new LinkedList<Media>(); | 1660 | LinkedList<Media> medias = new LinkedList<Media>(); |
1191 | 1538 | _media_lock.lock(); | 1661 | |
1192 | 1539 | foreach(var m in _media.values) | 1662 | foreach(var m in _media.values) |
1193 | 1540 | medias.add(m); | 1663 | medias.add(m); |
1194 | 1541 | _media_lock.unlock(); | ||
1195 | 1542 | 1664 | ||
1196 | 1543 | // first get from file | 1665 | // first get from file |
1197 | 1544 | foreach(var s in medias) { | 1666 | foreach(var s in medias) { |
1198 | @@ -1658,13 +1780,12 @@ | |||
1199 | 1658 | if(emit) { | 1780 | if(emit) { |
1200 | 1659 | Gee.LinkedList<Media> updated_medias = new Gee.LinkedList<Media>(); | 1781 | Gee.LinkedList<Media> updated_medias = new Gee.LinkedList<Media>(); |
1201 | 1660 | 1782 | ||
1203 | 1661 | _media_lock.lock(); | 1783 | |
1204 | 1662 | foreach(int i in media_ids()) { | 1784 | foreach(int i in media_ids()) { |
1205 | 1663 | if(media_from_id(i).album_artist == s.album_artist && media_from_id(i).album == s.album) { | 1785 | if(media_from_id(i).album_artist == s.album_artist && media_from_id(i).album == s.album) { |
1206 | 1664 | updated_medias.add(media_from_id(i)); | 1786 | updated_medias.add(media_from_id(i)); |
1207 | 1665 | } | 1787 | } |
1208 | 1666 | } | 1788 | } |
1209 | 1667 | _media_lock.unlock(); | ||
1210 | 1668 | 1789 | ||
1211 | 1669 | update_medias(updated_medias, false, false, true); | 1790 | update_medias(updated_medias, false, false, true); |
1212 | 1670 | } | 1791 | } |
1213 | @@ -1677,7 +1798,14 @@ | |||
1214 | 1677 | 1798 | ||
1215 | 1678 | progress_notification(message, 0.0); | 1799 | progress_notification(message, 0.0); |
1216 | 1679 | _doing_file_operations = true; | 1800 | _doing_file_operations = true; |
1217 | 1801 | |||
1218 | 1802 | // FIXME (BeatBox 0.7+) | ||
1219 | 1803 | // At this point, a signal should be emmited | ||
1220 | 1804 | // to let LibraryWindow know what's happening | ||
1221 | 1805 | // under the hood. | ||
1222 | 1806 | // UI code doesn't belong here. | ||
1223 | 1680 | lw.update_sensitivities(); | 1807 | lw.update_sensitivities(); |
1224 | 1808 | |||
1225 | 1681 | file_operations_started(); | 1809 | file_operations_started(); |
1226 | 1682 | return true; | 1810 | return true; |
1227 | 1683 | } | 1811 | } |
1228 | @@ -1694,15 +1822,16 @@ | |||
1229 | 1694 | pm.find_new_podcasts(); | 1822 | pm.find_new_podcasts(); |
1230 | 1695 | } | 1823 | } |
1231 | 1696 | else { | 1824 | else { |
1239 | 1697 | try { | 1825 | fetch_image_cache_async (); |
1240 | 1698 | Thread.create<void*>(fetch_thread_function, false); | 1826 | |
1241 | 1699 | } | 1827 | // FIXME (BeatBox 0.7+) |
1242 | 1700 | catch(GLib.ThreadError err) { | 1828 | // At this point, a signal should be emmited |
1243 | 1701 | warning("Could not create thread to load media pixbuf's: %s \n", err.message); | 1829 | // to let LibraryWindow know what's happening |
1244 | 1702 | } | 1830 | // under the hood. |
1245 | 1703 | 1831 | // UI code doesn't belong here. | |
1246 | 1704 | lw.update_sensitivities(); | 1832 | lw.update_sensitivities(); |
1247 | 1705 | lw.updateInfoLabel(); | 1833 | lw.updateInfoLabel(); |
1248 | 1834 | |||
1249 | 1706 | file_operations_done(); | 1835 | file_operations_done(); |
1250 | 1707 | } | 1836 | } |
1251 | 1708 | } | 1837 | } |
1252 | 1709 | 1838 | ||
1253 | === modified file 'src/Core/LibraryWindow.vala' | |||
1254 | --- src/Core/LibraryWindow.vala 2012-06-30 20:55:57 +0000 | |||
1255 | +++ src/Core/LibraryWindow.vala 2012-07-03 06:49:24 +0000 | |||
1256 | @@ -219,8 +219,8 @@ | |||
1257 | 219 | this.window_position = Gtk.WindowPosition.CENTER; | 219 | this.window_position = Gtk.WindowPosition.CENTER; |
1258 | 220 | 220 | ||
1259 | 221 | // set the size based on saved settings | 221 | // set the size based on saved settings |
1262 | 222 | this.set_default_size (lm.settings.getWindowWidth(), lm.settings.getWindowHeight()); | 222 | this.set_default_size (settings.getWindowWidth(), settings.getWindowHeight()); |
1263 | 223 | if(lm.settings.getWindowMaximized()) { | 223 | if(settings.getWindowMaximized()) { |
1264 | 224 | window_maximized = true; | 224 | window_maximized = true; |
1265 | 225 | this.maximize(); | 225 | this.maximize(); |
1266 | 226 | } | 226 | } |
1267 | @@ -282,7 +282,7 @@ | |||
1268 | 282 | viewSelector.append(Icons.VIEW_DETAILS.render_image (IconSize.MENU)); | 282 | viewSelector.append(Icons.VIEW_DETAILS.render_image (IconSize.MENU)); |
1269 | 283 | viewSelector.append(Icons.VIEW_ICONS.render_image (IconSize.MENU)); | 283 | viewSelector.append(Icons.VIEW_ICONS.render_image (IconSize.MENU)); |
1270 | 284 | viewSelector.valign = showSongInfo.valign = Gtk.Align.CENTER; | 284 | viewSelector.valign = showSongInfo.valign = Gtk.Align.CENTER; |
1272 | 285 | viewSelector.selected = lm.settings.getViewMode(); | 285 | viewSelector.selected = settings.getViewMode(); |
1273 | 286 | 286 | ||
1274 | 287 | viewSelectorBin.margin_left = 12; | 287 | viewSelectorBin.margin_left = 12; |
1275 | 288 | viewSelectorBin.margin_right = 12; | 288 | viewSelectorBin.margin_right = 12; |
1276 | @@ -363,12 +363,12 @@ | |||
1277 | 363 | repeatChooser.appendItem(_("Album")); | 363 | repeatChooser.appendItem(_("Album")); |
1278 | 364 | repeatChooser.appendItem(_("Artist")); | 364 | repeatChooser.appendItem(_("Artist")); |
1279 | 365 | repeatChooser.appendItem(_("All")); | 365 | repeatChooser.appendItem(_("All")); |
1281 | 366 | repeatChooser.setOption(lm.settings.getRepeatMode()); | 366 | repeatChooser.setOption(settings.getRepeatMode()); |
1282 | 367 | repeatChooser.setTooltip (_("Disable Repeat"), _("Enable Repeat")); | 367 | repeatChooser.setTooltip (_("Disable Repeat"), _("Enable Repeat")); |
1283 | 368 | 368 | ||
1284 | 369 | shuffleChooser.appendItem(_("Off")); | 369 | shuffleChooser.appendItem(_("Off")); |
1285 | 370 | shuffleChooser.appendItem(_("All")); | 370 | shuffleChooser.appendItem(_("All")); |
1287 | 371 | shuffleChooser.setOption(lm.settings.getShuffleMode()); | 371 | shuffleChooser.setOption(settings.getShuffleMode()); |
1288 | 372 | shuffleChooser.setTooltip (_("Turn off Shuffle"), _("Turn on Shuffle")); | 372 | shuffleChooser.setTooltip (_("Turn off Shuffle"), _("Turn on Shuffle")); |
1289 | 373 | 373 | ||
1290 | 374 | newPlaylistMenu = new Gtk.Menu(); | 374 | newPlaylistMenu = new Gtk.Menu(); |
1291 | @@ -445,7 +445,7 @@ | |||
1292 | 445 | 445 | ||
1293 | 446 | show_all(); | 446 | show_all(); |
1294 | 447 | infoBar.hide(); | 447 | infoBar.hide(); |
1296 | 448 | searchField.set_text(lm.settings.getSearchString()); | 448 | searchField.set_text(settings.getSearchString()); |
1297 | 449 | update_sensitivities(); | 449 | update_sensitivities(); |
1298 | 450 | hide_video_mode(); | 450 | hide_video_mode(); |
1299 | 451 | } | 451 | } |
1300 | @@ -713,7 +713,7 @@ | |||
1301 | 713 | if(!initializationFinished) | 713 | if(!initializationFinished) |
1302 | 714 | return; | 714 | return; |
1303 | 715 | 715 | ||
1305 | 716 | bool folderSet = (lm.settings.getMusicFolder() != ""); | 716 | bool folderSet = (settings.getMusicFolder() != ""); |
1306 | 717 | bool haveMedias = lm.media_count() > 0; | 717 | bool haveMedias = lm.media_count() > 0; |
1307 | 718 | bool doingOps = lm.doing_file_operations(); | 718 | bool doingOps = lm.doing_file_operations(); |
1308 | 719 | bool mediaActive = lm.media_active; | 719 | bool mediaActive = lm.media_active; |
1309 | @@ -811,7 +811,7 @@ | |||
1310 | 811 | 811 | ||
1311 | 812 | var label = ""; | 812 | var label = ""; |
1312 | 813 | if(lm.fo.import_type == FileOperator.ImportType.SET) | 813 | if(lm.fo.import_type == FileOperator.ImportType.SET) |
1314 | 814 | label = _("Importing music from") + " <b>" + Markup.escape_text(lm.settings.getMusicFolder()) + "</b>..."; | 814 | label = _("Importing music from") + " <b>" + Markup.escape_text(settings.getMusicFolder()) + "</b>..."; |
1315 | 815 | else if(lm.fo.import_type == FileOperator.ImportType.RESCAN) | 815 | else if(lm.fo.import_type == FileOperator.ImportType.RESCAN) |
1316 | 816 | label = _("Rescanning music folder for changes..."); | 816 | label = _("Rescanning music folder for changes..."); |
1317 | 817 | else if(lm.fo.import_type == FileOperator.ImportType.IMPORT || | 817 | else if(lm.fo.import_type == FileOperator.ImportType.IMPORT || |
1318 | @@ -1005,7 +1005,7 @@ | |||
1319 | 1005 | void on_quit() { | 1005 | void on_quit() { |
1320 | 1006 | // Stop listening to window state changes | 1006 | // Stop listening to window state changes |
1321 | 1007 | this.window_state_event.disconnect(window_state_changed); | 1007 | this.window_state_event.disconnect(window_state_changed); |
1323 | 1008 | lm.settings.setLastMediaPosition((int)((double)lm.player.getPosition()/1000000000)); | 1008 | settings.setLastMediaPosition((int)((double)lm.player.getPosition()/1000000000)); |
1324 | 1009 | if(lm.media_active) { | 1009 | if(lm.media_active) { |
1325 | 1010 | lm.media_info.media.resume_pos = (int)((double)lm.player.getPosition()/1000000000); | 1010 | lm.media_info.media.resume_pos = (int)((double)lm.player.getPosition()/1000000000); |
1326 | 1011 | lm.update_media(lm.media_info.media, false, false, false); | 1011 | lm.update_media(lm.media_info.media, false, false, false); |
1327 | @@ -1055,13 +1055,13 @@ | |||
1328 | 1055 | } | 1055 | } |
1329 | 1056 | } | 1056 | } |
1330 | 1057 | 1057 | ||
1332 | 1058 | if(final_folders.size > 0 && GLib.File.new_for_path(lm.settings.getMusicFolder()).query_exists()) { | 1058 | if(final_folders.size > 0 && GLib.File.new_for_path(settings.getMusicFolder()).query_exists()) { |
1333 | 1059 | topDisplay.show_progressbar(); | 1059 | topDisplay.show_progressbar(); |
1334 | 1060 | 1060 | ||
1336 | 1061 | lm.add_folder_to_library(final_folders); | 1061 | lm.add_folder_to_library_async (final_folders); |
1337 | 1062 | update_sensitivities(); | 1062 | update_sensitivities(); |
1338 | 1063 | } | 1063 | } |
1340 | 1064 | else if(!GLib.File.new_for_path(lm.settings.getMusicFolder()).query_exists()) { | 1064 | else if(!GLib.File.new_for_path(settings.getMusicFolder()).query_exists()) { |
1341 | 1065 | doAlert(_("Import Failed"), _("Your library's music folder could not be found. Please make sure your music folder is mounted before importing.")); | 1065 | doAlert(_("Import Failed"), _("Your library's music folder could not be found. Please make sure your music folder is mounted before importing.")); |
1342 | 1066 | } | 1066 | } |
1343 | 1067 | } | 1067 | } |
1344 | @@ -1080,7 +1080,7 @@ | |||
1345 | 1080 | topDisplay.set_label_markup("<b>" + _("Rescanning music folder for changes") + "</b>"); | 1080 | topDisplay.set_label_markup("<b>" + _("Rescanning music folder for changes") + "</b>"); |
1346 | 1081 | topDisplay.show_progressbar(); | 1081 | topDisplay.show_progressbar(); |
1347 | 1082 | 1082 | ||
1349 | 1083 | lm.rescan_music_folder(); | 1083 | lm.rescan_music_folder_async (); |
1350 | 1084 | update_sensitivities(); | 1084 | update_sensitivities(); |
1351 | 1085 | } | 1085 | } |
1352 | 1086 | else { | 1086 | else { |
1353 | @@ -1136,7 +1136,7 @@ | |||
1354 | 1136 | //searchField.set_text("up"); | 1136 | //searchField.set_text("up"); |
1355 | 1137 | 1137 | ||
1356 | 1138 | if(not_imported.size > 0) { | 1138 | if(not_imported.size > 0) { |
1358 | 1139 | NotImportedDialog nim = new NotImportedDialog(this, not_imported, lm.settings.getMusicFolder()); | 1139 | NotImportedDialog nim = new NotImportedDialog(this, not_imported, settings.getMusicFolder()); |
1359 | 1140 | nim.show(); | 1140 | nim.show(); |
1360 | 1141 | } | 1141 | } |
1361 | 1142 | 1142 | ||
1362 | @@ -1388,7 +1388,7 @@ | |||
1363 | 1388 | files_dragged.add(File.new_for_uri(uri).get_path()); | 1388 | files_dragged.add(File.new_for_uri(uri).get_path()); |
1364 | 1389 | } | 1389 | } |
1365 | 1390 | 1390 | ||
1367 | 1391 | lm.add_files_to_library(files_dragged); | 1391 | lm.add_files_to_library_async (files_dragged); |
1368 | 1392 | } | 1392 | } |
1369 | 1393 | 1393 | ||
1370 | 1394 | public void doAlert(string title, string message) { | 1394 | public void doAlert(string title, string message) { |
1371 | 1395 | 1395 | ||
1372 | === modified file 'src/Core/PodcastManager.vala' | |||
1373 | --- src/Core/PodcastManager.vala 2012-06-13 23:54:06 +0000 | |||
1374 | +++ src/Core/PodcastManager.vala 2012-07-03 06:49:24 +0000 | |||
1375 | @@ -66,16 +66,16 @@ | |||
1376 | 66 | 66 | ||
1377 | 67 | lm.start_file_operations(FETCHING_NEW); | 67 | lm.start_file_operations(FETCHING_NEW); |
1378 | 68 | try { | 68 | try { |
1380 | 69 | Thread.create<void*>(find_new_podcasts_thread, false); | 69 | new Thread<void*>.try (null, find_new_podcasts_thread); |
1381 | 70 | } | 70 | } |
1384 | 71 | catch(GLib.ThreadError err) { | 71 | catch (Error err) { |
1385 | 72 | stdout.printf("ERROR: Could not create thread to fetch new podcasts: %s \n", err.message); | 72 | warning ("Could not create thread to fetch new podcasts: %s", err.message); |
1386 | 73 | } | 73 | } |
1387 | 74 | 74 | ||
1388 | 75 | lm.have_fetched_new_podcasts = true; | 75 | lm.have_fetched_new_podcasts = true; |
1389 | 76 | } | 76 | } |
1390 | 77 | 77 | ||
1392 | 78 | public void* find_new_podcasts_thread () { | 78 | private void* find_new_podcasts_thread () { |
1393 | 79 | HashSet<string> rss_urls = new HashSet<string>(); | 79 | HashSet<string> rss_urls = new HashSet<string>(); |
1394 | 80 | HashSet<string> mp3_urls = new HashSet<string>(); | 80 | HashSet<string> mp3_urls = new HashSet<string>(); |
1395 | 81 | HashMap<string, string> rss_names = new HashMap<string, string>(); | 81 | HashMap<string, string> rss_names = new HashMap<string, string>(); |
1396 | @@ -174,7 +174,7 @@ | |||
1397 | 174 | //current_operation = FETCHING_FROM_RSS.printf("<b>" + Markup.escape_text(rss) + "</b>"); | 174 | //current_operation = FETCHING_FROM_RSS.printf("<b>" + Markup.escape_text(rss) + "</b>"); |
1398 | 175 | Timeout.add(500, doProgressNotificationWithTimeout); | 175 | Timeout.add(500, doProgressNotificationWithTimeout); |
1399 | 176 | 176 | ||
1401 | 177 | debug("podcast_rss: %s\n", rss); | 177 | debug("podcast_rss: %s", rss); |
1402 | 178 | 178 | ||
1403 | 179 | // create an HTTP session to twitter | 179 | // create an HTTP session to twitter |
1404 | 180 | var session = new Soup.SessionSync(); | 180 | var session = new Soup.SessionSync(); |
1405 | @@ -218,7 +218,7 @@ | |||
1406 | 218 | Xml.Doc* doc = Xml.Parser.parse_memory((string)message.response_body.data, (int)message.response_body.length); | 218 | Xml.Doc* doc = Xml.Parser.parse_memory((string)message.response_body.data, (int)message.response_body.length); |
1407 | 219 | if(doc == null) | 219 | if(doc == null) |
1408 | 220 | return null; | 220 | return null; |
1410 | 221 | //stdout.printf("%s\n", (string)message.response_body.data); | 221 | //stdout.printf("%s", (string)message.response_body.data); |
1411 | 222 | Xml.Node* root = doc->get_root_element (); | 222 | Xml.Node* root = doc->get_root_element (); |
1412 | 223 | if (root == null) { | 223 | if (root == null) { |
1413 | 224 | delete doc; | 224 | delete doc; |
1414 | @@ -279,7 +279,7 @@ | |||
1415 | 279 | Media new_p = new Media(""); | 279 | Media new_p = new Media(""); |
1416 | 280 | 280 | ||
1417 | 281 | for (Xml.Node* item_iter = iter->children; item_iter != null; item_iter = item_iter->next) { | 281 | for (Xml.Node* item_iter = iter->children; item_iter != null; item_iter = item_iter->next) { |
1419 | 282 | //stdout.printf("name is %s\n", item_iter->name); | 282 | //stdout.printf("name is %s", item_iter->name); |
1420 | 283 | if(item_iter->name == "title") | 283 | if(item_iter->name == "title") |
1421 | 284 | new_p.title = item_iter->get_content(); | 284 | new_p.title = item_iter->get_content(); |
1422 | 285 | else if(name == "author") { | 285 | else if(name == "author") { |
1423 | @@ -365,14 +365,14 @@ | |||
1424 | 365 | save_locally_ids = ids; | 365 | save_locally_ids = ids; |
1425 | 366 | 366 | ||
1426 | 367 | try { | 367 | try { |
1428 | 368 | Thread.create<void*>(save_episodes_locally_thread, false); | 368 | new Thread<void*>.try (null, save_episodes_locally_thread); |
1429 | 369 | } | 369 | } |
1432 | 370 | catch(GLib.ThreadError err) { | 370 | catch (Error err) { |
1433 | 371 | stdout.printf("ERROR: Could not create thread to save episodes locally: %s \n", err.message); | 371 | warning ("Could not create thread to save episodes locally: %s", err.message); |
1434 | 372 | } | 372 | } |
1435 | 373 | } | 373 | } |
1436 | 374 | 374 | ||
1438 | 375 | public void* save_episodes_locally_thread () { | 375 | private void* save_episodes_locally_thread () { |
1439 | 376 | if(save_locally_ids == null || save_locally_ids.size == 0) | 376 | if(save_locally_ids == null || save_locally_ids.size == 0) |
1440 | 377 | return null; | 377 | return null; |
1441 | 378 | 378 | ||
1442 | @@ -397,7 +397,7 @@ | |||
1443 | 397 | online_size = online_file.query_info("*", FileQueryInfoFlags.NONE).get_size(); | 397 | online_size = online_file.query_info("*", FileQueryInfoFlags.NONE).get_size(); |
1444 | 398 | } | 398 | } |
1445 | 399 | catch(Error err) { | 399 | catch(Error err) { |
1447 | 400 | stdout.printf("Could not read online podcast file's size for progress notification: %s\n", err.message); | 400 | stdout.printf("Could not read online podcast file's size for progress notification: %s", err.message); |
1448 | 401 | } | 401 | } |
1449 | 402 | 402 | ||
1450 | 403 | new_dest = lm.fo.get_new_destination(s); | 403 | new_dest = lm.fo.get_new_destination(s); |
1451 | @@ -408,7 +408,7 @@ | |||
1452 | 408 | file_size = (int)(new_dest.query_info("*", FileQueryInfoFlags.NONE).get_size() / 1000000); | 408 | file_size = (int)(new_dest.query_info("*", FileQueryInfoFlags.NONE).get_size() / 1000000); |
1453 | 409 | } | 409 | } |
1454 | 410 | catch(Error err) { | 410 | catch(Error err) { |
1456 | 411 | stdout.printf("Could not calculate downloaded podcast's file size: %s\n", err.message); | 411 | stdout.printf("Could not calculate downloaded podcast's file size: %s", err.message); |
1457 | 412 | } | 412 | } |
1458 | 413 | 413 | ||
1459 | 414 | s.file_size = file_size; | 414 | s.file_size = file_size; |
1460 | @@ -442,7 +442,7 @@ | |||
1461 | 442 | GLib.File original = GLib.File.new_for_uri(s.uri); | 442 | GLib.File original = GLib.File.new_for_uri(s.uri); |
1462 | 443 | 443 | ||
1463 | 444 | /* copy the file over */ | 444 | /* copy the file over */ |
1465 | 445 | debug("Copying %s to %s\n", s.uri, dest.get_uri()); | 445 | debug("Copying %s to %s", s.uri, dest.get_uri()); |
1466 | 446 | success = original.copy(dest, FileCopyFlags.NONE, canceller, null); | 446 | success = original.copy(dest, FileCopyFlags.NONE, canceller, null); |
1467 | 447 | 447 | ||
1468 | 448 | if(success || dest.query_exists()) { | 448 | if(success || dest.query_exists()) { |
1469 | @@ -456,10 +456,10 @@ | |||
1470 | 456 | }); | 456 | }); |
1471 | 457 | } | 457 | } |
1472 | 458 | else | 458 | else |
1474 | 459 | warning("Failure: Could not copy imported media %s to media folder %s\n", s.uri, dest.get_path()); | 459 | warning("Failure: Could not copy imported media %s to media folder %s", s.uri, dest.get_path()); |
1475 | 460 | } | 460 | } |
1476 | 461 | catch(GLib.Error err) { | 461 | catch(GLib.Error err) { |
1478 | 462 | warning("Could not copy imported media %s to media folder: %s\n", s.uri, err.message); | 462 | warning("Could not copy imported media %s to media folder: %s", s.uri, err.message); |
1479 | 463 | } | 463 | } |
1480 | 464 | 464 | ||
1481 | 465 | return success; | 465 | return success; |
1482 | @@ -483,7 +483,7 @@ | |||
1483 | 483 | current_local_size = new_dest.query_info("*", FileQueryInfoFlags.NONE).get_size(); | 483 | current_local_size = new_dest.query_info("*", FileQueryInfoFlags.NONE).get_size(); |
1484 | 484 | } | 484 | } |
1485 | 485 | catch(Error err) { | 485 | catch(Error err) { |
1487 | 486 | stdout.printf("Error reading current size of downloaded podcast: %s\n", err.message); | 486 | stdout.printf("Error reading current size of downloaded podcast: %s", err.message); |
1488 | 487 | } | 487 | } |
1489 | 488 | } | 488 | } |
1490 | 489 | 489 | ||
1491 | 490 | 490 | ||
1492 | === modified file 'src/DataBase/DataBaseUpdater.vala' | |||
1493 | --- src/DataBase/DataBaseUpdater.vala 2012-06-01 22:48:28 +0000 | |||
1494 | +++ src/DataBase/DataBaseUpdater.vala 2012-07-03 06:49:24 +0000 | |||
1495 | @@ -23,34 +23,27 @@ | |||
1496 | 23 | /* Merely a place holder for multiple pieces of information regarding | 23 | /* Merely a place holder for multiple pieces of information regarding |
1497 | 24 | * the current media playing. Mostly here because of dependence. */ | 24 | * the current media playing. Mostly here because of dependence. */ |
1498 | 25 | 25 | ||
1499 | 26 | using Gee; | ||
1500 | 27 | 26 | ||
1502 | 28 | public class BeatBox.DataBaseUpdater : GLib.Object { | 27 | public class BeatBox.DataBaseUpdater : Object { |
1503 | 29 | private LibraryManager lm; | 28 | private LibraryManager lm; |
1504 | 30 | private BeatBox.DataBaseManager dbm; | 29 | private BeatBox.DataBaseManager dbm; |
1505 | 31 | 30 | ||
1513 | 32 | LinkedList<Media> media_updates; | 31 | Gee.LinkedList<Media> media_updates; |
1514 | 33 | 32 | ||
1515 | 34 | Mutex update_mutex; | 33 | Gee.LinkedList<Object> toUpdate; // a queue of things to update |
1516 | 35 | Mutex remove_mutex; | 34 | Gee.LinkedList<Object> toRemove; |
1510 | 36 | |||
1511 | 37 | LinkedList<GLib.Object> toUpdate; // a queue of things to update | ||
1512 | 38 | LinkedList<GLib.Object> toRemove; | ||
1517 | 39 | bool inThread; | 35 | bool inThread; |
1518 | 40 | 36 | ||
1519 | 41 | public DataBaseUpdater(LibraryManager lm, BeatBox.DataBaseManager databm) { | 37 | public DataBaseUpdater(LibraryManager lm, BeatBox.DataBaseManager databm) { |
1520 | 42 | this.lm = lm; | 38 | this.lm = lm; |
1521 | 43 | dbm = databm; | 39 | dbm = databm; |
1522 | 44 | 40 | ||
1529 | 45 | update_mutex = new Mutex(); | 41 | media_updates = new Gee.LinkedList<Media>(); |
1530 | 46 | remove_mutex = new Mutex(); | 42 | toUpdate = new Gee.LinkedList<Object>(); |
1531 | 47 | 43 | toRemove = new Gee.LinkedList<Object>(); | |
1526 | 48 | media_updates = new LinkedList<Media>(); | ||
1527 | 49 | toUpdate = new LinkedList<GLib.Object>(); | ||
1528 | 50 | toRemove = new LinkedList<GLib.Object>(); | ||
1532 | 51 | inThread = false; | 44 | inThread = false; |
1533 | 52 | 45 | ||
1535 | 53 | tree_view_setups = new GLib.List<TreeViewSetup>(); | 46 | tree_view_setups = new List<TreeViewSetup>(); |
1536 | 54 | 47 | ||
1537 | 55 | Timeout.add(10000, periodic_save); | 48 | Timeout.add(10000, periodic_save); |
1538 | 56 | } | 49 | } |
1539 | @@ -61,76 +54,71 @@ | |||
1540 | 61 | return true; | 54 | return true; |
1541 | 62 | } | 55 | } |
1542 | 63 | 56 | ||
1544 | 64 | public void update_item(GLib.Object item) { | 57 | public void update_item(Object item) { |
1545 | 65 | if(!(toUpdate.contains(item))) | 58 | if(!(toUpdate.contains(item))) |
1546 | 66 | toUpdate.offer(item); | 59 | toUpdate.offer(item); |
1547 | 67 | 60 | ||
1604 | 68 | if(!inThread && lm.lw.initializationFinished) { | 61 | update_database_async (); |
1605 | 69 | try { | 62 | } |
1606 | 70 | inThread = true; | 63 | |
1607 | 71 | Thread.create<void*>(update_db_thread_function, false); | 64 | public void update_medias(Gee.Collection<Media> updates) { |
1608 | 72 | } | 65 | lock (media_updates) { |
1609 | 73 | catch(GLib.ThreadError err) { | 66 | foreach (var s in updates) |
1610 | 74 | stdout.printf("Could not create thread to update database: %s \n", err.message); | 67 | media_updates.offer (s); |
1611 | 75 | } | 68 | } |
1612 | 76 | } | 69 | |
1613 | 77 | } | 70 | update_database_async (); |
1614 | 78 | 71 | } | |
1615 | 79 | public void update_medias(Collection<Media> updates) { | 72 | |
1616 | 80 | update_mutex.lock(); | 73 | public void removeItem (Object item) { |
1617 | 81 | foreach(var s in updates) | 74 | lock (toRemove) { |
1618 | 82 | media_updates.offer(s); | 75 | if (!(toRemove.contains(item))) |
1619 | 83 | update_mutex.unlock(); | 76 | toRemove.offer (item); |
1620 | 84 | 77 | } | |
1621 | 85 | if(!inThread && lm.lw.initializationFinished) { | 78 | |
1622 | 86 | try { | 79 | update_database_async (); |
1623 | 87 | inThread = true; | 80 | } |
1624 | 88 | Thread.create<void*>(update_db_thread_function, false); | 81 | |
1625 | 89 | } | 82 | private async void update_database_async () { |
1626 | 90 | catch(GLib.ThreadError err) { | 83 | if(!inThread && lm.lw.initializationFinished) { |
1627 | 91 | stdout.printf("Could not create thread to update database: %s \n", err.message); | 84 | try { |
1628 | 92 | } | 85 | inThread = true; |
1629 | 93 | } | 86 | new Thread<void*>.try (null, update_db_thread_function); |
1630 | 94 | } | 87 | } |
1631 | 95 | 88 | catch (Error err) { | |
1632 | 96 | public void removeItem(GLib.Object item) { | 89 | warning ("Could not create thread to update database: %s", err.message); |
1633 | 97 | remove_mutex.lock(); | 90 | inThread = false; |
1634 | 98 | if(!(toRemove.contains(item))) | 91 | } |
1635 | 99 | toRemove.offer(item); | 92 | } |
1636 | 100 | remove_mutex.unlock(); | 93 | } |
1637 | 101 | 94 | ||
1638 | 102 | if(!inThread && lm.lw.initializationFinished) { | 95 | |
1639 | 103 | try { | 96 | Mutex update_db_lock; |
1640 | 104 | inThread = true; | 97 | |
1641 | 105 | Thread.create<void*>(update_db_thread_function, false); | 98 | private void* update_db_thread_function () { |
1642 | 106 | } | 99 | update_db_lock.lock (); |
1643 | 107 | catch(GLib.ThreadError err) { | 100 | |
1644 | 108 | stdout.printf("Could not create thread to update database: %s \n", err.message); | 101 | while (true) { |
1645 | 109 | } | 102 | Object? next = null; |
1646 | 110 | } | 103 | |
1647 | 111 | } | 104 | if (media_updates.size > 0) { |
1648 | 112 | 105 | dbm.update_medias (media_updates); | |
1649 | 113 | public void* update_db_thread_function () { | 106 | media_updates.clear (); |
1650 | 114 | while(true) { | 107 | } |
1651 | 115 | GLib.Object next; | 108 | else if ((next = toUpdate.poll()) != null) { |
1652 | 116 | 109 | // FIXME: NOTHING TO DO | |
1597 | 117 | update_mutex.lock(); | ||
1598 | 118 | remove_mutex.lock(); | ||
1599 | 119 | if(media_updates.size > 0) { | ||
1600 | 120 | dbm.update_medias(media_updates); | ||
1601 | 121 | media_updates.clear(); | ||
1602 | 122 | } | ||
1603 | 123 | else if((next = toUpdate.poll()) != null) { | ||
1653 | 124 | if(next is Playlist) { | 110 | if(next is Playlist) { |
1654 | 111 | warning ("update_db_thread_function: %next is Playlist. HANDLE IT!"); | ||
1655 | 125 | //dbm.update_playlist((Playlist)next); | 112 | //dbm.update_playlist((Playlist)next); |
1656 | 126 | } | 113 | } |
1657 | 127 | else if(next is SmartPlaylist) { | 114 | else if(next is SmartPlaylist) { |
1658 | 115 | warning ("update_db_thread_function: %next is SmartPlaylist. HANDLE IT!"); | ||
1659 | 128 | //dbm.update_smart_playlist((SmartPlaylist)next); | 116 | //dbm.update_smart_playlist((SmartPlaylist)next); |
1660 | 129 | } | 117 | } |
1661 | 130 | } | 118 | } |
1662 | 131 | else if((next = toRemove.poll()) != null) { | 119 | else if((next = toRemove.poll()) != null) { |
1665 | 132 | if(next is LinkedList) { | 120 | if(next is Gee.LinkedList) { |
1666 | 133 | dbm.remove_medias((LinkedList<string>)next); | 121 | dbm.remove_medias((Gee.LinkedList<string>)next); |
1667 | 134 | } | 122 | } |
1668 | 135 | else if(next is Playlist) { | 123 | else if(next is Playlist) { |
1669 | 136 | dbm.remove_playlist((Playlist)next); | 124 | dbm.remove_playlist((Playlist)next); |
1670 | @@ -141,18 +129,15 @@ | |||
1671 | 141 | } | 129 | } |
1672 | 142 | else { | 130 | else { |
1673 | 143 | inThread = false; | 131 | inThread = false; |
1677 | 144 | update_mutex.unlock(); | 132 | break; |
1675 | 145 | remove_mutex.unlock(); | ||
1676 | 146 | return null; | ||
1678 | 147 | } | 133 | } |
1679 | 148 | |||
1680 | 149 | update_mutex.unlock(); | ||
1681 | 150 | remove_mutex.unlock(); | ||
1682 | 151 | } | 134 | } |
1683 | 152 | 135 | ||
1684 | 136 | update_db_lock.unlock (); | ||
1685 | 137 | return null; | ||
1686 | 153 | } | 138 | } |
1687 | 154 | 139 | ||
1689 | 155 | GLib.List<TreeViewSetup> tree_view_setups; | 140 | List<TreeViewSetup> tree_view_setups; |
1690 | 156 | 141 | ||
1691 | 157 | public void register_autosaved_column (string name, TreeViewSetup setup) { | 142 | public void register_autosaved_column (string name, TreeViewSetup setup) { |
1692 | 158 | setup.set_data<string>("name", name); | 143 | setup.set_data<string>("name", name); |
1693 | @@ -160,7 +145,7 @@ | |||
1694 | 160 | } | 145 | } |
1695 | 161 | 146 | ||
1696 | 162 | void save_others() { | 147 | void save_others() { |
1698 | 163 | var playlists_and_queue = new LinkedList<Playlist>(); | 148 | var playlists_and_queue = new Gee.LinkedList<Playlist>(); |
1699 | 164 | playlists_and_queue.add_all(lm.playlists()); | 149 | playlists_and_queue.add_all(lm.playlists()); |
1700 | 165 | 150 | ||
1701 | 166 | Playlist p_queue = new Playlist(); | 151 | Playlist p_queue = new Playlist(); |
1702 | @@ -195,7 +180,7 @@ | |||
1703 | 195 | playlists_and_queue.add(p_podcast); | 180 | playlists_and_queue.add(p_podcast); |
1704 | 196 | playlists_and_queue.add(p_station); | 181 | playlists_and_queue.add(p_station); |
1705 | 197 | 182 | ||
1707 | 198 | debug("Doing periodic save\n"); | 183 | debug("Doing periodic save"); |
1708 | 199 | 184 | ||
1709 | 200 | dbm.save_playlists(playlists_and_queue); | 185 | dbm.save_playlists(playlists_and_queue); |
1710 | 201 | dbm.save_smart_playlists(lm.smart_playlists()); | 186 | dbm.save_smart_playlists(lm.smart_playlists()); |
1711 | 202 | 187 | ||
1712 | === modified file 'src/Devices/CDRomDevice.vala' | |||
1713 | --- src/Devices/CDRomDevice.vala 2012-06-01 22:48:28 +0000 | |||
1714 | +++ src/Devices/CDRomDevice.vala 2012-07-03 06:49:24 +0000 | |||
1715 | @@ -69,10 +69,10 @@ | |||
1716 | 69 | lm.progress_cancel_clicked.connect(cancel_transfer); | 69 | lm.progress_cancel_clicked.connect(cancel_transfer); |
1717 | 70 | 70 | ||
1718 | 71 | try { | 71 | try { |
1720 | 72 | Thread.create<void*>(finish_initialization_thread, false); | 72 | new Thread<void*>.try (null, finish_initialization_thread); |
1721 | 73 | } | 73 | } |
1724 | 74 | catch(GLib.ThreadError err) { | 74 | catch (Error err) { |
1725 | 75 | stdout.printf("ERROR: Could not create thread to finish ipod initialization: %s \n", err.message); | 75 | warning ("Could not create thread to finish ipod initialization: %s", err.message); |
1726 | 76 | } | 76 | } |
1727 | 77 | } | 77 | } |
1728 | 78 | 78 | ||
1729 | 79 | 79 | ||
1730 | === modified file 'src/Devices/DeviceManager.vala' | |||
1731 | --- src/Devices/DeviceManager.vala 2012-07-02 23:17:27 +0000 | |||
1732 | +++ src/Devices/DeviceManager.vala 2012-07-03 06:49:24 +0000 | |||
1733 | @@ -27,7 +27,6 @@ | |||
1734 | 27 | VolumeMonitor vm; | 27 | VolumeMonitor vm; |
1735 | 28 | LinkedList<Device> devices; | 28 | LinkedList<Device> devices; |
1736 | 29 | 29 | ||
1737 | 30 | Mutex _pref_lock; | ||
1738 | 31 | HashTable<string, DevicePreferences> _device_preferences; | 30 | HashTable<string, DevicePreferences> _device_preferences; |
1739 | 32 | 31 | ||
1740 | 33 | public signal void device_added(Device d); | 32 | public signal void device_added(Device d); |
1741 | @@ -38,15 +37,14 @@ | |||
1742 | 38 | vm = VolumeMonitor.get(); | 37 | vm = VolumeMonitor.get(); |
1743 | 39 | devices = new LinkedList<Device>(); | 38 | devices = new LinkedList<Device>(); |
1744 | 40 | 39 | ||
1745 | 41 | _pref_lock = new Mutex(); | ||
1746 | 42 | _device_preferences = new HashTable<string, DevicePreferences>(null, null); | 40 | _device_preferences = new HashTable<string, DevicePreferences>(null, null); |
1747 | 43 | 41 | ||
1748 | 44 | // pre-load devices and their preferences | 42 | // pre-load devices and their preferences |
1752 | 45 | _pref_lock.lock(); | 43 | lock (_device_preferences) { |
1753 | 46 | foreach(DevicePreferences dp in lm.dbm.load_devices()) { | 44 | foreach(DevicePreferences dp in lm.dbm.load_devices()) { |
1754 | 47 | _device_preferences.set(dp.id, dp); | 45 | _device_preferences.set(dp.id, dp); |
1755 | 46 | } | ||
1756 | 48 | } | 47 | } |
1757 | 49 | _pref_lock.unlock(); | ||
1758 | 50 | 48 | ||
1759 | 51 | vm.mount_added.connect(mount_added); | 49 | vm.mount_added.connect(mount_added); |
1760 | 52 | vm.mount_changed.connect(mount_changed); | 50 | vm.mount_changed.connect(mount_changed); |
1761 | @@ -59,10 +57,15 @@ | |||
1762 | 59 | 57 | ||
1763 | 60 | // this can take time if we have to rev up the cd drive | 58 | // this can take time if we have to rev up the cd drive |
1764 | 61 | try { | 59 | try { |
1766 | 62 | Thread.create<void*>(get_pre_existing_mounts, false); | 60 | new Thread<void*>.try (null, get_pre_existing_mounts); |
1767 | 63 | } | 61 | } |
1768 | 62 | <<<<<<< TREE | ||
1769 | 64 | catch(GLib.ThreadError err) { | 63 | catch(GLib.ThreadError err) { |
1770 | 65 | warning("ERROR: could not create mount getter thread: %s \n", err.message); | 64 | warning("ERROR: could not create mount getter thread: %s \n", err.message); |
1771 | 65 | ======= | ||
1772 | 66 | catch (Error err) { | ||
1773 | 67 | warning ("Could not create mount getter thread: %s", err.message); | ||
1774 | 68 | >>>>>>> MERGE-SOURCE | ||
1775 | 66 | } | 69 | } |
1776 | 67 | } | 70 | } |
1777 | 68 | 71 | ||
1778 | @@ -126,6 +129,7 @@ | |||
1779 | 126 | else if(lm.settings.getMusicFolder().contains(mount.get_default_location().get_path())) { | 129 | else if(lm.settings.getMusicFolder().contains(mount.get_default_location().get_path())) { |
1780 | 127 | // user mounted music folder, rescan for images | 130 | // user mounted music folder, rescan for images |
1781 | 128 | lm.settings.setMusicMountName(mount.get_volume().get_name()); | 131 | lm.settings.setMusicMountName(mount.get_volume().get_name()); |
1782 | 132 | <<<<<<< TREE | ||
1783 | 129 | lm.recheck_files_not_found(); | 133 | lm.recheck_files_not_found(); |
1784 | 130 | 134 | ||
1785 | 131 | try { | 135 | try { |
1786 | @@ -134,6 +138,10 @@ | |||
1787 | 134 | catch(GLib.ThreadError err) { | 138 | catch(GLib.ThreadError err) { |
1788 | 135 | message("Could not create thread to load media pixbuf's: %s \n", err.message); | 139 | message("Could not create thread to load media pixbuf's: %s \n", err.message); |
1789 | 136 | } | 140 | } |
1790 | 141 | ======= | ||
1791 | 142 | lm.recheck_files_not_found_async (); | ||
1792 | 143 | lm.fetch_image_cache_async (); | ||
1793 | 144 | >>>>>>> MERGE-SOURCE | ||
1794 | 137 | 145 | ||
1795 | 138 | return; | 146 | return; |
1796 | 139 | } | 147 | } |
1797 | @@ -190,11 +198,9 @@ | |||
1798 | 190 | public GLib.List<DevicePreferences> device_preferences() { | 198 | public GLib.List<DevicePreferences> device_preferences() { |
1799 | 191 | var rv = new GLib.List<DevicePreferences>(); | 199 | var rv = new GLib.List<DevicePreferences>(); |
1800 | 192 | 200 | ||
1804 | 193 | _pref_lock.lock(); | 201 | foreach (var pref in _device_preferences.get_values()) { |
1805 | 194 | foreach(var pref in _device_preferences.get_values()) { | 202 | rv.append (pref); |
1803 | 195 | rv.append(pref); | ||
1806 | 196 | } | 203 | } |
1807 | 197 | _pref_lock.unlock(); | ||
1808 | 198 | 204 | ||
1809 | 199 | return rv; | 205 | return rv; |
1810 | 200 | } | 206 | } |
1811 | @@ -204,8 +210,8 @@ | |||
1812 | 204 | } | 210 | } |
1813 | 205 | 211 | ||
1814 | 206 | public void add_device_preferences(DevicePreferences dp) { | 212 | public void add_device_preferences(DevicePreferences dp) { |
1818 | 207 | _pref_lock.lock(); | 213 | lock (_device_preferences) { |
1819 | 208 | _device_preferences.set(dp.id, dp); | 214 | _device_preferences.set(dp.id, dp); |
1820 | 209 | _pref_lock.unlock(); | 215 | } |
1821 | 210 | } | 216 | } |
1822 | 211 | } | 217 | } |
1823 | 212 | 218 | ||
1824 | === modified file 'src/Devices/iPodDevice.vala' | |||
1825 | --- src/Devices/iPodDevice.vala 2012-07-02 22:57:45 +0000 | |||
1826 | +++ src/Devices/iPodDevice.vala 2012-07-03 06:49:24 +0000 | |||
1827 | @@ -98,10 +98,10 @@ | |||
1828 | 98 | }); | 98 | }); |
1829 | 99 | 99 | ||
1830 | 100 | try { | 100 | try { |
1832 | 101 | Thread.create<void*>(finish_initialization_thread, false); | 101 | new Thread<void*>.try (null, finish_initialization_thread); |
1833 | 102 | } | 102 | } |
1836 | 103 | catch(GLib.ThreadError err) { | 103 | catch(Error err) { |
1837 | 104 | stdout.printf("ERROR: Could not create thread to finish ipod initialization: %s \n", err.message); | 104 | warning ("Could not create thread to finish ipod initialization: %s", err.message); |
1838 | 105 | } | 105 | } |
1839 | 106 | } | 106 | } |
1840 | 107 | 107 | ||
1841 | @@ -325,10 +325,10 @@ | |||
1842 | 325 | this.list = list; | 325 | this.list = list; |
1843 | 326 | 326 | ||
1844 | 327 | try { | 327 | try { |
1846 | 328 | Thread.create<void*>(sync_medias_thread, false); | 328 | new Thread<void*>.try (null, sync_medias_thread); |
1847 | 329 | } | 329 | } |
1850 | 330 | catch(GLib.ThreadError err) { | 330 | catch (Error err) { |
1851 | 331 | stdout.printf("ERROR: Could not create thread to sync medias: %s \n", err.message); | 331 | warning ("Could not create thread to sync medias: %s", err.message); |
1852 | 332 | return false; | 332 | return false; |
1853 | 333 | } | 333 | } |
1854 | 334 | 334 | ||
1855 | @@ -542,10 +542,10 @@ | |||
1856 | 542 | this.list = list; | 542 | this.list = list; |
1857 | 543 | 543 | ||
1858 | 544 | try { | 544 | try { |
1860 | 545 | Thread.create<void*>(add_medias_thread, false); | 545 | new Thread<void*>.try (null, add_medias_thread); |
1861 | 546 | } | 546 | } |
1864 | 547 | catch(GLib.ThreadError err) { | 547 | catch (Error err) { |
1865 | 548 | stdout.printf("ERROR: Could not create thread to add medias: %s \n", err.message); | 548 | warning ("Could not create thread to add medias: %s", err.message); |
1866 | 549 | return false; | 549 | return false; |
1867 | 550 | } | 550 | } |
1868 | 551 | 551 | ||
1869 | @@ -698,10 +698,10 @@ | |||
1870 | 698 | this.list = list; | 698 | this.list = list; |
1871 | 699 | 699 | ||
1872 | 700 | try { | 700 | try { |
1874 | 701 | Thread.create<void*>(remove_medias_thread, false); | 701 | new Thread<void*>.try (null, remove_medias_thread); |
1875 | 702 | } | 702 | } |
1878 | 703 | catch(GLib.ThreadError err) { | 703 | catch (Error err) { |
1879 | 704 | stdout.printf("ERROR: Could not create thread to remove medias: %s \n", err.message); | 704 | warning ("Could not create thread to remove medias: %s", err.message); |
1880 | 705 | return false; | 705 | return false; |
1881 | 706 | } | 706 | } |
1882 | 707 | 707 | ||
1883 | @@ -931,10 +931,10 @@ | |||
1884 | 931 | current_operation = _("Importing") + " <b>" + ((list.size > 1) ? list.size.to_string() : (list.get(0)).title) + "</b> " + _("items to library..."); | 931 | current_operation = _("Importing") + " <b>" + ((list.size > 1) ? list.size.to_string() : (list.get(0)).title) + "</b> " + _("items to library..."); |
1885 | 932 | 932 | ||
1886 | 933 | try { | 933 | try { |
1888 | 934 | Thread.create<void*>(transfer_medias_thread, false); | 934 | new Thread<void*>.try (null, transfer_medias_thread); |
1889 | 935 | } | 935 | } |
1892 | 936 | catch(GLib.ThreadError err) { | 936 | catch(Error err) { |
1893 | 937 | stdout.printf("ERROR: Could not create thread to transfer medias: %s \n", err.message); | 937 | warning ("Could not create thread to transfer media: %s", err.message); |
1894 | 938 | return false; | 938 | return false; |
1895 | 939 | } | 939 | } |
1896 | 940 | 940 | ||
1897 | 941 | 941 | ||
1898 | === modified file 'src/Lastfm/LastFM.vala' | |||
1899 | --- src/Lastfm/LastFM.vala 2012-06-06 02:59:17 +0000 | |||
1900 | +++ src/Lastfm/LastFM.vala 2012-07-03 06:49:24 +0000 | |||
1901 | @@ -20,10 +20,6 @@ | |||
1902 | 20 | * Boston, MA 02111-1307, USA. | 20 | * Boston, MA 02111-1307, USA. |
1903 | 21 | */ | 21 | */ |
1904 | 22 | 22 | ||
1905 | 23 | using Xml; | ||
1906 | 24 | using Soup; | ||
1907 | 25 | using Gee; | ||
1908 | 26 | |||
1909 | 27 | public class LastFM.Core : Object { | 23 | public class LastFM.Core : Object { |
1910 | 28 | BeatBox.LibraryManager lm; | 24 | BeatBox.LibraryManager lm; |
1911 | 29 | 25 | ||
1912 | @@ -36,7 +32,7 @@ | |||
1913 | 36 | public string session_key; | 32 | public string session_key; |
1914 | 37 | 33 | ||
1915 | 38 | public signal void logged_in(); | 34 | public signal void logged_in(); |
1917 | 39 | public signal void similar_retrieved(LinkedList<int> similarIDs, LinkedList<BeatBox.Media> similarDont); | 35 | public signal void similar_retrieved(Gee.LinkedList<int> similarIDs, Gee.LinkedList<BeatBox.Media> similarDont); |
1918 | 40 | public signal void top_artist_songs_retrieved(HashTable<int, BeatBox.Media> songs); | 36 | public signal void top_artist_songs_retrieved(HashTable<int, BeatBox.Media> songs); |
1919 | 41 | public signal void top_artist_albums_retrieved(HashTable<int, BeatBox.ExternalAlbum> albums); | 37 | public signal void top_artist_albums_retrieved(HashTable<int, BeatBox.ExternalAlbum> albums); |
1920 | 42 | public signal void track_fetched(); | 38 | public signal void track_fetched(); |
1921 | @@ -46,13 +42,10 @@ | |||
1922 | 46 | LastFM.SimilarMedias similarMedias; | 42 | LastFM.SimilarMedias similarMedias; |
1923 | 47 | LastFM.TopArtistSongs topArtistSongs; | 43 | LastFM.TopArtistSongs topArtistSongs; |
1924 | 48 | LastFM.TopArtistAlbums topArtistAlbums; | 44 | LastFM.TopArtistAlbums topArtistAlbums; |
1932 | 49 | 45 | ||
1933 | 50 | Mutex _artists_lock; | 46 | Gee.HashMap<string, LastFM.ArtistInfo> _artists;//key:artist |
1934 | 51 | Mutex _albums_lock; | 47 | Gee.HashMap<string, LastFM.AlbumInfo> _albums;//key:artist<sep>album |
1935 | 52 | Mutex _tracks_lock; | 48 | Gee.HashMap<string, LastFM.TrackInfo> _tracks;//key:artist<sep>album<sep>track |
1929 | 53 | HashMap<string, LastFM.ArtistInfo> _artists;//key:artist | ||
1930 | 54 | HashMap<string, LastFM.AlbumInfo> _albums;//key:artist<sep>album | ||
1931 | 55 | HashMap<string, LastFM.TrackInfo> _tracks;//key:artist<sep>album<sep>track | ||
1936 | 56 | 49 | ||
1937 | 57 | public Core(BeatBox.LibraryManager lmm) { | 50 | public Core(BeatBox.LibraryManager lmm) { |
1938 | 58 | lm = lmm; | 51 | lm = lmm; |
1939 | @@ -61,32 +54,28 @@ | |||
1940 | 61 | similarMedias = new LastFM.SimilarMedias(lm); | 54 | similarMedias = new LastFM.SimilarMedias(lm); |
1941 | 62 | topArtistSongs = new LastFM.TopArtistSongs(lm); | 55 | topArtistSongs = new LastFM.TopArtistSongs(lm); |
1942 | 63 | topArtistAlbums = new LastFM.TopArtistAlbums(lm); | 56 | topArtistAlbums = new LastFM.TopArtistAlbums(lm); |
1969 | 64 | 57 | ||
1970 | 65 | _artists_lock = new Mutex(); | 58 | _artists = new Gee.HashMap<string, LastFM.ArtistInfo>(); |
1971 | 66 | _albums_lock = new Mutex(); | 59 | _albums = new Gee.HashMap<string, LastFM.AlbumInfo>(); |
1972 | 67 | _tracks_lock = new Mutex(); | 60 | _tracks = new Gee.HashMap<string, LastFM.TrackInfo>(); |
1973 | 68 | 61 | ||
1974 | 69 | _artists = new HashMap<string, LastFM.ArtistInfo>(); | 62 | lock (_artists) { |
1975 | 70 | _albums = new HashMap<string, LastFM.AlbumInfo>(); | 63 | foreach (LastFM.ArtistInfo a in lm.dbm.load_artists()) { |
1976 | 71 | _tracks = new HashMap<string, LastFM.TrackInfo>(); | 64 | _artists.set (a.name.down(), a); |
1977 | 72 | 65 | } | |
1978 | 73 | _artists_lock.lock(); | 66 | } |
1979 | 74 | foreach(LastFM.ArtistInfo a in lm.dbm.load_artists()) { | 67 | |
1980 | 75 | _artists.set(a.name.down(), a); | 68 | lock (_albums) { |
1981 | 76 | } | 69 | foreach (LastFM.AlbumInfo a in lm.dbm.load_albums()) { |
1982 | 77 | _artists_lock.unlock(); | 70 | _albums.set (a.name.down() + " by " + a.artist.down(), a); |
1983 | 78 | 71 | } | |
1984 | 79 | _albums_lock.lock(); | 72 | } |
1985 | 80 | foreach(LastFM.AlbumInfo a in lm.dbm.load_albums()) { | 73 | |
1986 | 81 | _albums.set(a.name.down() + " by " + a.artist.down(), a); | 74 | lock (_tracks) { |
1987 | 82 | } | 75 | foreach (LastFM.TrackInfo t in lm.dbm.load_tracks()) { |
1988 | 83 | _albums_lock.unlock(); | 76 | _tracks.set (t.name.down() + " by " + t.artist.down(), t); |
1989 | 84 | 77 | } | |
1990 | 85 | _tracks_lock.lock(); | 78 | } |
1965 | 86 | foreach(LastFM.TrackInfo t in lm.dbm.load_tracks()) { | ||
1966 | 87 | _tracks.set(t.name.down() + " by " + t.artist.down(), t); | ||
1967 | 88 | } | ||
1968 | 89 | _tracks_lock.unlock(); | ||
1991 | 90 | 79 | ||
1992 | 91 | similarMedias.similar_retrieved.connect(similar_retrieved_signal); | 80 | similarMedias.similar_retrieved.connect(similar_retrieved_signal); |
1993 | 92 | topArtistSongs.top_artist_songs_retrieved.connect(top_artist_songs_retrieved_signal); | 81 | topArtistSongs.top_artist_songs_retrieved.connect(top_artist_songs_retrieved_signal); |
1994 | @@ -94,42 +83,40 @@ | |||
1995 | 94 | } | 83 | } |
1996 | 95 | 84 | ||
1997 | 96 | /************* Last FM Artist Stuff ************/ | 85 | /************* Last FM Artist Stuff ************/ |
2000 | 97 | public GLib.List<LastFM.ArtistInfo> artists() { | 86 | public List<LastFM.ArtistInfo> artists () { |
2001 | 98 | var rv = new GLib.List<LastFM.ArtistInfo>(); | 87 | var rv = new List<LastFM.ArtistInfo>(); |
2002 | 99 | foreach(var artist in _artists.values) | 88 | foreach(var artist in _artists.values) |
2003 | 100 | rv.append(artist); | 89 | rv.append(artist); |
2004 | 101 | 90 | ||
2005 | 102 | return rv; | 91 | return rv; |
2006 | 103 | } | 92 | } |
2007 | 104 | 93 | ||
2023 | 105 | public void save_artist(LastFM.ArtistInfo artist) { | 94 | public void save_artist (LastFM.ArtistInfo artist) { |
2024 | 106 | _artists_lock.lock(); | 95 | lock (_artists) { |
2025 | 107 | _artists.set(artist.name.down(), artist); | 96 | _artists.set (artist.name.down(), artist); |
2026 | 108 | _artists_lock.unlock(); | 97 | } |
2027 | 109 | } | 98 | } |
2028 | 110 | 99 | ||
2029 | 111 | public bool artist_info_exists(string artist_key) { | 100 | public bool artist_info_exists (string artist_key) { |
2030 | 112 | return _artists.get(artist_key.down()) != null; | 101 | return _artists.has_key (artist_key.down()); |
2031 | 113 | } | 102 | } |
2032 | 114 | 103 | ||
2033 | 115 | public LastFM.ArtistInfo? get_artist_from_media(BeatBox.Media m) { | 104 | public LastFM.ArtistInfo? get_artist_from_media (BeatBox.Media m) { |
2034 | 116 | return get_artist(m.album_artist.down()); | 105 | return get_artist (m.album_artist); |
2035 | 117 | } | 106 | } |
2036 | 118 | 107 | ||
2037 | 119 | public LastFM.ArtistInfo? get_artist(string artist_key) { | 108 | public LastFM.ArtistInfo? get_artist (string artist_key) { |
2038 | 120 | LastFM.ArtistInfo? rv = null; | 109 | LastFM.ArtistInfo? rv = null; |
2039 | 121 | 110 | ||
2045 | 122 | _artists_lock.lock(); | 111 | if (artist_info_exists (artist_key)) |
2046 | 123 | if(artist_info_exists(artist_key.down())) | 112 | rv = _artists.get (artist_key.down()); |
2047 | 124 | rv = _artists.get(artist_key.down()); | 113 | |
2043 | 125 | _artists_lock.unlock(); | ||
2044 | 126 | |||
2048 | 127 | return rv; | 114 | return rv; |
2049 | 128 | } | 115 | } |
2050 | 129 | 116 | ||
2051 | 130 | /************** LastFM Album stuff **************/ | 117 | /************** LastFM Album stuff **************/ |
2054 | 131 | public GLib.List<LastFM.AlbumInfo> albums() { | 118 | public List<LastFM.AlbumInfo> albums() { |
2055 | 132 | var rv = new GLib.List<LastFM.AlbumInfo>(); | 119 | var rv = new List<LastFM.AlbumInfo>(); |
2056 | 133 | foreach(var album in _albums.values) | 120 | foreach(var album in _albums.values) |
2057 | 134 | rv.append(album); | 121 | rv.append(album); |
2058 | 135 | 122 | ||
2059 | @@ -137,33 +124,31 @@ | |||
2060 | 137 | } | 124 | } |
2061 | 138 | 125 | ||
2062 | 139 | public void save_album(LastFM.AlbumInfo album) { | 126 | public void save_album(LastFM.AlbumInfo album) { |
2066 | 140 | _albums_lock.lock(); | 127 | lock (_albums) { |
2067 | 141 | _albums.set(album.name.down() + " by " + album.artist.down(), album); | 128 | _albums.set(album.name.down() + " by " + album.artist.down(), album); |
2068 | 142 | _albums_lock.unlock(); | 129 | } |
2069 | 143 | } | 130 | } |
2070 | 144 | 131 | ||
2071 | 145 | public bool album_info_exists(string album_key) { | 132 | public bool album_info_exists(string album_key) { |
2073 | 146 | return _albums.get(album_key) != null; | 133 | return _albums.has_key (album_key.down()); |
2074 | 147 | } | 134 | } |
2075 | 148 | 135 | ||
2078 | 149 | public LastFM.AlbumInfo? get_album_from_media(BeatBox.Media m) { | 136 | public LastFM.AlbumInfo? get_album_from_media (BeatBox.Media m) { |
2079 | 150 | return get_album(m.album.down() + " by " + m.album_artist.down()); | 137 | return get_album (m.album.down() + " by " + m.album_artist.down()); |
2080 | 151 | } | 138 | } |
2081 | 152 | 139 | ||
2082 | 153 | public LastFM.AlbumInfo? get_album(string album_key) { | 140 | public LastFM.AlbumInfo? get_album(string album_key) { |
2083 | 154 | LastFM.AlbumInfo? rv = null; | 141 | LastFM.AlbumInfo? rv = null; |
2084 | 155 | 142 | ||
2090 | 156 | _albums_lock.lock(); | 143 | if(album_info_exists (album_key)) |
2091 | 157 | if(album_info_exists(album_key.down())) | 144 | rv = _albums.get (album_key.down()); |
2092 | 158 | rv = _albums.get(album_key.down()); | 145 | |
2088 | 159 | _albums_lock.unlock(); | ||
2089 | 160 | |||
2093 | 161 | return rv; | 146 | return rv; |
2094 | 162 | } | 147 | } |
2095 | 163 | 148 | ||
2096 | 164 | /************** Last FM Track Stuff ***************/ | 149 | /************** Last FM Track Stuff ***************/ |
2099 | 165 | public GLib.List<LastFM.TrackInfo> tracks() { | 150 | public List<LastFM.TrackInfo> tracks() { |
2100 | 166 | var rv = new GLib.List<LastFM.TrackInfo>(); | 151 | var rv = new List<LastFM.TrackInfo>(); |
2101 | 167 | foreach(var track in _tracks.values) | 152 | foreach(var track in _tracks.values) |
2102 | 168 | rv.append(track); | 153 | rv.append(track); |
2103 | 169 | 154 | ||
2104 | @@ -171,37 +156,35 @@ | |||
2105 | 171 | } | 156 | } |
2106 | 172 | 157 | ||
2107 | 173 | public void save_track(LastFM.TrackInfo track) { | 158 | public void save_track(LastFM.TrackInfo track) { |
2111 | 174 | _tracks_lock.lock(); | 159 | lock (_tracks) { |
2112 | 175 | _tracks.set(track.name.down() + " by " + track.artist.down(), track); | 160 | _tracks.set (track.name.down() + " by " + track.artist.down(), track); |
2113 | 176 | _tracks_lock.unlock(); | 161 | } |
2114 | 177 | } | 162 | } |
2115 | 178 | 163 | ||
2116 | 179 | public bool track_info_exists(string track_key) { | 164 | public bool track_info_exists(string track_key) { |
2125 | 180 | return _tracks.get(track_key.down()) != null; | 165 | return _tracks.has_key (track_key.down()); |
2126 | 181 | } | 166 | } |
2127 | 182 | 167 | ||
2128 | 183 | public LastFM.TrackInfo? get_track_from_media(BeatBox.Media m) { | 168 | public LastFM.TrackInfo? get_track_from_media (BeatBox.Media m) { |
2129 | 184 | return get_track(m.title.down() + " by " + m.album_artist.down()); | 169 | return get_track (m.title.down() + " by " + m.album_artist.down()); |
2130 | 185 | } | 170 | } |
2131 | 186 | 171 | ||
2132 | 187 | public LastFM.TrackInfo? get_track(string track_key) { | 172 | public LastFM.TrackInfo? get_track (string track_key) { |
2133 | 188 | LastFM.TrackInfo? rv = null; | 173 | LastFM.TrackInfo? rv = null; |
2134 | 189 | 174 | ||
2139 | 190 | _tracks_lock.lock(); | 175 | if (track_info_exists (track_key.down())) |
2140 | 191 | if(track_info_exists(track_key.down())) | 176 | rv = _tracks.get (track_key.down()); |
2137 | 192 | rv = _tracks.get(track_key.down()); | ||
2138 | 193 | _tracks_lock.unlock(); | ||
2141 | 194 | 177 | ||
2142 | 195 | return rv; | 178 | return rv; |
2143 | 196 | } | 179 | } |
2144 | 197 | 180 | ||
2145 | 198 | /** Last.FM Api functions **/ | 181 | /** Last.FM Api functions **/ |
2148 | 199 | public static string fix_for_url(string fix) { | 182 | public static string fix_for_url (string fix) { |
2149 | 200 | return GLib.Uri.escape_string(fix, null, false); | 183 | return Uri.escape_string (fix, "", false); |
2150 | 201 | } | 184 | } |
2151 | 202 | 185 | ||
2152 | 203 | public string generate_md5(string text) { | 186 | public string generate_md5(string text) { |
2154 | 204 | return GLib.Checksum.compute_for_string(ChecksumType.MD5, text, text.length); | 187 | return Checksum.compute_for_string(ChecksumType.MD5, text, text.length); |
2155 | 205 | } | 188 | } |
2156 | 206 | 189 | ||
2157 | 207 | public string generate_getsession_signature(string token) { | 190 | public string generate_getsession_signature(string token) { |
2158 | @@ -227,9 +210,9 @@ | |||
2159 | 227 | public string? getToken() { | 210 | public string? getToken() { |
2160 | 228 | var url = "http://ws.audioscrobbler.com/2.0/?method=auth.gettoken&api_key=" + api; | 211 | var url = "http://ws.audioscrobbler.com/2.0/?method=auth.gettoken&api_key=" + api; |
2161 | 229 | 212 | ||
2163 | 230 | Xml.Doc* doc = Parser.parse_file (url); | 213 | Xml.Doc* doc = Xml.Parser.parse_file (url); |
2164 | 231 | if(doc == null) return null; | 214 | if(doc == null) return null; |
2166 | 232 | 215 | ||
2167 | 233 | Xml.Node* root = doc->get_root_element(); | 216 | Xml.Node* root = doc->get_root_element(); |
2168 | 234 | if(root == null) return null; | 217 | if(root == null) return null; |
2169 | 235 | 218 | ||
2170 | @@ -246,9 +229,9 @@ | |||
2171 | 246 | var sig = generate_getsession_signature(token); | 229 | var sig = generate_getsession_signature(token); |
2172 | 247 | var url = "http://ws.audioscrobbler.com/2.0/?method=auth.getSession&api_key=" + api + "&api_sig=" + sig + "&token=" + token; | 230 | var url = "http://ws.audioscrobbler.com/2.0/?method=auth.getSession&api_key=" + api + "&api_sig=" + sig + "&token=" + token; |
2173 | 248 | 231 | ||
2175 | 249 | message("url: %s\n", url); | 232 | message ("url: %s", url); |
2176 | 250 | 233 | ||
2178 | 251 | Xml.Doc* doc = Parser.parse_file (url); | 234 | Xml.Doc* doc = Xml.Parser.parse_file (url); |
2179 | 252 | if(doc == null) return null; | 235 | if(doc == null) return null; |
2180 | 253 | 236 | ||
2181 | 254 | Xml.Node* root = doc->get_root_element(); | 237 | Xml.Node* root = doc->get_root_element(); |
2182 | @@ -268,7 +251,7 @@ | |||
2183 | 268 | 251 | ||
2184 | 269 | public bool loveTrack(string title, string artist) { | 252 | public bool loveTrack(string title, string artist) { |
2185 | 270 | if(session_key == null || session_key == "") { | 253 | if(session_key == null || session_key == "") { |
2187 | 271 | debug("User tried to ban a track, but is not logged into Last FM\n"); | 254 | debug("User tried to ban a track, but is not logged into Last FM"); |
2188 | 272 | return false; | 255 | return false; |
2189 | 273 | } | 256 | } |
2190 | 274 | 257 | ||
2191 | @@ -277,7 +260,7 @@ | |||
2192 | 277 | Soup.SessionSync session = new Soup.SessionSync(); | 260 | Soup.SessionSync session = new Soup.SessionSync(); |
2193 | 278 | Soup.Message message = new Soup.Message ("POST", uri); | 261 | Soup.Message message = new Soup.Message ("POST", uri); |
2194 | 279 | 262 | ||
2196 | 280 | var headers = new Soup.MessageHeaders(MessageHeadersType.REQUEST); | 263 | var headers = new Soup.MessageHeaders(Soup.MessageHeadersType.REQUEST); |
2197 | 281 | headers.append("api_key", api); | 264 | headers.append("api_key", api); |
2198 | 282 | headers.append("api_sig", generate_tracklove_signature(artist, title)); | 265 | headers.append("api_sig", generate_tracklove_signature(artist, title)); |
2199 | 283 | headers.append("artist", artist); | 266 | headers.append("artist", artist); |
2200 | @@ -298,7 +281,7 @@ | |||
2201 | 298 | 281 | ||
2202 | 299 | public bool banTrack(string title, string artist) { | 282 | public bool banTrack(string title, string artist) { |
2203 | 300 | if(session_key == null || session_key == "") { | 283 | if(session_key == null || session_key == "") { |
2205 | 301 | debug("User tried to ban a track, but is not logged into Last FM\n"); | 284 | debug("User tried to ban a track, but is not logged into Last FM"); |
2206 | 302 | return false; | 285 | return false; |
2207 | 303 | } | 286 | } |
2208 | 304 | 287 | ||
2209 | @@ -307,7 +290,7 @@ | |||
2210 | 307 | Soup.SessionSync session = new Soup.SessionSync(); | 290 | Soup.SessionSync session = new Soup.SessionSync(); |
2211 | 308 | Soup.Message message = new Soup.Message ("POST", uri); | 291 | Soup.Message message = new Soup.Message ("POST", uri); |
2212 | 309 | 292 | ||
2214 | 310 | var headers = new Soup.MessageHeaders(MessageHeadersType.REQUEST); | 293 | var headers = new Soup.MessageHeaders(Soup.MessageHeadersType.REQUEST); |
2215 | 311 | headers.append("api_key", api); | 294 | headers.append("api_key", api); |
2216 | 312 | headers.append("api_sig", generate_trackban_signature(artist, title)); | 295 | headers.append("api_sig", generate_trackban_signature(artist, title)); |
2217 | 313 | headers.append("artist", artist); | 296 | headers.append("artist", artist); |
2218 | @@ -330,13 +313,13 @@ | |||
2219 | 330 | */ | 313 | */ |
2220 | 331 | public void fetchCurrentTrackInfo() { | 314 | public void fetchCurrentTrackInfo() { |
2221 | 332 | try { | 315 | try { |
2225 | 333 | Thread.create<void*>(track_thread_function, false); | 316 | new Thread<void*>.try (null, track_thread_function); |
2226 | 334 | } catch(GLib.ThreadError err) { | 317 | } catch (Error err) { |
2227 | 335 | warning ("ERROR: Could not create last fm thread: %s \n", err.message); | 318 | warning ("Could not create last fm thread: %s", err.message); |
2228 | 336 | } | 319 | } |
2229 | 337 | } | 320 | } |
2230 | 338 | 321 | ||
2232 | 339 | void* track_thread_function () { | 322 | private void* track_thread_function () { |
2233 | 340 | LastFM.TrackInfo track = new LastFM.TrackInfo.basic(); | 323 | LastFM.TrackInfo track = new LastFM.TrackInfo.basic(); |
2234 | 341 | 324 | ||
2235 | 342 | string album_artist_s = lm.media_info.media.album_artist; | 325 | string album_artist_s = lm.media_info.media.album_artist; |
2236 | @@ -364,13 +347,13 @@ | |||
2237 | 364 | 347 | ||
2238 | 365 | public void fetchCurrentAlbumInfo() { | 348 | public void fetchCurrentAlbumInfo() { |
2239 | 366 | try { | 349 | try { |
2243 | 367 | Thread.create<void*>(album_thread_function, false); | 350 | new Thread<void*>.try (null, album_thread_function); |
2244 | 368 | } catch(GLib.ThreadError err) { | 351 | } catch (Error err) { |
2245 | 369 | warning ("ERROR: Could not create last fm thread: %s \n", err.message); | 352 | warning ("Could not create last fm thread: %s", err.message); |
2246 | 370 | } | 353 | } |
2247 | 371 | } | 354 | } |
2248 | 372 | 355 | ||
2250 | 373 | void* album_thread_function () { | 356 | private void* album_thread_function () { |
2251 | 374 | LastFM.AlbumInfo album = new LastFM.AlbumInfo.basic(); | 357 | LastFM.AlbumInfo album = new LastFM.AlbumInfo.basic(); |
2252 | 375 | 358 | ||
2253 | 376 | string album_artist_s = lm.media_info.media.album_artist; | 359 | string album_artist_s = lm.media_info.media.album_artist; |
2254 | @@ -391,12 +374,12 @@ | |||
2255 | 391 | 374 | ||
2256 | 392 | /* If we found an album art, and we don't have one yet, save it to file **/ | 375 | /* If we found an album art, and we don't have one yet, save it to file **/ |
2257 | 393 | if(album.url_image.url != null && lm.get_cover_album_art_from_key(album_artist_s, album_s) == null) { | 376 | if(album.url_image.url != null && lm.get_cover_album_art_from_key(album_artist_s, album_s) == null) { |
2259 | 394 | debug("Saving album image locally for %s by %s\n", album_s, album_artist_s); | 377 | debug("Saving album image locally for %s by %s", album_s, album_artist_s); |
2260 | 395 | lm.save_album_locally(lm.media_info.media.rowid, album.url_image.url, false); | 378 | lm.save_album_locally(lm.media_info.media.rowid, album.url_image.url, false); |
2261 | 396 | } | 379 | } |
2262 | 397 | 380 | ||
2263 | 398 | // Fix up the track # on any songs in our library | 381 | // Fix up the track # on any songs in our library |
2265 | 399 | var updates = new LinkedList<BeatBox.Media>(); | 382 | var updates = new Gee.LinkedList<BeatBox.Media>(); |
2266 | 400 | foreach(var m in album.tracks()) { | 383 | foreach(var m in album.tracks()) { |
2267 | 401 | var in_lib = lm.media_from_name(m.title, m.artist); | 384 | var in_lib = lm.media_from_name(m.title, m.artist); |
2268 | 402 | if(in_lib != null && in_lib.track != m.track) { | 385 | if(in_lib != null && in_lib.track != m.track) { |
2269 | @@ -418,13 +401,13 @@ | |||
2270 | 418 | */ | 401 | */ |
2271 | 419 | public void fetchCurrentArtistInfo() { | 402 | public void fetchCurrentArtistInfo() { |
2272 | 420 | try { | 403 | try { |
2276 | 421 | Thread.create<void*>(artist_thread_function, false); | 404 | new Thread<void*>.try (null, artist_thread_function); |
2277 | 422 | } catch(GLib.ThreadError err) { | 405 | } catch (Error err) { |
2278 | 423 | warning ("ERROR: Could not create last fm thread: %s \n", err.message); | 406 | warning ("Could not create last fm thread: %s", err.message); |
2279 | 424 | } | 407 | } |
2280 | 425 | } | 408 | } |
2281 | 426 | 409 | ||
2283 | 427 | void* artist_thread_function () { | 410 | private void* artist_thread_function () { |
2284 | 428 | LastFM.ArtistInfo artist = new LastFM.ArtistInfo.basic(); | 411 | LastFM.ArtistInfo artist = new LastFM.ArtistInfo.basic(); |
2285 | 429 | 412 | ||
2286 | 430 | string album_artist_s = lm.media_info.media.album_artist; | 413 | string album_artist_s = lm.media_info.media.album_artist; |
2287 | @@ -456,15 +439,15 @@ | |||
2288 | 456 | */ | 439 | */ |
2289 | 457 | public void postNowPlaying() { | 440 | public void postNowPlaying() { |
2290 | 458 | try { | 441 | try { |
2294 | 459 | Thread.create<void*>(update_nowplaying_thread_function, false); | 442 | new Thread<void*>.try (null, update_nowplaying_thread_function); |
2295 | 460 | } catch(GLib.ThreadError err) { | 443 | } catch (Error err) { |
2296 | 461 | warning ("ERROR: Could not create last fm thread: %s \n", err.message); | 444 | warning ("Could not create last fm thread: %s", err.message); |
2297 | 462 | } | 445 | } |
2298 | 463 | } | 446 | } |
2299 | 464 | 447 | ||
2300 | 465 | void* update_nowplaying_thread_function() { | 448 | void* update_nowplaying_thread_function() { |
2301 | 466 | if(session_key == null || session_key == "") { | 449 | if(session_key == null || session_key == "") { |
2303 | 467 | debug("Last.FM user not logged in\n"); | 450 | debug("Last.FM user not logged in"); |
2304 | 468 | return null; | 451 | return null; |
2305 | 469 | } | 452 | } |
2306 | 470 | if(!lm.media_active) | 453 | if(!lm.media_active) |
2307 | @@ -477,7 +460,7 @@ | |||
2308 | 477 | Soup.SessionSync session = new Soup.SessionSync(); | 460 | Soup.SessionSync session = new Soup.SessionSync(); |
2309 | 478 | Soup.Message message = new Soup.Message ("POST", uri); | 461 | Soup.Message message = new Soup.Message ("POST", uri); |
2310 | 479 | 462 | ||
2312 | 480 | var headers = new Soup.MessageHeaders(MessageHeadersType.REQUEST); | 463 | var headers = new Soup.MessageHeaders(Soup.MessageHeadersType.REQUEST); |
2313 | 481 | headers.append("api_key", api); | 464 | headers.append("api_key", api); |
2314 | 482 | headers.append("api_sig", generate_trackupdatenowplaying_signature(artist, title)); | 465 | headers.append("api_sig", generate_trackupdatenowplaying_signature(artist, title)); |
2315 | 483 | headers.append("artist", artist); | 466 | headers.append("artist", artist); |
2316 | @@ -501,15 +484,15 @@ | |||
2317 | 501 | */ | 484 | */ |
2318 | 502 | public void postScrobbleTrack() { | 485 | public void postScrobbleTrack() { |
2319 | 503 | try { | 486 | try { |
2323 | 504 | Thread.create<void*>(scrobble_thread_function, false); | 487 | new Thread<void*>.try (null, scrobble_thread_function); |
2324 | 505 | } catch(GLib.ThreadError err) { | 488 | } catch (Error err) { |
2325 | 506 | warning ("ERROR: Could not create last fm thread: %s \n", err.message); | 489 | warning ("Could not create last fm thread: %s", err.message); |
2326 | 507 | } | 490 | } |
2327 | 508 | } | 491 | } |
2328 | 509 | 492 | ||
2329 | 510 | void* scrobble_thread_function () { | 493 | void* scrobble_thread_function () { |
2330 | 511 | if(session_key == null || session_key == "") { | 494 | if(session_key == null || session_key == "") { |
2332 | 512 | debug("Last.FM user not logged in\n"); | 495 | debug("Last.FM user not logged in"); |
2333 | 513 | return null; | 496 | return null; |
2334 | 514 | } | 497 | } |
2335 | 515 | if(!lm.media_active) | 498 | if(!lm.media_active) |
2336 | @@ -523,7 +506,7 @@ | |||
2337 | 523 | Soup.SessionSync session = new Soup.SessionSync(); | 506 | Soup.SessionSync session = new Soup.SessionSync(); |
2338 | 524 | Soup.Message message = new Soup.Message ("POST", uri); | 507 | Soup.Message message = new Soup.Message ("POST", uri); |
2339 | 525 | 508 | ||
2341 | 526 | var headers = new Soup.MessageHeaders(MessageHeadersType.REQUEST); | 509 | var headers = new Soup.MessageHeaders(Soup.MessageHeadersType.REQUEST); |
2342 | 527 | headers.append("api_key", api); | 510 | headers.append("api_key", api); |
2343 | 528 | headers.append("api_sig", generate_trackscrobble_signature(artist, title, timestamp)); | 511 | headers.append("api_sig", generate_trackscrobble_signature(artist, title, timestamp)); |
2344 | 529 | headers.append("artist", artist); | 512 | headers.append("artist", artist); |
2345 | @@ -547,7 +530,7 @@ | |||
2346 | 547 | similarMedias.queryForSimilar(lm.media_info.media); | 530 | similarMedias.queryForSimilar(lm.media_info.media); |
2347 | 548 | } | 531 | } |
2348 | 549 | 532 | ||
2350 | 550 | void similar_retrieved_signal(LinkedList<int> similarIDs, LinkedList<BeatBox.Media> similarDont) { | 533 | void similar_retrieved_signal(Gee.LinkedList<int> similarIDs, Gee.LinkedList<BeatBox.Media> similarDont) { |
2351 | 551 | similar_retrieved(similarIDs, similarDont); | 534 | similar_retrieved(similarIDs, similarDont); |
2352 | 552 | } | 535 | } |
2353 | 553 | 536 | ||
2354 | @@ -569,19 +552,19 @@ | |||
2355 | 569 | 552 | ||
2356 | 570 | public void fetch_remaining_album_art() { | 553 | public void fetch_remaining_album_art() { |
2357 | 571 | try { | 554 | try { |
2361 | 572 | Thread.create<void*>(fetch_remaining_album_art_thread, false); | 555 | new Thread<void*>.try (null, fetch_remaining_album_art_thread); |
2362 | 573 | } catch(GLib.ThreadError err) { | 556 | } catch (Error err) { |
2363 | 574 | warning ("ERROR: Could not create last fm thread: %s \n", err.message); | 557 | warning ("Could not create last fm thread: %s", err.message); |
2364 | 575 | } | 558 | } |
2365 | 576 | } | 559 | } |
2366 | 577 | 560 | ||
2367 | 578 | public void* fetch_remaining_album_art_thread() { | 561 | public void* fetch_remaining_album_art_thread() { |
2368 | 579 | var all_media = lm.medias(); | 562 | var all_media = lm.medias(); |
2370 | 580 | var remaining = new HashMap<string, BeatBox.Album>(); // hashmap of albums with no art | 563 | var remaining = new Gee.HashMap<string, BeatBox.Album>(); // hashmap of albums with no art |
2371 | 581 | foreach(var m in all_media) { | 564 | foreach(var m in all_media) { |
2372 | 582 | string key = lm.album_key(m); | 565 | string key = lm.album_key(m); |
2373 | 583 | 566 | ||
2375 | 584 | if(remaining.get(key) != null) // already known | 567 | if (remaining.has_key (key)) // already known |
2376 | 585 | continue; | 568 | continue; |
2377 | 586 | 569 | ||
2378 | 587 | if(lm.get_cover_album_art(m.rowid) == null) { | 570 | if(lm.get_cover_album_art(m.rowid) == null) { |
2379 | @@ -603,12 +586,12 @@ | |||
2380 | 603 | 586 | ||
2381 | 604 | /* If we found an album art, save it to file **/ | 587 | /* If we found an album art, save it to file **/ |
2382 | 605 | if(album_info != null && album_info.url_image.url != null && album_info.url_image.url != "") { | 588 | if(album_info != null && album_info.url_image.url != null && album_info.url_image.url != "") { |
2384 | 606 | debug("Saving album image locally for %s by %s\n", album_s, album_artist_s); | 589 | debug("Saving album image locally for %s by %s", album_s, album_artist_s); |
2385 | 607 | lm.save_album_locally(m.rowid, album_info.url_image.url, false); | 590 | lm.save_album_locally(m.rowid, album_info.url_image.url, false); |
2386 | 608 | } | 591 | } |
2387 | 609 | } | 592 | } |
2388 | 610 | 593 | ||
2390 | 611 | message("All remaining art fetched\n"); | 594 | message("All remaining art fetched"); |
2391 | 612 | 595 | ||
2392 | 613 | return null; | 596 | return null; |
2393 | 614 | } | 597 | } |
2394 | 615 | 598 | ||
2395 | === modified file 'src/Lastfm/SimilarMedia.vala' | |||
2396 | --- src/Lastfm/SimilarMedia.vala 2012-06-02 19:34:06 +0000 | |||
2397 | +++ src/Lastfm/SimilarMedia.vala 2012-07-03 06:49:24 +0000 | |||
2398 | @@ -20,8 +20,6 @@ | |||
2399 | 20 | * Boston, MA 02111-1307, USA. | 20 | * Boston, MA 02111-1307, USA. |
2400 | 21 | */ | 21 | */ |
2401 | 22 | 22 | ||
2402 | 23 | using Xml; | ||
2403 | 24 | |||
2404 | 25 | public class LastFM.SimilarMedias : Object { | 23 | public class LastFM.SimilarMedias : Object { |
2405 | 26 | BeatBox.LibraryManager _lm; | 24 | BeatBox.LibraryManager _lm; |
2406 | 27 | BeatBox.Media _base; | 25 | BeatBox.Media _base; |
2407 | @@ -29,7 +27,7 @@ | |||
2408 | 29 | 27 | ||
2409 | 30 | Gee.LinkedList<BeatBox.Media> similar; | 28 | Gee.LinkedList<BeatBox.Media> similar; |
2410 | 31 | 29 | ||
2412 | 32 | public signal void similar_retrieved( Gee.LinkedList<int> similarIDs, Gee.LinkedList<BeatBox.Media> similarDont); | 30 | public signal void similar_retrieved (Gee.LinkedList<int> similarIDs, Gee.LinkedList<BeatBox.Media> similarDont); |
2413 | 33 | 31 | ||
2414 | 34 | public class SimilarMedias(BeatBox.LibraryManager lm) { | 32 | public class SimilarMedias(BeatBox.LibraryManager lm) { |
2415 | 35 | _lm = lm; | 33 | _lm = lm; |
2416 | @@ -43,10 +41,10 @@ | |||
2417 | 43 | working = true; | 41 | working = true; |
2418 | 44 | 42 | ||
2419 | 45 | try { | 43 | try { |
2421 | 46 | Thread.create<void*>(similar_thread_function, false); | 44 | new Thread<void*>.try (null, similar_thread_function); |
2422 | 47 | } | 45 | } |
2425 | 48 | catch(GLib.ThreadError err) { | 46 | catch (Error err) { |
2426 | 49 | warning("ERROR: Could not create similar thread: %s \n", err.message); | 47 | warning ("Could not create similar thread: %s", err.message); |
2427 | 50 | } | 48 | } |
2428 | 51 | } | 49 | } |
2429 | 52 | } | 50 | } |
2430 | @@ -107,7 +105,7 @@ | |||
2431 | 107 | Xml.Node* iter; | 105 | Xml.Node* iter; |
2432 | 108 | for (iter = node->children; iter != null; iter = iter->next) { | 106 | for (iter = node->children; iter != null; iter = iter->next) { |
2433 | 109 | 107 | ||
2435 | 110 | if (iter->type != ElementType.ELEMENT_NODE) { | 108 | if (iter->type != Xml.ElementType.ELEMENT_NODE) { |
2436 | 111 | continue; | 109 | continue; |
2437 | 112 | } | 110 | } |
2438 | 113 | 111 | ||
2439 | 114 | 112 | ||
2440 | === modified file 'src/Lastfm/TopArtistAlbums.vala' | |||
2441 | --- src/Lastfm/TopArtistAlbums.vala 2012-07-02 23:17:27 +0000 | |||
2442 | +++ src/Lastfm/TopArtistAlbums.vala 2012-07-03 06:49:24 +0000 | |||
2443 | @@ -20,8 +20,6 @@ | |||
2444 | 20 | * Boston, MA 02111-1307, USA. | 20 | * Boston, MA 02111-1307, USA. |
2445 | 21 | */ | 21 | */ |
2446 | 22 | 22 | ||
2447 | 23 | using Xml; | ||
2448 | 24 | |||
2449 | 25 | public class LastFM.TopArtistAlbums : Object { | 23 | public class LastFM.TopArtistAlbums : Object { |
2450 | 26 | static const int MAX_RESULTS = 5; | 24 | static const int MAX_RESULTS = 5; |
2451 | 27 | BeatBox.LibraryManager _lm; | 25 | BeatBox.LibraryManager _lm; |
2452 | @@ -46,10 +44,10 @@ | |||
2453 | 46 | working = true; | 44 | working = true; |
2454 | 47 | 45 | ||
2455 | 48 | try { | 46 | try { |
2457 | 49 | Thread.create<void*>(top_artist_albums_thread_function, false); | 47 | new Thread<void*>.try (null, top_artist_albums_thread_function); |
2458 | 50 | } | 48 | } |
2461 | 51 | catch(GLib.ThreadError err) { | 49 | catch (Error err) { |
2462 | 52 | warning("ERROR: Could not create top artist albums thread: %s \n", err.message); | 50 | warning ("ERROR: Could not create top artist albums thread: %s", err.message); |
2463 | 53 | } | 51 | } |
2464 | 54 | } | 52 | } |
2465 | 55 | } | 53 | } |
2466 | @@ -79,7 +77,7 @@ | |||
2467 | 79 | async void uri_to_pixbuf(BeatBox.ExternalAlbum album) { | 77 | async void uri_to_pixbuf(BeatBox.ExternalAlbum album) { |
2468 | 80 | GLib.File file = GLib.File.new_for_uri(album.pixbuf_url); | 78 | GLib.File file = GLib.File.new_for_uri(album.pixbuf_url); |
2469 | 81 | if(file == null) { | 79 | if(file == null) { |
2471 | 82 | stdout.printf("Could not read image_uri as file\n"); | 80 | message ("Could not read image_uri as file"); |
2472 | 83 | return; | 81 | return; |
2473 | 84 | } | 82 | } |
2474 | 85 | 83 | ||
2475 | @@ -90,7 +88,11 @@ | |||
2476 | 90 | filestream = yield file.read_async(); | 88 | filestream = yield file.read_async(); |
2477 | 91 | pix = yield Gdk.Pixbuf.new_from_stream_at_scale_async(filestream, -1, Icons.ALBUM_VIEW_IMAGE_SIZE, true); | 89 | pix = yield Gdk.Pixbuf.new_from_stream_at_scale_async(filestream, -1, Icons.ALBUM_VIEW_IMAGE_SIZE, true); |
2478 | 92 | } catch(GLib.Error err) { | 90 | } catch(GLib.Error err) { |
2479 | 91 | <<<<<<< TREE | ||
2480 | 93 | debug("Failed to save load art locally from %s: %s\n", album.pixbuf_url, err.message); | 92 | debug("Failed to save load art locally from %s: %s\n", album.pixbuf_url, err.message); |
2481 | 93 | ======= | ||
2482 | 94 | warning("Failed to save album art locally from %s: %s", album.pixbuf_url, err.message); | ||
2483 | 95 | >>>>>>> MERGE-SOURCE | ||
2484 | 94 | } | 96 | } |
2485 | 95 | 97 | ||
2486 | 96 | if(pix != null) { | 98 | if(pix != null) { |
2487 | @@ -113,11 +115,11 @@ | |||
2488 | 113 | Xml.Doc* doc = Xml.Parser.parse_memory((string)message.response_body.data, (int)message.response_body.length); | 115 | Xml.Doc* doc = Xml.Parser.parse_memory((string)message.response_body.data, (int)message.response_body.length); |
2489 | 114 | 116 | ||
2490 | 115 | if(doc == null) | 117 | if(doc == null) |
2492 | 116 | GLib.message("Could not load top artist albums information for %s\n", artist); | 118 | GLib.message("Could not load top artist albums information for %s", artist); |
2493 | 117 | else if(doc->get_root_element() == null) | 119 | else if(doc->get_root_element() == null) |
2495 | 118 | GLib.message("Oddly, top artist albums information was invalid\n"); | 120 | GLib.message("Oddly, top artist albums information was invalid"); |
2496 | 119 | else { | 121 | else { |
2498 | 120 | //GLib.message("Getting top artist albums with %s... \n", url); | 122 | //GLib.message("Getting top artist albums with %s...", url); |
2499 | 121 | toAdd = null; | 123 | toAdd = null; |
2500 | 122 | 124 | ||
2501 | 123 | parse_top_artist_albums_nodes(doc->get_root_element(), ""); | 125 | parse_top_artist_albums_nodes(doc->get_root_element(), ""); |
2502 | @@ -132,7 +134,7 @@ | |||
2503 | 132 | 134 | ||
2504 | 133 | Xml.Node* iter; | 135 | Xml.Node* iter; |
2505 | 134 | for (iter = node->children; iter != null; iter = iter->next) { | 136 | for (iter = node->children; iter != null; iter = iter->next) { |
2507 | 135 | if (iter->type != ElementType.ELEMENT_NODE) { | 137 | if (iter->type != Xml.ElementType.ELEMENT_NODE) { |
2508 | 136 | continue; | 138 | continue; |
2509 | 137 | } | 139 | } |
2510 | 138 | 140 | ||
2511 | 139 | 141 | ||
2512 | === modified file 'src/Lastfm/TopArtistSongs.vala' | |||
2513 | --- src/Lastfm/TopArtistSongs.vala 2012-06-02 19:34:06 +0000 | |||
2514 | +++ src/Lastfm/TopArtistSongs.vala 2012-07-03 06:49:24 +0000 | |||
2515 | @@ -20,8 +20,6 @@ | |||
2516 | 20 | * Boston, MA 02111-1307, USA. | 20 | * Boston, MA 02111-1307, USA. |
2517 | 21 | */ | 21 | */ |
2518 | 22 | 22 | ||
2519 | 23 | using Xml; | ||
2520 | 24 | |||
2521 | 25 | public class LastFM.TopArtistSongs : Object { | 23 | public class LastFM.TopArtistSongs : Object { |
2522 | 26 | static const int MAX_RESULTS = 15; | 24 | static const int MAX_RESULTS = 15; |
2523 | 27 | BeatBox.LibraryManager _lm; | 25 | BeatBox.LibraryManager _lm; |
2524 | @@ -46,15 +44,15 @@ | |||
2525 | 46 | working = true; | 44 | working = true; |
2526 | 47 | 45 | ||
2527 | 48 | try { | 46 | try { |
2529 | 49 | Thread.create<void*>(top_artist_songs_thread_function, false); | 47 | new Thread<void*>.try (null, top_artist_songs_thread_function); |
2530 | 50 | } | 48 | } |
2533 | 51 | catch(GLib.ThreadError err) { | 49 | catch (Error err) { |
2534 | 52 | warning("ERROR: Could not create similar thread: %s \n", err.message); | 50 | warning("ERROR: Could not create similar thread: %s", err.message); |
2535 | 53 | } | 51 | } |
2536 | 54 | } | 52 | } |
2537 | 55 | } | 53 | } |
2538 | 56 | 54 | ||
2540 | 57 | void* top_artist_songs_thread_function () { | 55 | private void* top_artist_songs_thread_function () { |
2541 | 58 | songs = new HashTable<int, BeatBox.Media>(null, null); | 56 | songs = new HashTable<int, BeatBox.Media>(null, null); |
2542 | 59 | 57 | ||
2543 | 60 | getTopArtistTracks(_base.artist); | 58 | getTopArtistTracks(_base.artist); |
2544 | @@ -96,11 +94,11 @@ | |||
2545 | 96 | Xml.Doc* doc = Xml.Parser.parse_memory((string)message.response_body.data, (int)message.response_body.length); | 94 | Xml.Doc* doc = Xml.Parser.parse_memory((string)message.response_body.data, (int)message.response_body.length); |
2546 | 97 | 95 | ||
2547 | 98 | if(doc == null) | 96 | if(doc == null) |
2549 | 99 | GLib.message("Could not load top artist songs information for %s\n", artist); | 97 | GLib.message("Could not load top artist songs information for %s", artist); |
2550 | 100 | else if(doc->get_root_element() == null) | 98 | else if(doc->get_root_element() == null) |
2552 | 101 | GLib.message("Oddly, similar artist information was invalid\n"); | 99 | GLib.message("Oddly, similar artist information was invalid"); |
2553 | 102 | else { | 100 | else { |
2555 | 103 | //message("Getting similar tracks with %s... \n", url); | 101 | //message("Getting similar tracks with %s...", url); |
2556 | 104 | toAdd = null; | 102 | toAdd = null; |
2557 | 105 | 103 | ||
2558 | 106 | parse_top_artist_tracks_nodes(doc->get_root_element(), ""); | 104 | parse_top_artist_tracks_nodes(doc->get_root_element(), ""); |
2559 | @@ -115,7 +113,7 @@ | |||
2560 | 115 | 113 | ||
2561 | 116 | Xml.Node* iter; | 114 | Xml.Node* iter; |
2562 | 117 | for (iter = node->children; iter != null; iter = iter->next) { | 115 | for (iter = node->children; iter != null; iter = iter->next) { |
2564 | 118 | if (iter->type != ElementType.ELEMENT_NODE) { | 116 | if (iter->type != Xml.ElementType.ELEMENT_NODE) { |
2565 | 119 | continue; | 117 | continue; |
2566 | 120 | } | 118 | } |
2567 | 121 | 119 | ||
2568 | 122 | 120 | ||
2569 | === modified file 'src/Lists/GenericList.vala' | |||
2570 | --- src/Lists/GenericList.vala 2012-06-28 02:26:50 +0000 | |||
2571 | +++ src/Lists/GenericList.vala 2012-07-03 06:49:24 +0000 | |||
2572 | @@ -278,10 +278,10 @@ | |||
2573 | 278 | // For songs with no attached uri, try opening its lastfm url | 278 | // For songs with no attached uri, try opening its lastfm url |
2574 | 279 | if(m.uri == "") { | 279 | if(m.uri == "") { |
2575 | 280 | try { | 280 | try { |
2577 | 281 | Thread.create<void*>(take_action, false); | 281 | new Thread<void*>.try (null, take_action); |
2578 | 282 | } | 282 | } |
2581 | 283 | catch(GLib.ThreadError err) { | 283 | catch (Error err) { |
2582 | 284 | stdout.printf("ERROR: Could not create thread to have fun: %s \n", err.message); | 284 | warning ("Could not create thread to have fun: %s", err.message); |
2583 | 285 | } | 285 | } |
2584 | 286 | } | 286 | } |
2585 | 287 | else { | 287 | else { |
2586 | 288 | 288 | ||
2587 | === modified file 'src/Media/LyricFetcher.vala' | |||
2588 | --- src/Media/LyricFetcher.vala 2012-06-01 22:48:28 +0000 | |||
2589 | +++ src/Media/LyricFetcher.vala 2012-07-03 06:49:24 +0000 | |||
2590 | @@ -42,10 +42,10 @@ | |||
2591 | 42 | this.title = title; | 42 | this.title = title; |
2592 | 43 | 43 | ||
2593 | 44 | try { | 44 | try { |
2595 | 45 | Thread.create<void*> (fetch_lyrics_thread, false); | 45 | new Thread<void*>.try (null, fetch_lyrics_thread); |
2596 | 46 | } | 46 | } |
2599 | 47 | catch(GLib.ThreadError err) { | 47 | catch(GLib.Error err) { |
2600 | 48 | stderr.printf ("ERROR: Could not create lyrics thread: %s \n", err.message); | 48 | warning ("ERROR: Could not create lyrics thread: %s \n", err.message); |
2601 | 49 | } | 49 | } |
2602 | 50 | } | 50 | } |
2603 | 51 | 51 | ||
2604 | @@ -87,7 +87,7 @@ | |||
2605 | 87 | 87 | ||
2606 | 88 | /** LYRIC SOURCES **/ | 88 | /** LYRIC SOURCES **/ |
2607 | 89 | 89 | ||
2609 | 90 | private class AZLyricsFetcher : Object { | 90 | private class AZLyricsFetcher { |
2610 | 91 | 91 | ||
2611 | 92 | private const string URL_FORMAT = "http://www.azlyrics.com/lyrics/%s/%s.html"; | 92 | private const string URL_FORMAT = "http://www.azlyrics.com/lyrics/%s/%s.html"; |
2612 | 93 | 93 | ||
2613 | @@ -108,7 +108,7 @@ | |||
2614 | 108 | rv.artist = artist; | 108 | rv.artist = artist; |
2615 | 109 | } | 109 | } |
2616 | 110 | catch (Error err) { | 110 | catch (Error err) { |
2618 | 111 | //stderr.printf("Could not load contents of %s : %s\n", url, err.message); | 111 | //warning("Could not load contents of %s : %s\n", url, err.message); |
2619 | 112 | load_successful = false; | 112 | load_successful = false; |
2620 | 113 | } | 113 | } |
2621 | 114 | 114 | ||
2622 | @@ -122,13 +122,13 @@ | |||
2623 | 122 | load_successful = true; | 122 | load_successful = true; |
2624 | 123 | } | 123 | } |
2625 | 124 | catch (Error err) { | 124 | catch (Error err) { |
2627 | 125 | //stderr.printf ("Could not load contents of %s : %s\n", url, err.message); | 125 | //warning ("Could not load contents of %s : %s\n", url, err.message); |
2628 | 126 | load_successful = false; | 126 | load_successful = false; |
2629 | 127 | } | 127 | } |
2630 | 128 | } | 128 | } |
2631 | 129 | 129 | ||
2632 | 130 | if (load_successful) | 130 | if (load_successful) |
2634 | 131 | rv.content = parse_lyrics (uintcontent) + "\n"; | 131 | rv.content = "\n" + rv.title + "\n" + rv.artist + "\n\n\n" + parse_lyrics (uintcontent) + "\n"; |
2635 | 132 | else | 132 | else |
2636 | 133 | throw new FetchingError.LYRICS_NOT_FOUND (@"Lyrics not found for $title"); | 133 | throw new FetchingError.LYRICS_NOT_FOUND (@"Lyrics not found for $title"); |
2637 | 134 | 134 | ||
2638 | 135 | 135 | ||
2639 | === modified file 'src/Store/Widgets/AlbumView.vala' | |||
2640 | --- src/Store/Widgets/AlbumView.vala 2012-06-01 22:48:28 +0000 | |||
2641 | +++ src/Store/Widgets/AlbumView.vala 2012-07-03 06:49:24 +0000 | |||
2642 | @@ -174,20 +174,21 @@ | |||
2643 | 174 | 174 | ||
2644 | 175 | public void populate() { | 175 | public void populate() { |
2645 | 176 | try { | 176 | try { |
2650 | 177 | Thread.create<void*>(setalbum_thread_function, false); | 177 | new Thread<void*>.try (null, setalbum_thread_function); |
2651 | 178 | Thread.create<void*>(gettracks_thread_function, false); | 178 | new Thread<void*>.try (null, gettracks_thread_function); |
2652 | 179 | Thread.create<void*>(getsimilarreleases_thread_function, false); | 179 | new Thread<void*>.try (null, getsimilarreleases_thread_function); |
2653 | 180 | Thread.create<void*>(getalbuminfo_thread_function, false); | 180 | new Thread<void*>.try (null, getalbuminfo_thread_function); |
2654 | 181 | |||
2655 | 181 | storeView.max = 5; | 182 | storeView.max = 5; |
2656 | 182 | storeView.index = 0; | 183 | storeView.index = 0; |
2657 | 183 | storeView.progressNotification(); | 184 | storeView.progressNotification(); |
2658 | 184 | } | 185 | } |
2661 | 185 | catch(GLib.ThreadError err) { | 186 | catch (Error err) { |
2662 | 186 | stdout.printf("ERROR: Could not create thread to get populate ArtistView: %s \n", err.message); | 187 | warning ("Could not create thread to get populate ArtistView: %s", err.message); |
2663 | 187 | } | 188 | } |
2664 | 188 | } | 189 | } |
2665 | 189 | 190 | ||
2667 | 190 | public void* setalbum_thread_function () { | 191 | private void* setalbum_thread_function () { |
2668 | 191 | Store.Release r = store.getRelease(release.releaseID, 200); | 192 | Store.Release r = store.getRelease(release.releaseID, 200); |
2669 | 192 | r.image = Store.store.getPixbuf(r.imagePath, 200, 200); | 193 | r.image = Store.store.getPixbuf(r.imagePath, 200, 200); |
2670 | 193 | 194 | ||
2671 | @@ -198,7 +199,7 @@ | |||
2672 | 198 | ++storeView.index; | 199 | ++storeView.index; |
2673 | 199 | 200 | ||
2674 | 200 | try { | 201 | try { |
2676 | 201 | Thread.create<void*>(gettaglabels_thread_function, false); | 202 | new Thread<void*>.try (null, gettaglabels_thread_function); |
2677 | 202 | } | 203 | } |
2678 | 203 | catch (Error e) { | 204 | catch (Error e) { |
2679 | 204 | critical ("Couldn't get tags: %s", e.message); | 205 | critical ("Couldn't get tags: %s", e.message); |
2680 | @@ -227,7 +228,7 @@ | |||
2681 | 227 | return null; | 228 | return null; |
2682 | 228 | } | 229 | } |
2683 | 229 | 230 | ||
2685 | 230 | public void* getsimilarreleases_thread_function () { | 231 | private void* getsimilarreleases_thread_function () { |
2686 | 231 | foreach(var rel in release.getSimilar(1)) { | 232 | foreach(var rel in release.getSimilar(1)) { |
2687 | 232 | rel.image = Store.store.getPixbuf(rel.imagePath, 100, 100); | 233 | rel.image = Store.store.getPixbuf(rel.imagePath, 100, 100); |
2688 | 233 | similarReleasesList.add(rel); | 234 | similarReleasesList.add(rel); |
2689 | @@ -246,7 +247,7 @@ | |||
2690 | 246 | return null; | 247 | return null; |
2691 | 247 | } | 248 | } |
2692 | 248 | 249 | ||
2694 | 249 | public void* gettaglabels_thread_function () { | 250 | private void* gettaglabels_thread_function () { |
2695 | 250 | var labels = new LinkedList<Store.TagLabel>(); | 251 | var labels = new LinkedList<Store.TagLabel>(); |
2696 | 251 | 252 | ||
2697 | 252 | foreach(var format in release.formats) { | 253 | foreach(var format in release.formats) { |
2698 | @@ -289,7 +290,7 @@ | |||
2699 | 289 | return null; | 290 | return null; |
2700 | 290 | } | 291 | } |
2701 | 291 | 292 | ||
2703 | 292 | public void* getalbuminfo_thread_function () { | 293 | private void* getalbuminfo_thread_function () { |
2704 | 293 | /* first get album description */ | 294 | /* first get album description */ |
2705 | 294 | LastFM.AlbumInfo album = new LastFM.AlbumInfo.basic(); | 295 | LastFM.AlbumInfo album = new LastFM.AlbumInfo.basic(); |
2706 | 295 | 296 | ||
2707 | 296 | 297 | ||
2708 | === modified file 'src/Store/Widgets/ArtistView.vala' | |||
2709 | --- src/Store/Widgets/ArtistView.vala 2012-02-04 00:01:35 +0000 | |||
2710 | +++ src/Store/Widgets/ArtistView.vala 2012-07-03 06:49:24 +0000 | |||
2711 | @@ -58,7 +58,7 @@ | |||
2712 | 58 | setArtist(artist); | 58 | setArtist(artist); |
2713 | 59 | } | 59 | } |
2714 | 60 | 60 | ||
2716 | 61 | public void buildUI() { | 61 | private void buildUI() { |
2717 | 62 | VBox allDetails = new VBox(false, 0); | 62 | VBox allDetails = new VBox(false, 0); |
2718 | 63 | HBox topRow = new HBox(false, 0); | 63 | HBox topRow = new HBox(false, 0); |
2719 | 64 | VBox topInfo = new VBox(false, 0); | 64 | VBox topInfo = new VBox(false, 0); |
2720 | @@ -110,19 +110,19 @@ | |||
2721 | 110 | 110 | ||
2722 | 111 | public void populate() { | 111 | public void populate() { |
2723 | 112 | try { | 112 | try { |
2727 | 113 | Thread.create<void*>(setartist_thread_function, false); | 113 | new Thread<void*>.try (null, setartist_thread_function); |
2728 | 114 | Thread.create<void*>(gettracks_thread_function, false); | 114 | new Thread<void*>.try (null, gettracks_thread_function); |
2729 | 115 | Thread.create<void*>(getreleases_thread_function, false); | 115 | new Thread<void*>.try (null, getreleases_thread_function); |
2730 | 116 | storeView.index = 0; | 116 | storeView.index = 0; |
2731 | 117 | storeView.max = 5; // must get to 6 for progress bar to turn off | 117 | storeView.max = 5; // must get to 6 for progress bar to turn off |
2732 | 118 | storeView.progressNotification(); | 118 | storeView.progressNotification(); |
2733 | 119 | } | 119 | } |
2736 | 120 | catch(GLib.ThreadError err) { | 120 | catch (Error err) { |
2737 | 121 | stdout.printf("ERROR: Could not create thread to get populate ArtistView: %s \n", err.message); | 121 | warning ("Could not create thread to get populate ArtistView: %s", err.message); |
2738 | 122 | } | 122 | } |
2739 | 123 | } | 123 | } |
2740 | 124 | 124 | ||
2742 | 125 | public void* setartist_thread_function () { | 125 | private void* setartist_thread_function () { |
2743 | 126 | Store.Artist a = store.getArtist(artist.artistID); | 126 | Store.Artist a = store.getArtist(artist.artistID); |
2744 | 127 | ++storeView.index; | 127 | ++storeView.index; |
2745 | 128 | Idle.add( () => { | 128 | Idle.add( () => { |
2746 | @@ -134,7 +134,7 @@ | |||
2747 | 134 | return null; | 134 | return null; |
2748 | 135 | } | 135 | } |
2749 | 136 | 136 | ||
2751 | 137 | public void* gettracks_thread_function () { | 137 | private void* gettracks_thread_function () { |
2752 | 138 | foreach(var track in artist.getTopTracks(1, 25)) | 138 | foreach(var track in artist.getTopTracks(1, 25)) |
2753 | 139 | topTracksList.add(track); | 139 | topTracksList.add(track); |
2754 | 140 | ++storeView.index; | 140 | ++storeView.index; |
2755 | @@ -149,7 +149,7 @@ | |||
2756 | 149 | return null; | 149 | return null; |
2757 | 150 | } | 150 | } |
2758 | 151 | 151 | ||
2760 | 152 | public void* getreleases_thread_function () { | 152 | private void* getreleases_thread_function () { |
2761 | 153 | foreach(var rel in artist.getReleases("album", 1)) { | 153 | foreach(var rel in artist.getReleases("album", 1)) { |
2762 | 154 | rel.image = Store.store.getPixbuf(rel.imagePath, 100, 100); | 154 | rel.image = Store.store.getPixbuf(rel.imagePath, 100, 100); |
2763 | 155 | releasesList.add(rel); | 155 | releasesList.add(rel); |
2764 | 156 | 156 | ||
2765 | === modified file 'src/Store/Widgets/HomeView.vala' | |||
2766 | --- src/Store/Widgets/HomeView.vala 2012-02-04 00:01:35 +0000 | |||
2767 | +++ src/Store/Widgets/HomeView.vala 2012-07-03 06:49:24 +0000 | |||
2768 | @@ -41,7 +41,7 @@ | |||
2769 | 41 | buildUI(); | 41 | buildUI(); |
2770 | 42 | } | 42 | } |
2771 | 43 | 43 | ||
2773 | 44 | public void buildUI() { | 44 | private void buildUI() { |
2774 | 45 | allItems = new HBox(false, 0); | 45 | allItems = new HBox(false, 0); |
2775 | 46 | VBox leftItems = new VBox(false, 0); | 46 | VBox leftItems = new VBox(false, 0); |
2776 | 47 | VBox centerItems = new VBox(false, 0); | 47 | VBox centerItems = new VBox(false, 0); |
2777 | @@ -98,6 +98,7 @@ | |||
2778 | 98 | 98 | ||
2779 | 99 | } | 99 | } |
2780 | 100 | 100 | ||
2781 | 101 | // TODO: Move to utils namespace!! | ||
2782 | 101 | public static Gtk.Alignment wrap_alignment (Gtk.Widget widget, int top, int right, int bottom, int left) { | 102 | public static Gtk.Alignment wrap_alignment (Gtk.Widget widget, int top, int right, int bottom, int left) { |
2783 | 102 | var alignment = new Gtk.Alignment(0.0f, 0.0f, 1.0f, 1.0f); | 103 | var alignment = new Gtk.Alignment(0.0f, 0.0f, 1.0f, 1.0f); |
2784 | 103 | alignment.top_padding = top; | 104 | alignment.top_padding = top; |
2785 | @@ -111,21 +112,22 @@ | |||
2786 | 111 | 112 | ||
2787 | 112 | public void populate() { | 113 | public void populate() { |
2788 | 113 | try { | 114 | try { |
2794 | 114 | Thread.create<void*>(getartists_thread_function, false); | 115 | new Thread<void*>.try (null, getartists_thread_function); |
2795 | 115 | Thread.create<void*>(getreleases_thread_function, false); | 116 | new Thread<void*>.try (null, getreleases_thread_function); |
2796 | 116 | Thread.create<void*>(gettracks_thread_function, false); | 117 | new Thread<void*>.try (null, gettracks_thread_function); |
2797 | 117 | Thread.create<void*>(gettoprock_thread_function, false); | 118 | new Thread<void*>.try (null, gettoprock_thread_function); |
2798 | 118 | Thread.create<void*>(getgenres_thread_function, false); | 119 | new Thread<void*>.try (null, getgenres_thread_function); |
2799 | 120 | |||
2800 | 119 | storeView.max = 6; | 121 | storeView.max = 6; |
2801 | 120 | storeView.index = 0; | 122 | storeView.index = 0; |
2802 | 121 | storeView.progressNotification(); | 123 | storeView.progressNotification(); |
2803 | 122 | } | 124 | } |
2806 | 123 | catch(GLib.ThreadError err) { | 125 | catch (Error err) { |
2807 | 124 | stdout.printf("ERROR: Could not create thread to get populate ArtistView: %s \n", err.message); | 126 | warning ("Could not create thread to get populate ArtistView: %s", err.message); |
2808 | 125 | } | 127 | } |
2809 | 126 | } | 128 | } |
2810 | 127 | 129 | ||
2812 | 128 | public void* getartists_thread_function () { | 130 | private void* getartists_thread_function () { |
2813 | 129 | var tops = new LinkedList<Artist>(); | 131 | var tops = new LinkedList<Artist>(); |
2814 | 130 | 132 | ||
2815 | 131 | foreach(var art in store.topArtists("week", null, null, 1)) | 133 | foreach(var art in store.topArtists("week", null, null, 1)) |
2816 | @@ -144,7 +146,7 @@ | |||
2817 | 144 | return null; | 146 | return null; |
2818 | 145 | } | 147 | } |
2819 | 146 | 148 | ||
2821 | 147 | public void* getreleases_thread_function () { | 149 | private void* getreleases_thread_function () { |
2822 | 148 | var tops = new LinkedList<Release>(); | 150 | var tops = new LinkedList<Release>(); |
2823 | 149 | 151 | ||
2824 | 150 | foreach(var rel in store.topReleases("week", null, null, 1)) { | 152 | foreach(var rel in store.topReleases("week", null, null, 1)) { |
2825 | @@ -163,7 +165,7 @@ | |||
2826 | 163 | return null; | 165 | return null; |
2827 | 164 | } | 166 | } |
2828 | 165 | 167 | ||
2830 | 166 | public void* gettracks_thread_function () { | 168 | private void* gettracks_thread_function () { |
2831 | 167 | var tops = new LinkedList<Track>(); | 169 | var tops = new LinkedList<Track>(); |
2832 | 168 | 170 | ||
2833 | 169 | foreach(var track in store.topTracks("week", null, 1)) | 171 | foreach(var track in store.topTracks("week", null, 1)) |
2834 | @@ -182,7 +184,7 @@ | |||
2835 | 182 | return null; | 184 | return null; |
2836 | 183 | } | 185 | } |
2837 | 184 | 186 | ||
2839 | 185 | public void* gettoprock_thread_function () { | 187 | private void* gettoprock_thread_function () { |
2840 | 186 | var rock = new LinkedList<Release>(); | 188 | var rock = new LinkedList<Release>(); |
2841 | 187 | 189 | ||
2842 | 188 | foreach(var rel in store.topReleases("week", null, "rock", 1)) { | 190 | foreach(var rel in store.topReleases("week", null, "rock", 1)) { |
2843 | @@ -203,7 +205,7 @@ | |||
2844 | 203 | return null; | 205 | return null; |
2845 | 204 | } | 206 | } |
2846 | 205 | 207 | ||
2848 | 206 | public void* getgenres_thread_function () { | 208 | private void* getgenres_thread_function () { |
2849 | 207 | var gens = new LinkedList<Tag>(); | 209 | var gens = new LinkedList<Tag>(); |
2850 | 208 | 210 | ||
2851 | 209 | gens.add( new Tag.with_values("pop", "Pop", "") ); | 211 | gens.add( new Tag.with_values("pop", "Pop", "") ); |
2852 | 210 | 212 | ||
2853 | === modified file 'src/Store/Widgets/StoreView.vala' | |||
2854 | --- src/Store/Widgets/StoreView.vala 2012-03-16 05:21:31 +0000 | |||
2855 | +++ src/Store/Widgets/StoreView.vala 2012-07-03 06:49:24 +0000 | |||
2856 | @@ -94,16 +94,16 @@ | |||
2857 | 94 | setView(searchPage); | 94 | setView(searchPage); |
2858 | 95 | 95 | ||
2859 | 96 | try { | 96 | try { |
2863 | 97 | Thread.create<void*>(searchtracks_thread_function, false); | 97 | new Thread<void*>.try (null, searchtracks_thread_function); |
2864 | 98 | Thread.create<void*>(searchartists_thread_function, false); | 98 | new Thread<void*>.try (null, searchartists_thread_function); |
2865 | 99 | Thread.create<void*>(searchreleases_thread_function, false); | 99 | new Thread<void*>.try (null, searchreleases_thread_function); |
2866 | 100 | } | 100 | } |
2869 | 101 | catch(GLib.ThreadError err) { | 101 | catch (Error err) { |
2870 | 102 | stdout.printf("ERROR: Could not create thread to get populate ArtistView: %s \n", err.message); | 102 | warning ("Could not create thread to get populate ArtistView: %s", err.message); |
2871 | 103 | } | 103 | } |
2872 | 104 | } | 104 | } |
2873 | 105 | 105 | ||
2875 | 106 | public void* searchtracks_thread_function () { | 106 | private void* searchtracks_thread_function () { |
2876 | 107 | var search = new LinkedList<Store.Track>(); | 107 | var search = new LinkedList<Store.Track>(); |
2877 | 108 | 108 | ||
2878 | 109 | foreach(var track in store.searchTracks(lw.searchField.get_text(), 1)) | 109 | foreach(var track in store.searchTracks(lw.searchField.get_text(), 1)) |
2879 | @@ -119,7 +119,7 @@ | |||
2880 | 119 | return null; | 119 | return null; |
2881 | 120 | } | 120 | } |
2882 | 121 | 121 | ||
2884 | 122 | public void* searchartists_thread_function () { | 122 | private void* searchartists_thread_function () { |
2885 | 123 | var search = new LinkedList<Store.Artist>(); | 123 | var search = new LinkedList<Store.Artist>(); |
2886 | 124 | 124 | ||
2887 | 125 | foreach(var artist in store.searchArtists(lw.searchField.get_text(), null, 1)) | 125 | foreach(var artist in store.searchArtists(lw.searchField.get_text(), null, 1)) |
2888 | @@ -135,7 +135,7 @@ | |||
2889 | 135 | return null; | 135 | return null; |
2890 | 136 | } | 136 | } |
2891 | 137 | 137 | ||
2893 | 138 | public void* searchreleases_thread_function () { | 138 | private void* searchreleases_thread_function () { |
2894 | 139 | var search = new LinkedList<Store.Release>(); | 139 | var search = new LinkedList<Store.Release>(); |
2895 | 140 | 140 | ||
2896 | 141 | foreach(var rel in store.searchReleases(lw.searchField.get_text(), 1)) | 141 | foreach(var rel in store.searchReleases(lw.searchField.get_text(), 1)) |
2897 | 142 | 142 | ||
2898 | === modified file 'src/Views/SimilarMediaView.vala' | |||
2899 | --- src/Views/SimilarMediaView.vala 2012-06-19 22:50:13 +0000 | |||
2900 | +++ src/Views/SimilarMediaView.vala 2012-07-03 06:49:24 +0000 | |||
2901 | @@ -83,10 +83,10 @@ | |||
2902 | 83 | 83 | ||
2903 | 84 | public virtual void viewDoubleClick(TreePath path, TreeViewColumn column) { | 84 | public virtual void viewDoubleClick(TreePath path, TreeViewColumn column) { |
2904 | 85 | try { | 85 | try { |
2906 | 86 | Thread.create<void*>(take_action, false); | 86 | new Thread<void*>.try (null, take_action); |
2907 | 87 | } | 87 | } |
2910 | 88 | catch(GLib.ThreadError err) { | 88 | catch (Error err) { |
2911 | 89 | stdout.printf("ERROR: Could not create thread to have fun: %s \n", err.message); | 89 | warning ("Could not create thread to have fun: %s", err.message); |
2912 | 90 | } | 90 | } |
2913 | 91 | } | 91 | } |
2914 | 92 | 92 | ||
2915 | @@ -117,8 +117,8 @@ | |||
2916 | 117 | try { | 117 | try { |
2917 | 118 | GLib.AppInfo.launch_default_for_uri (s.lastfm_url, null); | 118 | GLib.AppInfo.launch_default_for_uri (s.lastfm_url, null); |
2918 | 119 | } | 119 | } |
2921 | 120 | catch(Error err) { | 120 | catch (Error err) { |
2922 | 121 | stdout.printf("Couldn't open the similar media's last fm page: %s\n", err.message); | 121 | warning ("Couldn't open the similar media's last fm page: %s", err.message); |
2923 | 122 | } | 122 | } |
2924 | 123 | } | 123 | } |
2925 | 124 | 124 | ||
2926 | 125 | 125 | ||
2927 | === modified file 'src/Widgets/EmbeddedAlert.vala' | |||
2928 | --- src/Widgets/EmbeddedAlert.vala 2012-06-25 23:39:54 +0000 | |||
2929 | +++ src/Widgets/EmbeddedAlert.vala 2012-07-03 06:49:24 +0000 | |||
2930 | @@ -20,12 +20,6 @@ | |||
2931 | 20 | * Authored by: Victor Eduardo <victoreduardm@gmail.com> | 20 | * Authored by: Victor Eduardo <victoreduardm@gmail.com> |
2932 | 21 | */ | 21 | */ |
2933 | 22 | 22 | ||
2934 | 23 | /** | ||
2935 | 24 | * An alert compliant with elementary's HIG | ||
2936 | 25 | * | ||
2937 | 26 | * TODO: Add description and examples | ||
2938 | 27 | */ | ||
2939 | 28 | |||
2940 | 29 | public class BeatBox.EmbeddedAlert : Gtk.EventBox { | 23 | public class BeatBox.EmbeddedAlert : Gtk.EventBox { |
2941 | 30 | 24 | ||
2942 | 31 | const string ERROR_ICON = "dialog-error"; | 25 | const string ERROR_ICON = "dialog-error"; |
2943 | @@ -43,11 +37,11 @@ | |||
2944 | 43 | protected Gtk.ButtonBox action_button_box; | 37 | protected Gtk.ButtonBox action_button_box; |
2945 | 44 | 38 | ||
2946 | 45 | const int MIN_HORIZONTAL_MARGIN = 84; | 39 | const int MIN_HORIZONTAL_MARGIN = 84; |
2948 | 46 | const int MIN_VERTICAL_MARGIN = 48; | 40 | const int MIN_VERTICAL_MARGIN = 6; |
2949 | 47 | 41 | ||
2950 | 48 | public EmbeddedAlert () { | 42 | public EmbeddedAlert () { |
2951 | 49 | get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); | 43 | get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); |
2953 | 50 | //get_style_context ().add_class (Granite.STYLE_CLASS_CONTENT_VIEW); // This variable is not in granite version in universe | 44 | get_style_context ().add_class (Granite.STYLE_CLASS_CONTENT_VIEW); |
2954 | 51 | 45 | ||
2955 | 52 | action_button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL); | 46 | action_button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL); |
2956 | 53 | action_button_box.valign = Gtk.Align.START; | 47 | action_button_box.valign = Gtk.Align.START; |
2957 | @@ -125,7 +119,7 @@ | |||
2958 | 125 | bool show_icon = true, Gtk.MessageType type = Gtk.MessageType.WARNING) | 119 | bool show_icon = true, Gtk.MessageType type = Gtk.MessageType.WARNING) |
2959 | 126 | { | 120 | { |
2960 | 127 | // Reset size request | 121 | // Reset size request |
2962 | 128 | set_size_request (1, 1); | 122 | set_size_request (0, 0); |
2963 | 129 | 123 | ||
2964 | 130 | if (primary_text == null) | 124 | if (primary_text == null) |
2965 | 131 | primary_text = ""; | 125 | primary_text = ""; |
2966 | 132 | 126 | ||
2967 | === modified file 'src/Widgets/SearchSuggester.vala' | |||
2968 | --- src/Widgets/SearchSuggester.vala 2012-06-01 22:48:28 +0000 | |||
2969 | +++ src/Widgets/SearchSuggester.vala 2012-07-03 06:49:24 +0000 | |||
2970 | @@ -71,9 +71,9 @@ | |||
2971 | 71 | //Timeout.add(750, () => { | 71 | //Timeout.add(750, () => { |
2972 | 72 | if(new_search == last_search && new_search.length > 2) { | 72 | if(new_search == last_search && new_search.length > 2) { |
2973 | 73 | try { | 73 | try { |
2977 | 74 | Thread.create<void*>(update_contents, false); | 74 | new Thread<void*>.try (null, update_contents); |
2978 | 75 | } catch(GLib.ThreadError err) { | 75 | } catch (Error err) { |
2979 | 76 | warning ("ERROR: Could not create search suggester thread: %s \n", err.message); | 76 | warning ("Could not create search suggester thread: %s", err.message); |
2980 | 77 | } | 77 | } |
2981 | 78 | } | 78 | } |
2982 | 79 | else if(new_search.length <= 2) { | 79 | else if(new_search.length <= 2) { |
2983 | 80 | 80 | ||
2984 | === modified file 'src/Widgets/StatusBar.vala' | |||
2985 | --- src/Widgets/StatusBar.vala 2012-03-04 00:33:20 +0000 | |||
2986 | +++ src/Widgets/StatusBar.vala 2012-07-03 06:49:24 +0000 | |||
2987 | @@ -22,81 +22,16 @@ | |||
2988 | 22 | 22 | ||
2989 | 23 | using Gtk; | 23 | using Gtk; |
2990 | 24 | 24 | ||
2992 | 25 | public class BeatBox.StatusBar : Gtk.Toolbar { | 25 | public class BeatBox.StatusBar : Granite.Widgets.StatusBar { |
2993 | 26 | 26 | ||
2994 | 27 | public uint total_items {get; private set; default = 0;} | 27 | public uint total_items {get; private set; default = 0;} |
2995 | 28 | public uint total_mbs {get; private set; default = 0;} | 28 | public uint total_mbs {get; private set; default = 0;} |
2996 | 29 | public uint total_secs {get; private set; default = 0;} | 29 | public uint total_secs {get; private set; default = 0;} |
2997 | 30 | public ViewWrapper.Hint media_type {get; private set;} | 30 | public ViewWrapper.Hint media_type {get; private set;} |
2998 | 31 | 31 | ||
2999 | 32 | private Label status_label; | ||
3000 | 33 | private Box left_box; | ||
3001 | 34 | private Box right_box; | ||
3002 | 35 | |||
3003 | 36 | private CssProvider style_provider; | ||
3004 | 37 | private StyleContext context; | ||
3005 | 38 | |||
3006 | 39 | private string STATUS_TEXT_FORMAT = _("%s, %s, %s"); | 32 | private string STATUS_TEXT_FORMAT = _("%s, %s, %s"); |
3007 | 40 | 33 | ||
3008 | 41 | private const string STATUSBAR_STYLESHEET = """ | ||
3009 | 42 | BeatBoxStatusBar { | ||
3010 | 43 | border-bottom-width: 0; | ||
3011 | 44 | border-right-width: 0; | ||
3012 | 45 | border-left-width: 0; | ||
3013 | 46 | |||
3014 | 47 | -GtkWidget-window-dragging: false; | ||
3015 | 48 | } | ||
3016 | 49 | |||
3017 | 50 | /* This prevents the huge vertical padding */ | ||
3018 | 51 | BeatBoxStatusBar .button { | ||
3019 | 52 | padding: 0px; | ||
3020 | 53 | } | ||
3021 | 54 | """; | ||
3022 | 55 | |||
3023 | 56 | public StatusBar () { | 34 | public StatusBar () { |
3024 | 57 | |||
3025 | 58 | style_provider = new CssProvider (); | ||
3026 | 59 | |||
3027 | 60 | try { | ||
3028 | 61 | style_provider.load_from_data (STATUSBAR_STYLESHEET, -1); | ||
3029 | 62 | } | ||
3030 | 63 | catch (Error err) { | ||
3031 | 64 | warning (err.message); | ||
3032 | 65 | } | ||
3033 | 66 | |||
3034 | 67 | /* Get rid of the "toolbar" class to avoid inheriting its style, | ||
3035 | 68 | since we want the widget to look more like a normal statusbar. */ | ||
3036 | 69 | get_style_context ().remove_class (STYLE_CLASS_TOOLBAR); | ||
3037 | 70 | |||
3038 | 71 | context = new StyleContext (); | ||
3039 | 72 | context.add_provider_for_screen (get_screen (), style_provider, STYLE_PROVIDER_PRIORITY_THEME); | ||
3040 | 73 | |||
3041 | 74 | status_label = new Label (""); | ||
3042 | 75 | status_label.set_justify (Justification.CENTER); | ||
3043 | 76 | |||
3044 | 77 | left_box = new Box (Orientation.HORIZONTAL, 0); | ||
3045 | 78 | right_box = new Box (Orientation.HORIZONTAL, 0); | ||
3046 | 79 | |||
3047 | 80 | var left_item = new ToolItem (); | ||
3048 | 81 | var status_label_item = new ToolItem (); | ||
3049 | 82 | var right_item = new ToolItem (); | ||
3050 | 83 | |||
3051 | 84 | left_item.add (left_box); | ||
3052 | 85 | status_label_item.add (status_label); | ||
3053 | 86 | right_item.add (right_box); | ||
3054 | 87 | |||
3055 | 88 | status_label_item.set_expand (true); | ||
3056 | 89 | |||
3057 | 90 | this.insert (left_item, 0); | ||
3058 | 91 | this.insert (status_label_item, 1); | ||
3059 | 92 | this.insert (right_item, 2); | ||
3060 | 93 | } | ||
3061 | 94 | |||
3062 | 95 | public void insert_widget (Gtk.Widget widget, bool? use_left_side = false) { | ||
3063 | 96 | if (use_left_side) | ||
3064 | 97 | left_box.pack_start (widget, false, false, 3); | ||
3065 | 98 | else | ||
3066 | 99 | right_box.pack_start (widget, false, false, 3); | ||
3067 | 100 | } | 35 | } |
3068 | 101 | 36 | ||
3069 | 102 | public void set_files_size (uint total_mbs) { | 37 | public void set_files_size (uint total_mbs) { |
3070 | 103 | 38 | ||
3071 | === modified file 'src/Widgets/StyledWidgets/StyledArtistImages.vala' | |||
3072 | --- src/Widgets/StyledWidgets/StyledArtistImages.vala 2012-07-02 23:17:27 +0000 | |||
3073 | +++ src/Widgets/StyledWidgets/StyledArtistImages.vala 2012-07-03 06:49:24 +0000 | |||
3074 | @@ -22,7 +22,6 @@ | |||
3075 | 22 | 22 | ||
3076 | 23 | using Gee; | 23 | using Gee; |
3077 | 24 | using Gtk; | 24 | using Gtk; |
3078 | 25 | using Xml; | ||
3079 | 26 | 25 | ||
3080 | 27 | public class BeatBox.StyledArtistImages : EventBox { | 26 | public class BeatBox.StyledArtistImages : EventBox { |
3081 | 28 | const string api = "YOFT4SZFVZLZZ1SVT"; | 27 | const string api = "YOFT4SZFVZLZZ1SVT"; |
3082 | @@ -118,13 +117,13 @@ | |||
3083 | 118 | images = new LinkedList<Gdk.Pixbuf>(); | 117 | images = new LinkedList<Gdk.Pixbuf>(); |
3084 | 119 | 118 | ||
3085 | 120 | try { | 119 | try { |
3089 | 121 | Thread.create<void*>(fetch_thread_function, false); | 120 | new Thread<void*>.try (null, fetch_thread_function); |
3090 | 122 | } catch(GLib.ThreadError err) { | 121 | } catch(Error err) { |
3091 | 123 | warning("Could not create thread to load artist pixbuf's: %s \n", err.message); | 122 | warning ("Could not create thread to load artist pixbuf's: %s", err.message); |
3092 | 124 | } | 123 | } |
3093 | 125 | } | 124 | } |
3094 | 126 | 125 | ||
3096 | 127 | public void* fetch_thread_function () { | 126 | private void* fetch_thread_function () { |
3097 | 128 | var url = "http://developer.echonest.com/api/v4/artist/images?api_key=" + api + "&name=" + | 127 | var url = "http://developer.echonest.com/api/v4/artist/images?api_key=" + api + "&name=" + |
3098 | 129 | LastFM.Core.fix_for_url(current_artist) + "&format=xml&start=0&results=15"; | 128 | LastFM.Core.fix_for_url(current_artist) + "&format=xml&start=0&results=15"; |
3099 | 130 | 129 | ||
3100 | @@ -197,7 +196,7 @@ | |||
3101 | 197 | // Loop over the passed node's children | 196 | // Loop over the passed node's children |
3102 | 198 | for (Xml.Node* iter = node->children; iter != null; iter = iter->next) { | 197 | for (Xml.Node* iter = node->children; iter != null; iter = iter->next) { |
3103 | 199 | // Spaces between tags are also nodes, discard them | 198 | // Spaces between tags are also nodes, discard them |
3105 | 200 | if (iter->type != ElementType.ELEMENT_NODE) { | 199 | if (iter->type != Xml.ElementType.ELEMENT_NODE) { |
3106 | 201 | continue; | 200 | continue; |
3107 | 202 | } | 201 | } |
3108 | 203 | 202 | ||
3109 | 204 | 203 | ||
3110 | === removed file 'src/Widgets/WarningLabel.vala' | |||
3111 | --- src/Widgets/WarningLabel.vala 2012-03-29 08:46:09 +0000 | |||
3112 | +++ src/Widgets/WarningLabel.vala 1970-01-01 00:00:00 +0000 | |||
3113 | @@ -1,99 +0,0 @@ | |||
3114 | 1 | /*- | ||
3115 | 2 | * Copyright (c) 2011-2012 Scott Ringwelski <sgringwe@mtu.edu> | ||
3116 | 3 | * | ||
3117 | 4 | * Originally Written by Scott Ringwelski for BeatBox Music Player | ||
3118 | 5 | * BeatBox Music Player: http://www.launchpad.net/beat-box | ||
3119 | 6 | * | ||
3120 | 7 | * This library is free software; you can redistribute it and/or | ||
3121 | 8 | * modify it under the terms of the GNU Library General Public | ||
3122 | 9 | * License as published by the Free Software Foundation; either | ||
3123 | 10 | * version 2 of the License, or (at your option) any later version. | ||
3124 | 11 | * | ||
3125 | 12 | * This library is distributed in the hope that it will be useful, | ||
3126 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3127 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
3128 | 15 | * Library General Public License for more details. | ||
3129 | 16 | * | ||
3130 | 17 | * You should have received a copy of the GNU Library General Public | ||
3131 | 18 | * License along with this library; if not, write to the | ||
3132 | 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
3133 | 20 | * Boston, MA 02111-1307, USA. | ||
3134 | 21 | */ | ||
3135 | 22 | |||
3136 | 23 | using Gtk; | ||
3137 | 24 | |||
3138 | 25 | public class BeatBox.WarningLabel : EventBox { | ||
3139 | 26 | |||
3140 | 27 | private Label errorLabel; // FIXME: Use Granite.Widgets.WrapLabel | ||
3141 | 28 | private Image warningIcon; | ||
3142 | 29 | |||
3143 | 30 | public bool show_icon { | ||
3144 | 31 | get { | ||
3145 | 32 | return warningIcon.visible; | ||
3146 | 33 | } | ||
3147 | 34 | set { | ||
3148 | 35 | warningIcon.set_no_show_all (!value); | ||
3149 | 36 | warningIcon.set_visible (value); | ||
3150 | 37 | } | ||
3151 | 38 | } | ||
3152 | 39 | |||
3153 | 40 | public WarningLabel(string icon_name = "dialog-warning") { | ||
3154 | 41 | errorLabel = new Label(""); | ||
3155 | 42 | warningIcon = Icons.render_image (icon_name, Gtk.IconSize.DIALOG); | ||
3156 | 43 | |||
3157 | 44 | //FIXME: use margins | ||
3158 | 45 | var content = new Box (Orientation.HORIZONTAL, 10); | ||
3159 | 46 | var content_wrapper = new Box (Orientation.HORIZONTAL, 0); | ||
3160 | 47 | var outer_box = new Box (Orientation.VERTICAL, 0); | ||
3161 | 48 | var top_padding = new Box (Orientation.VERTICAL, 0); | ||
3162 | 49 | var bottom_padding = new Box (Orientation.VERTICAL, 0); | ||
3163 | 50 | var left_padding = new Box (Orientation.HORIZONTAL, 0); | ||
3164 | 51 | var right_padding = new Box (Orientation.HORIZONTAL, 0); | ||
3165 | 52 | |||
3166 | 53 | content.pack_start (wrap_alignment(warningIcon, 0, 10, 10, 10), false, false, 0); | ||
3167 | 54 | content.pack_start (errorLabel, false, true, 0); | ||
3168 | 55 | |||
3169 | 56 | content_wrapper.pack_start (left_padding, true, true, 0); | ||
3170 | 57 | content_wrapper.pack_start (content, false, true, 0); | ||
3171 | 58 | content_wrapper.pack_start (right_padding, true, true, 0); | ||
3172 | 59 | |||
3173 | 60 | outer_box.pack_start (top_padding, true, true, 0); | ||
3174 | 61 | outer_box.pack_start (content_wrapper, false, true, 10); | ||
3175 | 62 | outer_box.pack_start (bottom_padding, true, true, 0); | ||
3176 | 63 | |||
3177 | 64 | add(outer_box); | ||
3178 | 65 | |||
3179 | 66 | // Add view-like theming | ||
3180 | 67 | get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); | ||
3181 | 68 | |||
3182 | 69 | errorLabel.xalign = 0.5f; | ||
3183 | 70 | errorLabel.set_justify(Justification.CENTER); | ||
3184 | 71 | errorLabel.ellipsize = Pango.EllipsizeMode.END; | ||
3185 | 72 | } | ||
3186 | 73 | |||
3187 | 74 | static Gtk.Alignment wrap_alignment (Gtk.Widget widget, int top, int right, int bottom, int left) { | ||
3188 | 75 | |||
3189 | 76 | var alignment = new Gtk.Alignment(0.0f, 0.0f, 1.0f, 1.0f); | ||
3190 | 77 | alignment.top_padding = top; | ||
3191 | 78 | alignment.right_padding = right; | ||
3192 | 79 | alignment.bottom_padding = bottom; | ||
3193 | 80 | alignment.left_padding = left; | ||
3194 | 81 | |||
3195 | 82 | alignment.add(widget); | ||
3196 | 83 | return alignment; | ||
3197 | 84 | } | ||
3198 | 85 | |||
3199 | 86 | |||
3200 | 87 | // We force our HIG here. Whenever show_icon is true, the title has to be left-aligned. | ||
3201 | 88 | |||
3202 | 89 | // FIXME: this should be: set_warning (string primary_text, string secondary_text, bool show_icon = true, ...) | ||
3203 | 90 | public void setWarning(string warning, Gtk.Justification? justification = Gtk.Justification.LEFT) { | ||
3204 | 91 | if (!show_icon) | ||
3205 | 92 | errorLabel.set_justify(Gtk.Justification.CENTER); | ||
3206 | 93 | else | ||
3207 | 94 | errorLabel.set_justify(justification); | ||
3208 | 95 | |||
3209 | 96 | errorLabel.set_markup(warning); | ||
3210 | 97 | } | ||
3211 | 98 | } | ||
3212 | 99 | |||
3213 | 100 | 0 | ||
3214 | === modified file 'src/Windows/AddPodcastWindow.vala' | |||
3215 | --- src/Windows/AddPodcastWindow.vala 2012-05-03 04:19:07 +0000 | |||
3216 | +++ src/Windows/AddPodcastWindow.vala 2012-07-03 06:49:24 +0000 | |||
3217 | @@ -173,10 +173,10 @@ | |||
3218 | 173 | next = url; | 173 | next = url; |
3219 | 174 | 174 | ||
3220 | 175 | try { | 175 | try { |
3222 | 176 | Thread.create<void*>(test_url_validity, false); | 176 | new Thread<void*>.try (null, test_url_validity); |
3223 | 177 | } | 177 | } |
3226 | 178 | catch(GLib.ThreadError err) { | 178 | catch (Error err) { |
3227 | 179 | stdout.printf("ERROR: Could not create thread to fetch new podcasts: %s \n", err.message); | 179 | warning ("Could not create thread to fetch new podcasts: %s", err.message); |
3228 | 180 | } | 180 | } |
3229 | 181 | } | 181 | } |
3230 | 182 | } | 182 | } |
3231 | 183 | 183 | ||
3232 | === modified file 'src/Windows/RemoveDuplicatesDialog.vala' | |||
3233 | --- src/Windows/RemoveDuplicatesDialog.vala 2012-06-14 23:08:24 +0000 | |||
3234 | +++ src/Windows/RemoveDuplicatesDialog.vala 2012-07-03 06:49:24 +0000 | |||
3235 | @@ -141,10 +141,10 @@ | |||
3236 | 141 | is_working.start(); | 141 | is_working.start(); |
3237 | 142 | 142 | ||
3238 | 143 | try { | 143 | try { |
3240 | 144 | Thread.create<void*>(find_duplicates_thread, false); | 144 | new Thread<void*>.try (null, find_duplicates_thread); |
3241 | 145 | } | 145 | } |
3244 | 146 | catch(GLib.ThreadError err) { | 146 | catch (Error err) { |
3245 | 147 | stdout.printf("ERROR: Could not create thread to analyze duplicates: %s \n", err.message); | 147 | warning ("Could not create thread to analyze duplicates: %s", err.message); |
3246 | 148 | } | 148 | } |
3247 | 149 | } | 149 | } |
3248 | 150 | 150 | ||
3249 | 151 | 151 | ||
3250 | === modified file 'src/Wrappers/PodcastViewWrapper.vala' | |||
3251 | --- src/Wrappers/PodcastViewWrapper.vala 2012-06-30 20:55:57 +0000 | |||
3252 | +++ src/Wrappers/PodcastViewWrapper.vala 2012-07-03 06:49:24 +0000 | |||
3253 | @@ -61,15 +61,15 @@ | |||
3254 | 61 | void welcome_screen_activated(int index) { | 61 | void welcome_screen_activated(int index) { |
3255 | 62 | if(index == 0) { | 62 | if(index == 0) { |
3256 | 63 | try { | 63 | try { |
3258 | 64 | Thread.create<void*>(take_action, false); | 64 | new Thread<void*>.try (null, take_action); |
3259 | 65 | } | 65 | } |
3262 | 66 | catch(GLib.ThreadError err) { | 66 | catch (Error err) { |
3263 | 67 | stdout.printf("ERROR: Could not create thread to have fun: %s \n", err.message); | 67 | warning ("Could not create thread to have fun: %s", err.message); |
3264 | 68 | } | 68 | } |
3265 | 69 | } | 69 | } |
3266 | 70 | } | 70 | } |
3267 | 71 | 71 | ||
3269 | 72 | public void* take_action () { | 72 | private void* take_action () { |
3270 | 73 | try { | 73 | try { |
3271 | 74 | GLib.AppInfo.launch_default_for_uri ("https://www.miroguide.com/toprated/", null); | 74 | GLib.AppInfo.launch_default_for_uri ("https://www.miroguide.com/toprated/", null); |
3272 | 75 | } | 75 | } |
3273 | 76 | 76 | ||
3274 | === modified file 'src/Wrappers/StationViewWrapper.vala' | |||
3275 | --- src/Wrappers/StationViewWrapper.vala 2012-06-30 20:55:57 +0000 | |||
3276 | +++ src/Wrappers/StationViewWrapper.vala 2012-07-03 06:49:24 +0000 | |||
3277 | @@ -61,10 +61,10 @@ | |||
3278 | 61 | void welcome_screen_activated(int index) { | 61 | void welcome_screen_activated(int index) { |
3279 | 62 | if(index == 0) { | 62 | if(index == 0) { |
3280 | 63 | try { | 63 | try { |
3282 | 64 | Thread.create<void*>(take_action, false); | 64 | new Thread<void*>.try (null, take_action); |
3283 | 65 | } | 65 | } |
3286 | 66 | catch(GLib.ThreadError err) { | 66 | catch(Error err) { |
3287 | 67 | stdout.printf("ERROR: Could not create thread to have fun: %s \n", err.message); | 67 | warning ("Could not create thread to have fun: %s", err.message); |
3288 | 68 | } | 68 | } |
3289 | 69 | } | 69 | } |
3290 | 70 | } | 70 | } |
3291 | 71 | 71 | ||
3292 | === modified file 'src/Wrappers/ViewWrapper.vala' | |||
3293 | --- src/Wrappers/ViewWrapper.vala 2012-06-30 20:55:57 +0000 | |||
3294 | +++ src/Wrappers/ViewWrapper.vala 2012-07-03 06:49:24 +0000 | |||
3295 | @@ -177,8 +177,6 @@ | |||
3296 | 177 | _artist_filter = ""; | 177 | _artist_filter = ""; |
3297 | 178 | _genre_filter = ""; | 178 | _genre_filter = ""; |
3298 | 179 | 179 | ||
3299 | 180 | in_update = new Mutex(); | ||
3300 | 181 | |||
3301 | 182 | set_orientation(Orientation.VERTICAL); | 180 | set_orientation(Orientation.VERTICAL); |
3302 | 183 | 181 | ||
3303 | 184 | // Setup container | 182 | // Setup container |
I haven't actually tested it yet, but I went through the whole diff and looks great. I did find a few locks that were missing, but maybe they just didn't show up in the diff.
Agree with your comments for the most part.
There was one thing I disagreed with - in lyrics fetcher - but that is no showstopper. Will merge when I get home or you can if you are ok with me skipping testing.
Awesome work!