From 71a8140abfcc6d53e65295653bed4f9fdc44ef9b Mon Sep 17 00:00:00 2001 From: "Srivats P." Date: Mon, 27 Dec 2010 16:20:30 +0530 Subject: [PATCH] Provide descriptive text and further pointer to user if a port group has no ports --- client/portgroup.cpp | 27 +++++++++++++++++++++++++-- client/portgroup.h | 2 ++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/client/portgroup.cpp b/client/portgroup.cpp index 43e68a3..92bc097 100644 --- a/client/portgroup.cpp +++ b/client/portgroup.cpp @@ -67,6 +67,9 @@ PortGroup::PortGroup(QHostAddress ip, quint16 port) this, SLOT(on_rpcChannel_disconnected())); connect(rpcChannel, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(on_rpcChannel_error(QAbstractSocket::SocketError))); + + connect(this, SIGNAL(portListChanged(quint32)), + this, SLOT(when_portListChanged(quint32)), Qt::QueuedConnection); } PortGroup::~PortGroup() @@ -155,6 +158,23 @@ void PortGroup::on_rpcChannel_error(QAbstractSocket::SocketError socketError) } } +void PortGroup::when_portListChanged(quint32 /*portGroupId*/) +{ + if (state() == QAbstractSocket::ConnectedState && numPorts() <= 0) + { + QMessageBox::warning(NULL, tr("Ostinato"), + QString("The portgroup %1:%2 does not contain any ports!\n\n" + "Packet Transmit/Capture requires elevated privileges. " + "Please ensure that you are running 'drone' - the server " + "component of Ostinato with admin/root OR setuid privilege.\n\n" + "For more information see " + "http://ostinato.googlecode.com/wiki/FAQ#" + "Q._Port_group_has_no_interfaces") + .arg(serverAddress().toString()) + .arg(int(serverPort()))); + } +} + void PortGroup::processPortIdList(PbRpcController *controller) { OstProto::PortIdList *portIdList @@ -221,7 +241,7 @@ void PortGroup::processPortConfigList(PbRpcController *controller) goto _error_exit; } - emit portListAboutToBeChanged(mPortGroupId); + //emit portListAboutToBeChanged(mPortGroupId); for(int i = 0; i < portConfigList->port_size(); i++) { @@ -232,7 +252,7 @@ void PortGroup::processPortConfigList(PbRpcController *controller) mPorts[id]->updatePortConfig(portConfigList->mutable_port(i)); } - emit portListChanged(mPortGroupId); + //emit portListChanged(mPortGroupId); // FIXME: check if we need new signals since we are not changing the // number of ports, just the port data @@ -735,6 +755,9 @@ void PortGroup::getPortStats() if (state() != QAbstractSocket::ConnectedState) goto _exit; + if (numPorts() <= 0) + goto _exit; + if (isGetStatsPending_) goto _exit; diff --git a/client/portgroup.h b/client/portgroup.h index 8261576..254e731 100644 --- a/client/portgroup.h +++ b/client/portgroup.h @@ -135,6 +135,8 @@ private slots: void on_rpcChannel_disconnected(); void on_rpcChannel_error(QAbstractSocket::SocketError socketError); + void when_portListChanged(quint32 portGroupId); + public slots: void when_configApply(int portIndex);