diff --git a/src/apps/mediaplayer/ControllerView.cpp b/src/apps/mediaplayer/ControllerView.cpp index 4bc98e6a39..f8e298722d 100644 --- a/src/apps/mediaplayer/ControllerView.cpp +++ b/src/apps/mediaplayer/ControllerView.cpp @@ -77,6 +77,9 @@ ControllerView::MessageReceived(BMessage* message) _CheckSkippable(); break; + case MSG_PLAYLIST_IMPORT_FAILED: + break; + default: TransportControlGroup::MessageReceived(message); } diff --git a/src/apps/mediaplayer/MainApp.cpp b/src/apps/mediaplayer/MainApp.cpp index 9d2213298b..24bb6f63f6 100644 --- a/src/apps/mediaplayer/MainApp.cpp +++ b/src/apps/mediaplayer/MainApp.cpp @@ -247,7 +247,6 @@ MainApp::ArgvReceived(int32 argc, char** argv) BMessage message(B_REFS_RECEIVED); for (int i = 1; i < argc; i++) { - printf("MainApp::ArgvReceived %s\n", argv[i]); BPath path; if (argv[i][0] != '/') path.SetTo(cwd, argv[i]); @@ -262,10 +261,8 @@ MainApp::ArgvReceived(int32 argc, char** argv) message.AddRef("refs", &ref); } - if (message.HasRef("refs")) { - printf("MainApp::ArgvReceived calling RefsReceived\n"); + if (message.HasRef("refs")) RefsReceived(&message); - } } diff --git a/src/apps/mediaplayer/MainWin.cpp b/src/apps/mediaplayer/MainWin.cpp index 774b4d15a0..6a0d8065e3 100644 --- a/src/apps/mediaplayer/MainWin.cpp +++ b/src/apps/mediaplayer/MainWin.cpp @@ -533,11 +533,9 @@ MainWin::MessageReceived(BMessage* msg) } case B_REFS_RECEIVED: - printf("MainWin::MessageReceived: B_REFS_RECEIVED\n"); _RefsReceived(msg); break; case B_SIMPLE_DATA: - printf("MainWin::MessageReceived: B_SIMPLE_DATA\n"); if (msg->HasRef("refs")) _RefsReceived(msg); break; @@ -604,6 +602,15 @@ MainWin::MessageReceived(BMessage* msg) } break; } + case MSG_PLAYLIST_IMPORT_FAILED: + { + BAlert* alert = new BAlert("Nothing to Play", "None of the files " + "you wanted to play appear to be media files.", "OK"); + alert->Go(); + + _ShowIfNeeded(); + break; + } // ControllerObserver messages case MSG_CONTROLLER_FILE_FINISHED: diff --git a/src/apps/mediaplayer/MediaPlayer.rdef b/src/apps/mediaplayer/MediaPlayer.rdef index 4b5cbe769a..4fbfbe44eb 100644 --- a/src/apps/mediaplayer/MediaPlayer.rdef +++ b/src/apps/mediaplayer/MediaPlayer.rdef @@ -8,7 +8,7 @@ resource app_version { variety = B_APPV_BETA, internal = 0, short_info = "MediaPlayer", - long_info = "MediaPlayer ©2006-2009 Haiku, Inc." + long_info = "MediaPlayer ©2006-2010 Haiku, Inc." }; resource app_flags B_SINGLE_LAUNCH; diff --git a/src/apps/mediaplayer/playlist/ImportPLItemsCommand.cpp b/src/apps/mediaplayer/playlist/ImportPLItemsCommand.cpp index f4dd717766..e0f889d46e 100644 --- a/src/apps/mediaplayer/playlist/ImportPLItemsCommand.cpp +++ b/src/apps/mediaplayer/playlist/ImportPLItemsCommand.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include "Playlist.h" @@ -43,12 +42,8 @@ ImportPLItemsCommand::ImportPLItemsCommand(Playlist* playlist, temp.AppendRefs(refsMessage); fNewCount = temp.CountItems(); - if (fNewCount <= 0) { - BAlert* alert = new BAlert("Nothing to Play", "None of the files " - "you wanted to play appear to be media files.", "OK"); - alert->Go(NULL); + if (fNewCount <= 0) return; - } fNewItems = new (nothrow) PlaylistItem*[fNewCount]; if (!fNewItems) diff --git a/src/apps/mediaplayer/playlist/Playlist.cpp b/src/apps/mediaplayer/playlist/Playlist.cpp index ba16f10927..f99ed580e4 100644 --- a/src/apps/mediaplayer/playlist/Playlist.cpp +++ b/src/apps/mediaplayer/playlist/Playlist.cpp @@ -53,6 +53,7 @@ void Playlist::Listener::ItemAdded(PlaylistItem* item, int32 index) {} void Playlist::Listener::ItemRemoved(int32 index) {} void Playlist::Listener::ItemsSorted() {} void Playlist::Listener::CurrentItemChanged(int32 newIndex) {} +void Playlist::Listener::ImportFailed() {} // #pragma mark - @@ -537,6 +538,14 @@ Playlist::AppendPlaylistToPlaylist(const entry_ref& ref, Playlist* playlist) } +void +Playlist::NotifyImportFailed() +{ + BAutolock _(this); + _NotifyImportFailed(); +} + + // #pragma mark - private @@ -664,3 +673,14 @@ Playlist::_NotifyCurrentItemChanged(int32 newIndex) const } } + +void +Playlist::_NotifyImportFailed() const +{ + BList listeners(fListeners); + int32 count = listeners.CountItems(); + for (int32 i = 0; i < count; i++) { + Listener* listener = (Listener*)listeners.ItemAtFast(i); + listener->ImportFailed(); + } +} diff --git a/src/apps/mediaplayer/playlist/Playlist.h b/src/apps/mediaplayer/playlist/Playlist.h index 3f53847cea..0f7ad7cf78 100644 --- a/src/apps/mediaplayer/playlist/Playlist.h +++ b/src/apps/mediaplayer/playlist/Playlist.h @@ -55,6 +55,8 @@ public: virtual void ItemsSorted(); virtual void CurrentItemChanged(int32 newIndex); + + virtual void ImportFailed(); }; public: @@ -106,6 +108,8 @@ public: static void AppendPlaylistToPlaylist(const entry_ref& ref, Playlist* playlist); + void NotifyImportFailed(); + private: Playlist(const Playlist& other); Playlist& operator=(const Playlist& other); @@ -122,6 +126,7 @@ private: void _NotifyItemRemoved(int32 index) const; void _NotifyItemsSorted() const; void _NotifyCurrentItemChanged(int32 newIndex) const; + void _NotifyImportFailed() const; private: BList fItems; diff --git a/src/apps/mediaplayer/playlist/PlaylistListView.cpp b/src/apps/mediaplayer/playlist/PlaylistListView.cpp index 0ce5e77bf7..5a289f959b 100644 --- a/src/apps/mediaplayer/playlist/PlaylistListView.cpp +++ b/src/apps/mediaplayer/playlist/PlaylistListView.cpp @@ -320,6 +320,8 @@ PlaylistListView::MessageReceived(BMessage* message) _SetCurrentPlaylistIndex(index); break; } + case MSG_PLAYLIST_IMPORT_FAILED: + break; // ControllerObserver messages case MSG_CONTROLLER_PLAYBACK_STATE_CHANGED: @@ -442,8 +444,10 @@ PlaylistListView::DrawListItem(BView* owner, int32 index, BRect frame) const void PlaylistListView::RefsReceived(BMessage* message, int32 appendIndex) { - fCommandStack->Perform(new (nothrow) ImportPLItemsCommand(fPlaylist, - message, appendIndex)); + if (fCommandStack->Perform(new (nothrow) ImportPLItemsCommand(fPlaylist, + message, appendIndex)) != B_OK) { + fPlaylist->NotifyImportFailed(); + } } diff --git a/src/apps/mediaplayer/playlist/PlaylistObserver.cpp b/src/apps/mediaplayer/playlist/PlaylistObserver.cpp index 7dfa163060..0b2d763f0e 100644 --- a/src/apps/mediaplayer/playlist/PlaylistObserver.cpp +++ b/src/apps/mediaplayer/playlist/PlaylistObserver.cpp @@ -1,10 +1,12 @@ /* - * Copyright 2007-2009 Stephan Aßmus . + * Copyright 2007-2010 Stephan Aßmus . * All rights reserved. Distributed under the terms of the MIT License. */ #include "PlaylistObserver.h" +#include + #include @@ -59,3 +61,13 @@ PlaylistObserver::CurrentItemChanged(int32 newIndex) DeliverMessage(message); } + +void +PlaylistObserver::ImportFailed() +{ + BMessage message(MSG_PLAYLIST_IMPORT_FAILED); + + DeliverMessage(message); +} + + diff --git a/src/apps/mediaplayer/playlist/PlaylistObserver.h b/src/apps/mediaplayer/playlist/PlaylistObserver.h index a594fa73fb..4eb4b9b88c 100644 --- a/src/apps/mediaplayer/playlist/PlaylistObserver.h +++ b/src/apps/mediaplayer/playlist/PlaylistObserver.h @@ -12,7 +12,8 @@ enum { MSG_PLAYLIST_ITEM_ADDED = 'plia', MSG_PLAYLIST_ITEM_REMOVED = 'plir', MSG_PLAYLIST_ITEMS_SORTED = 'plis', - MSG_PLAYLIST_CURRENT_ITEM_CHANGED = 'plcc' + MSG_PLAYLIST_CURRENT_ITEM_CHANGED = 'plcc', + MSG_PLAYLIST_IMPORT_FAILED = 'plif' }; class PlaylistObserver : public Playlist::Listener, public AbstractLOAdapter { @@ -26,6 +27,8 @@ public: virtual void ItemsSorted(); virtual void CurrentItemChanged(int32 newIndex); + + virtual void ImportFailed(); }; #endif // PLAYLIST_OBSERVER_H