+ * root node, together with an XML header.
+ *
+ * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
+ * time durations have the format "hh:mm:ss.ssssss".
+ *
+ * The audio clip or playlist can be completely reconstructed from
+ * the string returned by this method:
+ *
+ * Ptr::Ref audioClip1 = ... something ...;
+ * Ptr::Ref parser;
+ * parser->parse_memory(*audioClip1->getXmlDocumentString());
+ * const xmlpp::Document* document = parser->get_document();
+ * const xmlpp::Element* root = document->get_root_node();
+ * Ptr::Ref audioClip2(new AudioClip());
+ * audioClip2->configure(*root);
+ *
+ * results in two identical audio clips (and the same works for
+ * playlists, too).
+ *
+ * The XML document has the (pseudo-) DTD
*
* <!ELEMENT audioClip (metadata) >
* <!ATTLIST audioClip id NMTOKEN #REQUIRED >
@@ -484,10 +509,10 @@ class AudioClip : public Configurable,
* it was created by the default constructor or the constructor
* which takes a unique ID only), a null pointer is returned.
*
- * @return a string representation of the metadata in XML
+ * @return a string representation of the audio clip as an XML document
*/
- Ptr::Ref
- getMetadataString() throw ();
+ virtual Ptr::Ref
+ getXmlDocumentString(void) throw ();
/**
diff --git a/livesupport/modules/core/include/LiveSupport/Core/FadeInfo.h b/livesupport/modules/core/include/LiveSupport/Core/FadeInfo.h
index 91ee45786..ef2151868 100644
--- a/livesupport/modules/core/include/LiveSupport/Core/FadeInfo.h
+++ b/livesupport/modules/core/include/LiveSupport/Core/FadeInfo.h
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.5 $
+ Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/FadeInfo.h,v $
------------------------------------------------------------------------------*/
@@ -89,7 +89,7 @@ using namespace boost::posix_time;
*
*
* @author $Author: fgerlits $
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
class FadeInfo : public Configurable
{
@@ -221,12 +221,20 @@ class FadeInfo : public Configurable
}
/**
- * Return an XML representation of this FadeInfo object.
+ * Return an XML representation of this fadeInfo element.
+ *
+ * This is a string containing a single
+ * XML element, which is empty, and has a fadeIn and a fadeOut
+ * argument (of format hh:mm:ss.ssssss).
*
- * @return a string representation of the audio clip in XML
+ * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
+ * time durations have the format "hh:mm:ss.ssssss".
+ *
+ * @return a string representation of the audio clip as an XML element
*/
- virtual Ptr::Ref
- getXmlString(void) throw ();
+ Ptr::Ref
+ getXmlElementString(void) throw ();
+
};
diff --git a/livesupport/modules/core/include/LiveSupport/Core/Playable.h b/livesupport/modules/core/include/LiveSupport/Core/Playable.h
index a54d8fd04..121957b44 100644
--- a/livesupport/modules/core/include/LiveSupport/Core/Playable.h
+++ b/livesupport/modules/core/include/LiveSupport/Core/Playable.h
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.7 $
+ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playable.h,v $
------------------------------------------------------------------------------*/
@@ -73,7 +73,7 @@ using namespace boost::posix_time;
* It contains the methods which are common to these classes.
*
* @author $Author: fgerlits $
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
class Playable : public boost::enable_shared_from_this
{
@@ -213,13 +213,50 @@ class Playable : public boost::enable_shared_from_this
throw () = 0;
/**
- * Return an XML representation of this audio clip or playlist.
- * This consists of minimal information only, without any metadata.
+ * Return a partial XML representation of this audio clip or playlist.
+ *
+ * This is a string containing a single or
+ * XML element, with minimal information (ID, title, playlength)
+ * only, without an XML header or any other metadata.
*
- * @return a string representation of the audio clip in XML
+ * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
+ * time durations have the format "hh:mm:ss.ssssss".
+ *
+ * @return a string representation of the audio clip as an XML element
*/
- virtual Ptr::Ref
- getXmlString(void) throw () = 0;
+ virtual Ptr::Ref
+ getXmlElementString(void) throw () = 0;
+
+
+ /**
+ * Return a complete XML representation of this audio clip or playlist.
+ *
+ * This is a string containing a an XML document with an
+ * or root node, together with an XML header and a
+ * element (in the case of playlists, for the outermost
+ * playlist only).
+ *
+ * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
+ * time durations have the format "hh:mm:ss.ssssss".
+ *
+ * The audio clip or playlist can be reconstructed from
+ * the string returned by this method:
+ *
+ * Ptr::Ref audioClip1 = ... something ...;
+ * Ptr::Ref parser;
+ * parser->parse_memory(*audioClip1->getXmlDocumentString());
+ * const xmlpp::Document* document = parser->get_document();
+ * const xmlpp::Element* root = document->get_root_node();
+ * Ptr::Ref audioClip2(new AudioClip());
+ * audioClip2->configure(*root);
+ *
+ * results in two identical audio clips (this works for playlists,
+ * too, but see the note at Playlist::getXmlDocumentString()).
+ *
+ * @return a string representation of the audio clip as an XML document
+ */
+ virtual Ptr::Ref
+ getXmlDocumentString(void) throw () = 0;
/**
diff --git a/livesupport/modules/core/include/LiveSupport/Core/Playlist.h b/livesupport/modules/core/include/LiveSupport/Core/Playlist.h
index f6c13117a..a614e6655 100644
--- a/livesupport/modules/core/include/LiveSupport/Core/Playlist.h
+++ b/livesupport/modules/core/include/LiveSupport/Core/Playlist.h
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.29 $
+ Version : $Revision: 1.30 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Playlist.h,v $
------------------------------------------------------------------------------*/
@@ -93,7 +93,7 @@ using namespace boost::posix_time;
*
*
* @author $Author: fgerlits $
- * @version $Revision: 1.29 $
+ * @version $Revision: 1.30 $
*/
class Playlist : public Configurable,
public Playable
@@ -129,16 +129,6 @@ class Playlist : public Configurable,
*/
Ptr::Ref token;
- /**
- * Flag set if playlist is currently playing.
- */
- bool isLockedForPlaying;
-
- /**
- * Flag set if playlist is currently being edited.
- */
- bool isLockedForEditing;
-
/**
* A map type for storing the playlist elements associated with
* this playlist, indexed by their relative offsets.
@@ -169,15 +159,30 @@ class Playlist : public Configurable,
/**
- * The type for storing the metadata.
+ * This playlist in XML format.
*/
- typedef std::map::Ref>
- metadataType;
+ Ptr::Ref xmlPlaylist;
/**
- * The metadata for this playlist.
+ * Set the value of a metadata field in this playlist.
+ *
+ * @param value the new value of the metadata field.
+ * @param name the name of the metadata field (without prefix)
+ * @param prefix the prefix of the metadata field
*/
- metadataType metadata;
+ void
+ setMetadata(Ptr::Ref value,
+ const std::string &name, const std::string &prefix)
+ throw ();
+
+ /**
+ * Set the total playing length of this playlist.
+ *
+ * @param the playing length in microseconds precision.
+ */
+ void
+ setPlaylength(Ptr::Ref playlength)
+ throw ();
public:
@@ -221,8 +226,6 @@ class Playlist : public Configurable,
: Playable(PlaylistType)
{
elementList.reset(new PlaylistElementListType);
- this->isLockedForPlaying = false;
- this->isLockedForEditing = false;
}
/**
@@ -236,8 +239,6 @@ class Playlist : public Configurable,
this->id = id;
elementList.reset(new PlaylistElementListType);
- this->isLockedForPlaying = false;
- this->isLockedForEditing = false;
}
/**
@@ -254,18 +255,7 @@ class Playlist : public Configurable,
Playlist(Ptr::Ref id,
Ptr::Ref playlength,
Ptr::Ref uri = Ptr::Ref())
- throw ()
- : Playable(PlaylistType)
- {
- this->id = id;
- this->title.reset(new Glib::ustring(""));
- this->playlength = playlength;
- this->uri = uri;
-
- elementList.reset(new PlaylistElementListType);
- this->isLockedForPlaying = false;
- this->isLockedForEditing = false;
- }
+ throw ();
/**
* Create a playlist by specifying all details.
@@ -282,18 +272,7 @@ class Playlist : public Configurable,
Ptr::Ref title,
Ptr::Ref playlength,
Ptr::Ref uri = Ptr::Ref())
- throw ()
- : Playable(PlaylistType)
- {
- this->id = id;
- this->title = title;
- this->playlength = playlength;
- this->uri = uri;
-
- elementList.reset(new PlaylistElementListType);
- this->isLockedForPlaying = false;
- this->isLockedForEditing = false;
- }
+ throw ();
/**
* A virtual destructor, as this class has virtual functions.
@@ -339,10 +318,32 @@ class Playlist : public Configurable,
return id;
}
+
+ /**
+ * Return the title of this playlist.
+ *
+ * @return the title.
+ */
+ virtual Ptr::Ref
+ getTitle(void) const throw ()
+ {
+ return title;
+ }
+
+ /**
+ * Set the title of this playlist.
+ *
+ * @param title a new title.
+ */
+ virtual void
+ setTitle(Ptr::Ref title)
+ throw ();
+
+
/**
* Return the total playing length for this playlist.
*
- * @return the playing length in microseconds.
+ * @return the playing length in microseconds precision.
*/
virtual Ptr::Ref
getPlaylength(void) const throw ()
@@ -400,47 +401,16 @@ class Playlist : public Configurable,
}
/**
- * Test whether the playlist is locked for editing or playing.
+ * Test whether the playlist is locked for editing.
*
- * @return true if the playlist is currently being edited or
- * played; false otherwise
+ * @return true if the playlist is currently being edited
*/
bool
isLocked() const throw ()
{
- return isLockedForEditing || isLockedForPlaying;
+ return (token.get() != 0);
}
- /**
- * Test whether the playlist is currently available for editing.
- *
- * @return true if the playlist is available, false otherwise
- */
- bool
- canBeEdited() const throw ()
- {
- return isLockedForEditing && !isLockedForPlaying;
- }
-
- /**
- * Lock or unlock the playlist for editing.
- *
- * @return true if successfully obtained or released lock;
- * false otherwise.
- */
- bool
- setLockedForEditing(const bool lockStatus)
- throw ();
-
- /**
- * Lock or unlock the playlist for playing.
- *
- * @return true if successfully obtained or released lock;
- * false otherwise.
- */
- bool
- setLockedForPlaying(const bool lockStatus)
- throw ();
/**
* The iterator type for this class. A Playlist::const_iterator
@@ -503,11 +473,11 @@ class Playlist : public Configurable,
* @exception std::invalid_argument if the playlist already contains
* a playlist element with the same relative offset
*/
- void
- addAudioClip(Ptr::Ref audioClip,
- Ptr::Ref relativeOffset,
- Ptr::Ref fadeInfo
- = Ptr::Ref())
+ void
+ addAudioClip(Ptr::Ref audioClip,
+ Ptr::Ref relativeOffset,
+ Ptr::Ref fadeInfo
+ = Ptr::Ref())
throw (std::invalid_argument);
/**
@@ -524,11 +494,11 @@ class Playlist : public Configurable,
* @exception std::invalid_argument if the playlist already contains
* a playlist element with the same relative offset
*/
- void
- addPlaylist(Ptr::Ref playlist,
- Ptr::Ref relativeOffset,
- Ptr::Ref fadeInfo
- = Ptr::Ref())
+ void
+ addPlaylist(Ptr::Ref playlist,
+ Ptr::Ref relativeOffset,
+ Ptr::Ref fadeInfo
+ = Ptr::Ref())
throw (std::invalid_argument);
/**
@@ -540,9 +510,9 @@ class Playlist : public Configurable,
* @exception std::invalid_argument if there is no playlist element
* at the given relative offset
*/
- void
- setFadeInfo(Ptr::Ref relativeOffset,
- Ptr::Ref fadeInfo)
+ void
+ setFadeInfo(Ptr::Ref relativeOffset,
+ Ptr::Ref fadeInfo)
throw (std::invalid_argument);
/**
@@ -553,8 +523,8 @@ class Playlist : public Configurable,
* @exception std::invalid_argument if the playlist does not contain
* a playlist element at the specified relative offset
*/
- void
- removePlaylistElement(Ptr::Ref relativeOffset)
+ void
+ removePlaylistElement(Ptr::Ref relativeOffset)
throw (std::invalid_argument);
/**
@@ -562,56 +532,32 @@ class Playlist : public Configurable,
* If the playlength is the only thing amiss, playlist is considered
* valid, and the playlength is fixed. (Hence no 'const'.)
*/
- bool
- valid(void) throw ();
+ bool
+ valid(void) throw ();
/**
* Create a saved copy of this playlist. If a saved copy exists
* already, it is replaced by the current state.
*/
- void
- createSavedCopy(void) throw ();
+ void
+ createSavedCopy(void) throw ();
/**
* Delete the saved copy of the playlist, if exists (or do nothing).
*/
- void
- deleteSavedCopy(void) throw ()
- {
- savedCopy.reset();
- }
+ void
+ deleteSavedCopy(void) throw ()
+ {
+ savedCopy.reset();
+ }
/**
* Revert to the saved copy of this playlist. If there is no
* saved copy, do nothing and throw an exception.
*/
- void
- revertToSavedCopy(void) throw (std::invalid_argument);
-
-
- /**
- * Return the title of this playlist.
- *
- * @return the title.
- */
- virtual Ptr::Ref
- getTitle(void) const throw ()
- {
- return title;
- }
-
- /**
- * Set the title of this playlist.
- *
- * @param title a new title.
- */
- virtual void
- setTitle(Ptr::Ref title)
- throw ()
- {
- this->title = title;
- }
+ void
+ revertToSavedCopy(void) throw (std::invalid_argument);
/**
@@ -638,16 +584,55 @@ class Playlist : public Configurable,
/**
- * Return an XML representation of this audio clip.
- * This consists of minimal information (ID and playlength for
- * playlists; ID, playlength and title
- * for the audio clips, plus fade in / fade out info)
- * only, without any metadata.
+ * Return a partial XML representation of this audio clip or playlist.
+ *
+ * This is a string containing a single
+ * XML element, with minimal information (ID, title, playlength)
+ * only, without an XML header or any other metadata.
*
- * @return a string representation of the audio clip in XML
+ * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
+ * time durations have the format "hh:mm:ss.ssssss".
+ *
+ * @return a string representation of the playlist as an XML element
*/
- virtual Ptr::Ref
- getXmlString(void) throw ();
+ virtual Ptr::Ref
+ getXmlElementString(void) throw ();
+
+
+ /**
+ * Return a complete XML representation of this playlist.
+ *
+ * This is a string containing a an XML document with a
+ * root node, together with an XML header and a
+ * element (for the outermost playlist only).
+ *
+ * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
+ * time durations have the format "hh:mm:ss.ssssss".
+ *
+ * The playlist can be almost completely reconstructed from
+ * the string returned by this method:
+ *
+ * Ptr::Ref playlist1 = ... something ...;
+ * Ptr::Ref parser;
+ * parser->parse_memory(*playlist1->getXmlDocumentString());
+ * const xmlpp::Document* document = parser->get_document();
+ * const xmlpp::Element* root = document->get_root_node();
+ * Ptr::Ref playlist2(new Playlist());
+ * playlist2->configure(*root);
+ *
+ * results in two identical playlists if the audio clips
+ * and sub-playlists inside playlist1 do not contain any
+ * metadata other than title and playlength.
+ * All other metadata fields in the audio clips and sub-playlists
+ * will be lost.
+ *
+ * The uri and token fields are currently not part
+ * of the XML document string returned.
+ *
+ * @return a string representation of the playlist as an XML document
+ */
+ virtual Ptr::Ref
+ getXmlDocumentString(void) throw ();
};
diff --git a/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h b/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h
index e72999bf3..45e43804b 100644
--- a/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h
+++ b/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.10 $
+ Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/PlaylistElement.h,v $
------------------------------------------------------------------------------*/
@@ -104,7 +104,7 @@ class Playlist;
*
*
* @author $Author: fgerlits $
- * @version $Revision: 1.10 $
+ * @version $Revision: 1.11 $
*/
class PlaylistElement : public Configurable
{
@@ -369,14 +369,22 @@ class PlaylistElement : public Configurable
return fadeInfo;
}
+
/**
* Return an XML representation of this playlist element.
- * This consists of minimal information only, without any metadata.
+ *
+ * This is a string containing a single
+ * XML element, with its ID and relativeOffset attributes,
+ * plus an or XML element,
+ * plus an optional element.
*
- * @return a string representation of the audio clip in XML
+ * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers,
+ * time durations have the format "hh:mm:ss.ssssss".
+ *
+ * @return a string representation of the audio clip as an XML element
*/
- virtual Ptr::Ref
- getXmlString(void) throw ();
+ Ptr::Ref
+ getXmlElementString(void) throw ();
};
diff --git a/livesupport/modules/core/src/AudioClip.cxx b/livesupport/modules/core/src/AudioClip.cxx
index 616aada33..23da67dd6 100644
--- a/livesupport/modules/core/src/AudioClip.cxx
+++ b/livesupport/modules/core/src/AudioClip.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.19 $
+ Version : $Revision: 1.20 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClip.cxx,v $
------------------------------------------------------------------------------*/
@@ -52,9 +52,9 @@ using namespace LiveSupport::Core;
/* ================================================ local constants & macros */
-/*------------------------------------------------------------------------------
+/**
* The name of the config element for this class
- *----------------------------------------------------------------------------*/
+ */
const std::string AudioClip::configElementNameStr = "audioClip";
/**
@@ -273,8 +273,9 @@ AudioClip :: configure(const xmlpp::Element & element)
= dynamic_cast (*it);
xmlAudioClip.reset(new xmlpp::Document);
- xmlpp::Element* root = xmlAudioClip->create_root_node("audioClip");
- root->set_attribute("id", std::string(*id));
+ xmlpp::Element* root = xmlAudioClip->create_root_node(
+ configElementNameStr);
+ root->set_attribute(idAttrName, std::string(*id));
root->import_node(metadataElement, true); // true = recursive
const xmlpp::Node::NodeList dataFieldList
@@ -365,7 +366,8 @@ AudioClip :: getMetadata(const string &key) const
if (! rootNode) {
return value;
}
- xmlpp::Node::NodeList rootList = rootNode->get_children("metadata");
+ xmlpp::Node::NodeList rootList = rootNode->get_children(
+ metadataElementName);
if (rootList.size() == 0) {
return value;
}
@@ -420,19 +422,24 @@ AudioClip :: setMetadata(Ptr::Ref value,
title = value;
}
+ // create a new xmlpp::Document for the metadata if necessary
if (! xmlAudioClip) {
xmlAudioClip.reset(new xmlpp::Document);
}
xmlpp::Element* rootNode = xmlAudioClip->get_root_node();
if (! rootNode) {
- rootNode = xmlAudioClip->create_root_node("audioClip");
+ rootNode = xmlAudioClip->create_root_node(configElementNameStr);
+ if (id) {
+ rootNode->set_attribute(idAttrName, std::string(*id));
+ }
}
- xmlpp::Node::NodeList rootList = rootNode->get_children("metadata");
+ xmlpp::Node::NodeList rootList = rootNode->get_children(
+ metadataElementName);
xmlpp::Element* metadata;
if (rootList.size() > 0) {
metadata = dynamic_cast (rootList.front());
} else {
- metadata = rootNode->add_child("metadata");
+ metadata = rootNode->add_child(metadataElementName);
metadata->set_namespace_declaration(defaultPrefixUri);
metadata->set_namespace_declaration(titleElementUri,
titleElementPrefix);
@@ -440,6 +447,7 @@ AudioClip :: setMetadata(Ptr::Ref value,
extentElementPrefix);
}
+ // find the element to be modified
xmlpp::Node::NodeList nodeList = metadata->get_children(name);
xmlpp::Node::NodeList::iterator it = nodeList.begin();
xmlpp::Element* element = 0;
@@ -453,6 +461,7 @@ AudioClip :: setMetadata(Ptr::Ref value,
++it;
}
+ // or add it if it did not exist before
if (it == nodeList.end()) {
element = metadata->add_child(name);
try {
@@ -471,7 +480,7 @@ AudioClip :: setMetadata(Ptr::Ref value,
* Return a string containing the essential fields of this object, in XML.
*----------------------------------------------------------------------------*/
Ptr::Ref
-AudioClip :: getXmlString(void) throw ()
+AudioClip :: getXmlElementString(void) throw ()
{
Ptr::Ref xmlString(new Glib::ustring);
@@ -491,19 +500,26 @@ AudioClip :: getXmlString(void) throw ()
/*------------------------------------------------------------------------------
- * Return a string containing the metadata of the audio clip, in XML.
+ * Return a string containing an XML representation of this audio clip.
*----------------------------------------------------------------------------*/
Ptr::Ref
-AudioClip :: getMetadataString() throw ()
+AudioClip :: getXmlDocumentString() throw ()
{
- Ptr::Ref metadataString;
+ Ptr::Ref localDocument;
- if (!xmlAudioClip) {
- return metadataString;
+ if (xmlAudioClip) {
+ localDocument = xmlAudioClip;
+ } else {
+ localDocument.reset(new xmlpp::Document());
+ xmlpp::Element* rootNode = localDocument->create_root_node(
+ configElementNameStr);
+ if (id) {
+ rootNode->set_attribute(idAttrName, std::string(*id));
+ }
}
- metadataString.reset(new Glib::ustring(xmlAudioClip->write_to_string() ));
-
+ Ptr::Ref metadataString(new Glib::ustring(
+ localDocument->write_to_string() ));
return metadataString;
}
diff --git a/livesupport/modules/core/src/AudioClipTest.cxx b/livesupport/modules/core/src/AudioClipTest.cxx
index fe69a4599..9a4775147 100644
--- a/livesupport/modules/core/src/AudioClipTest.cxx
+++ b/livesupport/modules/core/src/AudioClipTest.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.9 $
+ Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/AudioClipTest.cxx,v $
------------------------------------------------------------------------------*/
@@ -131,14 +131,11 @@ AudioClipTest :: firstTest(void)
CPPUNIT_ASSERT(*alternativeTitle ==
"Alternative File Title ín sőmé %$#@* LÁNGŰAGÉ");
- CPPUNIT_ASSERT(*audioClip->getXmlString() ==
+ CPPUNIT_ASSERT(*audioClip->getXmlElementString() ==
"");
-//std::cerr << "\nxml: '" << *audioClip->getXmlString() << "'" << std::endl;
-//std::cerr << "\nmetadata: " << *audioClip->getMetadataString() << std::endl;
-
} catch (std::invalid_argument &e) {
CPPUNIT_FAIL("semantic error in configuration file");
} catch (xmlpp::exception &e) {
diff --git a/livesupport/modules/core/src/FadeInfo.cxx b/livesupport/modules/core/src/FadeInfo.cxx
index e51ecded5..b7ac846e1 100644
--- a/livesupport/modules/core/src/FadeInfo.cxx
+++ b/livesupport/modules/core/src/FadeInfo.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.4 $
+ Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/FadeInfo.cxx,v $
------------------------------------------------------------------------------*/
@@ -77,7 +77,7 @@ static const std::string fadeOutAttrName = "fadeOut";
*----------------------------------------------------------------------------*/
void
FadeInfo :: configure(const xmlpp::Element & element)
- throw (std::invalid_argument)
+ throw (std::invalid_argument)
{
if (element.get_name() != configElementNameStr) {
std::string eMsg = "bad configuration element ";
@@ -116,7 +116,7 @@ FadeInfo :: configure(const xmlpp::Element & element)
* Return a string containing the essential fields of this object, in XML.
*----------------------------------------------------------------------------*/
Ptr::Ref
-FadeInfo :: getXmlString(void) throw ()
+FadeInfo :: getXmlElementString(void) throw ()
{
Ptr::Ref xmlString(new Glib::ustring);
diff --git a/livesupport/modules/core/src/FadeInfoTest.cxx b/livesupport/modules/core/src/FadeInfoTest.cxx
index c6098d6da..a20c212b0 100644
--- a/livesupport/modules/core/src/FadeInfoTest.cxx
+++ b/livesupport/modules/core/src/FadeInfoTest.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.3 $
+ Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/FadeInfoTest.cxx,v $
------------------------------------------------------------------------------*/
@@ -117,7 +117,7 @@ FadeInfoTest :: firstTest(void)
CPPUNIT_ASSERT(fadeOut->seconds() == 1);
CPPUNIT_ASSERT(fadeOut->fractional_seconds() == 500);
- CPPUNIT_ASSERT(*fadeInfo->getXmlString() ==
+ CPPUNIT_ASSERT(*fadeInfo->getXmlElementString() ==
"");
diff --git a/livesupport/modules/core/src/Playlist.cxx b/livesupport/modules/core/src/Playlist.cxx
index 2362ec94e..051128de8 100644
--- a/livesupport/modules/core/src/Playlist.cxx
+++ b/livesupport/modules/core/src/Playlist.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.28 $
+ Version : $Revision: 1.29 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
------------------------------------------------------------------------------*/
@@ -46,9 +46,9 @@ using namespace LiveSupport::Core;
/* ================================================ local constants & macros */
-/*------------------------------------------------------------------------------
+/**
* The name of the config element for this class
- *----------------------------------------------------------------------------*/
+ */
const std::string Playlist::configElementNameStr = "playlist";
/**
@@ -71,12 +71,147 @@ static const std::string titleAttrName = "title";
*/
static const std::string elementListAttrName = "playlistElement";
+/**
+ * The name of the metadata child element.
+ */
+static const std::string metadataElementName = "metadata";
+
+/**
+ * The prefix of the extent (length) metadata element.
+ */
+static const std::string extentElementPrefix = "dcterms";
+
+/**
+ * The name of the extent (length) metadata element.
+ */
+static const std::string extentElementName = "extent";
+
+/**
+ * The URI identifier for the "dcterms" prefix
+ */
+static const std::string extentElementUri = "http://purl.org/dc/terms/";
+
+/**
+ * The prefix of the title metadata element.
+ */
+static const std::string titleElementPrefix = "dc";
+
+/**
+ * The name of the title metadata element.
+ */
+static const std::string titleElementName = "title";
+
+/**
+ * The URI identifier for the "dc" prefix
+ */
+static const std::string titleElementUri ="http://purl.org/dc/elements/1.1/";
+
+/**
+ * The URI identifier for the default XML namespace
+ */
+static const std::string defaultPrefixUri ="http://www.streamonthefly.org/";
+
/* =============================================== local function prototypes */
/* ============================================================= module code */
+/*------------------------------------------------------------------------------
+ * Copy constructor.
+ *----------------------------------------------------------------------------*/
+Playlist :: Playlist(const Playlist & otherPlaylist)
+ throw ()
+ : Playable(PlaylistType)
+{
+ id = otherPlaylist.id;
+ title = otherPlaylist.title;
+ playlength = otherPlaylist.playlength;
+ uri = otherPlaylist.uri;
+ token = otherPlaylist.token;
+
+ elementList.reset(new PlaylistElementListType(*otherPlaylist.elementList));
+
+ if (otherPlaylist.savedCopy) {
+ savedCopy.reset(new Playlist(*otherPlaylist.savedCopy));
+ }
+
+ if (otherPlaylist.xmlPlaylist) {
+ xmlPlaylist.reset(new xmlpp::Document);
+ xmlPlaylist->create_root_node_by_import(
+ otherPlaylist.xmlPlaylist->get_root_node(),
+ true); // true == recursive
+ }
+}
+
+
+/*------------------------------------------------------------------------------
+ * Test constructor without title.
+ *----------------------------------------------------------------------------*/
+Playlist :: Playlist(Ptr::Ref id,
+ Ptr::Ref playlength,
+ Ptr::Ref uri)
+ throw ()
+ : Playable(PlaylistType)
+{
+ this->id = id;
+ this->title.reset(new Glib::ustring(""));
+ this->playlength = playlength;
+ this->uri = uri;
+
+ elementList.reset(new PlaylistElementListType);
+
+ setTitle(title);
+ setPlaylength(playlength);
+}
+
+
+/*------------------------------------------------------------------------------
+ * Test constructor with title.
+ *----------------------------------------------------------------------------*/
+Playlist :: Playlist(Ptr::Ref id,
+ Ptr::Ref title,
+ Ptr::Ref playlength,
+ Ptr::Ref uri)
+ throw ()
+ : Playable(PlaylistType)
+{
+ this->id = id;
+ this->title = title;
+ this->playlength = playlength;
+ this->uri = uri;
+
+ elementList.reset(new PlaylistElementListType);
+
+ setTitle(title);
+ setPlaylength(playlength);
+}
+
+
+/*------------------------------------------------------------------------------
+ * Set the value of the title field.
+ *----------------------------------------------------------------------------*/
+void
+Playlist :: setTitle(Ptr::Ref title)
+ throw ()
+{
+ setMetadata(title, titleElementName, titleElementPrefix);
+}
+
+
+/*------------------------------------------------------------------------------
+ * Set the value of the playlength field (private).
+ *----------------------------------------------------------------------------*/
+void
+Playlist :: setPlaylength(Ptr::Ref playlength)
+ throw ()
+{
+ Ptr::Ref playlengthString(new const Glib::ustring(
+ to_simple_string(*playlength) ));
+ setMetadata(playlengthString, extentElementName, extentElementPrefix);
+}
+
+
/*------------------------------------------------------------------------------
* Create a playlist object based on an XML element.
*----------------------------------------------------------------------------*/
@@ -92,30 +227,29 @@ Playlist :: configure(const xmlpp::Element & element)
const xmlpp::Attribute * attribute;
- if (!(attribute = element.get_attribute(idAttrName))) {
- std::string eMsg = "missing attribute ";
- eMsg += idAttrName;
- throw std::invalid_argument(eMsg);
+ if (!id) {
+ if (!(attribute = element.get_attribute(idAttrName))) {
+ std::string eMsg = "missing attribute ";
+ eMsg += idAttrName;
+ throw std::invalid_argument(eMsg);
+ }
+ id.reset(new UniqueId(attribute->get_value()));
}
- id.reset(new UniqueId(attribute->get_value()));
-
- if (!(attribute = element.get_attribute(playlengthAttrName))) {
- std::string eMsg = "missing attribute ";
- eMsg += playlengthAttrName;
- throw std::invalid_argument(eMsg);
- }
- playlength.reset(new time_duration(
- duration_from_string(attribute->get_value())));
- Ptr::Ref playlengthString(new Glib::ustring(
- attribute->get_value() ));
- metadata["dcterms:extent"] = playlengthString;
- if ((attribute = element.get_attribute(titleAttrName))) {
- title.reset(new const Glib::ustring(attribute->get_value()));
- } else {
- title.reset(new const Glib::ustring(""));
+ if (!playlength
+ && (attribute = element.get_attribute(playlengthAttrName))) {
+ playlength.reset(new time_duration(
+ duration_from_string(attribute->get_value())));
+ Ptr::Ref playlengthString(new Glib::ustring(
+ attribute->get_value() ));
+ setMetadata(playlengthString, extentElementName, extentElementPrefix);
+ }
+
+ if (!title
+ && (attribute = element.get_attribute(titleAttrName))) {
+ title.reset(new const Glib::ustring(attribute->get_value()));
+ setMetadata(title, titleElementName, titleElementPrefix);
}
- metadata["dc:title"] = title;
xmlpp::Node::NodeList childNodes
= element.get_children(elementListAttrName);
@@ -129,35 +263,82 @@ Playlist :: configure(const xmlpp::Element & element)
addPlaylistElement(newPlaylistElement);
++it;
}
-
- isLockedForPlaying = false;
- isLockedForEditing = false;
-}
+ childNodes = element.get_children(metadataElementName);
+ it = childNodes.begin();
-/*------------------------------------------------------------------------------
- * Copy constructor.
- *----------------------------------------------------------------------------*/
-Playlist :: Playlist(const Playlist & otherPlaylist)
- throw ()
- : Playable(PlaylistType)
-{
- id = otherPlaylist.id;
- title = otherPlaylist.title;
- playlength = otherPlaylist.playlength;
- uri = otherPlaylist.uri;
- token = otherPlaylist.token;
+ if (it != childNodes.end()) {
+ const xmlpp::Element * metadataElement
+ = dynamic_cast (*it);
- isLockedForPlaying = otherPlaylist.isLockedForPlaying;
- isLockedForEditing = otherPlaylist.isLockedForEditing;
+ xmlPlaylist.reset(new xmlpp::Document);
+ xmlpp::Element* root = xmlPlaylist->create_root_node(
+ configElementNameStr);
+ root->set_attribute(idAttrName, std::string(*id));
+ root->import_node(metadataElement, true); // true = recursive
- elementList.reset(new PlaylistElementListType(*otherPlaylist.elementList));
-
- if (otherPlaylist.savedCopy) {
- savedCopy.reset(new Playlist(*otherPlaylist.savedCopy));
+ const xmlpp::Node::NodeList dataFieldList
+ = metadataElement->get_children();
+ xmlpp::Node::NodeList::const_iterator listIt = dataFieldList.begin();
+
+ while (listIt != dataFieldList.end()) {
+ const xmlpp::Node* dataNode = *listIt;
+ std::string prefix = dataNode->get_namespace_prefix();
+ std::string name = dataNode->get_name();
+ const xmlpp::Element*
+ dataElement
+ = dynamic_cast (dataNode);
+ if (!dataElement) {
+ ++listIt;
+ continue;
+ }
+
+ if (!playlength && prefix == extentElementPrefix
+ && name == extentElementName) {
+ if (dataElement->has_child_text()) {
+ playlength.reset(new time_duration(duration_from_string(
+ dataElement->get_child_text()->get_content() )));
+ } else { // or just leave blank? bad either way
+ playlength.reset(new time_duration(0,0,0,0));
+ }
+ }
+
+ if (!title && prefix == titleElementPrefix
+ && name == titleElementName) {
+ Glib::ustring value;
+ if (dataElement->has_child_text()) {
+ value = dataElement->get_child_text()->get_content();
+ } else {
+ value = "";
+ }
+ Ptr::Ref ptrToValue(
+ new const Glib::ustring(value));
+ title = ptrToValue;
+ }
+
+ ++listIt;
+ }
+
+ ++it;
+ if (it != childNodes.end()) {
+ std::string eMsg = "more than one ";
+ eMsg += metadataElementName;
+ eMsg += " XML element";
+ throw std::invalid_argument(eMsg);
+ }
+ }
+
+ if (!playlength) {
+ std::string eMsg = "missing attribute ";
+ eMsg += playlengthAttrName;
+ eMsg += " or metadata element ";
+ eMsg += extentElementPrefix + ":" + extentElementName;
+ throw std::invalid_argument(eMsg);
}
- metadata = otherPlaylist.metadata;
+ if (!title) {
+ title.reset(new const Glib::ustring(""));
+ }
}
@@ -202,7 +383,7 @@ Playlist::addAudioClip(Ptr::Ref audioClip,
*relativeOffset
+ *audioClip->getPlaylength()));
if (*endOffset > *playlength) {
- playlength = endOffset;
+ setPlaylength(endOffset);
}
}
@@ -229,7 +410,7 @@ Playlist::addPlaylist(Ptr::Ref playlist,
*relativeOffset
+ *playlist->getPlaylength()));
if (*endOffset > *playlength) {
- playlength = endOffset;
+ setPlaylength(endOffset);
}
}
@@ -269,52 +450,6 @@ Playlist::removePlaylistElement(Ptr::Ref relativeOffset)
}
-/*------------------------------------------------------------------------------
- * Lock or unlock the playlist for editing.
- *----------------------------------------------------------------------------*/
-bool
-Playlist::setLockedForEditing(const bool lockStatus)
- throw ()
-{
- if (lockStatus == true) {
- if (isLockedForPlaying || isLockedForEditing) {
- return false;
- } else {
- isLockedForEditing = true;
- return true;
- }
- } else {
- if (isLockedForPlaying) {
- return false;
- } else {
- isLockedForEditing = false;
- return true; // returns true also if playlist
- } // was already unlocked!
- }
-}
-
-
-/*------------------------------------------------------------------------------
- * Lock or unlock the playlist for playing.
- *----------------------------------------------------------------------------*/
-bool
-Playlist::setLockedForPlaying(const bool lockStatus)
- throw ()
-{
- if (lockStatus == true) {
- if (isLockedForPlaying) {
- return false;
- } else {
- isLockedForPlaying = true; // preserve LockedForEditing state
- return true;
- }
- } else {
- isLockedForPlaying = false; // restore LockedForEditing state;
- return true; // returns true also if playlist
- } // was already unlocked!
-}
-
-
/*------------------------------------------------------------------------------
* Validate the playlist.
*----------------------------------------------------------------------------*/
@@ -342,12 +477,12 @@ Playlist::valid(void) throw ()
return false;
}
*runningTime += *(playlist->getPlaylength());
- } else { // this should never happen
+ } else { // this should never happen
return false;
}
++it;
}
- playlength = runningTime; // fix playlength, if everything else is OK
+ setPlaylength(runningTime); // fix playlength, if everything else is OK
return true;
}
@@ -358,18 +493,7 @@ Playlist::valid(void) throw ()
void
Playlist::createSavedCopy(void) throw ()
{
- savedCopy = Ptr::Ref(new Playlist);
-
- savedCopy->id = this->id;
- savedCopy->playlength = this->playlength;
- savedCopy->isLockedForPlaying = this->isLockedForPlaying;
- savedCopy->isLockedForEditing = this->isLockedForEditing;
-
- // note: we create a new copy of the playlist element map, but not of the
- // individual playlist elements, which (i think) are immutable
- savedCopy->elementList.reset(new PlaylistElementListType(*elementList));
-
- savedCopy->savedCopy.reset();
+ savedCopy = Ptr::Ref(new Playlist(*this));
}
@@ -383,11 +507,13 @@ Playlist::revertToSavedCopy(void) throw (std::invalid_argument)
throw (std::invalid_argument("playlist has no saved copy"));
}
- this->id = savedCopy->id;
- this->playlength = savedCopy->playlength;
- this->isLockedForPlaying = savedCopy->isLockedForPlaying;
- this->isLockedForEditing = savedCopy->isLockedForEditing;
- this->elementList = savedCopy->elementList;
+ this->id = savedCopy->id;
+ this->title = savedCopy->title;
+ this->playlength = savedCopy->playlength;
+ this->uri = savedCopy->uri;
+ this->token = savedCopy->token;
+ this->elementList = savedCopy->elementList;
+ this->xmlPlaylist = savedCopy->xmlPlaylist;
savedCopy.reset();
}
@@ -400,35 +526,125 @@ Ptr::Ref
Playlist :: getMetadata(const string &key) const
throw ()
{
- metadataType::const_iterator it = metadata.find(key);
+ std::string name, prefix;
+ separateNameAndNameSpace(key, name, prefix);
- if (it != metadata.end()) {
- Ptr::Ref data(new Glib::ustring(*it->second));
- return data;
- } else {
- Ptr::Ref nullPointer;
- return nullPointer;
+ Ptr::Ref value;
+
+ if (! xmlPlaylist) {
+ return value;
}
+ xmlpp::Element* rootNode = xmlPlaylist->get_root_node();
+ if (! rootNode) {
+ return value;
+ }
+ xmlpp::Node::NodeList rootList = rootNode->get_children(
+ metadataElementName);
+ if (rootList.size() == 0) {
+ return value;
+ }
+
+ xmlpp::Node* metadata = rootList.front();
+ xmlpp::Node::NodeList nodeList = metadata->get_children(name);
+ xmlpp::Node::NodeList::iterator it = nodeList.begin();
+
+ while (it != nodeList.end()) {
+ xmlpp::Node* node = *it;
+ if (node->get_namespace_prefix() == prefix) {
+ xmlpp::Element* element = dynamic_cast (node);
+ value.reset(new Glib::ustring(element->get_child_text()
+ ->get_content()));
+ return value;
+ }
+ ++it;
+ }
+
+ return value;
}
/*------------------------------------------------------------------------------
- * Set the value of a metadata field.
+ * Set the value of a metadata field (public).
*----------------------------------------------------------------------------*/
void
Playlist :: setMetadata(Ptr::Ref value,
- const string &key)
+ const std::string &key)
throw ()
{
- metadata[key] = value;
-
- if (key == "dcterms:extent") {
- playlength.reset(new time_duration(duration_from_string(*value)));
+ std::string name, prefix;
+ separateNameAndNameSpace(key, name, prefix);
+ setMetadata(value, name, prefix);
+}
+
+
+/*------------------------------------------------------------------------------
+ * Set the value of a metadata field (private).
+ *----------------------------------------------------------------------------*/
+void
+Playlist :: setMetadata(Ptr::Ref value,
+ const std::string &name, const std::string &prefix)
+ throw ()
+{
+ if (prefix == extentElementPrefix && name == extentElementName) {
+ playlength.reset(new time_duration(
+ duration_from_string(*value) ));
}
- if (key == "dc:title") {
+ if (prefix == titleElementPrefix && name == titleElementName) {
title = value;
- }
+ }
+
+ // create a new xmlpp::Document for the metadata if necessary
+ if (! xmlPlaylist) {
+ xmlPlaylist.reset(new xmlpp::Document);
+ }
+ xmlpp::Element* rootNode = xmlPlaylist->get_root_node();
+ if (! rootNode) {
+ rootNode = xmlPlaylist->create_root_node(configElementNameStr);
+ if (id) {
+ rootNode->set_attribute(idAttrName, std::string(*id));
+ }
+ }
+ xmlpp::Node::NodeList rootList = rootNode->get_children(
+ metadataElementName);
+ xmlpp::Element* metadata;
+ if (rootList.size() > 0) {
+ metadata = dynamic_cast (rootList.front());
+ } else {
+ metadata = rootNode->add_child(metadataElementName);
+ metadata->set_namespace_declaration(defaultPrefixUri);
+ metadata->set_namespace_declaration(titleElementUri,
+ titleElementPrefix);
+ metadata->set_namespace_declaration(extentElementUri,
+ extentElementPrefix);
+ }
+
+ // find the element to be modified
+ xmlpp::Node::NodeList nodeList = metadata->get_children(name);
+ xmlpp::Node::NodeList::iterator it = nodeList.begin();
+ xmlpp::Element* element = 0;
+
+ while (it != nodeList.end()) {
+ xmlpp::Node* node = *it;
+ if (node->get_namespace_prefix() == prefix) {
+ element = dynamic_cast (nodeList.front());
+ break;
+ }
+ ++it;
+ }
+
+ // or add it if it did not exist before
+ if (it == nodeList.end()) {
+ element = metadata->add_child(name);
+ try {
+ element->set_namespace(prefix);
+ }
+ catch (xmlpp::exception &e) {
+ // this namespace has not been declared; well OK, do nothing then
+ }
+ }
+
+ element->set_child_text(*value);
}
@@ -436,7 +652,7 @@ Playlist :: setMetadata(Ptr::Ref value,
* Return a string containing the essential fields of this object, in XML.
*----------------------------------------------------------------------------*/
Ptr::Ref
-Playlist :: getXmlString(void) throw ()
+Playlist :: getXmlElementString(void) throw ()
{
Ptr::Ref xmlString(new Glib::ustring);
@@ -451,10 +667,10 @@ Playlist :: getXmlString(void) throw ()
xmlString->append(Glib::ustring(titleAttrName) + "=\""
+ *getTitle()
+ "\">\n");
-
+
PlaylistElementListType::const_iterator it = elementList->begin();
while (it != elementList->end()) {
- xmlString->append(*it->second->getXmlString() + "\n");
+ xmlString->append(*it->second->getXmlElementString() + "\n");
++it;
}
@@ -464,3 +680,40 @@ Playlist :: getXmlString(void) throw ()
return xmlString;
}
+
+/*------------------------------------------------------------------------------
+ * Return a string containing an XML representation of this playlist.
+ *----------------------------------------------------------------------------*/
+Ptr::Ref
+Playlist :: getXmlDocumentString() throw ()
+{
+ Ptr::Ref localDocument;
+
+ if (xmlPlaylist) {
+ localDocument = xmlPlaylist;
+ } else {
+ localDocument.reset(new xmlpp::Document());
+ xmlpp::Element* rootNode = localDocument->create_root_node(
+ configElementNameStr);
+ if (id) {
+ rootNode->set_attribute(idAttrName, std::string(*id));
+ }
+ }
+
+ Glib::ustring playlistElementsXmlString("\n");
+ Playlist::const_iterator it = this->begin();
+ while (it != this->end()) {
+ playlistElementsXmlString += *(it->second->getXmlElementString());
+ playlistElementsXmlString += '\n';
+ ++it;
+ }
+
+ Ptr::Ref metadataString(new Glib::ustring(
+ localDocument->write_to_string() ));
+ unsigned int insertPosition = metadataString->find(metadataElementName);
+ insertPosition = metadataString->rfind('<', insertPosition);
+ metadataString->insert(insertPosition, playlistElementsXmlString);
+
+ return metadataString;
+}
+
diff --git a/livesupport/modules/core/src/PlaylistElement.cxx b/livesupport/modules/core/src/PlaylistElement.cxx
index b5a3e93cf..4edf765e1 100644
--- a/livesupport/modules/core/src/PlaylistElement.cxx
+++ b/livesupport/modules/core/src/PlaylistElement.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.10 $
+ Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistElement.cxx,v $
------------------------------------------------------------------------------*/
@@ -189,7 +189,7 @@ PlaylistElement :: configure(const xmlpp::Element & element)
* Return a string containing the essential fields of this object, in XML.
*----------------------------------------------------------------------------*/
Ptr::Ref
-PlaylistElement :: getXmlString(void) throw ()
+PlaylistElement :: getXmlElementString(void) throw ()
{
Ptr::Ref xmlString(new Glib::ustring);
@@ -201,9 +201,9 @@ PlaylistElement :: getXmlString(void) throw ()
xmlString->append(relativeOffsetAttrName + "=\""
+ to_simple_string(*relativeOffset)
+ "\">\n");
- xmlString->append(*getPlayable()->getXmlString() + "\n");
+ xmlString->append(*getPlayable()->getXmlElementString() + "\n");
if (fadeInfo) {
- xmlString->append(*fadeInfo->getXmlString() + "\n");
+ xmlString->append(*fadeInfo->getXmlElementString() + "\n");
}
xmlString->append("");
xmlString->append(configElementNameStr + ">");
diff --git a/livesupport/modules/core/src/PlaylistElementTest.cxx b/livesupport/modules/core/src/PlaylistElementTest.cxx
index f68debf41..c98bd627b 100644
--- a/livesupport/modules/core/src/PlaylistElementTest.cxx
+++ b/livesupport/modules/core/src/PlaylistElementTest.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.7 $
+ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistElementTest.cxx,v $
------------------------------------------------------------------------------*/
@@ -148,7 +148,7 @@ PlaylistElementTest :: firstTest(void)
CPPUNIT_ASSERT(playlistElement->getType()
== PlaylistElement::AudioClipType);
- CPPUNIT_ASSERT(*playlistElement->getXmlString() ==
+ CPPUNIT_ASSERT(*playlistElement->getXmlElementString() ==
"\n"
"total_seconds() == 34);
CPPUNIT_ASSERT(playlist->valid());
- CPPUNIT_ASSERT(*playlist->getXmlString() ==
-"\n"
+ CPPUNIT_ASSERT(*playlist->getXmlElementString() ==
+"\n"
"\n"
"\n"
"\n"
@@ -144,7 +145,6 @@ PlaylistTest :: firstTest(void)
== PlaylistElement::AudioClipType);
CPPUNIT_ASSERT(playlistElement->getAudioClip()->getId()->getId()
== 0x10001);
-
++it;
CPPUNIT_ASSERT(it != playlist->end());
playlistElement = it->second;
@@ -157,36 +157,8 @@ PlaylistTest :: firstTest(void)
== 0x10002);
++it;
-// CPPUNIT_ASSERT(it == playlist->end());
-}
-
-
-/*------------------------------------------------------------------------------
- * Test to see if locking works
- *----------------------------------------------------------------------------*/
-void
-PlaylistTest :: lockTest(void)
- throw (CPPUNIT_NS::Exception)
-{
- CPPUNIT_ASSERT(!playlist->isLocked());
- CPPUNIT_ASSERT(!playlist->canBeEdited());
-
- CPPUNIT_ASSERT(playlist->setLockedForEditing(true));
- CPPUNIT_ASSERT(playlist->isLocked());
- CPPUNIT_ASSERT(playlist->canBeEdited());
- CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
-
- CPPUNIT_ASSERT(playlist->setLockedForPlaying(true));
- CPPUNIT_ASSERT(playlist->isLocked());
- CPPUNIT_ASSERT(!playlist->canBeEdited());
- CPPUNIT_ASSERT(!playlist->setLockedForEditing(true));
- CPPUNIT_ASSERT(!playlist->setLockedForEditing(false));
- CPPUNIT_ASSERT(!playlist->setLockedForPlaying(true));
-
- CPPUNIT_ASSERT(playlist->setLockedForPlaying(false));
- CPPUNIT_ASSERT(playlist->isLocked());
- CPPUNIT_ASSERT(playlist->canBeEdited());
- CPPUNIT_ASSERT(playlist->setLockedForEditing(false));
+ ++it;
+ CPPUNIT_ASSERT(it == playlist->end());
}
diff --git a/livesupport/modules/core/src/PlaylistTest.h b/livesupport/modules/core/src/PlaylistTest.h
index 8dd419080..aa72ad85e 100644
--- a/livesupport/modules/core/src/PlaylistTest.h
+++ b/livesupport/modules/core/src/PlaylistTest.h
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.9 $
+ Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.h,v $
------------------------------------------------------------------------------*/
@@ -58,14 +58,13 @@ namespace Core {
* Unit test for the UploadPlaylistMetohd class.
*
* @author $Author: fgerlits $
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
* @see Playlist
*/
class PlaylistTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(PlaylistTest);
CPPUNIT_TEST(firstTest);
- CPPUNIT_TEST(lockTest);
CPPUNIT_TEST(audioClipTest);
CPPUNIT_TEST(savedCopyTest);
CPPUNIT_TEST(fadeInfoTest);
@@ -89,14 +88,6 @@ class PlaylistTest : public CPPUNIT_NS::TestFixture
void
firstTest(void) throw (CPPUNIT_NS::Exception);
- /**
- * Testing the locks.
- *
- * @exception CPPUNIT_NS::Exception on test failures.
- */
- void
- lockTest(void) throw (CPPUNIT_NS::Exception);
-
/**
* Trying to add a new audio clip.
*
diff --git a/livesupport/modules/storage/src/WebStorageClient.cxx b/livesupport/modules/storage/src/WebStorageClient.cxx
index 6153a7e3c..e913f78fd 100644
--- a/livesupport/modules/storage/src/WebStorageClient.cxx
+++ b/livesupport/modules/storage/src/WebStorageClient.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.35 $
+ Version : $Revision: 1.36 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/WebStorageClient.cxx,v $
------------------------------------------------------------------------------*/
@@ -352,12 +352,6 @@ static const std::string editPlaylistTokenParamName = "token";
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ storage server constants: savePlaylist */
-/*------------------------------------------------------------------------------
- * XML header string
- *----------------------------------------------------------------------------*/
-static const Glib::ustring xmlHeaderString
- = "";
-
/*------------------------------------------------------------------------------
* The name of the 'save playlist' method on the storage server
*----------------------------------------------------------------------------*/
@@ -1054,7 +1048,7 @@ WebStorageClient :: savePlaylist(Ptr::Ref sessionId,
parameters[savePlaylistTokenParamName]
= *playlist->getToken();
parameters[savePlaylistNewPlaylistParamName]
- = std::string(xmlHeaderString + *playlist->getXmlString());
+ = std::string(*playlist->getXmlDocumentString());
result.clear();
if (!xmlRpcClient.execute(savePlaylistMethodName.c_str(),
@@ -1505,7 +1499,7 @@ WebStorageClient :: storeAudioClip(Ptr::Ref sessionId,
= std::string(*audioClip->getId());
}
parameters[storeAudioClipMetadataParamName]
- = std::string(*audioClip->getMetadataString());
+ = std::string(*audioClip->getXmlDocumentString());
parameters[storeAudioClipFileNameParamName]
= std::string(*audioClip->getUri());
parameters[storeAudioClipChecksumParamName]
diff --git a/livesupport/products/scheduler/etc/authenticationClient.xml b/livesupport/products/scheduler/etc/authenticationClient.xml
index f13840213..7a1580f07 100644
--- a/livesupport/products/scheduler/etc/authenticationClient.xml
+++ b/livesupport/products/scheduler/etc/authenticationClient.xml
@@ -4,16 +4,15 @@
-
+
+
+
+
+
-
-
-
-
]>
-
-
-
+
+
+
diff --git a/livesupport/products/scheduler/etc/storageClient.xml b/livesupport/products/scheduler/etc/storageClient.xml
index 557ce5a2a..9ad61269a 100644
--- a/livesupport/products/scheduler/etc/storageClient.xml
+++ b/livesupport/products/scheduler/etc/storageClient.xml
@@ -3,18 +3,48 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
]>
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx
index 0f499e231..f2ce0a470 100644
--- a/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx
+++ b/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.14 $
+ Version : $Revision: 1.15 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/AddAudioClipToPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@@ -158,7 +158,7 @@ AddAudioClipToPlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
return;
}
- if (!playlist->canBeEdited()) {
+ if (!playlist->isLocked()) {
XmlRpcTools::markError(errorId+6,
"playlist has not been opened for editing",
returnValue);
diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx b/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx
index 79c29ce65..27a16a583 100644
--- a/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx
+++ b/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.12 $
+ Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@@ -146,11 +146,5 @@ CreatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
return;
}
- if (!playlist->setLockedForEditing(true)) { // this should never happen
- XmlRpcTools :: markError(errorId+3,
- "could not open new playlist for editing",
- returnValue);
- return;
- }
XmlRpcTools :: playlistToXmlRpcValue(playlist, returnValue);
}
diff --git a/livesupport/products/scheduler/src/CreatePlaylistMethod.h b/livesupport/products/scheduler/src/CreatePlaylistMethod.h
index c0aaa8bcc..721e52374 100644
--- a/livesupport/products/scheduler/src/CreatePlaylistMethod.h
+++ b/livesupport/products/scheduler/src/CreatePlaylistMethod.h
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.7 $
+ Version : $Revision: 1.8 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/CreatePlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@@ -90,12 +90,11 @@ using namespace LiveSupport::Core;
*
* - 201 - invalid argument format
* - 202 - could not create playlist
- * - 203 - could not open new playlist for editing
* - 220 - missing session ID argument
*
*
* @author $Author: fgerlits $
- * @version $Revision: 1.7 $
+ * @version $Revision: 1.8 $
*/
class CreatePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{
diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx
index d173e81bc..0e30b583c 100644
--- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx
+++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.15 $
+ Version : $Revision: 1.16 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.cxx,v $
------------------------------------------------------------------------------*/
@@ -142,13 +142,6 @@ OpenPlaylistForEditingMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
return;
}
- if (!playlist->setLockedForEditing(true)) {
- XmlRpcTools::markError(errorId+5,
- "could not lock playlist",
- returnValue);
- return;
- }
-
playlist->createSavedCopy();
XmlRpcTools::playlistToXmlRpcValue(playlist, returnValue);
diff --git a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h
index e4d1e2423..940854cf3 100644
--- a/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h
+++ b/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.9 $
+ Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/OpenPlaylistForEditingMethod.h,v $
------------------------------------------------------------------------------*/
@@ -94,11 +94,10 @@ using namespace LiveSupport::Core;
* 101 - invalid argument format
* 102 - argument is not a playlist ID
* 104 - could not open playlist for editing
- * 105 - could not lock playlist
* 120 - missing session ID argument
*
* @author $Author: fgerlits $
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
class OpenPlaylistForEditingMethod : public XmlRpc::XmlRpcServerMethod
{
diff --git a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx
index 94cbe1dee..020f95fb3 100644
--- a/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx
+++ b/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.11 $
+ Version : $Revision: 1.12 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/RemoveAudioClipFromPlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@@ -153,7 +153,7 @@ RemoveAudioClipFromPlaylistMethod :: execute(
return;
}
- if (!playlist->canBeEdited()) {
+ if (!playlist->isLocked()) {
XmlRpcTools::markError(errorId+5,
"playlist has not been opened for editing",
returnValue);
diff --git a/livesupport/products/scheduler/src/SavePlaylistMethod.cxx b/livesupport/products/scheduler/src/SavePlaylistMethod.cxx
index bc189931a..e508cf387 100644
--- a/livesupport/products/scheduler/src/SavePlaylistMethod.cxx
+++ b/livesupport/products/scheduler/src/SavePlaylistMethod.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.9 $
+ Version : $Revision: 1.10 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@@ -137,13 +137,6 @@ SavePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
return;
}
- if (!playlist->setLockedForEditing(false)) {
- XmlRpcTools::markError(errorId+4,
- "could not unlock playlist",
- returnValue);
- return;
- }
-
playlist->deleteSavedCopy();
try {
diff --git a/livesupport/products/scheduler/src/SavePlaylistMethod.h b/livesupport/products/scheduler/src/SavePlaylistMethod.h
index a87347f18..83d5b1eb3 100644
--- a/livesupport/products/scheduler/src/SavePlaylistMethod.h
+++ b/livesupport/products/scheduler/src/SavePlaylistMethod.h
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.5 $
+ Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/SavePlaylistMethod.h,v $
------------------------------------------------------------------------------*/
@@ -87,12 +87,11 @@ using namespace LiveSupport::Core;
* 701 - invalid argument format
* 702 - argument is not a playlist ID
* 703 - playlist not found
- * 704 - could not unlock playlist
* 705 - could not save playlist
* 720 - missing session ID argument
*
* @author $Author: fgerlits $
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
class SavePlaylistMethod : public XmlRpc::XmlRpcServerMethod
{
diff --git a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx
index ba239818d..7ef09c99b 100644
--- a/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx
+++ b/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.8 $
+ Version : $Revision: 1.9 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/UpdateFadeInFadeOutMethod.cxx,v $
------------------------------------------------------------------------------*/
@@ -175,7 +175,7 @@ UpdateFadeInFadeOutMethod :: execute(
return;
}
- if (!playlist->canBeEdited()) {
+ if (!playlist->isLocked()) {
XmlRpcTools::markError(errorId+7,
"playlist has not been opened for editing",
returnValue);
diff --git a/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx b/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx
index 7272b81a0..2c472f2f8 100644
--- a/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx
+++ b/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx
@@ -22,7 +22,7 @@
Author : $Author: fgerlits $
- Version : $Revision: 1.10 $
+ Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/scheduler/src/ValidatePlaylistMethod.cxx,v $
------------------------------------------------------------------------------*/
@@ -142,7 +142,7 @@ ValidatePlaylistMethod :: execute(XmlRpc::XmlRpcValue & rootParameter,
return;
}
- if (!playlist->canBeEdited()) {
+ if (!playlist->isLocked()) {
XmlRpcTools::markError(errorId+4,
"playlist has not been opened for editing",
returnValue);