aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/upnp/Directory.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-14 21:25:43 +0100
committerMax Kellermann <max@duempel.org>2014-01-14 22:33:18 +0100
commit676d8bb624ef9fb7a8a4983b258d07787efec6b1 (patch)
treebd8be367773915125a600ebcb4707ece3f1efa86 /src/db/upnp/Directory.cxx
parent4bcaf5d3064ca8846f8652413b2e0deba80aa624 (diff)
downloadmpd-676d8bb624ef9fb7a8a4983b258d07787efec6b1.tar.gz
mpd-676d8bb624ef9fb7a8a4983b258d07787efec6b1.tar.xz
mpd-676d8bb624ef9fb7a8a4983b258d07787efec6b1.zip
db/upnp/Object: add attribute "tag"
Replaces "m_title" and "m_props". More bloat removed.
Diffstat (limited to 'src/db/upnp/Directory.cxx')
-rw-r--r--src/db/upnp/Directory.cxx39
1 files changed, 19 insertions, 20 deletions
diff --git a/src/db/upnp/Directory.cxx b/src/db/upnp/Directory.cxx
index 35d556c28..3b6428389 100644
--- a/src/db/upnp/Directory.cxx
+++ b/src/db/upnp/Directory.cxx
@@ -21,6 +21,9 @@
#include "Directory.hxx"
#include "Util.hxx"
#include "Expat.hxx"
+#include "Tags.hxx"
+#include "tag/TagBuilder.hxx"
+#include "tag/TagTable.hxx"
#include <algorithm>
#include <string>
@@ -28,14 +31,6 @@
#include <string.h>
-static const char *const upnptags[] = {
- "upnp:artist",
- "upnp:album",
- "upnp:genre",
- "upnp:originalTrackNumber",
- nullptr,
-};
-
gcc_pure
static UPnPDirObject::ItemClass
ParseItemClass(const char *name)
@@ -77,6 +72,7 @@ titleToPathElt(std::string &&s)
class UPnPDirParser final : public CommonExpatParser {
std::vector<std::string> m_path;
UPnPDirObject m_tobj;
+ TagBuilder tag;
public:
UPnPDirParser(UPnPDirContent& dir)
@@ -130,7 +126,7 @@ protected:
const char *duration =
GetAttribute(attrs, "duration");
if (duration != nullptr)
- m_tobj.duration = ParseDuration(duration);
+ tag.SetTime(ParseDuration(duration));
}
break;
@@ -150,8 +146,10 @@ protected:
virtual void EndElement(const XML_Char *name)
{
if ((!strcmp(name, "container") || !strcmp(name, "item")) &&
- checkobjok())
+ checkobjok()) {
+ tag.Commit(m_tobj.tag);
m_dir.objects.push_back(std::move(m_tobj));
+ }
m_path.pop_back();
}
@@ -160,14 +158,19 @@ protected:
{
std::string str(s, len);
trimstring(str);
- switch (m_path.back()[0]) {
- case 'd':
- if (!m_path.back().compare("dc:title")) {
- m_tobj.m_title = str;
+
+ TagType type = tag_table_lookup(upnp_tags,
+ m_path.back().c_str());
+ if (type != TAG_NUM_OF_ITEM_TYPES) {
+ tag.AddItem(type, str.c_str());
+
+ if (type == TAG_TITLE)
m_tobj.name = titleToPathElt(std::move(str));
- }
- break;
+ return;
+ }
+
+ switch (m_path.back()[0]) {
case 'r':
if (!m_path.back().compare("res")) {
m_tobj.url = str;
@@ -178,10 +181,6 @@ protected:
m_tobj.item_class = ParseItemClass(str.c_str());
break;
}
-
- for (auto i = upnptags; *i != nullptr; ++i)
- if (!m_path.back().compare(*i))
- m_tobj.m_props[*i] += str;
break;
}
}