Skip to content

Commit

Permalink
1.9.33
Browse files Browse the repository at this point in the history
  • Loading branch information
tongvanlinh committed Apr 26, 2024
1 parent dd57d80 commit d89d773
Show file tree
Hide file tree
Showing 121 changed files with 3,182 additions and 3,099 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
[submodule "contrib/quotient"]
path = contrib/quotient
url = https://github.com/tongvanlinh/libQuotient.git
[submodule "contrib/qzxing"]
path = contrib/qzxing
url = https://github.com/ftylitak/qzxing.git
[submodule "contrib/zxing"]
path = contrib/zxing
url = https://github.com/zxing-cpp/zxing-cpp.git
57 changes: 32 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required( VERSION 3.1 )
#set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version")
project(nunchuk-qt VERSION 0.1.0)
project(Nunchuk VERSION 1.9.33)
set( CMAKE_CXX_STANDARD 20 )
set( CMAKE_CXX_STANDARD_REQUIRED ON)
set( CMAKE_INCLUDE_CURRENT_DIR ON )
Expand Down Expand Up @@ -47,9 +47,6 @@ if(DQLIMIT_ONE)
endif(DQLIMIT_ONE)

find_package(Qt5 REQUIRED Qml Quick Core Gui Multimedia Sql Concurrent Svg)
if(APPLE)
find_package(Iconv)
endif()

set(QAppEngine_SRCS
QAppEngine/QOutlog/QOutlog.cpp
Expand All @@ -69,6 +66,19 @@ set(QAppEngine_MOCS
)
QT5_WRAP_CPP(MOCS_APPENGINE ${QAppEngine_MOCS})

set(QRScranner_SRCS
QRScanner/QBarcodeDecoder.cpp
QRScanner/QBarcodeFilter.cpp
QRScanner/QBarcodeGenerator.cpp
)

set(QRScranner_MOCS
QRScanner/QBarcodeDecoder.h
QRScanner/QBarcodeFilter.h
QRScanner/QBarcodeGenerator.h
)
QT5_WRAP_CPP(MOCS_QRSCANNER ${QRScranner_MOCS})

set(Views_SRCS
Views/STATE_ID_ROOT.cpp
Views/STATE_ID_SCR_ADD_HARDWARE_SIGNER.cpp
Expand Down Expand Up @@ -162,7 +172,6 @@ set(Views_MOCS
QT5_WRAP_CPP(MOCS_VIEWS ${Views_MOCS})

set(${PROJECT_NAME}_SRCS
contrib/nayuki/QrCode.cpp
Models/AppSetting.cpp
Models/AppModel.cpp
Models/ServiceSetting.cpp
Expand All @@ -178,8 +187,6 @@ set(${PROJECT_NAME}_SRCS
Models/Worker.cpp
Models/QWarningMessage.cpp
Models/OnBoardingModel.cpp
ifaces/QRCodeItem.cpp
ifaces/QRGenerator.cpp
ifaces/bridgeifaces.cpp
ifaces/nunchuckiface.cpp
ifaces/nunchucklistener.cpp
Expand Down Expand Up @@ -243,6 +250,8 @@ set(${PROJECT_NAME}_INC_PATH
ifaces
Models
RegisterTypes
QRScanner
QRScanner/private
contrib/libnunchuk/src
)
include_directories(${${PROJECT_NAME}_INC_PATH})
Expand All @@ -257,7 +266,6 @@ set(${PROJECT_NAME}_MOCS
Models/WalletModel.h
Models/Worker.h
Models/OnBoardingModel.h
ifaces/QRCodeItem.h
ifaces/bridgeifaces.h
RegisterTypes/DashRectangle.h
ifaces/Servers/DracoDefines.h
Expand All @@ -267,15 +275,13 @@ QT5_WRAP_CPP(MOCS ${${PROJECT_NAME}_MOCS})

set( QRCODE_SCANNER ON )
if(QRCODE_SCANNER)
SET(QZXING_MULTIMEDIA ON)
SET(QZXING_USE_QML ON)
add_definitions( -DQZXING_QML )
add_definitions( -DQZXING_MULTIMEDIA )
add_definitions( -DENABLE_ENCODER_GENERIC )
add_definitions( -DENABLE_DECODER_QR_CODE )
add_definitions( -DENABLE_ENCODER_QR_CODE )
add_definitions( -DNO_ICONV )
add_subdirectory(contrib/qzxing/src qzxing)
set(ZXING_UNIT_TESTS OFF)
set(ZXING_BLACKBOX_TESTS OFF)
set(ZXING_EXAMPLES OFF)
set(BUILD_SHARED_LIBS OFF)
# add_definitions ( -DQR_DFS_IMPROVE )
# add_definitions ( -DQR_DFS_IMPROVE_TEST )
add_subdirectory(contrib/zxing ZXing)
endif(QRCODE_SCANNER)

add_subdirectory(contrib/libnunchuk nunchuk EXCLUDE_FROM_ALL)
Expand All @@ -291,9 +297,9 @@ if(APPLE)
# And this part tells CMake where to find and install the file itself
set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/Icon.icns)
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
add_executable( ${PROJECT_NAME} MACOSX_BUNDLE ${QAppEngine_SRCS} ${Views_SRCS} ${${PROJECT_NAME}_SRCS} ${UIS} ${RSCS} ${MOCS_APPENGINE} ${MOCS_VIEWS} ${MOCS} ${APP_ICON_MACOSX})
add_executable( ${PROJECT_NAME} MACOSX_BUNDLE ${QAppEngine_SRCS} ${QRScranner_SRCS} ${Views_SRCS} ${${PROJECT_NAME}_SRCS} ${UIS} ${RSCS} ${MOCS_APPENGINE} ${MOCS_QRSCANNER} ${MOCS_VIEWS} ${MOCS} ${APP_ICON_MACOSX})
else()
add_executable ( ${PROJECT_NAME} WIN32 ${QAppEngine_SRCS} ${Views_SRCS} ${${PROJECT_NAME}_SRCS} ${UIS} ${RSCS} ${MOCS_APPENGINE} ${MOCS_VIEWS} ${MOCS})
add_executable ( ${PROJECT_NAME} WIN32 ${QAppEngine_SRCS} ${QRScranner_SRCS} ${Views_SRCS} ${${PROJECT_NAME}_SRCS} ${UIS} ${RSCS} ${MOCS_APPENGINE} ${MOCS_QRSCANNER} ${MOCS_VIEWS} ${MOCS})
endif()

if(APPLE)
Expand All @@ -309,19 +315,20 @@ if (NOT WIN32)
target_compile_options(${PROJECT_NAME} PRIVATE -Werror=return-type)
endif()

target_link_libraries (${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick Qt5::Concurrent Qt5::Svg )
target_link_libraries (${PROJECT_NAME} PUBLIC Qt5::Core Qt5::Gui Qt5::Qml Qt5::Quick Qt5::Concurrent Qt5::Svg )

if(UNIX AND NOT APPLE)
target_link_libraries("${PROJECT_NAME}" -Wl,--start-group nunchuk)
target_link_libraries("${PROJECT_NAME}" PUBLIC -Wl,--start-group nunchuk)
else()
target_link_libraries("${PROJECT_NAME}" nunchuk)
target_link_libraries("${PROJECT_NAME}" PUBLIC nunchuk)
endif()

target_link_libraries("${PROJECT_NAME}" Quotient Qt5::Sql )
target_link_libraries("${PROJECT_NAME}" PUBLIC Quotient Qt5::Sql )
target_include_directories("${PROJECT_NAME}" PUBLIC "${PROJECT_SOURCE_DIR}/contrib/quotient/lib" )

if(QRCODE_SCANNER)
target_link_libraries (${PROJECT_NAME} Qt5::Multimedia qzxing)
target_link_libraries (${PROJECT_NAME} PUBLIC Qt5::Multimedia)
target_link_libraries (${PROJECT_NAME} PUBLIC ZXing)
endif(QRCODE_SCANNER)

find_package(Qt5Keychain QUIET)
Expand All @@ -331,6 +338,6 @@ endif()
if(USE_KEYCHAIN)
message( STATUS "Using Qt Keychain ${Qt5Keychain_VERSION} at ${Qt5Keychain_DIR}")
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_KEYCHAIN)
target_link_libraries(${PROJECT_NAME} ${QTKEYCHAIN_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PUBLIC ${QTKEYCHAIN_LIBRARIES})
include_directories(${QTKEYCHAIN_INCLUDE_DIR})
endif()
16 changes: 16 additions & 0 deletions CreateICNS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
IFS='.' read -ra ADDR <<< "$1"
ICONSET=${ADDR[0]}.iconset
mkdir $ICONSET
sips -z 16 16 $1 --out $ICONSET/icon_16x16.png
sips -z 32 32 $1 --out $ICONSET/[email protected]
sips -z 32 32 $1 --out $ICONSET/icon_32x32.png
sips -z 64 64 $1 --out $ICONSET/[email protected]
sips -z 128 128 $1 --out $ICONSET/icon_128x128.png
sips -z 256 256 $1 --out $ICONSET/[email protected]
sips -z 256 256 $1 --out $ICONSET/icon_256x256.png
sips -z 512 512 $1 --out $ICONSET/[email protected]
sips -z 512 512 $1 --out $ICONSET/icon_512x512.png
cp $1 $ICONSET/[email protected]
iconutil -c icns $ICONSET
rm -R $ICONSET
Binary file modified Icon.icns
Binary file not shown.
12 changes: 6 additions & 6 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>${PRODUCT_NAME}</string>
<string>${PROJECT_NAME}</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<string>${PROJECT_NAME}</string>
<key>CFBundleIconFile</key>
<string>Icon.icns</string>
<key>CFBundleIdentifier</key>
Expand All @@ -21,11 +21,11 @@
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<string>${PROJECT_NAME}</string>
<key>CFBundleShortVersionString</key>
<string>1.9.32</string>
<string>${PROJECT_VERSION}</string>
<key>CFBundleGetInfoString</key>
<string>${PRODUCT_NAME} 1.9.32</string>
<string>${PROJECT_NAME} ${PROJECT_VERSION}</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSCameraUsageDescription</key>
Expand All @@ -35,7 +35,7 @@
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleVersion</key>
<string>1.9.32</string>
<string>${PROJECT_VERSION}</string>
<key>CFBundleIconName</key>
<string>AppIcon</string>
<key>UIPrerenderedIcon</key>
Expand Down
102 changes: 74 additions & 28 deletions Models/AppModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Premiums/QGroupWallets.h"
#include "Premiums/QWalletServicesTag.h"
#include "ServiceSetting.h"
#include "OnBoardingModel.h"

AppModel::AppModel(): inititalized_{false},
walletList_(QWalletListModelPtr(new WalletListModel())),
Expand All @@ -55,7 +56,8 @@ AppModel::AppModel(): inititalized_{false},
warningMessage_(QWarningMessagePtr(new QWarningMessage())),
exchangeRates_(0), btcRates_(0),lasttime_checkEstimatedFee_(QDateTime::currentDateTime()),
m_primaryKey(NULL),
newKeySignMessage_("")
newKeySignMessage_(""),
timeLogging_(QDateTime::currentDateTime())
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
connect(&timerRefreshHealthCheck_, &QTimer::timeout, this, &AppModel::timerHealthCheckTimeHandle, Qt::QueuedConnection);
Expand Down Expand Up @@ -96,6 +98,23 @@ AppModel::~AppModel(){
disconnect();
}

void AppModel::confirmSyncingWalletFromServer(bool yes, bool no)
{
QString fingerPrint = WalletsMng->UpdateSyncWalletFlows(yes, no);
if (yes) {
int index = masterSignerList()->getIndexNameByFingerPrint(fingerPrint);
if (index >= 0) {
QEventProcessor::instance()->sendEvent(E::EVT_HOME_MASTER_SIGNER_INFO_REQUEST, index);
emit syncingConfirmWalletRemoveKey(fingerPrint);
}
}
}

void AppModel::setTimeLogging(const QDateTime &newTimeLogging)
{
timeLogging_ = newTimeLogging;
}

QString AppModel::newKeySignMessage() const
{
return newKeySignMessage_;
Expand Down Expand Up @@ -152,6 +171,19 @@ int AppModel::addSignerWizard() const
return m_addSignerWizard;
}

bool AppModel::checkAutoSignOut()
{
QDateTime now = QDateTime::currentDateTime();
qint64 secs = timeLogging_.secsTo(now);
qint64 _7days = 7 * 24 * 60 * 60;
if(secs > _7days){
ClientController::instance()->requestSignout();
timeLogging_ = now;
return true;
}
return false;
}

QString AppModel::lasttimeCheckEstimatedFee() const
{
QDateTime in = lasttime_checkEstimatedFee_;
Expand Down Expand Up @@ -620,13 +652,14 @@ int AppModel::walletListCurrentIndex() const
return walletListCurrentIndex_;
}

void AppModel::setWalletListCurrentIndex(int index)
void AppModel::setWalletListCurrentIndex(int index, bool force)
{
if(walletListCurrentIndex_ != index){
walletListCurrentIndex_ = index;
}
emit walletListCurrentIndexChanged();
setWalletInfoByIndex(walletListCurrentIndex_);
setWalletInfoByIndex(walletListCurrentIndex_, force);
emit QGroupWallets::instance()->dashboardInfoChanged();
}

AppModel *AppModel::instance() {
Expand All @@ -653,19 +686,16 @@ void AppModel::requestSyncWalletDb(const QString &wallet_id)

void AppModel::requestCreateUserWallets()
{
if(CLIENT_INSTANCE->subscription().isEmpty()) {
QtConcurrent::run([]() {
WalletsMng->GetListWallet(GROUP_WALLET);
AppModel::instance()->startReloadUserDb();
});
}
else {
QtConcurrent::run([]() {
WalletsMng->GetListWallet(USER_WALLET);
WalletsMng->GetListWallet(GROUP_WALLET);
AppModel::instance()->startReloadUserDb();
});
}
QtConcurrent::run([]() {
WalletsMng->GetListWallet(USER_WALLET);
WalletsMng->GetListWallet(GROUP_WALLET);
AppModel::instance()->startReloadUserDb();
static bool needCheckOnboarding = true;
if(needCheckOnboarding){
needCheckOnboarding = false;
AppModel::instance()->requestOnboarding();
}
});
}

void AppModel::requestSyncSharedWallets()
Expand Down Expand Up @@ -716,11 +746,28 @@ void AppModel::requestClearData()
if(remoteSignerList()){
remoteSignerList()->cleardata();
}

WalletsMng->clear();
setWalletListCurrentIndex(-1);
AppSetting::instance()->setSyncPercent(0);
QUserWallets::instance()->reset();
QGroupWallets::instance()->reset();
WalletsMng->clear();
}

void AppModel::requestOnboarding()
{
timeoutHandler(1000,[=]{
if (CLIENT_INSTANCE->isSubscribed() || !QGroupWallets::instance()->existGroupPending()) {
AppSetting::instance()->setIsFirstTimeOnboarding(true);
}
else {
DBG_INFO << "Checking Onboarding " << AppSetting::instance()->isFirstTimeOnboarding();
if (!AppSetting::instance()->isFirstTimeOnboarding()) {
OnBoardingModel::instance()->setState("onboarding");
QEventProcessor::instance()->sendEvent(E::EVT_ONBOARDING_REQUEST);
}
}
});
}

QWalletListModelPtr AppModel::walletListPtr() const
Expand Down Expand Up @@ -912,15 +959,10 @@ QWalletPtr AppModel::walletInfoPtr() const
return walletInfo_;
}

void AppModel::setWalletInfo(WalletId wallet_id)
void AppModel::setWalletInfo(const QWalletPtr &d, bool force)
{
auto w = AppModel::instance()->walletListPtr()->getWalletById(wallet_id);
setWalletInfo(w);
}

void AppModel::setWalletInfo(const QWalletPtr &d)
{
if(d && 0 != QString::compare(d.data()->id(), walletInfo_->id(), Qt::CaseInsensitive)){
bool allow = force || !qUtils::strCompare(d.data()->id(), walletInfo_->id());
if(d && allow){
walletInfo_ = d;
if(walletInfo_){
QString wallet_id = walletInfo_.data()->id();
Expand All @@ -933,20 +975,23 @@ void AppModel::setWalletInfo(const QWalletPtr &d)
}
emit walletInfoChanged();
}
if(walletInfo_){
DBG_INFO << "Force set" << allow << "Wallet Role " << walletInfo_.data()->myRole() << walletInfo_.data()->slug();
}
}

void AppModel::setWalletInfoByIndex(const int index)
void AppModel::setWalletInfoByIndex(const int index, bool force)
{
if(index == -1){
setWalletInfo(QWalletPtr(new Wallet()));
setWalletInfo(QWalletPtr(new Wallet()), force);
}
else{
if(walletList_){
QWalletPtr newWallet = walletList_.data()->getWalletByIndex(index);
if(!newWallet){
newWallet = QWalletPtr(new Wallet());
}
setWalletInfo(newWallet);
setWalletInfo(newWallet, force);
}
}
}
Expand Down Expand Up @@ -1047,6 +1092,7 @@ void AppModel::timerFeeRatesHandle()

void AppModel::timerCheckAuthorizedHandle()
{
checkAutoSignOut();
Draco::instance()->getMe();
QGroupWallets::instance()->GetAllGroups();
QUserWallets::instance()->GetListAllRequestAddKey();
Expand Down
Loading

0 comments on commit d89d773

Please sign in to comment.