1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

OP-35 Add new method to connection manager to let a plugin initiate a disconnection. Needed for Uploader plugin.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2052 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-11-01 13:34:27 +00:00 committed by edouard
parent ba781dec9a
commit f19439b1c7
2 changed files with 30 additions and 0 deletions

View File

@ -123,6 +123,35 @@ void ConnectionManager::aboutToRemoveObject(QObject *obj)
{
}
/**
* Method called by plugins who want to force a disconnection. Used
* by Uploader gadget for instance.
*/
bool ConnectionManager::disconnectDevice()
{
// Check if we are currently connected or not
if(!m_ioDev)
{
return false; // We were not connected
}
else
{
//signal interested plugins that we are disconnecting the device
emit deviceDisconnected();
if(m_connectionDevice.connection)
{
m_connectionDevice.connection->closeDevice(m_connectionDevice.devName);
m_ioDev = NULL;
m_connectionDevice.connection = NULL;
}
m_connectBtn->setText("Connect");
m_availableDevList->setEnabled(true);
}
}
/**
* Slot called when the user pressed the connect/disconnect button
*/

View File

@ -69,6 +69,7 @@ public:
void init();
QIODevice *getCurrentConnection();
bool disconnectDevice();
protected:
void unregisterAll(IConnection *connection);