Build fix for UI and mac.

This commit is contained in:
Adam Ierymenko 2014-10-29 19:54:24 -07:00
parent 0e84eb3852
commit 8bd9f7d51d
4 changed files with 57 additions and 43 deletions

View File

@ -18,37 +18,37 @@ SOURCES += main.cpp \
installdialog.cpp \
licensedialog.cpp \
onetimedialog.cpp \
../control/IpcConnection.cpp \
../control/IpcListener.cpp \
../control/NodeControlClient.cpp \
../control/NodeControlService.cpp \
../node/C25519.cpp \
../node/CertificateOfMembership.cpp \
../node/Defaults.cpp \
../node/Dictionary.cpp \
../node/HttpClient.cpp \
../node/Identity.cpp \
../node/IncomingPacket.cpp \
../node/InetAddress.cpp \
../node/IpcConnection.cpp \
../node/IpcListener.cpp \
../node/Logger.cpp \
../node/Multicaster.cpp \
../node/Network.cpp \
../node/NetworkConfig.cpp \
../node/Node.cpp \
../node/NodeConfig.cpp \
../node/OutboundMulticast.cpp \
../node/Packet.cpp \
../node/PacketDecoder.cpp \
../node/Peer.cpp \
../node/Poly1305.cpp \
../node/RoutingTable.cpp \
../node/Salsa20.cpp \
../node/Service.cpp \
../node/SHA512.cpp \
../node/SocketManager.cpp \
../node/SoftwareUpdater.cpp \
../node/Switch.cpp \
../node/TcpSocket.cpp \
../node/Topology.cpp \
../node/UdpSocket.cpp \
../node/Utils.cpp \
../ext/lz4/lz4.c \
../node/Dictionary.cpp
../ext/lz4/lz4.c
HEADERS += mainwindow.h \
aboutwindow.h \
@ -58,7 +58,12 @@ HEADERS += mainwindow.h \
licensedialog.h \
main.h \
onetimedialog.h \
../control/IpcConnection.hpp \
../control/IpcListener.hpp \
../control/NodeControlClient.hpp \
../control/NodeControlService.hpp \
../node/Address.hpp \
../node/AntiRecursion.hpp \
../node/Array.hpp \
../node/AtomicCounter.hpp \
../node/BandwidthAccount.hpp \
@ -69,11 +74,12 @@ HEADERS += mainwindow.h \
../node/Constants.hpp \
../node/Defaults.hpp \
../node/Dictionary.hpp \
../node/EthernetTap.hpp \
../node/EthernetTapFactory.hpp \
../node/HttpClient.hpp \
../node/Identity.hpp \
../node/IncomingPacket.hpp \
../node/InetAddress.hpp \
../node/IpcConnection.hpp \
../node/IpcListener.hpp \
../node/Logger.hpp \
../node/MAC.hpp \
../node/Multicaster.hpp \
@ -84,11 +90,12 @@ HEADERS += mainwindow.h \
../node/Node.hpp \
../node/NodeConfig.hpp \
../node/NonCopyable.hpp \
../node/OutboundMulticast.hpp \
../node/Packet.hpp \
../node/PacketDecoder.hpp \
../node/Path.hpp \
../node/Peer.hpp \
../node/Poly1305.hpp \
../node/RoutingTable.hpp \
../node/RuntimeEnvironment.hpp \
../node/Salsa20.hpp \
../node/Service.hpp \
@ -98,15 +105,10 @@ HEADERS += mainwindow.h \
../node/SocketManager.hpp \
../node/SoftwareUpdater.hpp \
../node/Switch.hpp \
../node/RoutingTable.hpp \
../node/TcpSocket.hpp \
../node/Thread.hpp \
../node/Topology.hpp \
../node/UdpSocket.hpp \
../node/Utils.hpp \
../ext/lz4/lz4.h \
../node/EthernetTap.hpp \
../node/EthernetTapFactory.hpp
../ext/lz4/lz4.h
FORMS += mainwindow.ui \
aboutwindow.ui \

View File

@ -62,8 +62,11 @@
#include "mac_doprivileged.h"
#endif
#include "../node/Utils.hpp"
#include "../node/Identity.hpp"
// Globally visible
ZeroTier::Node::NodeControlClient *zeroTierClient = (ZeroTier::Node::NodeControlClient *)0;
ZeroTier::NodeControlClient *zeroTierClient = (ZeroTier::NodeControlClient *)0;
// Main window instance for app
QMainWindow *mainWindow = (MainWindow *)0;
@ -77,6 +80,7 @@ static void handleZTMessage(void *arg,const char *line)
ztReplies_m.lock();
if (line) {
//printf("%s\n",line);
if ((line[0] == '.')&&(line[1] == (char)0)) {
// The message is packed into an event and sent to the main window where
// the actual parsing code lives.
@ -136,7 +140,7 @@ MainWindow::~MainWindow()
{
delete ui;
delete zeroTierClient;
zeroTierClient = (ZeroTier::Node::NodeControlClient *)0;
zeroTierClient = (ZeroTier::NodeControlClient *)0;
mainWindow = (MainWindow *)0;
}
@ -161,7 +165,7 @@ void MainWindow::timerEvent(QTimerEvent *event) // event can be null since code
if (!zeroTierClient) {
#ifdef __APPLE__
if ((!QFile::exists(ZeroTier::Node::NodeControlClient::authTokenDefaultUserPath()))&&(QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one"))) {
if ((!QFile::exists(ZeroTier::NodeControlClient::authTokenDefaultUserPath()))&&(QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one"))) {
// Authorize user by copying auth token into local home directory
QMessageBox::information(this,"Authorization Needed","Administrator privileges are required to allow the current user to control ZeroTier One on this computer. (You only have to do this once.)",QMessageBox::Ok,QMessageBox::NoButton);
@ -204,14 +208,21 @@ void MainWindow::timerEvent(QTimerEvent *event) // event can be null since code
#endif // __APPLE__
try {
zeroTierClient = new ZeroTier::Node::NodeControlClient((const char *)0,&handleZTMessage,this);
std::string buf;
if (ZeroTier::Utils::readFile("/Library/Application Support/ZeroTier/One/identity.public",buf)) {
ZeroTier::Identity id;
if (id.fromString(buf)) {
std::string authToken(ZeroTier::NodeControlClient::getAuthToken(ZeroTier::NodeControlClient::authTokenDefaultUserPath(),false));
zeroTierClient = new ZeroTier::NodeControlClient((std::string(ZT_IPC_ENDPOINT_BASE) + id.address().toString()).c_str(),authToken.c_str(),&handleZTMessage,this);
const char *err = zeroTierClient->error();
if (err) {
delete zeroTierClient;
zeroTierClient = (ZeroTier::Node::NodeControlClient *)0;
zeroTierClient = (ZeroTier::NodeControlClient *)0;
}
}
}
} catch ( ... ) {
zeroTierClient = (ZeroTier::Node::NodeControlClient *)0;
zeroTierClient = (ZeroTier::NodeControlClient *)0;
}
}
@ -237,7 +248,7 @@ void MainWindow::customEvent(QEvent *event)
ZTMessageEvent *m = (ZTMessageEvent *)event; // only one custom event type so far
if (m->ztMessage.size() == 0)
return;
std::vector<std::string> hdr(ZeroTier::Node::NodeControlClient::splitLine(m->ztMessage[0]));
std::vector<std::string> hdr(ZeroTier::NodeControlClient::splitLine(m->ztMessage[0]));
if (hdr.size() < 2)
return;
if (hdr[0] != "200")
@ -255,7 +266,7 @@ void MainWindow::customEvent(QEvent *event)
} else if (hdr[1] == "listnetworks") {
std::map< std::string,std::vector<std::string> > newNetworks;
for(unsigned long i=1;i<m->ztMessage.size();++i) {
std::vector<std::string> l(ZeroTier::Node::NodeControlClient::splitLine(m->ztMessage[i]));
std::vector<std::string> l(ZeroTier::NodeControlClient::splitLine(m->ztMessage[i]));
// 200 listnetworks <nwid> <name> <mac> <status> <config age> <type> <dev> <ips>
if ((l.size() == 10)&&(l[2].length() == 16))
newNetworks[l[2]] = l;

View File

@ -42,6 +42,7 @@
#include "../node/Constants.hpp"
#include "../node/Node.hpp"
#include "../node/Utils.hpp"
#include "../control/NodeControlClient.hpp"
namespace Ui {
class MainWindow;
@ -49,7 +50,7 @@ class MainWindow;
// Globally visible instance of local client for communicating with ZT1
// Can be null if not connected, or will point to current
extern ZeroTier::Node::NodeControlClient *zeroTierClient;
extern ZeroTier::NodeControlClient *zeroTierClient;
// Globally visible pointer to main app window
extern QMainWindow *mainWindow;

View File

@ -68,7 +68,7 @@ mac-ui: FORCE
$(CODESIGN) -vvv "build-ZeroTierUI-release/ZeroTier One.app"
clean:
rm -rf *.dSYM testnet.o selftest.o build-* $(OBJS) $(TESTNET_OBJS) zerotier-* ZeroTierOneInstaller-* "ZeroTier One.zip" "ZeroTier One.dmg"
rm -rf *.dSYM testnet.o selftest.o build-* *.o $(OBJS) $(TESTNET_OBJS) zerotier-* ZeroTierOneInstaller-* "ZeroTier One.zip" "ZeroTier One.dmg"
# For our use -- builds official signed binary, packages in installer and download DMG
official: FORCE