db/upnp: move the UPnPDeviceDirectory instance to class UpnpDatabase
Delete the object when closing the database.
This commit is contained in:
parent
a827714823
commit
1a09003a6e
|
@ -163,9 +163,10 @@ UpnpDatabase::Open(Error &error)
|
||||||
if (!m_lib)
|
if (!m_lib)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_superdir = UPnPDeviceDirectory::getTheDir();
|
m_superdir = new UPnPDeviceDirectory();
|
||||||
if (!m_superdir || !m_superdir->ok()) {
|
if (!m_superdir->ok()) {
|
||||||
error.Set(upnp_domain, "Discovery services startup failed");
|
error.Set(m_superdir->GetError());
|
||||||
|
delete m_superdir;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +181,8 @@ void
|
||||||
UpnpDatabase::Close()
|
UpnpDatabase::Close()
|
||||||
{
|
{
|
||||||
delete m_root;
|
delete m_root;
|
||||||
// TBD decide what we do with the lib and superdir objects
|
delete m_superdir;
|
||||||
|
// TBD decide what we do with the lib object
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -275,17 +275,6 @@ UPnPDeviceDirectory::search()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
UPnPDeviceDirectory *UPnPDeviceDirectory::getTheDir()
|
|
||||||
{
|
|
||||||
// TODO: elimate static variable
|
|
||||||
static UPnPDeviceDirectory *theDevDir;
|
|
||||||
if (theDevDir == nullptr)
|
|
||||||
theDevDir = new UPnPDeviceDirectory();
|
|
||||||
if (theDevDir && !theDevDir->ok())
|
|
||||||
return 0;
|
|
||||||
return theDevDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
UPnPDeviceDirectory::getDirServices(std::vector<ContentDirectoryService> &out)
|
UPnPDeviceDirectory::getDirServices(std::vector<ContentDirectoryService> &out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,14 +46,12 @@ class UPnPDeviceDirectory {
|
||||||
|
|
||||||
time_t m_lastSearch;
|
time_t m_lastSearch;
|
||||||
|
|
||||||
UPnPDeviceDirectory();
|
|
||||||
public:
|
public:
|
||||||
|
UPnPDeviceDirectory();
|
||||||
|
|
||||||
UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
|
UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
|
||||||
UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
|
UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
|
||||||
|
|
||||||
/** This class is a singleton. Get the instance here */
|
|
||||||
static UPnPDeviceDirectory *getTheDir();
|
|
||||||
|
|
||||||
/** Retrieve the directory services currently seen on the network */
|
/** Retrieve the directory services currently seen on the network */
|
||||||
bool getDirServices(std::vector<ContentDirectoryService> &);
|
bool getDirServices(std::vector<ContentDirectoryService> &);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue