Features
- Ostinato Client - will start the server as a child process at startup and terminate it at exit - Ostinato Server (Drone) - is now a system tray application - if not able to bind to a IP/Port successfully, informs the user and exits - the GUI is now nothing more than a TextLabel Others - If a getStats() request is pending, the client will not queue up any more requests till a reply is received for the pending one - Nitpicks in the Payload protocol Widget, PortsWindow Widget
This commit is contained in:
parent
4c5b8faff7
commit
bb6a9235c3
@ -1,6 +1,7 @@
|
|||||||
#include <QApplication>
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "portgrouplist.h"
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#include "dbgthread.h"
|
#include "dbgthread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "portgrouplist.h"
|
||||||
|
#include "portstatswindow.h"
|
||||||
|
#include "portswindow.h"
|
||||||
#include "ui_about.h"
|
#include "ui_about.h"
|
||||||
|
|
||||||
|
#include <QDockWidget>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
PortGroupList *pgl;
|
PortGroupList *pgl;
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow (parent)
|
: QMainWindow (parent)
|
||||||
{
|
{
|
||||||
|
localServer_ = new QProcess(this);
|
||||||
|
localServer_->start("drone.exe");
|
||||||
|
|
||||||
pgl = new PortGroupList;
|
pgl = new PortGroupList;
|
||||||
|
|
||||||
portsWindow = new PortsWindow(pgl, this);
|
portsWindow = new PortsWindow(pgl, this);
|
||||||
@ -37,6 +45,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
delete pgl;
|
||||||
|
localServer_->terminate();
|
||||||
|
localServer_->waitForFinished();
|
||||||
|
delete localServer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionHelpAbout_triggered()
|
void MainWindow::on_actionHelpAbout_triggered()
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
#ifndef _MAIN_WINDOW_H
|
#ifndef _MAIN_WINDOW_H
|
||||||
#define _MAIN_WINDOW_H
|
#define _MAIN_WINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QDockWidget>
|
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
#include "portswindow.h"
|
class PortsWindow;
|
||||||
#include "portstatswindow.h"
|
class PortStatsWindow;
|
||||||
|
|
||||||
|
class QDockWidget;
|
||||||
|
class QProcess;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow, private Ui::MainWindow
|
class MainWindow : public QMainWindow, private Ui::MainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QProcess *localServer_;
|
||||||
PortsWindow *portsWindow;
|
PortsWindow *portsWindow;
|
||||||
PortStatsWindow *statsWindow;
|
PortStatsWindow *statsWindow;
|
||||||
QDockWidget *portsDock;
|
QDockWidget *portsDock;
|
||||||
|
@ -21,6 +21,7 @@ PortGroup::PortGroup(QHostAddress ip, quint16 port)
|
|||||||
*/
|
*/
|
||||||
rpcController = new PbRpcController;
|
rpcController = new PbRpcController;
|
||||||
rpcControllerStats = new PbRpcController;
|
rpcControllerStats = new PbRpcController;
|
||||||
|
isGetStatsPending_ = false;
|
||||||
serviceStub = new OstProto::OstService::Stub(rpcChannel,
|
serviceStub = new OstProto::OstService::Stub(rpcChannel,
|
||||||
OstProto::OstService::STUB_OWNS_CHANNEL);
|
OstProto::OstService::STUB_OWNS_CHANNEL);
|
||||||
|
|
||||||
@ -640,8 +641,12 @@ void PortGroup::getPortStats()
|
|||||||
if (state() != QAbstractSocket::ConnectedState)
|
if (state() != QAbstractSocket::ConnectedState)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (isGetStatsPending_)
|
||||||
|
return;
|
||||||
|
|
||||||
portStatsList = new OstProto::PortStatsList;
|
portStatsList = new OstProto::PortStatsList;
|
||||||
rpcControllerStats->Reset();
|
rpcControllerStats->Reset();
|
||||||
|
isGetStatsPending_ = true;
|
||||||
serviceStub->getStats(rpcControllerStats, &portIdList, portStatsList,
|
serviceStub->getStats(rpcControllerStats, &portIdList, portStatsList,
|
||||||
NewCallback(this, &PortGroup::processPortStatsList, portStatsList));
|
NewCallback(this, &PortGroup::processPortStatsList, portStatsList));
|
||||||
}
|
}
|
||||||
@ -669,6 +674,7 @@ void PortGroup::processPortStatsList(OstProto::PortStatsList *portStatsList)
|
|||||||
|
|
||||||
_error_exit:
|
_error_exit:
|
||||||
delete portStatsList;
|
delete portStatsList;
|
||||||
|
isGetStatsPending_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortGroup::clearPortStats(QList<uint> *portList)
|
void PortGroup::clearPortStats(QList<uint> *portList)
|
||||||
|
@ -34,6 +34,7 @@ private:
|
|||||||
PbRpcChannel *rpcChannel;
|
PbRpcChannel *rpcChannel;
|
||||||
PbRpcController *rpcController;
|
PbRpcController *rpcController;
|
||||||
PbRpcController *rpcControllerStats;
|
PbRpcController *rpcControllerStats;
|
||||||
|
bool isGetStatsPending_;
|
||||||
::OstProto::OstService::Stub *serviceStub;
|
::OstProto::OstService::Stub *serviceStub;
|
||||||
|
|
||||||
::OstProto::PortIdList portIdList;
|
::OstProto::PortIdList portIdList;
|
||||||
|
@ -71,7 +71,6 @@ PortsWindow::PortsWindow(PortGroupList *pgl, QWidget *parent)
|
|||||||
|
|
||||||
PortsWindow::~PortsWindow()
|
PortsWindow::~PortsWindow()
|
||||||
{
|
{
|
||||||
delete plm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortsWindow::on_tvStreamList_activated(const QModelIndex & index)
|
void PortsWindow::on_tvStreamList_activated(const QModelIndex & index)
|
||||||
|
@ -18,6 +18,9 @@
|
|||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="childrenCollapsible" >
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
<widget class="QTreeView" name="tvPortList" >
|
<widget class="QTreeView" name="tvPortList" >
|
||||||
<property name="contextMenuPolicy" >
|
<property name="contextMenuPolicy" >
|
||||||
<enum>Qt::ActionsContextMenu</enum>
|
<enum>Qt::ActionsContextMenu</enum>
|
||||||
|
@ -5,63 +5,100 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>142</width>
|
<width>299</width>
|
||||||
<height>98</height>
|
<height>114</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QGridLayout" >
|
||||||
<item>
|
<item row="0" column="0" >
|
||||||
<widget class="QGroupBox" name="groupBox_6" >
|
<widget class="QLabel" name="label" >
|
||||||
<property name="title" >
|
<property name="text" >
|
||||||
<string>Data Pattern</string>
|
<string>Type</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>cmbPatternMode</cstring>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="cmbPatternMode" >
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Fixed Word</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Increment Byte</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Decrement Byte</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text" >
|
|
||||||
<string>Random</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lePattern" >
|
|
||||||
<property name="inputMask" >
|
|
||||||
<string>>HH HH HH HH; </string>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string> </string>
|
|
||||||
</property>
|
|
||||||
<property name="maxLength" >
|
|
||||||
<number>11</number>
|
|
||||||
</property>
|
|
||||||
<property name="alignment" >
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1" >
|
||||||
|
<widget class="QComboBox" name="cmbPatternMode" >
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Fixed Word</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Increment Byte</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Decrement Byte</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text" >
|
||||||
|
<string>Random</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2" >
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" >
|
||||||
|
<widget class="QLabel" name="label_2" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Pattern</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" >
|
||||||
|
<cstring>lePattern</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" >
|
||||||
|
<widget class="QLineEdit" name="lePattern" >
|
||||||
|
<property name="inputMask" >
|
||||||
|
<string>>HH HH HH HH; </string>
|
||||||
|
</property>
|
||||||
|
<property name="text" >
|
||||||
|
<string> </string>
|
||||||
|
</property>
|
||||||
|
<property name="maxLength" >
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="alignment" >
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1" >
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -27,14 +27,25 @@ bool RpcServer::registerService(::google::protobuf::Service *service,
|
|||||||
connect(server, SIGNAL(newConnection()), this, SLOT(when_newConnection()));
|
connect(server, SIGNAL(newConnection()), this, SLOT(when_newConnection()));
|
||||||
if (!server->listen(QHostAddress::Any, tcpPortNum))
|
if (!server->listen(QHostAddress::Any, tcpPortNum))
|
||||||
{
|
{
|
||||||
LogInt(tr("Unable to start the server: %1").arg(server->errorString()));
|
qDebug("Unable to start the server: %s",
|
||||||
|
server->errorString().toAscii().constData());
|
||||||
|
errorString_ = QString("Error starting Ostinato server: %1").arg(
|
||||||
|
server->errorString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogInt(tr("The server is running on %1:%2").arg(server->serverAddress().toString()).arg(server->serverPort()));
|
qDebug("The server is running on %s: %d",
|
||||||
|
server->serverAddress().toString().toAscii().constData(),
|
||||||
|
server->serverPort());
|
||||||
|
errorString_ = QString();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RpcServer::errorString()
|
||||||
|
{
|
||||||
|
return errorString_;
|
||||||
|
}
|
||||||
|
|
||||||
void RpcServer::done(::google::protobuf::Message *resp, PbRpcController *PbRpcController)
|
void RpcServer::done(::google::protobuf::Message *resp, PbRpcController *PbRpcController)
|
||||||
{
|
{
|
||||||
QIODevice *blob;
|
QIODevice *blob;
|
||||||
@ -111,7 +122,7 @@ void RpcServer::when_newConnection()
|
|||||||
{
|
{
|
||||||
QTcpSocket *sock;
|
QTcpSocket *sock;
|
||||||
|
|
||||||
LogInt(tr("already connected, no new connections will be accepted\n"));
|
qDebug("already connected, no new connections will be accepted");
|
||||||
|
|
||||||
// Accept and close connection
|
// Accept and close connection
|
||||||
//! \todo (MED) Send reason msg to client
|
//! \todo (MED) Send reason msg to client
|
||||||
@ -122,7 +133,9 @@ void RpcServer::when_newConnection()
|
|||||||
}
|
}
|
||||||
|
|
||||||
clientSock = server->nextPendingConnection();
|
clientSock = server->nextPendingConnection();
|
||||||
LogInt(tr("accepting new connection from %1:%2").arg(clientSock->peerAddress().toString()).arg(clientSock->peerPort()));
|
qDebug("accepting new connection from %s: %d",
|
||||||
|
clientSock->peerAddress().toString().toAscii().constData(),
|
||||||
|
clientSock->peerPort());
|
||||||
|
|
||||||
connect(clientSock, SIGNAL(readyRead()),
|
connect(clientSock, SIGNAL(readyRead()),
|
||||||
this, SLOT(when_dataAvail()));
|
this, SLOT(when_dataAvail()));
|
||||||
@ -137,7 +150,9 @@ _exit:
|
|||||||
|
|
||||||
void RpcServer::when_disconnected()
|
void RpcServer::when_disconnected()
|
||||||
{
|
{
|
||||||
LogInt(tr("connection closed from %1:%2").arg(clientSock->peerAddress().toString()).arg(clientSock->peerPort()));
|
qDebug("connection closed from %s: %d",
|
||||||
|
clientSock->peerAddress().toString().toAscii().constData(),
|
||||||
|
clientSock->peerPort());
|
||||||
|
|
||||||
clientSock->deleteLater();
|
clientSock->deleteLater();
|
||||||
clientSock = NULL;
|
clientSock = NULL;
|
||||||
@ -145,7 +160,7 @@ void RpcServer::when_disconnected()
|
|||||||
|
|
||||||
void RpcServer::when_error(QAbstractSocket::SocketError socketError)
|
void RpcServer::when_error(QAbstractSocket::SocketError socketError)
|
||||||
{
|
{
|
||||||
LogInt(clientSock->errorString());
|
qDebug("%s", clientSock->errorString().toAscii().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RpcServer::when_dataAvail()
|
void RpcServer::when_dataAvail()
|
||||||
|
@ -23,8 +23,7 @@ class RpcServer : public QObject
|
|||||||
|
|
||||||
bool isPending;
|
bool isPending;
|
||||||
int pendingMethodId;
|
int pendingMethodId;
|
||||||
|
QString errorString_;
|
||||||
void LogInt (QString log) {qDebug("%s", log.toAscii().data());}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RpcServer(); //! \todo (LOW) use 'parent' param
|
RpcServer(); //! \todo (LOW) use 'parent' param
|
||||||
@ -32,6 +31,7 @@ public:
|
|||||||
|
|
||||||
bool registerService(::google::protobuf::Service *service,
|
bool registerService(::google::protobuf::Service *service,
|
||||||
quint16 tcpPortNum);
|
quint16 tcpPortNum);
|
||||||
|
QString errorString();
|
||||||
void done(::google::protobuf::Message *resp, PbRpcController *controller);
|
void done(::google::protobuf::Message *resp, PbRpcController *controller);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
#ifndef _ABSTRACT_HOST
|
|
||||||
#define _ABSTRACT_HOST
|
|
||||||
|
|
||||||
class AbstractHost
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void Log(const char* str) = 0;
|
|
||||||
#if 0 // PB
|
|
||||||
virtual int SendMsg(const void* msg, int size) = 0;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,23 +1,76 @@
|
|||||||
#include "drone.h"
|
#include "drone.h"
|
||||||
|
|
||||||
|
#include "rpcserver.h"
|
||||||
|
#include "myservice.h"
|
||||||
|
|
||||||
|
#include <QCloseEvent>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
extern int myport;
|
extern int myport;
|
||||||
|
|
||||||
Drone::Drone(QDialog *parent)
|
Drone::Drone(QWidget *parent)
|
||||||
: QDialog(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
rpcServer = new RpcServer();
|
rpcServer = new RpcServer();
|
||||||
service = new MyService(this);
|
service = new MyService();
|
||||||
rpcServer->registerService(service, myport ? myport : 7878);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Drone::Log(const char* str)
|
|
||||||
{
|
|
||||||
ui.teLog->append(QString(str));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Drone::LogInt(const QString &str)
|
Drone::~Drone()
|
||||||
{
|
{
|
||||||
ui.teLog->append(str);
|
trayIcon_->hide();
|
||||||
|
delete rpcServer;
|
||||||
|
delete service;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Drone::init()
|
||||||
|
{
|
||||||
|
Q_ASSERT(rpcServer);
|
||||||
|
|
||||||
|
if (!rpcServer->registerService(service, myport ? myport : 7878))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(0, qApp->applicationName(),
|
||||||
|
rpcServer->errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
trayIconMenu_ = new QMenu(this);
|
||||||
|
|
||||||
|
trayIconMenu_->addAction(actionShow);
|
||||||
|
trayIconMenu_->addAction(actionExit);
|
||||||
|
trayIconMenu_->setDefaultAction(actionShow);
|
||||||
|
trayIcon_ = new QSystemTrayIcon();
|
||||||
|
trayIcon_->setIcon(QIcon(":/icons/portgroup.png"));
|
||||||
|
trayIcon_->setToolTip(qApp->applicationName());
|
||||||
|
trayIcon_->setContextMenu(trayIconMenu_);
|
||||||
|
trayIcon_->show();
|
||||||
|
|
||||||
|
connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
|
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
|
||||||
|
connect(this, SIGNAL(hideMe(bool)), this, SLOT(setHidden(bool)),
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Drone::changeEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
if (event->type() == QEvent::WindowStateChange && isMinimized())
|
||||||
|
{
|
||||||
|
emit hideMe(true);
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget::changeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Drone::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||||
|
{
|
||||||
|
if (reason == QSystemTrayIcon::DoubleClick)
|
||||||
|
{
|
||||||
|
showNormal();
|
||||||
|
activateWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,37 @@
|
|||||||
#ifndef _DRONE_H
|
#ifndef _DRONE_H
|
||||||
#define _DRONE_H
|
#define _DRONE_H
|
||||||
|
|
||||||
#include <QTcpServer>
|
|
||||||
#include <QTcpSocket>
|
|
||||||
|
|
||||||
#include "ui_drone.h"
|
#include "ui_drone.h"
|
||||||
#include "abstracthost.h"
|
|
||||||
#include "rpcserver.h"
|
|
||||||
#include "myservice.h"
|
|
||||||
|
|
||||||
class Drone : public QDialog, AbstractHost
|
#include <QMenu>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
|
class RpcServer;
|
||||||
|
namespace OstProto { class OstService; }
|
||||||
|
|
||||||
|
class Drone : public QWidget, Ui::Drone
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ui::Drone ui;
|
Drone(QWidget *parent = 0);
|
||||||
Drone(QDialog *parent = 0);
|
~Drone();
|
||||||
void Log(const char *msg);
|
bool init();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void hideMe(bool hidden);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent(QEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSystemTrayIcon *trayIcon_;
|
||||||
|
QMenu *trayIconMenu_;
|
||||||
|
RpcServer *rpcServer;
|
||||||
|
OstProto::OstService *service;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||||
|
|
||||||
private:
|
|
||||||
RpcServer *rpcServer;
|
|
||||||
OstProto::OstService *service;
|
|
||||||
void LogInt(const QString &msg);
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,6 +11,7 @@ unix:LIBS += -L"../common" -lostproto
|
|||||||
win32:LIBS += -L"../rpc/debug" -lpbrpc
|
win32:LIBS += -L"../rpc/debug" -lpbrpc
|
||||||
unix:LIBS += -L"../rpc" -lpbrpc
|
unix:LIBS += -L"../rpc" -lpbrpc
|
||||||
POST_TARGETDEPS += "../common/debug/libostproto.a" "../rpc/debug/libpbrpc.a"
|
POST_TARGETDEPS += "../common/debug/libostproto.a" "../rpc/debug/libpbrpc.a"
|
||||||
|
RESOURCES += drone.qrc
|
||||||
HEADERS += drone.h
|
HEADERS += drone.h
|
||||||
FORMS += drone.ui
|
FORMS += drone.ui
|
||||||
SOURCES += drone_main.cpp drone.cpp
|
SOURCES += drone_main.cpp drone.cpp
|
||||||
|
182
server/drone.ui
182
server/drone.ui
@ -1,69 +1,82 @@
|
|||||||
<ui version="4.0" >
|
<ui version="4.0" >
|
||||||
<class>Drone</class>
|
<class>Drone</class>
|
||||||
<widget class="QDialog" name="Drone" >
|
<widget class="QWidget" name="Drone" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>268</width>
|
||||||
<height>300</height>
|
<height>216</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle" >
|
||||||
<string>Drone</string>
|
<string>Drone</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="windowIcon" >
|
||||||
|
<iconset resource="drone.qrc" >:/icons/portgroup.png</iconset>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="twDisplay" >
|
<spacer>
|
||||||
<property name="currentIndex" >
|
<property name="orientation" >
|
||||||
<number>1</number>
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2" >
|
||||||
|
<property name="text" >
|
||||||
|
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
|
p, li { white-space: pre-wrap; }
|
||||||
|
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:29pt; font-weight:600;">Ostinato</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment" >
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tabStatus" >
|
|
||||||
<attribute name="title" >
|
|
||||||
<string>Status</string>
|
|
||||||
</attribute>
|
|
||||||
<widget class="QLabel" name="label" >
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>160</x>
|
|
||||||
<y>100</y>
|
|
||||||
<width>46</width>
|
|
||||||
<height>14</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string>TODO</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="tabLog" >
|
|
||||||
<attribute name="title" >
|
|
||||||
<string>Log</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QHBoxLayout" >
|
|
||||||
<item>
|
|
||||||
<widget class="QTextEdit" name="teLog" >
|
|
||||||
<property name="readOnly" >
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="acceptRichText" >
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>(Server)</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment" >
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>TODO: Info/Status here</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment" >
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>51</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" >
|
<layout class="QHBoxLayout" >
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pbClearLog" >
|
|
||||||
<property name="text" >
|
|
||||||
<string>Clear Log</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
@ -84,41 +97,82 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" >
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
<action name="actionShow" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Show</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionExit" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Exit</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="drone.qrc" />
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>pushButton</sender>
|
<sender>pushButton</sender>
|
||||||
<signal>clicked(bool)</signal>
|
<signal>clicked()</signal>
|
||||||
<receiver>Drone</receiver>
|
<receiver>actionExit</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>trigger()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel" >
|
<hint type="sourcelabel" >
|
||||||
<x>341</x>
|
<x>134</x>
|
||||||
<y>279</y>
|
<y>194</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel" >
|
<hint type="destinationlabel" >
|
||||||
<x>226</x>
|
<x>-1</x>
|
||||||
<y>268</y>
|
<y>-1</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>pbClearLog</sender>
|
<sender>actionShow</sender>
|
||||||
<signal>clicked()</signal>
|
<signal>triggered()</signal>
|
||||||
<receiver>teLog</receiver>
|
<receiver>Drone</receiver>
|
||||||
<slot>clear()</slot>
|
<slot>showNormal()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel" >
|
<hint type="sourcelabel" >
|
||||||
<x>52</x>
|
<x>-1</x>
|
||||||
<y>278</y>
|
<y>-1</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel" >
|
<hint type="destinationlabel" >
|
||||||
<x>100</x>
|
<x>133</x>
|
||||||
<y>185</y>
|
<y>107</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>actionExit</sender>
|
||||||
|
<signal>triggered()</signal>
|
||||||
|
<receiver>Drone</receiver>
|
||||||
|
<slot>close()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel" >
|
||||||
|
<x>-1</x>
|
||||||
|
<y>-1</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel" >
|
||||||
|
<x>133</x>
|
||||||
|
<y>107</y>
|
||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
@ -1,18 +1,25 @@
|
|||||||
#include "drone.h"
|
#include "drone.h"
|
||||||
|
|
||||||
Drone *drone;
|
|
||||||
|
|
||||||
int myport;
|
int myport;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
Drone drone;
|
||||||
|
|
||||||
|
app.setApplicationName(drone.objectName());
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
myport = atoi(argv[1]);
|
myport = atoi(argv[1]);
|
||||||
|
|
||||||
drone = new Drone;
|
if (!drone.init())
|
||||||
drone->show();
|
exit(-1);
|
||||||
return app.exec();
|
|
||||||
|
drone.setWindowFlags(drone.windowFlags()
|
||||||
|
| Qt::WindowMaximizeButtonHint
|
||||||
|
| Qt::WindowMinimizeButtonHint);
|
||||||
|
drone.showMinimized();
|
||||||
|
app.exec();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
server/icons/portgroup.png
Normal file
BIN
server/icons/portgroup.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 667 B |
@ -14,7 +14,7 @@
|
|||||||
#include <Ntddndis.h>
|
#include <Ntddndis.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LOG(...) {sprintf(logStr, __VA_ARGS__); host->Log(logStr);}
|
#define LOG(...) {}
|
||||||
#define MB (1024*1024)
|
#define MB (1024*1024)
|
||||||
|
|
||||||
StreamInfo::StreamInfo()
|
StreamInfo::StreamInfo()
|
||||||
@ -831,14 +831,13 @@ _found:
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
MyService::MyService(AbstractHost *host)
|
MyService::MyService()
|
||||||
{
|
{
|
||||||
pcap_if_t *dev;
|
pcap_if_t *dev;
|
||||||
int i=0;
|
int i=0;
|
||||||
char errbuf[PCAP_ERRBUF_SIZE];
|
char errbuf[PCAP_ERRBUF_SIZE];
|
||||||
|
|
||||||
// Init Data
|
// Init Data
|
||||||
this->host = host;
|
|
||||||
numPorts = 0;
|
numPorts = 0;
|
||||||
alldevs = NULL;
|
alldevs = NULL;
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include "../common/protocol.pb.h"
|
#include "../common/protocol.pb.h"
|
||||||
#include "../common/streambase.h"
|
#include "../common/streambase.h"
|
||||||
#include "abstracthost.h"
|
|
||||||
#include <pcap.h>
|
#include <pcap.h>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@ -191,9 +190,6 @@ public:
|
|||||||
|
|
||||||
class MyService: public OstProto::OstService
|
class MyService: public OstProto::OstService
|
||||||
{
|
{
|
||||||
AbstractHost *host;
|
|
||||||
char logStr[1024];
|
|
||||||
|
|
||||||
uint numPorts;
|
uint numPorts;
|
||||||
|
|
||||||
/*! PortInfo::d::port_id and index into portInfo[] are same! */
|
/*! PortInfo::d::port_id and index into portInfo[] are same! */
|
||||||
@ -203,7 +199,7 @@ class MyService: public OstProto::OstService
|
|||||||
int getStreamIndex(unsigned int portIdx,unsigned int streamId);
|
int getStreamIndex(unsigned int portIdx,unsigned int streamId);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyService(AbstractHost* host);
|
MyService();
|
||||||
virtual ~MyService();
|
virtual ~MyService();
|
||||||
|
|
||||||
/* Methods provided by the service */
|
/* Methods provided by the service */
|
||||||
|
Loading…
Reference in New Issue
Block a user