From 9ffda4f955283c50e559c23541567cca5fbf1607 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 12 Dec 2013 15:47:00 -0800 Subject: Update Qt build to enable building against local static libraries, rename Network to NetworkWidget to avoid filesystem or object naming collision with Network.o in node/. --- ZeroTierUI/ZeroTierUI.pro | 87 ++++++++- ZeroTierUI/mainwindow.cpp | 10 +- ZeroTierUI/network.cpp | 106 ----------- ZeroTierUI/network.h | 37 ---- ZeroTierUI/network.ui | 427 ------------------------------------------- ZeroTierUI/networkwidget.cpp | 106 +++++++++++ ZeroTierUI/networkwidget.h | 37 ++++ ZeroTierUI/networkwidget.ui | 427 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 652 insertions(+), 585 deletions(-) delete mode 100644 ZeroTierUI/network.cpp delete mode 100644 ZeroTierUI/network.h delete mode 100644 ZeroTierUI/network.ui create mode 100644 ZeroTierUI/networkwidget.cpp create mode 100644 ZeroTierUI/networkwidget.h create mode 100644 ZeroTierUI/networkwidget.ui (limited to 'ZeroTierUI') diff --git a/ZeroTierUI/ZeroTierUI.pro b/ZeroTierUI/ZeroTierUI.pro index 0bfcb819..245982d3 100644 --- a/ZeroTierUI/ZeroTierUI.pro +++ b/ZeroTierUI/ZeroTierUI.pro @@ -7,25 +7,92 @@ mac:ICON = zt1icon.icns mac:QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 mac:QMAKE_INFO_PLIST = Info.plist -# ZeroTier One must be built before building this, since it links in the -# client code and some stuff from Utils to talk to the running service. -LIBS += ../node/*.o - SOURCES += main.cpp\ mainwindow.cpp \ - network.cpp \ - aboutwindow.cpp + aboutwindow.cpp \ + ../node/C25519.cpp \ + ../node/CertificateOfMembership.cpp \ + ../node/Defaults.cpp \ + ../node/Demarc.cpp \ + ../node/EthernetTap.cpp \ + ../node/HttpClient.cpp \ + ../node/Identity.cpp \ + ../node/InetAddress.cpp \ + ../node/Logger.cpp \ + ../node/Multicaster.cpp \ + ../node/Network.cpp \ + ../node/NetworkConfig.cpp \ + ../node/Node.cpp \ + ../node/NodeConfig.cpp \ + ../node/Packet.cpp \ + ../node/PacketDecoder.cpp \ + ../node/Peer.cpp \ + ../node/Poly1305.cpp \ + ../node/Salsa20.cpp \ + ../node/Service.cpp \ + ../node/SHA512.cpp \ + ../node/SoftwareUpdater.cpp \ + ../node/Switch.cpp \ + ../node/SysEnv.cpp \ + ../node/Topology.cpp \ + ../node/UdpSocket.cpp \ + ../node/Utils.cpp \ + ../ext/lz4/lz4.c \ + ../ext/lz4/lz4hc.c \ + networkwidget.cpp HEADERS += mainwindow.h \ - network.h \ aboutwindow.h \ ../node/Node.hpp \ ../node/Utils.hpp \ - ../node/Defaults.hpp + ../node/Defaults.hpp \ + ../node/Address.hpp \ + ../node/Array.hpp \ + ../node/AtomicCounter.hpp \ + ../node/BandwidthAccount.hpp \ + ../node/Buffer.hpp \ + ../node/C25519.hpp \ + ../node/CertificateOfMembership.hpp \ + ../node/CMWC4096.hpp \ + ../node/Condition.hpp \ + ../node/Constants.hpp \ + ../node/Demarc.hpp \ + ../node/Dictionary.hpp \ + ../node/EthernetTap.hpp \ + ../node/HttpClient.hpp \ + ../node/Identity.hpp \ + ../node/InetAddress.hpp \ + ../node/Logger.hpp \ + ../node/MAC.hpp \ + ../node/Multicaster.hpp \ + ../node/MulticastGroup.hpp \ + ../node/Mutex.hpp \ + ../node/Network.hpp \ + ../node/NetworkConfig.hpp \ + ../node/NodeConfig.hpp \ + ../node/NonCopyable.hpp \ + ../node/Packet.hpp \ + ../node/PacketDecoder.hpp \ + ../node/Peer.hpp \ + ../node/Poly1305.hpp \ + ../node/RuntimeEnvironment.hpp \ + ../node/Salsa20.hpp \ + ../node/Service.hpp \ + ../node/SHA512.hpp \ + ../node/SharedPtr.hpp \ + ../node/SoftwareUpdater.hpp \ + ../node/Switch.hpp \ + ../node/SysEnv.hpp \ + ../node/Thread.hpp \ + ../node/Topology.hpp \ + ../node/UdpSocket.hpp \ + ../ext/lz4/lz4.h \ + ../ext/lz4/lz4hc.h \ + networkwidget.h FORMS += mainwindow.ui \ - network.ui \ - aboutwindow.ui + aboutwindow.ui \ + networkwidget.ui RESOURCES += \ resources.qrc diff --git a/ZeroTierUI/mainwindow.cpp b/ZeroTierUI/mainwindow.cpp index 6e972c73..afc981c6 100644 --- a/ZeroTierUI/mainwindow.cpp +++ b/ZeroTierUI/mainwindow.cpp @@ -1,6 +1,6 @@ #include "mainwindow.h" #include "aboutwindow.h" -#include "network.h" +#include "networkwidget.h" #include "ui_mainwindow.h" #include @@ -143,13 +143,13 @@ void MainWindow::customEvent(QEvent *event) byNwid[l[2]] = l; } - std::map< std::string,std::pair > existingByNwid; + std::map< std::string,std::pair > existingByNwid; for(int r=0;rnetworkListWidget->count();++r) { - Network *nw = (Network *)ui->networkListWidget->itemWidget(ui->networkListWidget->item(r)); + NetworkWidget *nw = (NetworkWidget *)ui->networkListWidget->itemWidget(ui->networkListWidget->item(r)); existingByNwid[nw->networkId()] = std::make_pair(r,nw); } - for(std::map< std::string,std::pair >::iterator i(existingByNwid.begin());i!=existingByNwid.end();++i) { + for(std::map< std::string,std::pair >::iterator i(existingByNwid.begin());i!=existingByNwid.end();++i) { if (byNwid.count(i->first)) { std::vector &l = byNwid[i->first]; i->second.second->setNetworkName(l[3]); @@ -165,7 +165,7 @@ void MainWindow::customEvent(QEvent *event) for(std::map< std::string,std::vector >::iterator i(byNwid.begin());i!=byNwid.end();++i) { if (!existingByNwid.count(i->first)) { std::vector &l = i->second; - Network *nw = new Network((QWidget *)0,i->first); + NetworkWidget *nw = new NetworkWidget((QWidget *)0,i->first); nw->setNetworkName(l[3]); nw->setStatus(l[4],l[5]); nw->setNetworkType(l[6]); diff --git a/ZeroTierUI/network.cpp b/ZeroTierUI/network.cpp deleted file mode 100644 index e23bc6ba..00000000 --- a/ZeroTierUI/network.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "network.h" -#include "mainwindow.h" -#include "ui_network.h" - -#include -#include -#include -#include -#include -#include -#include - -Network::Network(QWidget *parent,const std::string &nwid) : - QWidget(parent), - ui(new Ui::Network), - networkIdStr(nwid) -{ - ui->setupUi(this); - ui->networkIdPushButton->setText(QString(nwid.c_str())); - QFontMetrics fm(ui->ipListWidget->font()); - int lineHeight = ui->ipListWidget->spacing() + fm.height(); - ui->ipListWidget->setMinimumHeight(lineHeight * 3); - ui->ipListWidget->setMaximumHeight(lineHeight * 3); -} - -Network::~Network() -{ - delete ui; -} - -void Network::setStatus(const std::string &status,const std::string &age) -{ - ui->statusLabel->setText(QString(status.c_str())); - if (status == "OK") - ui->ageLabel->setText(QString("(configuration is ") + age.c_str() + " seconds old)"); - else ui->ageLabel->setText(QString()); -} - -void Network::setNetworkName(const std::string &name) -{ - ui->nameLabel->setText(QString(name.c_str())); -} - -void Network::setNetworkType(const std::string &type) -{ - ui->networkTypeLabel->setText(QString(type.c_str())); - if (type == "?") - ui->networkTypeLabel->setToolTip("Waiting for configuration..."); - else if (type == "public") - ui->networkTypeLabel->setToolTip("This network can be joined by anyone."); - else if (type == "private") - ui->networkTypeLabel->setToolTip("This network is private, only authorized peers can join."); - else ui->networkTypeLabel->setToolTip(QString()); -} - -void Network::setNetworkDeviceName(const std::string &dev) -{ - ui->deviceLabel->setText(QString(dev.c_str())); -} - -void Network::setIps(const std::string &commaSeparatedList) -{ - QStringList ips(QString(commaSeparatedList.c_str()).split(QChar(','),QString::SkipEmptyParts)); - if (commaSeparatedList == "-") - ips.clear(); - - QStringList tmp; - ips.sort(); - for(QStringList::iterator i(ips.begin());i!=ips.end();++i) { - QString ipOnly(*i); - int slashIdx = ipOnly.indexOf('/'); - if (slashIdx > 0) - ipOnly.truncate(slashIdx); - tmp.append(ipOnly); - } - ips = tmp; - - for(QStringList::iterator i(ips.begin());i!=ips.end();++i) { - if (ui->ipListWidget->findItems(*i,Qt::MatchCaseSensitive).size() == 0) - ui->ipListWidget->addItem(*i); - } - - for(int i=0;iipListWidget->count();++i) { - QListWidgetItem *item = ui->ipListWidget->item(i); - if (!ips.contains(item->text())) - ui->ipListWidget->removeItemWidget(item); - } -} - -const std::string &Network::networkId() -{ - return networkIdStr; -} - -void Network::on_leaveNetworkButton_clicked() -{ - if (QMessageBox::question(this,"Leave Network?",QString("Are you sure you want to leave network '") + networkIdStr.c_str() + "'?",QMessageBox::No,QMessageBox::Yes) == QMessageBox::Yes) { - zeroTierClient->send((QString("leave ") + networkIdStr.c_str()).toStdString()); - this->setEnabled(false); - } -} - -void Network::on_networkIdPushButton_clicked() -{ - QApplication::clipboard()->setText(ui->networkIdPushButton->text()); -} diff --git a/ZeroTierUI/network.h b/ZeroTierUI/network.h deleted file mode 100644 index a50354af..00000000 --- a/ZeroTierUI/network.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef NETWORK_H -#define NETWORK_H - -#include - -#include - -namespace Ui { -class Network; -} - -class Network : public QWidget -{ - Q_OBJECT - -public: - explicit Network(QWidget *parent = 0,const std::string &nwid = std::string()); - virtual ~Network(); - - void setStatus(const std::string &status,const std::string &age); - void setNetworkName(const std::string &name); - void setNetworkType(const std::string &type); - void setNetworkDeviceName(const std::string &dev); - void setIps(const std::string &commaSeparatedList); - - const std::string &networkId(); - -private slots: - void on_leaveNetworkButton_clicked(); - void on_networkIdPushButton_clicked(); - -private: - Ui::Network *ui; - std::string networkIdStr; -}; - -#endif // NETWORK_H diff --git a/ZeroTierUI/network.ui b/ZeroTierUI/network.ui deleted file mode 100644 index e6dc6524..00000000 --- a/ZeroTierUI/network.ui +++ /dev/null @@ -1,427 +0,0 @@ - - - Network - - - - 0 - 0 - 580 - 253 - - - - - 0 - 0 - - - - Network - - - - - - - 6 - - - 6 - - - 6 - - - 6 - - - 6 - - - - - - 0 - 0 - - - - - QFormLayout::ExpandingFieldsGrow - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - Qt::AlignHCenter|Qt::AlignTop - - - 6 - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Network ID: - - - Qt::PlainText - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Click to Copy Network ID to Clipboard - - - border: 0; padding: 0; margin: 0; text-align: left; - - - 0000000000000000 - - - true - - - - - - - Name: - - - Qt::PlainText - - - - - - - - 75 - true - - - - ? - - - Qt::PlainText - - - - - - - Type: - - - Qt::PlainText - - - - - - - - 75 - true - - - - ? - - - Qt::PlainText - - - - - - - Status: - - - Qt::PlainText - - - - - - - Device: - - - Qt::PlainText - - - - - - - - 75 - true - - - - ? - - - Qt::PlainText - - - - - - - - 0 - 0 - - - - - 12 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 75 - true - - - - ? - - - Qt::PlainText - - - - - - - - 0 - 0 - - - - - 10 - - - - (configuration is 0 seconds old) - - - Qt::PlainText - - - - - - - - - - - - - - 0 - 0 - - - - - 3 - - - QLayout::SetNoConstraint - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - false - - - - IP Address Assignments - - - Qt::PlainText - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - Courier - 12 - - - - Qt::NoFocus - - - QAbstractItemView::NoEditTriggers - - - false - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::ScrollPerPixel - - - true - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 10 - false - - - - padding: 0.1em; margin:0; - - - Leave Network - - - - - - - - - - - - - - diff --git a/ZeroTierUI/networkwidget.cpp b/ZeroTierUI/networkwidget.cpp new file mode 100644 index 00000000..3b461d80 --- /dev/null +++ b/ZeroTierUI/networkwidget.cpp @@ -0,0 +1,106 @@ +#include "networkwidget.h" +#include "mainwindow.h" +#include "ui_networkwidget.h" + +#include +#include +#include +#include +#include +#include +#include + +NetworkWidget::NetworkWidget(QWidget *parent,const std::string &nwid) : + QWidget(parent), + ui(new Ui::NetworkWidget), + networkIdStr(nwid) +{ + ui->setupUi(this); + ui->networkIdPushButton->setText(QString(nwid.c_str())); + QFontMetrics fm(ui->ipListWidget->font()); + int lineHeight = ui->ipListWidget->spacing() + fm.height(); + ui->ipListWidget->setMinimumHeight(lineHeight * 3); + ui->ipListWidget->setMaximumHeight(lineHeight * 3); +} + +NetworkWidget::~NetworkWidget() +{ + delete ui; +} + +void NetworkWidget::setStatus(const std::string &status,const std::string &age) +{ + ui->statusLabel->setText(QString(status.c_str())); + if (status == "OK") + ui->ageLabel->setText(QString("(configuration is ") + age.c_str() + " seconds old)"); + else ui->ageLabel->setText(QString()); +} + +void NetworkWidget::setNetworkName(const std::string &name) +{ + ui->nameLabel->setText(QString(name.c_str())); +} + +void NetworkWidget::setNetworkType(const std::string &type) +{ + ui->networkTypeLabel->setText(QString(type.c_str())); + if (type == "?") + ui->networkTypeLabel->setToolTip("Waiting for configuration..."); + else if (type == "public") + ui->networkTypeLabel->setToolTip("This network can be joined by anyone."); + else if (type == "private") + ui->networkTypeLabel->setToolTip("This network is private, only authorized peers can join."); + else ui->networkTypeLabel->setToolTip(QString()); +} + +void NetworkWidget::setNetworkDeviceName(const std::string &dev) +{ + ui->deviceLabel->setText(QString(dev.c_str())); +} + +void NetworkWidget::setIps(const std::string &commaSeparatedList) +{ + QStringList ips(QString(commaSeparatedList.c_str()).split(QChar(','),QString::SkipEmptyParts)); + if (commaSeparatedList == "-") + ips.clear(); + + QStringList tmp; + ips.sort(); + for(QStringList::iterator i(ips.begin());i!=ips.end();++i) { + QString ipOnly(*i); + int slashIdx = ipOnly.indexOf('/'); + if (slashIdx > 0) + ipOnly.truncate(slashIdx); + tmp.append(ipOnly); + } + ips = tmp; + + for(QStringList::iterator i(ips.begin());i!=ips.end();++i) { + if (ui->ipListWidget->findItems(*i,Qt::MatchCaseSensitive).size() == 0) + ui->ipListWidget->addItem(*i); + } + + for(int i=0;iipListWidget->count();++i) { + QListWidgetItem *item = ui->ipListWidget->item(i); + if (!ips.contains(item->text())) + ui->ipListWidget->removeItemWidget(item); + } +} + +const std::string &NetworkWidget::networkId() +{ + return networkIdStr; +} + +void NetworkWidget::on_leaveNetworkButton_clicked() +{ + if (QMessageBox::question(this,"Leave Network?",QString("Are you sure you want to leave network '") + networkIdStr.c_str() + "'?",QMessageBox::No,QMessageBox::Yes) == QMessageBox::Yes) { + zeroTierClient->send((QString("leave ") + networkIdStr.c_str()).toStdString()); + this->setEnabled(false); + } +} + +void NetworkWidget::on_networkIdPushButton_clicked() +{ + QApplication::clipboard()->setText(ui->networkIdPushButton->text()); +} diff --git a/ZeroTierUI/networkwidget.h b/ZeroTierUI/networkwidget.h new file mode 100644 index 00000000..2d1e7a87 --- /dev/null +++ b/ZeroTierUI/networkwidget.h @@ -0,0 +1,37 @@ +#ifndef NETWORK_H +#define NETWORK_H + +#include + +#include + +namespace Ui { +class NetworkWidget; +} + +class NetworkWidget : public QWidget +{ + Q_OBJECT + +public: + explicit NetworkWidget(QWidget *parent = 0,const std::string &nwid = std::string()); + virtual ~NetworkWidget(); + + void setStatus(const std::string &status,const std::string &age); + void setNetworkName(const std::string &name); + void setNetworkType(const std::string &type); + void setNetworkDeviceName(const std::string &dev); + void setIps(const std::string &commaSeparatedList); + + const std::string &networkId(); + +private slots: + void on_leaveNetworkButton_clicked(); + void on_networkIdPushButton_clicked(); + +private: + Ui::NetworkWidget *ui; + std::string networkIdStr; +}; + +#endif // NETWORK_H diff --git a/ZeroTierUI/networkwidget.ui b/ZeroTierUI/networkwidget.ui new file mode 100644 index 00000000..b0bd2c51 --- /dev/null +++ b/ZeroTierUI/networkwidget.ui @@ -0,0 +1,427 @@ + + + NetworkWidget + + + + 0 + 0 + 580 + 253 + + + + + 0 + 0 + + + + Network + + + + + + + 6 + + + 6 + + + 6 + + + 6 + + + 6 + + + + + + 0 + 0 + + + + + QFormLayout::ExpandingFieldsGrow + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::AlignHCenter|Qt::AlignTop + + + 6 + + + 2 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Network ID: + + + Qt::PlainText + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Click to Copy Network ID to Clipboard + + + border: 0; padding: 0; margin: 0; text-align: left; + + + 0000000000000000 + + + true + + + + + + + Name: + + + Qt::PlainText + + + + + + + + 75 + true + + + + ? + + + Qt::PlainText + + + + + + + Type: + + + Qt::PlainText + + + + + + + + 75 + true + + + + ? + + + Qt::PlainText + + + + + + + Status: + + + Qt::PlainText + + + + + + + Device: + + + Qt::PlainText + + + + + + + + 75 + true + + + + ? + + + Qt::PlainText + + + + + + + + 0 + 0 + + + + + 12 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 75 + true + + + + ? + + + Qt::PlainText + + + + + + + + 0 + 0 + + + + + 10 + + + + (configuration is 0 seconds old) + + + Qt::PlainText + + + + + + + + + + + + + + 0 + 0 + + + + + 3 + + + QLayout::SetNoConstraint + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + false + + + + IP Address Assignments + + + Qt::PlainText + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + Courier + 12 + + + + Qt::NoFocus + + + QAbstractItemView::NoEditTriggers + + + false + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::ScrollPerPixel + + + true + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 10 + false + + + + padding: 0.1em; margin:0; + + + Leave Network + + + + + + + + + + + + + + -- cgit v1.2.3