added title field in saved playlist

fixed (kind of; I still don't understand them) some problems arising from
    StorageException -> XmlRpcException change
This commit is contained in:
fgerlits 2005-01-10 10:36:56 +00:00
parent 9a185bb141
commit 67910f4fcf
4 changed files with 67 additions and 34 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.22 $
Version : $Revision: 1.23 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/Playlist.cxx,v $
------------------------------------------------------------------------------*/
@ -61,6 +61,11 @@ static const std::string idAttrName = "id";
*/
static const std::string playlengthAttrName = "playlength";
/**
* The name of the attribute to get the title of the playlist.
*/
static const std::string titleAttrName = "title";
/**
* The name of playlist element child nodes.
*/
@ -102,6 +107,13 @@ Playlist :: configure(const xmlpp::Element & element)
playlength.reset(new time_duration(
duration_from_string(attribute->get_value())));
if ((attribute = element.get_attribute(titleAttrName))) {
title.reset(new const Glib::ustring(attribute->get_value()));
}
else {
title.reset(new const Glib::ustring(""));
}
xmlpp::Node::NodeList childNodes
= element.get_children(elementListAttrName);
xmlpp::Node::NodeList::iterator it = childNodes.begin();
@ -365,7 +377,7 @@ Ptr<Glib::ustring>::Ref
Playlist :: getMetadata(const string &key, const string &ns) const
throw ()
{
std::string completeKey = key + ns;
std::string completeKey = ns + ":" + key;
metadataType::const_iterator it = metadata.find(completeKey);
if (it != metadata.end()) {
@ -387,10 +399,19 @@ Playlist :: setMetadata(Ptr<const Glib::ustring>::Ref value,
const string &key, const string &ns)
throw ()
{
std::string completeKey = key + ns;
std::string completeKey = ns + ":" + key;
metadata[completeKey] = value;
if (completeKey == "dcterms:extent") {
playlength.reset(new time_duration(duration_from_string(*value)));
}
if (completeKey == "dc:title") {
title = value;
}
}
/*------------------------------------------------------------------------------
* Return a string containing the essential fields of this object, in XML.
*----------------------------------------------------------------------------*/
@ -402,11 +423,14 @@ Playlist :: getXmlString(void) throw ()
xmlString->append("<");
xmlString->append(configElementNameStr + " ");
xmlString->append(idAttrName + "=\""
+ std::string(*id)
+ std::string(*getId())
+ "\" ");
xmlString->append(playlengthAttrName + "=\""
+ to_simple_string(*playlength)
+ "\">\n");
+ to_simple_string(*getPlaylength())
+ "\" ");
xmlString->append(Glib::ustring(titleAttrName) + "=\""
+ *getTitle()
+ "\">\n");
PlaylistElementListType::const_iterator it = elementList->begin();
while (it != elementList->end()) {

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.18 $
Version : $Revision: 1.19 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/PlaylistTest.cxx,v $
------------------------------------------------------------------------------*/
@ -114,9 +114,8 @@ PlaylistTest :: firstTest(void)
CPPUNIT_ASSERT(duration->total_seconds() == 34);
CPPUNIT_ASSERT(playlist->valid());
CPPUNIT_ASSERT(*playlist->getXmlString() ==
"<playlist id=\"0000000000000001\" playlength=\"00:00:34\">\n"
"<playlist id=\"0000000000000001\" playlength=\"00:00:34\" title=\"\">\n"
"<playlistElement id=\"0000000000000101\" relativeOffset=\"00:00:00\">\n"
"<audioClip id=\"0000000000010001\" playlength=\"00:00:11\" title=\"one\"/>\n"
"</playlistElement>\n"
@ -126,7 +125,7 @@ PlaylistTest :: firstTest(void)
"fadeOut=\"00:00:01.500000\"/>\n"
"</playlistElement>\n"
"<playlistElement id=\"0000000000000103\" relativeOffset=\"00:00:23\">\n"
"<playlist id=\"0000000000000002\" playlength=\"00:00:11\">\n"
"<playlist id=\"0000000000000002\" playlength=\"00:00:11\" title=\"\">\n"
"<playlistElement id=\"0000000000000111\" relativeOffset=\"00:00:00\">\n"
"<audioClip id=\"0000000000010003\" playlength=\"00:00:11\" title=\"three\"/>\n"
"</playlistElement>\n"