diff --git a/client/port.cpp b/client/port.cpp index 8771c0c..7f3b275 100644 --- a/client/port.cpp +++ b/client/port.cpp @@ -81,6 +81,10 @@ void Port::updatePortConfig(OstProto::Port *port) d.MergeFrom(*port); + // Setup a user-friendly alias for Win32 ports + if (name().startsWith("\\Device\\NPF_")) + setAlias(QString("if%1").arg(id())); + if (recalc) recalculateAverageRates(); } diff --git a/client/port.h b/client/port.h index 85ce89a..8496843 100644 --- a/client/port.h +++ b/client/port.h @@ -79,7 +79,8 @@ public: ~Port(); quint32 portGroupId() const { return mPortGroupId; } - const QString& userAlias() const { return mUserAlias; } + const QString userAlias() const + { return mUserAlias.isEmpty() ? name() : mUserAlias; } quint32 id() const { return d.port_id().id(); } @@ -103,7 +104,7 @@ public: { return avgBitsPerSec_; } //void setAdminEnable(AdminStatus status) { mAdminStatus = status; } - void setAlias(QString &alias) { mUserAlias = alias; } + void setAlias(QString alias) { mUserAlias = alias; } //void setExclusive(bool flag); int numStreams() { return mStreams.size(); } diff --git a/client/portgroup.cpp b/client/portgroup.cpp index 99faff4..d81767c 100644 --- a/client/portgroup.cpp +++ b/client/portgroup.cpp @@ -425,7 +425,6 @@ void PortGroup::processPortConfigList(PbRpcController *controller) { Port *port = mPorts[j]; - // FIXME: How to handle the generated ifX Win32 port names if (port->name() == pc->port_config().name().c_str()) { if (!port->userName().isEmpty() // rsvd? @@ -436,7 +435,7 @@ void PortGroup::processPortConfigList(PbRpcController *controller) "Port will not be reconfigured.") .arg(serverFullName()) .arg(j) - .arg(port->name()) + .arg(port->userAlias()) .arg(port->userName()); QMessageBox::warning(NULL, tr("Open Session"), warning); qWarning(qPrintable(warning)); diff --git a/client/portmodel.cpp b/client/portmodel.cpp index 479e2bc..cd1c9d7 100644 --- a/client/portmodel.cpp +++ b/client/portmodel.cpp @@ -179,7 +179,7 @@ QVariant PortModel::data(const QModelIndex &index, int role) const return QString("Port %1: %2 %3(%4)") .arg(port->id()) - .arg(port->name()) + .arg(port->userAlias()) .arg(rsvdBy) .arg(port->description()); } diff --git a/server/pcapport.cpp b/server/pcapport.cpp index 9fb13dc..45024a1 100644 --- a/server/pcapport.cpp +++ b/server/pcapport.cpp @@ -101,12 +101,8 @@ PcapPort::PcapPort(int id, const char *device) { if (strcmp(device, dev->name) == 0) { -#ifdef Q_OS_WIN32 - data_.set_name(QString("if%1").arg(id).toStdString()); -#else if (dev->name) data_.set_name(dev->name); -#endif if (dev->description) data_.set_description(dev->description);