diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx index f319a4f20..defc46008 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.cxx @@ -807,7 +807,7 @@ GLiveSupport :: acquirePlayable(Ptr::Ref id) void LiveSupport :: GLiveSupport :: GLiveSupport :: uncachePlaylist(Ptr::Ref id) - throw () + throw (XmlRpcException) { Ptr::Ref playlist; PlaylistMap::iterator it; @@ -829,7 +829,7 @@ GLiveSupport :: uncachePlaylist(Ptr::Ref id) *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: releaseOpennedAudioClips(void) throw () +GLiveSupport :: releaseOpennedAudioClips(void) throw (XmlRpcException) { AudioClipMap::iterator it = opennedAudioClips->begin(); AudioClipMap::iterator end = opennedAudioClips->end(); @@ -853,7 +853,7 @@ GLiveSupport :: releaseOpennedAudioClips(void) throw () *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: releaseOpennedPlaylists(void) throw () +GLiveSupport :: releaseOpennedPlaylists(void) throw (XmlRpcException) { PlaylistMap::iterator it = opennedPlaylists->begin(); PlaylistMap::iterator end = opennedPlaylists->end(); @@ -911,7 +911,7 @@ GLiveSupport :: uploadPlaylistArchive(Ptr::Ref path) void LiveSupport :: GLiveSupport :: GLiveSupport :: addToScratchpad(Ptr::Ref playable) - throw () + throw (XmlRpcException) { if (playable->getType() == Playable::AudioClipType) { acquireAudioClip(playable->getId()); @@ -1631,7 +1631,7 @@ LiveSupport :: GLiveSupport :: GLiveSupport :: uploadToHub(Ptr::Ref playable) throw () { - masterPanel->updateSearchWindow(playable); + masterPanel->uploadToHub(playable); } diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h index c36ed267f..efab910be 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupport.h @@ -294,7 +294,8 @@ class GLiveSupport : public LocalizedConfigurable, * @param id the id of the playlist to remove. */ void - uncachePlaylist(Ptr::Ref id) throw (); + uncachePlaylist(Ptr::Ref id) + throw (XmlRpcException); /** * The list of keyboard shortcuts for the various windows. @@ -373,8 +374,14 @@ class GLiveSupport : public LocalizedConfigurable, if (cuePlayer.get()) { cuePlayer->deInitialize(); } - releaseOpennedAudioClips(); - releaseOpennedPlaylists(); + try { + releaseOpennedAudioClips(); + } catch (XmlRpcException &e) { + } + try { + releaseOpennedPlaylists(); + } catch(XmlRpcException &e) { + } } /** @@ -558,7 +565,8 @@ class GLiveSupport : public LocalizedConfigurable, * @param playable the audio clip or playlist to be added */ void - addToScratchpad(Ptr::Ref playable) throw (); + addToScratchpad(Ptr::Ref playable) + throw (XmlRpcException); /** * Reset the storage behind GLiveSupport. @@ -706,13 +714,13 @@ class GLiveSupport : public LocalizedConfigurable, * Release all openned audio clips. */ void - releaseOpennedAudioClips(void) throw (); + releaseOpennedAudioClips(void) throw (XmlRpcException); /** * Release all openned playlists. */ void - releaseOpennedPlaylists(void) throw (); + releaseOpennedPlaylists(void) throw (XmlRpcException); /** * Add a file to the Live Mode, and update it. diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.cxx b/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.cxx index caa51ccc6..197e54054 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.cxx +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.cxx @@ -109,7 +109,7 @@ const std::string password = "q"; * Set up the test environment *----------------------------------------------------------------------------*/ void -GLiveSupportTest :: setUp(void) throw () +GLiveSupportTest :: setUp(void) throw (CPPUNIT_NS::Exception) { Gtk::Main kit(0, 0); @@ -146,7 +146,9 @@ GLiveSupportTest :: setUp(void) throw () } ifs.close(); - gLiveSupport->resetStorage(); + CPPUNIT_ASSERT_NO_THROW( + gLiveSupport->resetStorage(); + ); if (!gLiveSupport->login(login, password)) { std::cerr << "gLiveSupport unable to log in" << std::endl; diff --git a/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.h b/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.h index 7d408cdfe..d2790ba1a 100644 --- a/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.h +++ b/livesupport/src/products/gLiveSupport/src/GLiveSupportTest.h @@ -136,7 +136,7 @@ class GLiveSupportTest : public BaseTestMethod * Set up the environment for the test case. */ void - setUp(void) throw (); + setUp(void) throw (CPPUNIT_NS::Exception); /** * Clean up the environment after the test case. diff --git a/livesupport/src/products/gLiveSupport/src/LiveModeWindow.cxx b/livesupport/src/products/gLiveSupport/src/LiveModeWindow.cxx index 14ca5635e..5f3756fbe 100644 --- a/livesupport/src/products/gLiveSupport/src/LiveModeWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/LiveModeWindow.cxx @@ -287,7 +287,12 @@ LiveModeWindow :: onOutputPlay(void) throw () Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; gLiveSupport->setNowPlaying(playable); treeView->removeItem(iter); - gLiveSupport->playOutputAudio(playable); + try { + gLiveSupport->playOutputAudio(playable); + } catch (std::logic_error &e) { + std::cerr << "cannot play on live mode output device: " + << e.what() << std::endl; + } } } diff --git a/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx b/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx index 5c31a5d45..792e7a5d3 100644 --- a/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.cxx @@ -548,17 +548,27 @@ MasterPanelWindow :: updateSchedulerWindow( std::cerr << e.what() << std::endl; return; } - - schedulerWindow.reset(new SchedulerWindow(gLiveSupport, - bundle, - schedulerButton)); + + try { + schedulerWindow.reset(new SchedulerWindow(gLiveSupport, + bundle, + schedulerButton)); + } catch (XmlRpcException &e) { + std::cerr << e.what() << std::endl; + return; + } } if (time.get()) { schedulerWindow->setTime(time); } - schedulerWindow->showContents(); + try { + schedulerWindow->showContents(); + } catch (XmlRpcException &e) { + std::cerr << e.what() << std::endl; + return; + } if (!schedulerWindow->is_visible()) { schedulerWindow->show(); @@ -570,8 +580,7 @@ MasterPanelWindow :: updateSchedulerWindow( * The event when the Search button has been clicked. *----------------------------------------------------------------------------*/ void -MasterPanelWindow :: updateSearchWindow(Ptr::Ref playable) - throw () +MasterPanelWindow :: updateSearchWindow(void) throw () { if (!searchWindow.get()) { Ptr::Ref bundle; @@ -587,12 +596,7 @@ MasterPanelWindow :: updateSearchWindow(Ptr::Ref playable) searchButton)); } - bool dontWantUploadOrItWasOK = true; - if (playable) { - dontWantUploadOrItWasOK = searchWindow->uploadToHub(playable); - } - - if (dontWantUploadOrItWasOK && !searchWindow->is_visible()) { + if (!searchWindow->is_visible()) { searchWindow->show(); } } @@ -817,3 +821,33 @@ MasterPanelWindow :: onKeyPressed(GdkEventKey * event) throw () return false; } + +/*------------------------------------------------------------------------------ + * The event when the Search button has been clicked. + *----------------------------------------------------------------------------*/ +void +MasterPanelWindow :: uploadToHub(Ptr::Ref playable) + throw () +{ + if (!searchWindow.get()) { + Ptr::Ref bundle; + try { + bundle = getBundle("searchWindow"); + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; + return; + } + + searchWindow.reset(new SearchWindow(gLiveSupport, + bundle, + searchButton)); + } + + bool success = searchWindow->uploadToHub(playable); + + if (success && !searchWindow->is_visible()) { + searchWindow->show(); + } +} + + diff --git a/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.h b/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.h index d7cd627ec..3a1f12b13 100644 --- a/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.h +++ b/livesupport/src/products/gLiveSupport/src/MasterPanelWindow.h @@ -495,14 +495,9 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject /** * Update the Search Window. - * - * @param playable (optional) add this item to the pending "upload - * to hub" tasks displayed in the Transports tab. */ void - updateSearchWindow(Ptr::Ref playable - = Ptr::Ref()) - throw (); + updateSearchWindow(void) throw (); /** * Update the Options Window @@ -525,6 +520,16 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject */ void setNowPlaying(Ptr::Ref playable) throw (); + + /** + * Upload a Playable object to the network hub. + * And display it in the Transports tab of the Search Window. + * + * @param playable the audio clip or playlist to be uploaded. + */ + void + uploadToHub(Ptr::Ref playable) throw (); + }; /* ================================================= external data structures */ diff --git a/livesupport/src/products/gLiveSupport/src/SchedulerWindow.cxx b/livesupport/src/products/gLiveSupport/src/SchedulerWindow.cxx index a628d318b..95fdb170a 100644 --- a/livesupport/src/products/gLiveSupport/src/SchedulerWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/SchedulerWindow.cxx @@ -73,7 +73,7 @@ SchedulerWindow :: SchedulerWindow ( Ptr::Ref gLiveSupport, Ptr::Ref bundle, Button * windowOpenerButton) - throw () + throw (XmlRpcException) : GuiWindow(gLiveSupport, bundle, WidgetConstants::schedulerWindowTitleImage, @@ -258,7 +258,10 @@ SchedulerWindow :: onDateSelected (void) throw () showContents(); } } catch (std::out_of_range &e) { - // TODO: report error + // TODO: report date out of range error + std::cerr << e.what() << std::endl; + } catch (std::out_of_range &e) { + // TODO: report storage server error std::cerr << e.what() << std::endl; } } @@ -280,7 +283,7 @@ SchedulerWindow :: setTime(Ptr::Ref time) * date *----------------------------------------------------------------------------*/ void -SchedulerWindow :: showContents(void) throw () +SchedulerWindow :: showContents(void) throw (XmlRpcException) { calendar->select_month(selectedDate->month() - 1, selectedDate->year()); calendar->select_day(selectedDate->day()); @@ -372,7 +375,12 @@ SchedulerWindow :: onDeleteItem(void) throw () } catch (XmlRpcException &e) { // TODO: signal error here } - showContents(); + + try { + showContents(); + } catch (XmlRpcException &e) { + // TODO: signal error here + } } } } diff --git a/livesupport/src/products/gLiveSupport/src/SchedulerWindow.h b/livesupport/src/products/gLiveSupport/src/SchedulerWindow.h index 60374c187..fc6c6d8d0 100644 --- a/livesupport/src/products/gLiveSupport/src/SchedulerWindow.h +++ b/livesupport/src/products/gLiveSupport/src/SchedulerWindow.h @@ -266,7 +266,7 @@ class SchedulerWindow : public GuiWindow SchedulerWindow(Ptr::Ref gLiveSupport, Ptr::Ref bundle, Button * windowOpenerButton) - throw (); + throw (XmlRpcException); /** * Virtual destructor. @@ -288,7 +288,7 @@ class SchedulerWindow : public GuiWindow * Update the display, with regards to the currently selected day. */ virtual void - showContents(void) throw (); + showContents(void) throw (XmlRpcException); }; diff --git a/livesupport/src/products/gLiveSupport/src/ScratchpadWindow.cxx b/livesupport/src/products/gLiveSupport/src/ScratchpadWindow.cxx index e799d2663..75010a46f 100644 --- a/livesupport/src/products/gLiveSupport/src/ScratchpadWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/ScratchpadWindow.cxx @@ -289,7 +289,14 @@ ScratchpadWindow :: onAddToPlaylistButtonClicked (void) throw () Gtk::TreeIter ti = treeModel->get_iter(*iter); if (ti) { Ptr::Ref playable = (*ti)[modelColumns.playableColumn]; - gLiveSupport->addToPlaylist(playable->getId()); + try { + gLiveSupport->addToPlaylist(playable->getId()); + } catch (XmlRpcException &e) { + // just ignore the bad items + std::cerr << "error in ScratchpadWindow::" + "onAddToPlaylistButtonClicked(): " + << e.what() << std::endl; + } } } } @@ -445,7 +452,13 @@ void ScratchpadWindow :: onAddToPlaylist(void) throw () { Ptr::Ref playable = currentRow[modelColumns.playableColumn]; - gLiveSupport->addToPlaylist(playable->getId()); + try { + gLiveSupport->addToPlaylist(playable->getId()); + } catch (XmlRpcException &e) { + std::cerr << "error in ScratchpadWindow::onAddToPlaylist(): " + << e.what() << std::endl; + return; + } } @@ -458,21 +471,28 @@ ScratchpadWindow :: onSchedulePlaylist(void) throw () { Ptr::Ref playable = currentRow[modelColumns.playableColumn]; Ptr::Ref uid = playable->getId(); - - if (!gLiveSupport->existsPlaylist(uid)) { - return; - } - - Ptr::Ref playlist = gLiveSupport->getPlaylist(uid); - + Ptr::Ref bundle; + Ptr::Ref playlist; + try { - bundle = gLiveSupport->getBundle("schedulePlaylistWindow"); + if (!gLiveSupport->existsPlaylist(uid)) { + return; + } + + playlist = gLiveSupport->getPlaylist(uid); + + bundle = gLiveSupport->getBundle("schedulePlaylistWindow"); + } catch (std::invalid_argument &e) { std::cerr << e.what() << std::endl; return; + } catch (XmlRpcException &e) { + std::cerr << "error in ScratchpadWindow::onSchedulePlaylist(): " + << e.what() << std::endl; + return; } - + // TODO: this should be somewhere else; figure out where Ptr::Ref scheduleWindow; scheduleWindow.reset(new SchedulePlaylistWindow(gLiveSupport, @@ -505,13 +525,17 @@ ScratchpadWindow :: onExportPlaylist(void) throw () Ptr::Ref playable = currentRow[modelColumns.playableColumn]; Ptr::Ref playlist = playable->getPlaylist(); - if (playlist) { - exportPlaylistWindow.reset(new ExportPlaylistWindow( + try { + if (playlist) { + exportPlaylistWindow.reset(new ExportPlaylistWindow( gLiveSupport, gLiveSupport->getBundle("exportPlaylistWindow"), playlist)); - exportPlaylistWindow->set_transient_for(*this); - Gtk::Main::run(*exportPlaylistWindow); + exportPlaylistWindow->set_transient_for(*this); + Gtk::Main::run(*exportPlaylistWindow); + } + } catch (std::invalid_argument &e) { + std::cerr << e.what() << std::endl; } } @@ -609,6 +633,17 @@ void ScratchpadWindow :: addItem(Ptr::Ref playable) throw () { + // cache the item if it hasn't been cached yet + if (!playable->getToken()) { + try { + gLiveSupport->acquirePlayable(playable->getId()); + } catch (XmlRpcException &e) { + std::cerr << "could not acquire playable in ScratchpadWindow: " + << e.what() << std::endl; + return; + } + } + removeItem(playable->getId()); Gtk::TreeModel::Row row = *treeModel->prepend(); @@ -631,11 +666,6 @@ ScratchpadWindow :: addItem(Ptr::Ref playable) row[modelColumns.titleColumn] = Glib::Markup::escape_text( *playable->getTitle()); - - // cache the item if it hasn't been cached yet - if (!playable->getToken()) { - gLiveSupport->acquirePlayable(playable->getId()); - } } @@ -646,7 +676,15 @@ void ScratchpadWindow :: addItem(Ptr::Ref id) throw () { - Ptr::Ref playable = gLiveSupport->acquirePlayable(id); + Ptr::Ref playable; + try { + playable = gLiveSupport->acquirePlayable(id); + } catch (XmlRpcException &e) { + std::cerr << "could not acquire playable in ScratchpadWindow: " + << e.what() << std::endl; + return; + } + addItem(playable); } diff --git a/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx b/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx index 551b97ac9..908e8f3db 100644 --- a/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx @@ -702,7 +702,12 @@ SearchWindow :: onAddToScratchpad(void) throw () if (iter) { Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; if (playable) { - gLiveSupport->addToScratchpad(playable); + try { + gLiveSupport->addToScratchpad(playable); + } catch (XmlRpcException &e) { + std::cerr << "error in SearchWindow::onAddToScratchpad(): " + << e.what() << std::endl; + } } } } @@ -722,7 +727,12 @@ SearchWindow :: onAddToLiveMode(void) throw () Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; if (playable) { gLiveSupport->addToLiveMode(playable); - gLiveSupport->addToScratchpad(playable); + try { + gLiveSupport->addToScratchpad(playable); + } catch (XmlRpcException &e) { + std::cerr << "error in SearchWindow::onAddToLiveMode(): " + << e.what() << std::endl; + } } } } @@ -744,10 +754,15 @@ SearchWindow :: onExportPlaylist(void) throw () if (playable) { Ptr::Ref playlist = playable->getPlaylist(); if (playlist) { - exportPlaylistWindow.reset(new ExportPlaylistWindow( + try { + exportPlaylistWindow.reset(new ExportPlaylistWindow( gLiveSupport, gLiveSupport->getBundle("exportPlaylistWindow"), playlist)); + } catch (XmlRpcException &e) { + std::cerr << e.what() << std::endl; + return; + } exportPlaylistWindow->set_transient_for(*this); Gtk::Main::run(*exportPlaylistWindow); } diff --git a/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx b/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx index 831982daf..6bb3117dc 100644 --- a/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx @@ -318,7 +318,12 @@ SimplePlaylistManagementWindow :: cancelPlaylist(void) throw () DialogWindow::ButtonType result = dialogWindow->run(); switch (result) { case DialogWindow::noButton: - gLiveSupport->cancelEditedPlaylist(); + try { + gLiveSupport->cancelEditedPlaylist(); + } catch (XmlRpcException &e) { + std::cerr << e.what() << std::endl; + return false; + } break; case DialogWindow::yesButton: @@ -425,7 +430,14 @@ SimplePlaylistManagementWindow :: onTitleEdited(void) throw() { Ptr::Ref playlist = gLiveSupport->getEditedPlaylist(); if (!playlist) { - playlist = gLiveSupport->openPlaylistForEditing(); + try { + playlist = gLiveSupport->openPlaylistForEditing(); + } catch (XmlRpcException &e) { + std::cerr << "error in SimplePlaylistManagementWindow::" + "onTitleEdited(): " + << e.what() << std::endl; + return; + } } Ptr::Ref title(new Glib::ustring( nameEntry->get_text()));