eliminated some uncaught exceptions;

I hope this fixed #1630
This commit is contained in:
fgerlits 2006-05-19 16:30:03 +00:00
parent 21e94fe1ab
commit c1b1b7abf4
12 changed files with 193 additions and 66 deletions

View file

@ -807,7 +807,7 @@ GLiveSupport :: acquirePlayable(Ptr<const UniqueId>::Ref id)
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: uncachePlaylist(Ptr<const UniqueId>::Ref id) GLiveSupport :: uncachePlaylist(Ptr<const UniqueId>::Ref id)
throw () throw (XmlRpcException)
{ {
Ptr<Playlist>::Ref playlist; Ptr<Playlist>::Ref playlist;
PlaylistMap::iterator it; PlaylistMap::iterator it;
@ -829,7 +829,7 @@ GLiveSupport :: uncachePlaylist(Ptr<const UniqueId>::Ref id)
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: releaseOpennedAudioClips(void) throw () GLiveSupport :: releaseOpennedAudioClips(void) throw (XmlRpcException)
{ {
AudioClipMap::iterator it = opennedAudioClips->begin(); AudioClipMap::iterator it = opennedAudioClips->begin();
AudioClipMap::iterator end = opennedAudioClips->end(); AudioClipMap::iterator end = opennedAudioClips->end();
@ -853,7 +853,7 @@ GLiveSupport :: releaseOpennedAudioClips(void) throw ()
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: releaseOpennedPlaylists(void) throw () GLiveSupport :: releaseOpennedPlaylists(void) throw (XmlRpcException)
{ {
PlaylistMap::iterator it = opennedPlaylists->begin(); PlaylistMap::iterator it = opennedPlaylists->begin();
PlaylistMap::iterator end = opennedPlaylists->end(); PlaylistMap::iterator end = opennedPlaylists->end();
@ -911,7 +911,7 @@ GLiveSupport :: uploadPlaylistArchive(Ptr<const Glib::ustring>::Ref path)
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: addToScratchpad(Ptr<Playable>::Ref playable) GLiveSupport :: addToScratchpad(Ptr<Playable>::Ref playable)
throw () throw (XmlRpcException)
{ {
if (playable->getType() == Playable::AudioClipType) { if (playable->getType() == Playable::AudioClipType) {
acquireAudioClip(playable->getId()); acquireAudioClip(playable->getId());
@ -1631,7 +1631,7 @@ LiveSupport :: GLiveSupport ::
GLiveSupport :: uploadToHub(Ptr<Playable>::Ref playable) GLiveSupport :: uploadToHub(Ptr<Playable>::Ref playable)
throw () throw ()
{ {
masterPanel->updateSearchWindow(playable); masterPanel->uploadToHub(playable);
} }

View file

@ -294,7 +294,8 @@ class GLiveSupport : public LocalizedConfigurable,
* @param id the id of the playlist to remove. * @param id the id of the playlist to remove.
*/ */
void void
uncachePlaylist(Ptr<const UniqueId>::Ref id) throw (); uncachePlaylist(Ptr<const UniqueId>::Ref id)
throw (XmlRpcException);
/** /**
* The list of keyboard shortcuts for the various windows. * The list of keyboard shortcuts for the various windows.
@ -373,8 +374,14 @@ class GLiveSupport : public LocalizedConfigurable,
if (cuePlayer.get()) { if (cuePlayer.get()) {
cuePlayer->deInitialize(); cuePlayer->deInitialize();
} }
releaseOpennedAudioClips(); try {
releaseOpennedPlaylists(); 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 * @param playable the audio clip or playlist to be added
*/ */
void void
addToScratchpad(Ptr<Playable>::Ref playable) throw (); addToScratchpad(Ptr<Playable>::Ref playable)
throw (XmlRpcException);
/** /**
* Reset the storage behind GLiveSupport. * Reset the storage behind GLiveSupport.
@ -706,13 +714,13 @@ class GLiveSupport : public LocalizedConfigurable,
* Release all openned audio clips. * Release all openned audio clips.
*/ */
void void
releaseOpennedAudioClips(void) throw (); releaseOpennedAudioClips(void) throw (XmlRpcException);
/** /**
* Release all openned playlists. * Release all openned playlists.
*/ */
void void
releaseOpennedPlaylists(void) throw (); releaseOpennedPlaylists(void) throw (XmlRpcException);
/** /**
* Add a file to the Live Mode, and update it. * Add a file to the Live Mode, and update it.

View file

@ -109,7 +109,7 @@ const std::string password = "q";
* Set up the test environment * Set up the test environment
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
GLiveSupportTest :: setUp(void) throw () GLiveSupportTest :: setUp(void) throw (CPPUNIT_NS::Exception)
{ {
Gtk::Main kit(0, 0); Gtk::Main kit(0, 0);
@ -146,7 +146,9 @@ GLiveSupportTest :: setUp(void) throw ()
} }
ifs.close(); ifs.close();
gLiveSupport->resetStorage(); CPPUNIT_ASSERT_NO_THROW(
gLiveSupport->resetStorage();
);
if (!gLiveSupport->login(login, password)) { if (!gLiveSupport->login(login, password)) {
std::cerr << "gLiveSupport unable to log in" << std::endl; std::cerr << "gLiveSupport unable to log in" << std::endl;

View file

@ -136,7 +136,7 @@ class GLiveSupportTest : public BaseTestMethod
* Set up the environment for the test case. * Set up the environment for the test case.
*/ */
void void
setUp(void) throw (); setUp(void) throw (CPPUNIT_NS::Exception);
/** /**
* Clean up the environment after the test case. * Clean up the environment after the test case.

View file

@ -287,7 +287,12 @@ LiveModeWindow :: onOutputPlay(void) throw ()
Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn];
gLiveSupport->setNowPlaying(playable); gLiveSupport->setNowPlaying(playable);
treeView->removeItem(iter); 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;
}
} }
} }

View file

@ -548,17 +548,27 @@ MasterPanelWindow :: updateSchedulerWindow(
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return; return;
} }
schedulerWindow.reset(new SchedulerWindow(gLiveSupport, try {
bundle, schedulerWindow.reset(new SchedulerWindow(gLiveSupport,
schedulerButton)); bundle,
schedulerButton));
} catch (XmlRpcException &e) {
std::cerr << e.what() << std::endl;
return;
}
} }
if (time.get()) { if (time.get()) {
schedulerWindow->setTime(time); schedulerWindow->setTime(time);
} }
schedulerWindow->showContents(); try {
schedulerWindow->showContents();
} catch (XmlRpcException &e) {
std::cerr << e.what() << std::endl;
return;
}
if (!schedulerWindow->is_visible()) { if (!schedulerWindow->is_visible()) {
schedulerWindow->show(); schedulerWindow->show();
@ -570,8 +580,7 @@ MasterPanelWindow :: updateSchedulerWindow(
* The event when the Search button has been clicked. * The event when the Search button has been clicked.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
MasterPanelWindow :: updateSearchWindow(Ptr<Playable>::Ref playable) MasterPanelWindow :: updateSearchWindow(void) throw ()
throw ()
{ {
if (!searchWindow.get()) { if (!searchWindow.get()) {
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle;
@ -587,12 +596,7 @@ MasterPanelWindow :: updateSearchWindow(Ptr<Playable>::Ref playable)
searchButton)); searchButton));
} }
bool dontWantUploadOrItWasOK = true; if (!searchWindow->is_visible()) {
if (playable) {
dontWantUploadOrItWasOK = searchWindow->uploadToHub(playable);
}
if (dontWantUploadOrItWasOK && !searchWindow->is_visible()) {
searchWindow->show(); searchWindow->show();
} }
} }
@ -817,3 +821,33 @@ MasterPanelWindow :: onKeyPressed(GdkEventKey * event) throw ()
return false; return false;
} }
/*------------------------------------------------------------------------------
* The event when the Search button has been clicked.
*----------------------------------------------------------------------------*/
void
MasterPanelWindow :: uploadToHub(Ptr<Playable>::Ref playable)
throw ()
{
if (!searchWindow.get()) {
Ptr<ResourceBundle>::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();
}
}

View file

@ -495,14 +495,9 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
/** /**
* Update the Search Window. * Update the Search Window.
*
* @param playable (optional) add this item to the pending "upload
* to hub" tasks displayed in the Transports tab.
*/ */
void void
updateSearchWindow(Ptr<Playable>::Ref playable updateSearchWindow(void) throw ();
= Ptr<Playable>::Ref())
throw ();
/** /**
* Update the Options Window * Update the Options Window
@ -525,6 +520,16 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
*/ */
void void
setNowPlaying(Ptr<Playable>::Ref playable) throw (); setNowPlaying(Ptr<Playable>::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<Playable>::Ref playable) throw ();
}; };
/* ================================================= external data structures */ /* ================================================= external data structures */

View file

@ -73,7 +73,7 @@ SchedulerWindow :: SchedulerWindow (
Ptr<GLiveSupport>::Ref gLiveSupport, Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Button * windowOpenerButton)
throw () throw (XmlRpcException)
: GuiWindow(gLiveSupport, : GuiWindow(gLiveSupport,
bundle, bundle,
WidgetConstants::schedulerWindowTitleImage, WidgetConstants::schedulerWindowTitleImage,
@ -258,7 +258,10 @@ SchedulerWindow :: onDateSelected (void) throw ()
showContents(); showContents();
} }
} catch (std::out_of_range &e) { } 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; std::cerr << e.what() << std::endl;
} }
} }
@ -280,7 +283,7 @@ SchedulerWindow :: setTime(Ptr<boost::posix_time::ptime>::Ref time)
* date * date
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
SchedulerWindow :: showContents(void) throw () SchedulerWindow :: showContents(void) throw (XmlRpcException)
{ {
calendar->select_month(selectedDate->month() - 1, selectedDate->year()); calendar->select_month(selectedDate->month() - 1, selectedDate->year());
calendar->select_day(selectedDate->day()); calendar->select_day(selectedDate->day());
@ -372,7 +375,12 @@ SchedulerWindow :: onDeleteItem(void) throw ()
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
// TODO: signal error here // TODO: signal error here
} }
showContents();
try {
showContents();
} catch (XmlRpcException &e) {
// TODO: signal error here
}
} }
} }
} }

View file

@ -266,7 +266,7 @@ class SchedulerWindow : public GuiWindow
SchedulerWindow(Ptr<GLiveSupport>::Ref gLiveSupport, SchedulerWindow(Ptr<GLiveSupport>::Ref gLiveSupport,
Ptr<ResourceBundle>::Ref bundle, Ptr<ResourceBundle>::Ref bundle,
Button * windowOpenerButton) Button * windowOpenerButton)
throw (); throw (XmlRpcException);
/** /**
* Virtual destructor. * Virtual destructor.
@ -288,7 +288,7 @@ class SchedulerWindow : public GuiWindow
* Update the display, with regards to the currently selected day. * Update the display, with regards to the currently selected day.
*/ */
virtual void virtual void
showContents(void) throw (); showContents(void) throw (XmlRpcException);
}; };

View file

@ -289,7 +289,14 @@ ScratchpadWindow :: onAddToPlaylistButtonClicked (void) throw ()
Gtk::TreeIter ti = treeModel->get_iter(*iter); Gtk::TreeIter ti = treeModel->get_iter(*iter);
if (ti) { if (ti) {
Ptr<Playable>::Ref playable = (*ti)[modelColumns.playableColumn]; Ptr<Playable>::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 () ScratchpadWindow :: onAddToPlaylist(void) throw ()
{ {
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; Ptr<Playable>::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<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
Ptr<UniqueId>::Ref uid = playable->getId(); Ptr<UniqueId>::Ref uid = playable->getId();
if (!gLiveSupport->existsPlaylist(uid)) {
return;
}
Ptr<Playlist>::Ref playlist = gLiveSupport->getPlaylist(uid);
Ptr<ResourceBundle>::Ref bundle; Ptr<ResourceBundle>::Ref bundle;
Ptr<Playlist>::Ref playlist;
try { try {
bundle = gLiveSupport->getBundle("schedulePlaylistWindow"); if (!gLiveSupport->existsPlaylist(uid)) {
return;
}
playlist = gLiveSupport->getPlaylist(uid);
bundle = gLiveSupport->getBundle("schedulePlaylistWindow");
} catch (std::invalid_argument &e) { } catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return; return;
} catch (XmlRpcException &e) {
std::cerr << "error in ScratchpadWindow::onSchedulePlaylist(): "
<< e.what() << std::endl;
return;
} }
// TODO: this should be somewhere else; figure out where // TODO: this should be somewhere else; figure out where
Ptr<SchedulePlaylistWindow>::Ref scheduleWindow; Ptr<SchedulePlaylistWindow>::Ref scheduleWindow;
scheduleWindow.reset(new SchedulePlaylistWindow(gLiveSupport, scheduleWindow.reset(new SchedulePlaylistWindow(gLiveSupport,
@ -505,13 +525,17 @@ ScratchpadWindow :: onExportPlaylist(void) throw ()
Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = currentRow[modelColumns.playableColumn];
Ptr<Playlist>::Ref playlist = playable->getPlaylist(); Ptr<Playlist>::Ref playlist = playable->getPlaylist();
if (playlist) { try {
exportPlaylistWindow.reset(new ExportPlaylistWindow( if (playlist) {
exportPlaylistWindow.reset(new ExportPlaylistWindow(
gLiveSupport, gLiveSupport,
gLiveSupport->getBundle("exportPlaylistWindow"), gLiveSupport->getBundle("exportPlaylistWindow"),
playlist)); playlist));
exportPlaylistWindow->set_transient_for(*this); exportPlaylistWindow->set_transient_for(*this);
Gtk::Main::run(*exportPlaylistWindow); Gtk::Main::run(*exportPlaylistWindow);
}
} catch (std::invalid_argument &e) {
std::cerr << e.what() << std::endl;
} }
} }
@ -609,6 +633,17 @@ void
ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable) ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
throw () 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()); removeItem(playable->getId());
Gtk::TreeModel::Row row = *treeModel->prepend(); Gtk::TreeModel::Row row = *treeModel->prepend();
@ -631,11 +666,6 @@ ScratchpadWindow :: addItem(Ptr<Playable>::Ref playable)
row[modelColumns.titleColumn] = Glib::Markup::escape_text( row[modelColumns.titleColumn] = Glib::Markup::escape_text(
*playable->getTitle()); *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<const UniqueId>::Ref id) ScratchpadWindow :: addItem(Ptr<const UniqueId>::Ref id)
throw () throw ()
{ {
Ptr<Playable>::Ref playable = gLiveSupport->acquirePlayable(id); Ptr<Playable>::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); addItem(playable);
} }

View file

@ -702,7 +702,12 @@ SearchWindow :: onAddToScratchpad(void) throw ()
if (iter) { if (iter) {
Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn];
if (playable) { 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<Playable>::Ref playable = (*iter)[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn];
if (playable) { if (playable) {
gLiveSupport->addToLiveMode(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) { if (playable) {
Ptr<Playlist>::Ref playlist = playable->getPlaylist(); Ptr<Playlist>::Ref playlist = playable->getPlaylist();
if (playlist) { if (playlist) {
exportPlaylistWindow.reset(new ExportPlaylistWindow( try {
exportPlaylistWindow.reset(new ExportPlaylistWindow(
gLiveSupport, gLiveSupport,
gLiveSupport->getBundle("exportPlaylistWindow"), gLiveSupport->getBundle("exportPlaylistWindow"),
playlist)); playlist));
} catch (XmlRpcException &e) {
std::cerr << e.what() << std::endl;
return;
}
exportPlaylistWindow->set_transient_for(*this); exportPlaylistWindow->set_transient_for(*this);
Gtk::Main::run(*exportPlaylistWindow); Gtk::Main::run(*exportPlaylistWindow);
} }

View file

@ -318,7 +318,12 @@ SimplePlaylistManagementWindow :: cancelPlaylist(void) throw ()
DialogWindow::ButtonType result = dialogWindow->run(); DialogWindow::ButtonType result = dialogWindow->run();
switch (result) { switch (result) {
case DialogWindow::noButton: case DialogWindow::noButton:
gLiveSupport->cancelEditedPlaylist(); try {
gLiveSupport->cancelEditedPlaylist();
} catch (XmlRpcException &e) {
std::cerr << e.what() << std::endl;
return false;
}
break; break;
case DialogWindow::yesButton: case DialogWindow::yesButton:
@ -425,7 +430,14 @@ SimplePlaylistManagementWindow :: onTitleEdited(void) throw()
{ {
Ptr<Playlist>::Ref playlist = gLiveSupport->getEditedPlaylist(); Ptr<Playlist>::Ref playlist = gLiveSupport->getEditedPlaylist();
if (!playlist) { if (!playlist) {
playlist = gLiveSupport->openPlaylistForEditing(); try {
playlist = gLiveSupport->openPlaylistForEditing();
} catch (XmlRpcException &e) {
std::cerr << "error in SimplePlaylistManagementWindow::"
"onTitleEdited(): "
<< e.what() << std::endl;
return;
}
} }
Ptr<Glib::ustring>::Ref title(new Glib::ustring( Ptr<Glib::ustring>::Ref title(new Glib::ustring(
nameEntry->get_text())); nameEntry->get_text()));