mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 15:15:39 +08:00
refs #199 , method to unregister DBus objects for a graceful shutdown of our DBusServer
This commit is contained in:
@@ -145,5 +145,33 @@ namespace BlackCore
|
|||||||
return this->m_busServer.lastError();
|
return this->m_busServer.lastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unregister all objects
|
||||||
|
*/
|
||||||
|
void CDBusServer::unregisterAllObjects()
|
||||||
|
{
|
||||||
|
if (this->m_objects.isEmpty()) return;
|
||||||
|
foreach(QString path, this->m_objects.keys())
|
||||||
|
{
|
||||||
|
switch (this->m_serverMode)
|
||||||
|
{
|
||||||
|
case CDBusServer::SERVERMODE_SESSIONBUS:
|
||||||
|
QDBusConnection::sessionBus().unregisterObject(path);
|
||||||
|
break;
|
||||||
|
case CDBusServer::SERVERMODE_SYSTEMBUS:
|
||||||
|
QDBusConnection::systemBus().unregisterObject(path);
|
||||||
|
break;
|
||||||
|
case CDBusServer::SERVERMODE_P2P:
|
||||||
|
{
|
||||||
|
foreach(QDBusConnection con, this->m_DBusConnections)
|
||||||
|
{
|
||||||
|
con.unregisterObject(path);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // all paths
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace BlackCore
|
} // namespace BlackCore
|
||||||
|
|
||||||
|
|||||||
@@ -80,9 +80,14 @@ namespace BlackCore
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! \brief Connection by name
|
/*!
|
||||||
const QDBusConnection getDbusConnection(const QString &connectionName) const
|
* \brief Connection by name
|
||||||
|
* \param connectionName empty string makes sense with session / system DBus, otherwise provide name for P2P
|
||||||
|
* \return
|
||||||
|
*/
|
||||||
|
const QDBusConnection getDBusConnection(const QString &connectionName = "")
|
||||||
{
|
{
|
||||||
|
if (connectionName.isEmpty()) return this->m_DBusConnections.first();
|
||||||
return this->m_DBusConnections.value(connectionName, CDBusServer::defaultConnection());
|
return this->m_DBusConnections.value(connectionName, CDBusServer::defaultConnection());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +98,9 @@ namespace BlackCore
|
|||||||
return this->m_DBusConnections.values();
|
return this->m_DBusConnections.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! \brief Default connection
|
//! Unregister all objects
|
||||||
|
void unregisterAllObjects();
|
||||||
|
|
||||||
//! Default connection
|
//! Default connection
|
||||||
static const QDBusConnection &defaultConnection()
|
static const QDBusConnection &defaultConnection()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user