Skip to content

Commit

Permalink
LuKa v1.1 - Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Arielony committed Jan 31, 2018
0 parents commit aa4145f
Show file tree
Hide file tree
Showing 2,644 changed files with 717,583 additions and 0 deletions.
248 changes: 248 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
cmake_minimum_required(VERSION 2.8.6)
include(CryptoNoteWallet.cmake)

project(${CN_PROJECT_NAME})

execute_process(COMMAND git log -1 --pretty=format:%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_REVISION)

set(CRYPTONOTE_LIB cryptonote)

set(CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.10.0\\5.10.0\\msvc2015_64")
set(BOOST_ROOT "C:\\local\\boost_1_64_0_14_64")
set(BOOST_LIBRARYDIR "C:\\local\\boost_1_64_0_14_64\\libs")


include_directories(${CMAKE_BINARY_DIR}
src
include
cryptonote/external
cryptonote/external/rocksdb/include/
cryptonote/include
cryptonote/src
)

find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5DBus REQUIRED)



include_directories(${Qt5DBus_INCLUDE_DIRS} cryptonote/external/rocksdb/include/ include src external "${CMAKE_CURRENT_BINARY_DIR}/version")

set(Boost_USE_STATIC_LIBS ON)
if(WIN32)
set(Boost_USE_STATIC_RUNTIME OFF)
else(WIN32)
set(Boost_USE_STATIC_RUNTIME ON)
endif(WIN32)

find_package(Boost 1.58 REQUIRED COMPONENTS date_time filesystem program_options regex serialization system thread chrono)
if ((${Boost_MAJOR_VERSION} EQUAL 1) AND (${Boost_MINOR_VERSION} EQUAL 54))
message(SEND_ERROR "Boost version 1.58 is unsupported, more details are available here http://goo.gl/RrCFmA")
endif ()

include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})

set(VERSION "")
configure_file("cryptonote/src/version.h.in" "version.h")
configure_file("src/CryptoNoteWalletConfig.h.in" "CryptoNoteWalletConfig.h")

add_definitions(-DGIT_REVISION="${GIT_REVISION}")

set(CMAKE_AUTOMOC ON)

file(GLOB_RECURSE CRYPTONOTE_SOURCES
cryptonote/external/miniupnpc/connecthostport.c
cryptonote/external/miniupnpc/igd_desc_parse.c
cryptonote/external/miniupnpc/minisoap.c
cryptonote/external/miniupnpc/miniupnpc.c
cryptonote/external/miniupnpc/miniwget.c
cryptonote/external/miniupnpc/minixml.c
cryptonote/external/miniupnpc/portlistingparse.c
cryptonote/external/miniupnpc/receivedata.c
cryptonote/external/miniupnpc/upnpcommands.c
cryptonote/external/miniupnpc/upnpreplyparse.c
cryptonote/src/BlockchainExplorer/BlockchainExplorer.cpp
cryptonote/src/BlockchainExplorer/BlockchainExplorerErrors.cpp
cryptonote/src/Common/Base58.cpp
cryptonote/src/Common/CommandLine.cpp
cryptonote/src/Common/Util.cpp
cryptonote/src/Common/StringTools.cpp
cryptonote/src/Common/JsonValue.cpp
cryptonote/src/Common/ConsoleTools.cpp
cryptonote/src/Common/MemoryInputStream.cpp
cryptonote/src/Common/PathTools.cpp
cryptonote/src/Common/StdInputStream.cpp
cryptonote/src/Common/StdOutputStream.cpp
cryptonote/src/Common/StreamTools.cpp
cryptonote/src/Common/StringOutputStream.cpp
cryptonote/src/Common/StringView.cpp
cryptonote/src/Common/VectorOutputStream.cpp
cryptonote/src/Common/ScopeExit.cpp
cryptonote/src/ConnectivityTool/ConnectivityTool.cpp
cryptonote/src/crypto/blake256.c
cryptonote/src/crypto/chacha8.c
cryptonote/src/crypto/crypto-ops-data.c
cryptonote/src/crypto/crypto-ops.c
cryptonote/src/crypto/crypto.cpp
cryptonote/src/crypto/groestl.c
cryptonote/src/crypto/hash-extra-blake.c
cryptonote/src/crypto/hash-extra-groestl.c
cryptonote/src/crypto/hash-extra-jh.c
cryptonote/src/crypto/hash-extra-skein.c
cryptonote/src/crypto/hash.c
cryptonote/src/crypto/jh.c
cryptonote/src/crypto/keccak.c
cryptonote/src/crypto/oaes_lib.c
cryptonote/src/crypto/random.c
cryptonote/src/crypto/skein.c
cryptonote/src/crypto/slow-hash.c
cryptonote/src/crypto/slow-hash.cpp
cryptonote/src/crypto/tree-hash.c
cryptonote/src/CryptoNoteCore/*.cpp
cryptonote/src/CryptoNoteProtocol/*.cpp
cryptonote/src/Daemon/*.cpp
cryptonote/src/HTTP/*.cpp
cryptonote/src/InProcessNode/InProcessNode.cpp
cryptonote/src/InProcessNode/InProcessNodeErrors.cpp
cryptonote/src/Logging/*.cpp
cryptonote/src/NodeRpcProxy/NodeErrors.cpp
cryptonote/src/NodeRpcProxy/NodeRpcProxy.cpp
cryptonote/src/P2p/*.cpp
cryptonote/src/Rpc/*.cpp
cryptonote/src/Serialization/*.cpp
cryptonote/src/Transfers/BlockchainSynchronizer.cpp
cryptonote/src/Transfers/SynchronizationState.cpp
cryptonote/src/Transfers/TransfersConsumer.cpp
cryptonote/src/Transfers/TransfersContainer.cpp
cryptonote/src/Transfers/TransfersSubscription.cpp
cryptonote/src/Transfers/TransfersSynchronizer.cpp
cryptonote/src/Wallet/*.cpp
cryptonote/src/WalletLegacy/KeysStorage.cpp
cryptonote/src/WalletLegacy/WalletLegacy.cpp
cryptonote/src/WalletLegacy/WalletHelper.cpp
cryptonote/src/WalletLegacy/WalletLegacySerializer.cpp
cryptonote/src/WalletLegacy/WalletLegacySerialization.cpp
cryptonote/src/WalletLegacy/WalletTransactionSender.cpp
cryptonote/src/WalletLegacy/WalletUnconfirmedTransactions.cpp
cryptonote/src/WalletLegacy/WalletUserTransactionsCache.cpp
cryptonote/src/System/ContextGroup.cpp
cryptonote/src/System/Event.cpp
cryptonote/src/System/EventLock.cpp
cryptonote/src/System/InterruptedException.cpp
cryptonote/src/System/Ipv4Address.cpp
cryptonote/src/System/TcpStream.cpp
cryptonote/src/JsonRpcServer/*.cpp
cryptonote/src/PaymentGate/*.cpp
cryptonote/src/PaymentGateService/*.cpp
cryptonote/src/Miner/*.cpp
)

file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS src/*.h)
file(GLOB_RECURSE FORMS src/gui/ui/*.ui)

if(MSVC)
include_directories(Platform/Windows)
set(SOURCES ${SOURCES} ${CMAKE_SOURCE_DIR}/Platform/Windows/ApplicationEventHandler.cpp)
elseif(APPLE)
include_directories(Platform/OSX)
include_directories(Platform/Posix)
set(SOURCES ${SOURCES} ${CMAKE_SOURCE_DIR}/Platform/OSX/ApplicationEventHandler.h ${CMAKE_SOURCE_DIR}/Platform/OSX/ApplicationEventHandler.mm ${CMAKE_SOURCE_DIR}/Platform/OSX/INotificationMonitorObserver.h ${CMAKE_SOURCE_DIR}/Platform/OSX/NotificationMonitor.h ${CMAKE_SOURCE_DIR}/Platform/OSX/NotificationMonitor.mm ${CMAKE_SOURCE_DIR}/Platform/OSX/WalletApplication.mm )
set(SOURCES ${SOURCES} ${CMAKE_SOURCE_DIR}/Platform/Posix/System/MemoryMappedFile.cpp)
else()
include_directories(Platform/Linux)
include_directories(Platform/Posix)
set(SOURCES ${SOURCES} ${CMAKE_SOURCE_DIR}/Platform/Linux/ApplicationEventHandler.cpp)
set(SOURCES ${SOURCES} ${CMAKE_SOURCE_DIR}/Platform/Posix/System/MemoryMappedFile.cpp)
endif()


set(QRC src/resources.qrc)

qt5_wrap_ui(UIS ${FORMS})
qt5_add_resources(RCC ${QRC})

if (WIN32)
if (NOT MSVC)
message(FATAL_ERROR "Only MSVC is supported on this platform")
endif ()

add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600 /DSTATICLIB)
include_directories(cryptonote/src/Platform/msc)

set(PLATFORM_DIR Windows)
set(BUILD_PLATFORM WIN32)
set(BUILD_RESOURCES src/lukawallet.rc)
set(QTMAIN Qt5::WinMain)

elseif (UNIX)

set(CRYPTONOTE_SOURCES ${CRYPTONOTE_SOURCES} cryptonote/external/miniupnpc/minissdpc.c)

if (APPLE)
enable_language(ASM)
file(GLOB_RECURSE OBJC_SOURCES src/*.mm)
set(SOURCES ${SOURCES} ${OBJC_SOURCES})
set(PLATFORM_DIR OSX)
set(MACOSX_BUNDLE_INFO_STRING "LuKa GUI wallet")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${VERSION_VERSION}.${VERSION_MINOR}.${VERSION_PATCH}")
set(MACOSX_BUNDLE_BUNDLE_NAME LuKaWallet)
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_VERSION}.${VERSION_MINOR}.${VERSION_PATCH}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "$${VERSION_VERSION}.${VERSION_MINOR}.${VERSION_PATCH}")

find_package(Qt5PrintSupport REQUIRED)

include_directories(/usr/include/malloc)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes -std=c++11 -stdlib=libc++")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -maes -D_DARWIN_C_SOURCE")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa -framework OpenGL -framework CoreFoundation -framework Carbon -framework IOKit -L/usr/lib")

set(MACOSX_BUNDLE_ICON_FILE cryptonote.icns)
set(APPLICATION_ICON src/images/cryptonote.icns)
set_source_files_properties(${APPLICATION_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")

set(BUILD_PLATFORM MACOSX_BUNDLE)
set(BUILD_RESOURCES ${APPLICATION_ICON})

GET_TARGET_PROPERTY(QT_LIB_DIR "${Qt5Widgets_LIBRARIES}" LOCATION)
GET_FILENAME_COMPONENT(QT_LIB_DIR "${QT_LIB_DIR}" PATH)

else(APPLE)

set(PLATFORM_DIR Linux)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -maes -std=c++11")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maes -std=c11")
endif (APPLE)
endif ()

include_directories(cryptonote/src/Platform/${PLATFORM_DIR})
file(GLOB PLATFORM_SOURCES cryptonote/src/Platform/${PLATFORM_DIR}/System/*)
set(CRYPTONOTE_SOURCES ${CRYPTONOTE_SOURCES} ${PLATFORM_SOURCES} ${CRYPTONOTE_PLATFORM})

add_library(${CRYPTONOTE_LIB} STATIC ${CRYPTONOTE_SOURCES})
set_target_properties(${CRYPTONOTE_LIB} PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
target_link_libraries(${CRYPTONOTE_LIB} rocksdb ${Boost_LIBRARIES} ${Qt5DBus_LIBRARIES})

add_executable(${PROJECT_NAME} ${BUILD_PLATFORM} ${BUILD_RESOURCES} ${SOURCES} ${HEADERS} ${UIS} ${RCC})

set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS _GNU_SOURCE)
target_link_libraries(${PROJECT_NAME} rocksdb ${Boost_LIBRARIES} ${QTMAIN} ${CRYPTONOTE_LIB} ${Qt5DBus_LIBRARIES})

if (APPLE)
qt5_use_modules(${PROJECT_NAME} PrintSupport)
elseif (UNIX)
target_link_libraries(${PROJECT_NAME} -lpthread)
elseif (WIN32)
target_link_libraries(${PROJECT_NAME} rpcrt4.lib wtsapi32.lib Imm32 Iphlpapi Winmm)
endif (APPLE)

qt5_use_modules(${PROJECT_NAME} Widgets Gui Network)

add_subdirectory(cryptonote/external)
#add_subdirectory(cryptonote/src)
4 changes: 4 additions & 0 deletions CryptoNoteWallet.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(CN_PROJECT_NAME "LuKa")
set(CN_CURRENCY_DISPLAY_NAME "luka")
set(CN_CURRENCY_TICKER "LUK")
set(CN_VERSION 1.2.0)
125 changes: 125 additions & 0 deletions Platform/Linux/ApplicationEventHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// Copyright (c) 2015-2017, The Bytecoin developers
//
// This file is part of Bytecoin.
//
// Chavezcoin is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Chavezcoin is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Chavezcoin. If not, see <http://www.gnu.org/licenses/>.

#include <QtDBus/QtDBus>
#include <QDBusConnection>
#include <QDBusError>
#include <QLocalSocket>

#include "ApplicationEventHandler.h"
#include "WalletLogger/WalletLogger.h"

namespace WalletGui {

namespace {

const char DBUS_GNOME_SS_SERVICE_NAME[] = "org.gnome.ScreenSaver";
const char DBUS_GNOME_SS_PATH[] = "/org/gnome/ScreenSaver";
const char DBUS_GNOME_SS_INTERFACE[] = "org.gnome.ScreenSaver";
const char DBUS_GNOME_SS_MEMBER[] = "ActiveChanged";

const char DBUS_FREEDESKTOP_SS_SERVICE_NAME[] = "org.freedesktop.ScreenSaver";
const char DBUS_FREEDESKTOP_SS_PATH[] = "/org/freedesktop/ScreenSaver";
const char DBUS_FREEDESKTOP_SS_INTERFACE[] = "org.freedesktop.ScreenSaver";
const char DBUS_FREEDESKTOP_SS_MEMBER[] = "ActiveChanged";

const char PAYMENT_SERVER_NAME[] = "chavezcoin-payment-server-YrmF1jZEv5ahqXuD99d5H1jXQ";

}

ApplicationEventHandler::ApplicationEventHandler(QObject* _parent) : QLocalServer(_parent) {
}

ApplicationEventHandler::~ApplicationEventHandler() {
}

void ApplicationEventHandler::init() {
QDBusConnection::sessionBus().connect(DBUS_GNOME_SS_SERVICE_NAME, DBUS_GNOME_SS_PATH, DBUS_GNOME_SS_INTERFACE, DBUS_GNOME_SS_MEMBER,
this, SLOT(screenStateChanged(bool)));
QDBusConnection::sessionBus().connect(DBUS_FREEDESKTOP_SS_SERVICE_NAME, DBUS_FREEDESKTOP_SS_PATH, DBUS_FREEDESKTOP_SS_INTERFACE,
DBUS_FREEDESKTOP_SS_MEMBER, this, SLOT(screenStateChanged(bool)));

connect(this, &ApplicationEventHandler::newConnection, this, &ApplicationEventHandler::accept);
removeServer(PAYMENT_SERVER_NAME);
if (!listen(PAYMENT_SERVER_NAME)) {
WalletLogger::critical(tr("[Application event handler] Start payment server error: %1.").arg(errorString()));
}
WalletLogger::info(tr("[ApplicationEventHandler] 1"));
}

QUrl ApplicationEventHandler::getLastReceivedUrl() {
return m_receivedUrl;
}

void ApplicationEventHandler::sendUrl(const QUrl& _url) {
m_receivedUrl = _url;
QLocalSocket* socket = new QLocalSocket(this);
socket->connectToServer(PAYMENT_SERVER_NAME);
if (!socket->waitForConnected(5000)) {
socket->deleteLater();
return;
}

QByteArray data = _url.toString().toUtf8();
socket->waitForBytesWritten(100);
socket->deleteLater();
}

void ApplicationEventHandler::addObserver(IApplicationEventHandlerObserver* _observer) {
QObject* observer = dynamic_cast<QObject*>(_observer);
connect(this, SIGNAL(urlReceivedSignal(QUrl)), observer, SLOT(urlReceived(QUrl)));
connect(this, SIGNAL(screenLockedSignal()), observer, SLOT(screenLocked()));
connect(this, SIGNAL(screenUnlockedSignal()), observer, SLOT(screenUnlocked()));
}

void ApplicationEventHandler::removeObserver(IApplicationEventHandlerObserver* _observer) {
QObject* observer = dynamic_cast<QObject*>(_observer);
disconnect(this, SIGNAL(urlReceivedSignal(QUrl)), observer, SLOT(urlReceived(QUrl)));
disconnect(this, SIGNAL(screenLockedSignal()), observer, SLOT(screenLocked()));
disconnect(this, SIGNAL(screenUnlockedSignal()), observer, SLOT(screenUnlocked()));
}

void ApplicationEventHandler::accept() {
WalletLogger::debug(tr("[Application event handler] New socket connection."));
QLocalSocket* socket = nextPendingConnection();
if (socket == nullptr) {
return;
}

connect(socket, &QLocalSocket::readyRead, this, &ApplicationEventHandler::readyRead);
connect(socket, &QLocalSocket::disconnected, socket, &QLocalSocket::deleteLater);
}

void ApplicationEventHandler::readyRead() {
QByteArray rawData = qobject_cast<QLocalSocket*>(sender())->readAll();
WalletLogger::debug(tr("[Application event handler] Received data: %1.").arg(QString::fromUtf8(rawData)));
QUrl paymentUrl = QUrl::fromUserInput(rawData);
if (paymentUrl.isValid()) {
WalletLogger::info(tr("[Application event handler] Received URI: %1.").arg(paymentUrl.toString()));
Q_EMIT urlReceivedSignal(paymentUrl);
}
}

void ApplicationEventHandler::screenStateChanged(bool _isLocked) {
if (_isLocked) {
Q_EMIT screenLockedSignal();
} else {
Q_EMIT screenUnlockedSignal();
}
}

}
Loading

0 comments on commit aa4145f

Please sign in to comment.