mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-03-10 22:44:21 +00:00
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/.
This commit is contained in:
parent
239c9e46ea
commit
9ffda4f955
@ -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
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "mainwindow.h"
|
||||
#include "aboutwindow.h"
|
||||
#include "network.h"
|
||||
#include "networkwidget.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <string>
|
||||
@ -143,13 +143,13 @@ void MainWindow::customEvent(QEvent *event)
|
||||
byNwid[l[2]] = l;
|
||||
}
|
||||
|
||||
std::map< std::string,std::pair<int,Network *> > existingByNwid;
|
||||
std::map< std::string,std::pair<int,NetworkWidget *> > existingByNwid;
|
||||
for(int r=0;r<ui->networkListWidget->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<int,Network *> >::iterator i(existingByNwid.begin());i!=existingByNwid.end();++i) {
|
||||
for(std::map< std::string,std::pair<int,NetworkWidget *> >::iterator i(existingByNwid.begin());i!=existingByNwid.end();++i) {
|
||||
if (byNwid.count(i->first)) {
|
||||
std::vector<std::string> &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<std::string> >::iterator i(byNwid.begin());i!=byNwid.end();++i) {
|
||||
if (!existingByNwid.count(i->first)) {
|
||||
std::vector<std::string> &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]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "network.h"
|
||||
#include "networkwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ui_network.h"
|
||||
#include "ui_networkwidget.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QString>
|
||||
@ -10,9 +10,9 @@
|
||||
#include <QList>
|
||||
#include <QMessageBox>
|
||||
|
||||
Network::Network(QWidget *parent,const std::string &nwid) :
|
||||
NetworkWidget::NetworkWidget(QWidget *parent,const std::string &nwid) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Network),
|
||||
ui(new Ui::NetworkWidget),
|
||||
networkIdStr(nwid)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -23,12 +23,12 @@ Network::Network(QWidget *parent,const std::string &nwid) :
|
||||
ui->ipListWidget->setMaximumHeight(lineHeight * 3);
|
||||
}
|
||||
|
||||
Network::~Network()
|
||||
NetworkWidget::~NetworkWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Network::setStatus(const std::string &status,const std::string &age)
|
||||
void NetworkWidget::setStatus(const std::string &status,const std::string &age)
|
||||
{
|
||||
ui->statusLabel->setText(QString(status.c_str()));
|
||||
if (status == "OK")
|
||||
@ -36,12 +36,12 @@ void Network::setStatus(const std::string &status,const std::string &age)
|
||||
else ui->ageLabel->setText(QString());
|
||||
}
|
||||
|
||||
void Network::setNetworkName(const std::string &name)
|
||||
void NetworkWidget::setNetworkName(const std::string &name)
|
||||
{
|
||||
ui->nameLabel->setText(QString(name.c_str()));
|
||||
}
|
||||
|
||||
void Network::setNetworkType(const std::string &type)
|
||||
void NetworkWidget::setNetworkType(const std::string &type)
|
||||
{
|
||||
ui->networkTypeLabel->setText(QString(type.c_str()));
|
||||
if (type == "?")
|
||||
@ -53,12 +53,12 @@ void Network::setNetworkType(const std::string &type)
|
||||
else ui->networkTypeLabel->setToolTip(QString());
|
||||
}
|
||||
|
||||
void Network::setNetworkDeviceName(const std::string &dev)
|
||||
void NetworkWidget::setNetworkDeviceName(const std::string &dev)
|
||||
{
|
||||
ui->deviceLabel->setText(QString(dev.c_str()));
|
||||
}
|
||||
|
||||
void Network::setIps(const std::string &commaSeparatedList)
|
||||
void NetworkWidget::setIps(const std::string &commaSeparatedList)
|
||||
{
|
||||
QStringList ips(QString(commaSeparatedList.c_str()).split(QChar(','),QString::SkipEmptyParts));
|
||||
if (commaSeparatedList == "-")
|
||||
@ -87,12 +87,12 @@ void Network::setIps(const std::string &commaSeparatedList)
|
||||
}
|
||||
}
|
||||
|
||||
const std::string &Network::networkId()
|
||||
const std::string &NetworkWidget::networkId()
|
||||
{
|
||||
return networkIdStr;
|
||||
}
|
||||
|
||||
void Network::on_leaveNetworkButton_clicked()
|
||||
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());
|
||||
@ -100,7 +100,7 @@ void Network::on_leaveNetworkButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void Network::on_networkIdPushButton_clicked()
|
||||
void NetworkWidget::on_networkIdPushButton_clicked()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->networkIdPushButton->text());
|
||||
}
|
@ -6,16 +6,16 @@
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class Network;
|
||||
class NetworkWidget;
|
||||
}
|
||||
|
||||
class Network : public QWidget
|
||||
class NetworkWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Network(QWidget *parent = 0,const std::string &nwid = std::string());
|
||||
virtual ~Network();
|
||||
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);
|
||||
@ -30,7 +30,7 @@ private slots:
|
||||
void on_networkIdPushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::Network *ui;
|
||||
Ui::NetworkWidget *ui;
|
||||
std::string networkIdStr;
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Network</class>
|
||||
<widget class="QWidget" name="Network">
|
||||
<class>NetworkWidget</class>
|
||||
<widget class="QWidget" name="NetworkWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
@ -207,11 +207,11 @@ void Utils::getSecureRandom(void *buf,unsigned int bytes)
|
||||
{
|
||||
int fd = ::open("/dev/urandom",O_RDONLY);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr,"FATAL ERROR: unable to open /dev/urandom"ZT_EOL_S);
|
||||
fprintf(stderr,"FATAL ERROR: unable to open /dev/urandom%s",ZT_EOL_S);
|
||||
exit(-1);
|
||||
}
|
||||
if ((int)::read(fd,randbuf,sizeof(randbuf)) != (int)sizeof(randbuf)) {
|
||||
fprintf(stderr,"FATAL ERROR: unable to read from /dev/urandom"ZT_EOL_S);
|
||||
fprintf(stderr,"FATAL ERROR: unable to read from /dev/urandom%s",ZT_EOL_S);
|
||||
exit(-1);
|
||||
}
|
||||
::close(fd);
|
||||
|
Loading…
x
Reference in New Issue
Block a user