2009-12-28 04:05:42 -06:00
|
|
|
#ifndef _PORT_GROUP_H
|
|
|
|
#define _PORT_GROUP_H
|
|
|
|
|
|
|
|
#include "port.h"
|
|
|
|
#include <QHostAddress>
|
|
|
|
#include <QTcpSocket>
|
|
|
|
|
|
|
|
#include "../common/protocol.pb.h"
|
|
|
|
#include "pbrpcchannel.h"
|
|
|
|
|
|
|
|
/* TODO
|
|
|
|
HIGH
|
|
|
|
MED
|
|
|
|
LOW
|
|
|
|
- Allow hostnames in addition to IP Address as "server address"
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEFAULT_SERVER_PORT 7878
|
|
|
|
|
|
|
|
class QFile;
|
|
|
|
|
|
|
|
class PortGroup : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
2010-02-09 09:21:52 -06:00
|
|
|
static quint32 mPortGroupAllocId;
|
|
|
|
quint32 mPortGroupId;
|
|
|
|
QString mUserAlias; // user defined
|
|
|
|
|
|
|
|
PbRpcChannel *rpcChannel;
|
2010-02-17 09:26:42 -06:00
|
|
|
PbRpcController *statsController;
|
2010-02-09 09:21:52 -06:00
|
|
|
bool isGetStatsPending_;
|
|
|
|
|
2010-02-17 09:26:42 -06:00
|
|
|
OstProto::OstService::Stub *serviceStub;
|
2010-02-09 09:21:52 -06:00
|
|
|
|
2010-02-17 09:26:42 -06:00
|
|
|
OstProto::PortIdList *portIdList_;
|
|
|
|
OstProto::PortStatsList *portStatsList_;
|
2009-12-28 04:05:42 -06:00
|
|
|
|
|
|
|
public: // FIXME(HIGH): member access
|
|
|
|
QList<Port*> mPorts;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PortGroup(QHostAddress ip = QHostAddress::LocalHost,
|
|
|
|
quint16 port = DEFAULT_SERVER_PORT);
|
|
|
|
~PortGroup();
|
|
|
|
|
|
|
|
void connectToHost() { rpcChannel->establish(); }
|
|
|
|
void connectToHost(QHostAddress ip, quint16 port)
|
|
|
|
{ rpcChannel->establish(ip, port); }
|
|
|
|
void disconnectFromHost() { rpcChannel->tearDown(); }
|
|
|
|
|
|
|
|
int numPorts() const { return mPorts.size(); }
|
|
|
|
quint32 id() const { return mPortGroupId; }
|
|
|
|
|
|
|
|
const QString& userAlias() const { return mUserAlias; }
|
|
|
|
void setUserAlias(QString alias) { mUserAlias = alias; };
|
|
|
|
|
|
|
|
const QHostAddress& serverAddress() const
|
|
|
|
{ return rpcChannel->serverAddress(); }
|
|
|
|
quint16 serverPort() const
|
|
|
|
{ return rpcChannel->serverPort(); }
|
|
|
|
QAbstractSocket::SocketState state() const
|
|
|
|
{ return rpcChannel->state(); }
|
|
|
|
|
2010-02-17 09:26:42 -06:00
|
|
|
void processPortIdList(PbRpcController *controller);
|
|
|
|
void processPortConfigList(PbRpcController *controller);
|
|
|
|
|
|
|
|
void processAddStreamAck(PbRpcController *controller);
|
|
|
|
void processDeleteStreamAck(PbRpcController *controller);
|
|
|
|
void processModifyStreamAck(int portIndex, PbRpcController *controller);
|
2009-12-28 04:05:42 -06:00
|
|
|
|
2010-02-09 09:21:52 -06:00
|
|
|
void modifyPort(int portId, bool isExclusive);
|
2010-02-17 09:26:42 -06:00
|
|
|
void processModifyPortAck(PbRpcController *controller);
|
|
|
|
void processUpdatedPortConfig(PbRpcController *controller);
|
2010-02-09 09:21:52 -06:00
|
|
|
|
2010-02-17 09:26:42 -06:00
|
|
|
void getStreamIdList();
|
|
|
|
void processStreamIdList(int portIndex, PbRpcController *controller);
|
|
|
|
void getStreamConfigList();
|
|
|
|
void processStreamConfigList(int portIndex, PbRpcController *controller);
|
2009-12-28 04:05:42 -06:00
|
|
|
|
|
|
|
void processModifyStreamAck(OstProto::Ack *ack);
|
|
|
|
|
|
|
|
void startTx(QList<uint> *portList = NULL);
|
2010-02-17 09:26:42 -06:00
|
|
|
void processStartTxAck(PbRpcController *controller);
|
2009-12-28 04:05:42 -06:00
|
|
|
void stopTx(QList<uint> *portList = NULL);
|
2010-02-17 09:26:42 -06:00
|
|
|
void processStopTxAck(PbRpcController *controller);
|
2009-12-28 04:05:42 -06:00
|
|
|
|
|
|
|
void startCapture(QList<uint> *portList = NULL);
|
2010-02-17 09:26:42 -06:00
|
|
|
void processStartCaptureAck(PbRpcController *controller);
|
2009-12-28 04:05:42 -06:00
|
|
|
void stopCapture(QList<uint> *portList = NULL);
|
2010-02-17 09:26:42 -06:00
|
|
|
void processStopCaptureAck(PbRpcController *controller);
|
2009-12-28 04:05:42 -06:00
|
|
|
void viewCapture(QList<uint> *portList = NULL);
|
2010-02-17 09:26:42 -06:00
|
|
|
void processViewCaptureAck(PbRpcController *controller);
|
2009-12-28 04:05:42 -06:00
|
|
|
|
|
|
|
void getPortStats();
|
2010-02-17 09:26:42 -06:00
|
|
|
void processPortStatsList();
|
2009-12-28 04:05:42 -06:00
|
|
|
void clearPortStats(QList<uint> *portList = NULL);
|
2010-02-17 09:26:42 -06:00
|
|
|
void processClearStatsAck(PbRpcController *controller);
|
2009-12-28 04:05:42 -06:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void portGroupDataChanged(int portGroupId, int portId = 0xFFFF);
|
|
|
|
void portListAboutToBeChanged(quint32 portGroupId);
|
|
|
|
void portListChanged(quint32 portGroupId);
|
|
|
|
void statsChanged(quint32 portGroupId);
|
|
|
|
|
|
|
|
private slots:
|
2010-02-09 09:21:52 -06:00
|
|
|
void on_rpcChannel_stateChanged(QAbstractSocket::SocketState state);
|
2009-12-28 04:05:42 -06:00
|
|
|
void on_rpcChannel_connected();
|
|
|
|
void on_rpcChannel_disconnected();
|
|
|
|
void on_rpcChannel_error(QAbstractSocket::SocketError socketError);
|
|
|
|
|
|
|
|
public slots:
|
2010-02-17 09:26:42 -06:00
|
|
|
void when_configApply(int portIndex);
|
2009-12-28 04:05:42 -06:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|