db/upnp: eliminate redundant Namei() parameter "oobjid"
The caller should better obtain the object id from the returned UPnPDirObject instance.
This commit is contained in:
parent
3e4fb92cfb
commit
154250f551
@ -130,7 +130,7 @@ private:
|
|||||||
|
|
||||||
bool Namei(ContentDirectoryService &server,
|
bool Namei(ContentDirectoryService &server,
|
||||||
const std::vector<std::string> &vpath,
|
const std::vector<std::string> &vpath,
|
||||||
std::string &oobjid, UPnPDirObject &dirent,
|
UPnPDirObject &dirent,
|
||||||
Error &error) const;
|
Error &error) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -232,8 +232,7 @@ UpnpDatabase::GetSong(const char *uri, Error &error) const
|
|||||||
vpath.erase(vpath.begin());
|
vpath.erase(vpath.begin());
|
||||||
UPnPDirObject dirent;
|
UPnPDirObject dirent;
|
||||||
if (vpath.front() != rootid) {
|
if (vpath.front() != rootid) {
|
||||||
std::string objid;
|
if (!Namei(server, vpath, dirent, error))
|
||||||
if (!Namei(server, vpath, objid, dirent, error))
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else {
|
} else {
|
||||||
if (!ReadNode(server, vpath.back().c_str(), dirent,
|
if (!ReadNode(server, vpath.back().c_str(), dirent,
|
||||||
@ -465,10 +464,9 @@ UpnpDatabase::BuildPath(ContentDirectoryService &server,
|
|||||||
bool
|
bool
|
||||||
UpnpDatabase::Namei(ContentDirectoryService &server,
|
UpnpDatabase::Namei(ContentDirectoryService &server,
|
||||||
const std::vector<std::string> &vpath,
|
const std::vector<std::string> &vpath,
|
||||||
std::string &oobjid, UPnPDirObject &odirent,
|
UPnPDirObject &odirent,
|
||||||
Error &error) const
|
Error &error) const
|
||||||
{
|
{
|
||||||
oobjid.clear();
|
|
||||||
std::string objid(rootid);
|
std::string objid(rootid);
|
||||||
|
|
||||||
if (vpath.empty()) {
|
if (vpath.empty()) {
|
||||||
@ -476,7 +474,6 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
|
|||||||
if (!ReadNode(server, rootid, odirent, error))
|
if (!ReadNode(server, rootid, odirent, error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
oobjid = rootid;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,7 +500,6 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
|
|||||||
if (i == vpath.size() - 1) {
|
if (i == vpath.size() - 1) {
|
||||||
// The last element in the path was found and it's
|
// The last element in the path was found and it's
|
||||||
// a container, we're done
|
// a container, we're done
|
||||||
oobjid = objid;
|
|
||||||
odirent = std::move(*child);
|
odirent = std::move(*child);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -513,7 +509,6 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
|
|||||||
// If this is the last path elt, we found the target,
|
// If this is the last path elt, we found the target,
|
||||||
// else it does not exist
|
// else it does not exist
|
||||||
if (i == vpath.size() - 1) {
|
if (i == vpath.size() - 1) {
|
||||||
oobjid = objid;
|
|
||||||
odirent = std::move(*child);
|
odirent = std::move(*child);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -565,9 +560,8 @@ UpnpDatabase::VisitServer(ContentDirectoryService &server,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Translate the target path into an object id and the associated metadata.
|
// Translate the target path into an object id and the associated metadata.
|
||||||
std::string objid;
|
|
||||||
UPnPDirObject tdirent;
|
UPnPDirObject tdirent;
|
||||||
if (!Namei(server, vpath, objid, tdirent, error))
|
if (!Namei(server, vpath, tdirent, error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* If recursive is set, this is a search... No use sending it
|
/* If recursive is set, this is a search... No use sending it
|
||||||
@ -575,7 +569,7 @@ UpnpDatabase::VisitServer(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, objid.c_str(), selection,
|
return SearchSongs(server, tdirent.m_id.c_str(), selection,
|
||||||
visit_song, error);
|
visit_song, error);
|
||||||
|
|
||||||
if (tdirent.type == UPnPDirObject::Type::ITEM) {
|
if (tdirent.type == UPnPDirObject::Type::ITEM) {
|
||||||
@ -610,7 +604,8 @@ UpnpDatabase::VisitServer(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(m_lib->getclh(), objid.c_str(), dirbuf, error))
|
if (!server.readDir(m_lib->getclh(), tdirent.m_id.c_str(), dirbuf,
|
||||||
|
error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (auto &dirent : dirbuf.objects) {
|
for (auto &dirent : dirbuf.objects) {
|
||||||
|
Loading…
Reference in New Issue
Block a user