db/upnp/Object: apply coding style
This commit is contained in:
parent
2d9876a261
commit
5e73007b1d
@ -129,7 +129,7 @@ public:
|
|||||||
state(NONE),
|
state(NONE),
|
||||||
tag_type(TAG_NUM_OF_ITEM_TYPES)
|
tag_type(TAG_NUM_OF_ITEM_TYPES)
|
||||||
{
|
{
|
||||||
m_tobj.clear();
|
m_tobj.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -147,31 +147,31 @@ protected:
|
|||||||
switch (name[0]) {
|
switch (name[0]) {
|
||||||
case 'c':
|
case 'c':
|
||||||
if (!strcmp(name, "container")) {
|
if (!strcmp(name, "container")) {
|
||||||
m_tobj.clear();
|
m_tobj.Clear();
|
||||||
m_tobj.type = UPnPDirObject::Type::CONTAINER;
|
m_tobj.type = UPnPDirObject::Type::CONTAINER;
|
||||||
|
|
||||||
const char *id = GetAttribute(attrs, "id");
|
const char *id = GetAttribute(attrs, "id");
|
||||||
if (id != nullptr)
|
if (id != nullptr)
|
||||||
m_tobj.m_id = id;
|
m_tobj.id = id;
|
||||||
|
|
||||||
const char *pid = GetAttribute(attrs, "parentID");
|
const char *pid = GetAttribute(attrs, "parentID");
|
||||||
if (pid != nullptr)
|
if (pid != nullptr)
|
||||||
m_tobj.m_pid = pid;
|
m_tobj.parent_id = pid;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
if (!strcmp(name, "item")) {
|
if (!strcmp(name, "item")) {
|
||||||
m_tobj.clear();
|
m_tobj.Clear();
|
||||||
m_tobj.type = UPnPDirObject::Type::ITEM;
|
m_tobj.type = UPnPDirObject::Type::ITEM;
|
||||||
|
|
||||||
const char *id = GetAttribute(attrs, "id");
|
const char *id = GetAttribute(attrs, "id");
|
||||||
if (id != nullptr)
|
if (id != nullptr)
|
||||||
m_tobj.m_id = id;
|
m_tobj.id = id;
|
||||||
|
|
||||||
const char *pid = GetAttribute(attrs, "parentID");
|
const char *pid = GetAttribute(attrs, "parentID");
|
||||||
if (pid != nullptr)
|
if (pid != nullptr)
|
||||||
m_tobj.m_pid = pid;
|
m_tobj.parent_id = pid;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool checkobjok() {
|
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.name.empty() ||
|
||||||
(m_tobj.type == UPnPDirObject::Type::ITEM &&
|
(m_tobj.type == UPnPDirObject::Type::ITEM &&
|
||||||
m_tobj.item_class == UPnPDirObject::ItemClass::UNKNOWN))
|
m_tobj.item_class == UPnPDirObject::ItemClass::UNKNOWN))
|
||||||
|
@ -50,8 +50,16 @@ public:
|
|||||||
PLAYLIST,
|
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;
|
std::string url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,10 +79,9 @@ public:
|
|||||||
|
|
||||||
UPnPDirObject &operator=(UPnPDirObject &&) = default;
|
UPnPDirObject &operator=(UPnPDirObject &&) = default;
|
||||||
|
|
||||||
void clear()
|
void Clear() {
|
||||||
{
|
id.clear();
|
||||||
m_id.clear();
|
parent_id.clear();
|
||||||
m_pid.clear();
|
|
||||||
url.clear();
|
url.clear();
|
||||||
type = Type::UNKNOWN;
|
type = Type::UNKNOWN;
|
||||||
item_class = ItemClass::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,
|
// So we return synthetic and ugly paths based on the object id,
|
||||||
// which we later have to detect.
|
// which we later have to detect.
|
||||||
const std::string path = songPath(server.getFriendlyName(),
|
const std::string path = songPath(server.getFriendlyName(),
|
||||||
dirent.m_id);
|
dirent.id);
|
||||||
if (!visitSong(std::move(dirent), path.c_str(),
|
if (!visitSong(std::move(dirent), path.c_str(),
|
||||||
selection, visit_song,
|
selection, visit_song,
|
||||||
error))
|
error))
|
||||||
@ -447,13 +447,13 @@ UpnpDatabase::BuildPath(const ContentDirectoryService &server,
|
|||||||
std::string &path,
|
std::string &path,
|
||||||
Error &error) const
|
Error &error) const
|
||||||
{
|
{
|
||||||
const char *pid = idirent.m_id.c_str();
|
const char *pid = idirent.id.c_str();
|
||||||
path.clear();
|
path.clear();
|
||||||
UPnPDirObject dirent;
|
UPnPDirObject dirent;
|
||||||
while (strcmp(pid, rootid) != 0) {
|
while (strcmp(pid, rootid) != 0) {
|
||||||
if (!ReadNode(server, pid, dirent, error))
|
if (!ReadNode(server, pid, dirent, error))
|
||||||
return false;
|
return false;
|
||||||
pid = dirent.m_pid.c_str();
|
pid = dirent.parent_id.c_str();
|
||||||
|
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
path = dirent.name;
|
path = dirent.name;
|
||||||
@ -509,7 +509,7 @@ UpnpDatabase::Namei(const ContentDirectoryService &server,
|
|||||||
return false;
|
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(),
|
std::string path = songPath(server.getFriendlyName(),
|
||||||
dirent.m_id);
|
dirent.id);
|
||||||
if (!visitSong(std::move(dirent), path.c_str(),
|
if (!visitSong(std::move(dirent), path.c_str(),
|
||||||
selection,
|
selection,
|
||||||
visit_song, error))
|
visit_song, error))
|
||||||
@ -640,7 +640,7 @@ UpnpDatabase::VisitServer(const ContentDirectoryService &server,
|
|||||||
recursion (1-deep) here, which will handle the "add dir"
|
recursion (1-deep) here, which will handle the "add dir"
|
||||||
case. */
|
case. */
|
||||||
if (selection.recursive && selection.filter)
|
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);
|
visit_song, error);
|
||||||
|
|
||||||
const char *const base_uri = selection.uri.empty()
|
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
|
and loop here, but it's not useful as mpd will only return
|
||||||
data to the client when we're done anyway. */
|
data to the client when we're done anyway. */
|
||||||
UPnPDirContent dirbuf;
|
UPnPDirContent dirbuf;
|
||||||
if (!server.readDir(handle, tdirent.m_id.c_str(), dirbuf,
|
if (!server.readDir(handle, tdirent.id.c_str(), dirbuf,
|
||||||
error))
|
error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user