Commit 5e73007b authored by Max Kellermann's avatar Max Kellermann

db/upnp/Object: apply coding style

parent 2d9876a2
......@@ -129,7 +129,7 @@ public:
state(NONE),
tag_type(TAG_NUM_OF_ITEM_TYPES)
{
m_tobj.clear();
m_tobj.Clear();
}
protected:
......@@ -147,31 +147,31 @@ protected:
switch (name[0]) {
case 'c':
if (!strcmp(name, "container")) {
m_tobj.clear();
m_tobj.Clear();
m_tobj.type = UPnPDirObject::Type::CONTAINER;
const char *id = GetAttribute(attrs, "id");
if (id != nullptr)
m_tobj.m_id = id;
m_tobj.id = id;
const char *pid = GetAttribute(attrs, "parentID");
if (pid != nullptr)
m_tobj.m_pid = pid;
m_tobj.parent_id = pid;
}
break;
case 'i':
if (!strcmp(name, "item")) {
m_tobj.clear();
m_tobj.Clear();
m_tobj.type = UPnPDirObject::Type::ITEM;
const char *id = GetAttribute(attrs, "id");
if (id != nullptr)
m_tobj.m_id = id;
m_tobj.id = id;
const char *pid = GetAttribute(attrs, "parentID");
if (pid != nullptr)
m_tobj.m_pid = pid;
m_tobj.parent_id = pid;
}
break;
......@@ -198,7 +198,7 @@ protected:
}
bool checkobjok() {
if (m_tobj.m_id.empty() || m_tobj.m_pid.empty() ||
if (m_tobj.id.empty() || m_tobj.parent_id.empty() ||
m_tobj.name.empty() ||
(m_tobj.type == UPnPDirObject::Type::ITEM &&
m_tobj.item_class == UPnPDirObject::ItemClass::UNKNOWN))
......
......@@ -50,8 +50,16 @@ public:
PLAYLIST,
};
std::string m_id; // ObjectId
std::string m_pid; // Parent ObjectId
/**
* ObjectId
*/
std::string id;
/**
* Parent's ObjectId
*/
std::string parent_id;
std::string url;
/**
......@@ -71,10 +79,9 @@ public:
UPnPDirObject &operator=(UPnPDirObject &&) = default;
void clear()
{
m_id.clear();
m_pid.clear();
void Clear() {
id.clear();
parent_id.clear();
url.clear();
type = Type::UNKNOWN;
item_class = ItemClass::UNKNOWN;
......
......@@ -412,7 +412,7 @@ UpnpDatabase::SearchSongs(const ContentDirectoryService &server,
// So we return synthetic and ugly paths based on the object id,
// which we later have to detect.
const std::string path = songPath(server.getFriendlyName(),
dirent.m_id);
dirent.id);
if (!visitSong(std::move(dirent), path.c_str(),
selection, visit_song,
error))
......@@ -447,13 +447,13 @@ UpnpDatabase::BuildPath(const ContentDirectoryService &server,
std::string &path,
Error &error) const
{
const char *pid = idirent.m_id.c_str();
const char *pid = idirent.id.c_str();
path.clear();
UPnPDirObject dirent;
while (strcmp(pid, rootid) != 0) {
if (!ReadNode(server, pid, dirent, error))
return false;
pid = dirent.m_pid.c_str();
pid = dirent.parent_id.c_str();
if (path.empty())
path = dirent.name;
......@@ -509,7 +509,7 @@ UpnpDatabase::Namei(const ContentDirectoryService &server,
return false;
}
objid = std::move(child->m_id);
objid = std::move(child->id);
}
}
......@@ -621,7 +621,7 @@ UpnpDatabase::VisitServer(const ContentDirectoryService &server,
}
std::string path = songPath(server.getFriendlyName(),
dirent.m_id);
dirent.id);
if (!visitSong(std::move(dirent), path.c_str(),
selection,
visit_song, error))
......@@ -640,7 +640,7 @@ UpnpDatabase::VisitServer(const ContentDirectoryService &server,
recursion (1-deep) here, which will handle the "add dir"
case. */
if (selection.recursive && selection.filter)
return SearchSongs(server, tdirent.m_id.c_str(), selection,
return SearchSongs(server, tdirent.id.c_str(), selection,
visit_song, error);
const char *const base_uri = selection.uri.empty()
......@@ -658,7 +658,7 @@ UpnpDatabase::VisitServer(const ContentDirectoryService &server,
and loop here, but it's not useful as mpd will only return
data to the client when we're done anyway. */
UPnPDirContent dirbuf;
if (!server.readDir(handle, tdirent.m_id.c_str(), dirbuf,
if (!server.readDir(handle, tdirent.id.c_str(), dirbuf,
error))
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment