diff --git a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx index 8d9751609..bd7519d22 100644 --- a/livesupport/products/gLiveSupport/src/DjBagWindow.cxx +++ b/livesupport/products/gLiveSupport/src/DjBagWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/Attic/DjBagWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -385,7 +385,6 @@ DjBagWindow :: onSchedulePlaylist(void) throw () Ptr::Ref storage = gLiveSupport->getStorage(); - // append the appropriate playable object to the end of the playlist if (!storage->existsPlaylist(sessionId, uid)) { return; } @@ -401,7 +400,6 @@ DjBagWindow :: onSchedulePlaylist(void) throw () } Ptr::Ref scheduleWindow; - scheduleWindow.reset(new SchedulePlaylistWindow(gLiveSupport, bundle, playlist)); diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index daa9b2a4d..aa39a4b10 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.12 $ + Version : $Revision: 1.13 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ ------------------------------------------------------------------------------*/ @@ -329,14 +329,53 @@ GLiveSupport :: uploadFile(Ptr::Ref title, /*------------------------------------------------------------------------------ - * Upload a file to the server. + * Open a playlist for editing. + *----------------------------------------------------------------------------*/ +Ptr::Ref +LiveSupport :: GLiveSupport :: +GLiveSupport :: openPlaylistForEditing(Ptr::Ref playlistId) + throw (XmlRpcException) +{ + releaseEditedPlaylist(); + + if (!playlistId.get()) { + editedPlaylist = storage->createPlaylist(sessionId); + playlistId = editedPlaylist->getId(); + } + + editedPlaylist = storage->editPlaylist(sessionId, playlistId); + + return editedPlaylist; +} + + +/*------------------------------------------------------------------------------ + * Release the edited playlist. *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: addToPlaylist(Ptr::Ref id) throw () +GLiveSupport :: releaseEditedPlaylist(void) + throw (XmlRpcException) +{ + if (editedPlaylist.get()) { + if (editedPlaylist->isLocked()) { + storage->releasePlaylist(sessionId, editedPlaylist); + } + editedPlaylist.reset(); + } +} + + +/*------------------------------------------------------------------------------ + * Add a playlist to the currently edited playlist + *----------------------------------------------------------------------------*/ +void +LiveSupport :: GLiveSupport :: +GLiveSupport :: addToPlaylist(Ptr::Ref id) + throw (XmlRpcException) { if (!editedPlaylist.get()) { - editedPlaylist = storage->createPlaylist(sessionId); + openPlaylistForEditing(); } // for some wierd reason, the storage functions won't accept @@ -361,14 +400,16 @@ GLiveSupport :: addToPlaylist(Ptr::Ref id) throw () *----------------------------------------------------------------------------*/ Ptr::Ref LiveSupport :: GLiveSupport :: -GLiveSupport :: uploadPlaylist(Ptr::Ref title) +GLiveSupport :: savePlaylist(void) throw (XmlRpcException) { - editedPlaylist->setTitle(title); - storage->savePlaylist(sessionId, editedPlaylist); + Ptr::Ref playlist = storage->getPlaylist(sessionId, + editedPlaylist->getId()); + // add the saved playlist to the DJ Bag, and update it + // TODO: if already in the DJ bag, don't add, just pop it to the front djBagContents->push_front(editedPlaylist); masterPanel->updateDjBagWindow(); @@ -385,11 +426,8 @@ GLiveSupport :: schedulePlaylist(Ptr::Ref playlist, Ptr::Ref playtime) throw (XmlRpcException) { -std::cerr << "schedulePlaylist #1" << std::endl; scheduler->uploadPlaylist(sessionId, playlist->getId(), playtime); -std::cerr << "schedulePlaylist #2" << std::endl; masterPanel->updateSchedulerWindow(playtime); -std::cerr << "schedulePlaylist #3" << std::endl; } diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index 0a71971d5..40aa0e7e8 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.14 $ + Version : $Revision: 1.15 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ ------------------------------------------------------------------------------*/ @@ -95,7 +95,7 @@ class MasterPanelWindow; * respective documentation. * * @author $Author: maroy $ - * @version $Revision: 1.14 $ + * @version $Revision: 1.15 $ * @see LocalizedObject#getBundle(const xmlpp::Element &) * @see AuthenticationClientFactory * @see StorageClientFactory @@ -369,29 +369,61 @@ class GLiveSupport : public LocalizedConfigurable, return editedPlaylist; } + /** + * Create a new playlist or Open a playlist for editing. + * The opened playlist can be later accessed by getEditedPlaylist(). + * Always release the opened playlist by calling + * releaseEditedPlaylist() + * + * @param playlistId the id of the playlist to open for editing. + * if a reference to 0, create a new playlist. + * @return the new playlist object, which is opened for editing. + * @exception XmlRpcException on XMl-RPC errors. + * @see #getEditedPlaylist + * @see #releaseEditedPlaylist + */ + Ptr::Ref + openPlaylistForEditing( + Ptr::Ref playlistId = Ptr::Ref()) + throw (XmlRpcException); + /** * Add a playable item to the currently open playlist. * If there is no currently open playlist, open the simple playlist * management window with a new playlist, holding only this one * entry. + * Always release the opened playlist by calling + * releaseEditedPlaylist() * * @param id the id of the playable object to add to the playlist. + * @exception XmlRpcException on XMl-RPC errors. + * @see #releaseEditedPlaylist */ void - addToPlaylist(Ptr::Ref id) throw (); - + addToPlaylist(Ptr::Ref id) + throw (XmlRpcException); /** * Save the currently edited playlist in storage. + * This call has to be preceeded by a call to openPlaylistForEditing() + * or addToPlaylist(). * - * @param title the title of the audio clip. - * @return the audio clip that was uploaded. + * @return the audio clip that was saved. * @exception XmlRpcException on upload failures. + * @see #openPlaylistForEditing + * @see #addToPlaylist */ Ptr::Ref - uploadPlaylist(Ptr::Ref title) - throw (XmlRpcException); + savePlaylist(void) throw (XmlRpcException); + + /** + * Release the playlist that was opened for editing. + * + * @exception XmlRpcException on XML-RPC errors. + * @see #openPlaylistForEditing + */ + void + releaseEditedPlaylist(void) throw (XmlRpcException); - /** * Return the scheduled entries for a specified time interval. * diff --git a/livesupport/products/gLiveSupport/src/SchedulePlaylistWindow.cxx b/livesupport/products/gLiveSupport/src/SchedulePlaylistWindow.cxx index a5b1ede5a..6206a7cb3 100644 --- a/livesupport/products/gLiveSupport/src/SchedulePlaylistWindow.cxx +++ b/livesupport/products/gLiveSupport/src/SchedulePlaylistWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SchedulePlaylistWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -82,7 +82,10 @@ SchedulePlaylistWindow :: SchedulePlaylistWindow ( std::cerr << e.what() << std::endl; } - playlistLabel.reset(new Gtk::Label(*playlist->getTitle())); +// the title is lost, for some reason, see +// http://bugs.campware.org/view.php?id=534 +// playlistLabel.reset(new Gtk::Label(*playlist->getTitle())); + playlistLabel.reset(new Gtk::Label("TODO: playlist title here")); calendar.reset(new Gtk::Calendar()); hourEntry.reset(new Gtk::Entry()); minuteEntry.reset(new Gtk::Entry()); @@ -154,11 +157,6 @@ SchedulePlaylistWindow :: onScheduleButtonClicked (void) throw () return; } - std::cerr << "selected time: " << *selectedTime << std::endl; - std::cerr << "playist: " << playlist->getId()->getId() - << ", " << *playlist->getTitle() - << std::endl; - try { gLiveSupport->schedulePlaylist(playlist, selectedTime); } catch (XmlRpcException &e) { diff --git a/livesupport/products/gLiveSupport/src/SchedulerWindow.cxx b/livesupport/products/gLiveSupport/src/SchedulerWindow.cxx index 536eab00a..622603991 100644 --- a/livesupport/products/gLiveSupport/src/SchedulerWindow.cxx +++ b/livesupport/products/gLiveSupport/src/SchedulerWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SchedulerWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -196,6 +196,7 @@ SchedulerWindow :: showContents(void) throw () *midnight)); entries = gLiveSupport->displaySchedule(from, to); + it = entries->begin(); end = entries->end(); entriesModel->clear(); @@ -217,7 +218,10 @@ SchedulerWindow :: showContents(void) throw () row[entryColumns->idColumn] = entry->getId(); row[entryColumns->startColumn] = to_simple_string(*entry->getStartTime()); - row[entryColumns->titleColumn] = *playlist->getTitle(); +// the title is lost, for some reason, see +// http://bugs.campware.org/view.php?id=534 +// row[entryColumns->titleColumn] = *playlist->getTitle(); + row[entryColumns->titleColumn] = "TODO: playlist title here"; row[entryColumns->endColumn] = to_simple_string(*entry->getEndTime()); ++it; diff --git a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx index dee4ed9c7..13f890b20 100644 --- a/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx +++ b/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/SimplePlaylistManagementWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -145,11 +145,21 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () title.reset(new Glib::ustring(nameEntry->get_text())); - playlist = gLiveSupport->uploadPlaylist(title); + playlist = gLiveSupport->getEditedPlaylist(); + playlist->setTitle(title); - Glib::ustring statusText("uploaded playlist "); - statusText += *playlist->getTitle(); - statusBar->set_text(statusText); + playlist = gLiveSupport->savePlaylist(); + + Ptr::Ref uTitle = ustringToUnicodeString( + playlist->getTitle()); + Formattable arguments[] = { *uTitle }; + Ptr::Ref statusText = formatMessageUstring( + "playlistSavedMessage", + arguments, + 1); + statusBar->set_text(*statusText); + + gLiveSupport->releaseEditedPlaylist(); } catch (XmlRpcException &e) { statusBar->set_text(e.what()); } @@ -162,6 +172,8 @@ SimplePlaylistManagementWindow :: onSaveButtonClicked (void) throw () void SimplePlaylistManagementWindow :: onCloseButtonClicked (void) throw () { + gLiveSupport->releaseEditedPlaylist(); + hide(); } diff --git a/livesupport/products/gLiveSupport/var/hu.txt b/livesupport/products/gLiveSupport/var/hu.txt index e75c28761..8f2889bf8 100644 --- a/livesupport/products/gLiveSupport/var/hu.txt +++ b/livesupport/products/gLiveSupport/var/hu.txt @@ -84,6 +84,7 @@ hu:table saveButtonLabel:string { "elment" } closeButtonLabel:string { "bezár" } statusBar:string { "állapotsor" } + playlistSavedMessage:string { "playlist {0} elmentve" } } schedulerWindow:table diff --git a/livesupport/products/gLiveSupport/var/root.txt b/livesupport/products/gLiveSupport/var/root.txt index 5356363ee..af6252d47 100644 --- a/livesupport/products/gLiveSupport/var/root.txt +++ b/livesupport/products/gLiveSupport/var/root.txt @@ -84,6 +84,7 @@ root:table saveButtonLabel:string { "save" } closeButtonLabel:string { "close" } statusBar:string { "status bar" } + playlistSavedMessage:string { "saved playlist {0}" } } schedulerWindow:table