From 7d696a7063c7510485f2fbf315731212d28e49e0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 18 Jan 2014 16:08:30 +0100 Subject: db/upnp/Discovery: eliminate Error attribute Move code to method Start() and add Error& parameters to several methods. --- src/db/UpnpDatabasePlugin.cxx | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'src/db/UpnpDatabasePlugin.cxx') diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx index 054e20377..98c8a5ff3 100644 --- a/src/db/UpnpDatabasePlugin.cxx +++ b/src/db/UpnpDatabasePlugin.cxx @@ -165,8 +165,7 @@ UpnpDatabase::Open(Error &error) } m_superdir = new UPnPDeviceDirectory(m_lib); - if (!m_superdir->ok()) { - error.Set(m_superdir->GetError()); + if (!m_superdir->Start(error)) { delete m_superdir; delete m_lib; return false; @@ -215,20 +214,12 @@ upnpItemToSong(const UPnPDirObject &dirent, const char *uri) Song * UpnpDatabase::GetSong(const char *uri, Error &error) const { - if (!m_superdir->ok()) { - error.Set(upnp_domain, - "UpnpDatabase::GetSong() superdir is sick"); - return nullptr; - } - Song *song = nullptr; auto vpath = stringToTokens(uri, "/", true); if (vpath.size() >= 2) { ContentDirectoryService server; - if (!m_superdir->getServer(vpath[0].c_str(), server)) { - error.Set(upnp_domain, "server not found"); + if (!m_superdir->getServer(vpath[0].c_str(), server, error)) return nullptr; - } vpath.erase(vpath.begin()); UPnPDirObject dirent; @@ -688,12 +679,8 @@ UpnpDatabase::Visit(const DatabaseSelection &selection, Error &error) const { std::vector servers; - if (!m_superdir->ok() || - !m_superdir->getDirServices(servers)) { - error.Set(upnp_domain, - "UpnpDatabase::Visit() superdir is sick"); + if (!m_superdir->getDirServices(servers, error)) return false; - } auto vpath = stringToTokens(selection.uri, "/", true); if (vpath.empty()) { @@ -748,12 +735,8 @@ UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection, return true; std::vector servers; - if (!m_superdir->ok() || - !m_superdir->getDirServices(servers)) { - error.Set(upnp_domain, - "UpnpDatabase::Visit() superdir is sick"); + if (!m_superdir->getDirServices(servers, error)) return false; - } std::set values; for (auto& server : servers) { -- cgit v1.2.3