2 ******************************************************************************
4 * @file connectionmanager.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
7 * @addtogroup GCSPlugins GCS Plugins
9 * @addtogroup CorePlugin Core Plugin
11 * @brief The Core GCS plugin
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef CONNECTIONMANAGER_H
30 #define CONNECTIONMANAGER_H
32 #include "mainwindow.h"
33 #include "generalsettings.h"
34 #include <coreplugin/iconnection.h>
36 #include <QtCore/QVector>
37 #include <QtCore/QIODevice>
38 #include <QtCore/QLinkedList>
39 #include <QPushButton>
42 #include "core_global.h"
50 } // namespace Internal
54 DevListItem(IConnection
*c
, IConnection::device d
) :
55 connection(c
), device(d
) {}
57 DevListItem() : connection(NULL
) {}
61 if (connection
== NULL
) {
64 return connection
->shortName() + ": " + device
.displayName
;
67 bool operator==(const DevListItem
&rhs
)
69 return connection
== rhs
.connection
&& device
== rhs
.device
;
72 IConnection
*connection
;
73 IConnection::device device
;
77 class CORE_EXPORT ConnectionManager
: public QWidget
{
81 ConnectionManager(Internal::MainWindow
*mainWindow
);
82 virtual ~ConnectionManager();
86 DevListItem
getCurrentDevice()
88 return m_connectionDevice
;
90 DevListItem
findDevice(const QString
&devName
);
92 QLinkedList
<DevListItem
> getAvailableDevices()
102 void addWidget(QWidget
*widget
);
104 bool connectDevice(DevListItem device
);
105 bool disconnectDevice();
106 void suspendPolling();
107 void resumePolling();
110 void updateConnectionList(IConnection
*connection
);
111 void registerDevice(IConnection
*conn
, IConnection::device device
);
112 void updateConnectionDropdown();
115 void deviceConnected(QIODevice
*device
);
116 void deviceAboutToDisconnect();
117 void deviceDisconnected();
118 void availableDevicesChanged(const QLinkedList
<Core::DevListItem
> devices
);
121 void telemetryConnected();
122 void telemetryDisconnected();
125 void objectAdded(QObject
*obj
);
126 void aboutToRemoveObject(QObject
*obj
);
128 void onConnectClicked();
129 void onDeviceSelectionChanged(int index
);
130 void devChanged(IConnection
*connection
);
132 void onConnectionDestroyed(QObject
*obj
);
133 void connectionsCallBack(); // used to call devChange after all the plugins are loaded
134 void reconnectSlot();
135 void reconnectCheckSlot();
138 QComboBox
*m_availableDevList
;
139 QPushButton
*m_connectBtn
;
140 QLinkedList
<DevListItem
> m_devList
;
141 QList
<IConnection
*> m_connectionsList
;
143 // currently connected connection plugin
144 DevListItem m_connectionDevice
;
146 // currently connected QIODevice
150 bool connectDevice();
152 Internal::MainWindow
*m_mainWindow
;
153 QList
<IConnection
*> connectionBackup
;
155 QTimer
*reconnectCheck
;
159 #endif // CONNECTIONMANAGER_H