2008-05-03 09:37:10 -05:00
|
|
|
#ifndef _PORT_GROUP_H
|
|
|
|
#define _PORT_GROUP_H
|
|
|
|
|
|
|
|
#include "port.h"
|
|
|
|
#include <QHostAddress>
|
|
|
|
#include <QTcpSocket>
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
#include "../common/protocol.pb.h"
|
|
|
|
#include "pbrpcchannel.h"
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
/* TODO
|
|
|
|
HIGH
|
|
|
|
MED
|
|
|
|
LOW
|
|
|
|
- Allow hostnames in addition to IP Address as "server address"
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEFAULT_SERVER_PORT 7878
|
|
|
|
|
|
|
|
class PortGroup : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
quint32 mPortGroupId;
|
|
|
|
static quint32 mPortGroupAllocId;
|
|
|
|
QString mUserAlias; // user defined
|
2008-08-08 22:22:13 -05:00
|
|
|
#if 0 // PB
|
2008-05-03 09:37:10 -05:00
|
|
|
QTcpSocket *mpSocket;
|
|
|
|
QHostAddress mServerAddress;
|
|
|
|
quint16 mServerPort;
|
2008-08-08 22:22:13 -05:00
|
|
|
#endif
|
|
|
|
PbRpcChannel *rpcChannel;
|
|
|
|
::google::protobuf::RpcController *rpcController;
|
|
|
|
OstProto::OstService::Stub *serviceStub;
|
2008-05-03 09:37:10 -05:00
|
|
|
public: // FIXME(HIGH): member access
|
|
|
|
QList<Port> mPorts;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PortGroup(QHostAddress ip = QHostAddress::LocalHost,
|
|
|
|
quint16 port = DEFAULT_SERVER_PORT);
|
|
|
|
~PortGroup();
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
void connectToHost() { rpcChannel->establish(); }
|
|
|
|
void connectToHost(QHostAddress ip, quint16 port)
|
|
|
|
{ rpcChannel->establish(ip, port); }
|
|
|
|
void disconnectFromHost() { rpcChannel->tearDown(); }
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
int numPorts() const { return mPorts.size(); }
|
|
|
|
quint32 id() const { return mPortGroupId; }
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
const QString& userAlias() const { return mUserAlias; }
|
2008-05-03 09:37:10 -05:00
|
|
|
void setUserAlias(QString alias) { mUserAlias = alias; };
|
|
|
|
|
2008-08-08 22:22:13 -05:00
|
|
|
const QHostAddress& serverAddress() const
|
|
|
|
{ return rpcChannel->serverAddress(); }
|
|
|
|
quint16 serverPort() const
|
|
|
|
{ return rpcChannel->serverPort(); }
|
|
|
|
QAbstractSocket::SocketState state() const
|
|
|
|
{ return rpcChannel->state(); }
|
|
|
|
|
|
|
|
void processPortIdList(OstProto::PortIdList *portIdList);
|
|
|
|
void processPortConfigList(OstProto::PortConfigList *portConfigList);
|
|
|
|
|
2008-05-03 09:37:10 -05:00
|
|
|
signals:
|
|
|
|
void portGroupDataChanged(PortGroup* portGroup);
|
|
|
|
void portListAboutToBeChanged(quint32 portGroupId);
|
|
|
|
void portListChanged(quint32 portGroupId);
|
|
|
|
|
|
|
|
private slots:
|
2008-08-08 22:22:13 -05:00
|
|
|
void on_rpcChannel_stateChanged();
|
|
|
|
void on_rpcChannel_connected();
|
|
|
|
void on_rpcChannel_disconnected();
|
|
|
|
void on_rpcChannel_error(QAbstractSocket::SocketError socketError);
|
|
|
|
#if 0 // PB
|
|
|
|
void on_rpcChannel_when_dataAvail();
|
|
|
|
#endif
|
2008-05-03 09:37:10 -05:00
|
|
|
|
|
|
|
private:
|
2008-08-08 22:22:13 -05:00
|
|
|
#if 0 // PB
|
2008-05-03 09:37:10 -05:00
|
|
|
void ProcessCapabilityInfo(const char *msg, qint32 size);
|
|
|
|
void ProcessMsg(const char *msg, quint32 size);
|
2008-08-08 22:22:13 -05:00
|
|
|
#endif
|
2008-05-03 09:37:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|