1
0
Fork 0
forked from lthn/blockchain

tor integration in UI

This commit is contained in:
cryptozoidberg 2022-04-09 22:36:11 +02:00
parent 46e57bf215
commit 2dfc2862fc
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
7 changed files with 42 additions and 1 deletions

View file

@ -194,7 +194,7 @@ if(BUILD_GUI)
QT5_USE_MODULES(Zano WebEngineWidgets WebChannel)
find_package(Qt5PrintSupport REQUIRED)
target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash tor-connect Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
if (UNIX AND NOT APPLE)
target_link_libraries(Zano rt)
endif()

View file

@ -947,6 +947,17 @@ bool MainWindow::set_options(const view::gui_options& opt)
CATCH_ENTRY2(false);
}
bool MainWindow::update_tor_status(const view::current_action_status& opt)
{
TRY_ENTRY();
std::string json_str;
epee::serialization::store_t_to_json(opt, json_str, 0, epee::serialization::eol_lf);
LOG_PRINT_L0("SENDING SIGNAL -> [HANDLE_CURRENT_ACTION_STATE]:" << std::endl << json_str);
QMetaObject::invokeMethod(this, "handle_current_action_state", Qt::QueuedConnection, Q_ARG(QString, json_str.c_str()));
return true;
CATCH_ENTRY2(false);
}
bool MainWindow::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
TRY_ENTRY();

View file

@ -197,6 +197,7 @@ signals:
void set_options(const QString str); //general function
void get_wallet_name();
void handle_deeplink_click(const QString str);
void handle_current_action_state(const QString str);
private:
//-------------------- i_core_event_handler --------------------
@ -216,6 +217,7 @@ private:
virtual bool init(const std::string& path);
virtual bool pos_block_found(const currency::block& block_found);
virtual bool set_options(const view::gui_options& opt);
virtual bool update_tor_status(const view::current_action_status& opt);
//--------- QAbstractNativeEventFilter ---------------------------
virtual bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
//----------------------------------------------

View file

@ -600,6 +600,18 @@ public:
END_KV_SERIALIZE_MAP()
};
struct current_action_status
{
uint64_t wallet_id;
std::string status;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(wallet_id)
KV_SERIALIZE(status)
END_KV_SERIALIZE_MAP()
};
struct wallet_sync_status_info
{
bool is_daemon_connected;
@ -828,6 +840,7 @@ public:
virtual bool pos_block_found(const currency::block& block_found){ return true; }
virtual bool money_transfer_cancel(const transfer_event_info& wsi){ return true; }
virtual bool set_options(const gui_options& opt){ return true; }
virtual bool update_tor_status(const current_action_status & opt) { return true; }
};
}

View file

@ -16,6 +16,7 @@ public:
virtual void on_pos_block_found(size_t wallet_id, const currency::block& /*block*/) {}
virtual void on_sync_progress(size_t wallet_id, const uint64_t& /*percents*/) {}
virtual void on_transfer_canceled(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti) {}
virtual void on_tor_status_change(size_t wallet_id, const std::string& state) {}
};
struct i_wallet_to_i_backend_adapter: public tools::i_wallet2_callback
@ -39,6 +40,11 @@ struct i_wallet_to_i_backend_adapter: public tools::i_wallet2_callback
virtual void on_transfer_canceled(const tools::wallet_public::wallet_transfer_info& wti) {
m_pbackend->on_transfer_canceled(m_wallet_id, wti);
}
virtual void on_tor_status_change(const std::string& state)
{
m_pbackend->on_tor_status_change(m_wallet_id, state);
}
private:
i_backend_wallet_callback* m_pbackend;
size_t m_wallet_id;

View file

@ -1871,6 +1871,13 @@ void wallets_manager::on_transfer_canceled(size_t wallet_id, const tools::wallet
}
m_pview->money_transfer_cancel(tei);
}
void wallets_manager::on_tor_status_change(size_t wallet_id, const std::string& state)
{
view::current_action_status tsu = { wallet_id , state };
m_pview->update_tor_status(tsu);
}
void wallets_manager::wallet_vs_options::worker_func()
{
LOG_PRINT_GREEN("[WALLET_HANDLER] Wallet handler thread started, addr: " << w->get()->get_account().get_public_address_str(), LOG_LEVEL_0);

View file

@ -187,6 +187,8 @@ private:
virtual void on_pos_block_found(size_t wallet_id, const currency::block& /*block*/);
virtual void on_sync_progress(size_t wallet_id, const uint64_t& /*percents*/);
virtual void on_transfer_canceled(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti);
virtual void on_tor_status_change(size_t wallet_id, const std::string& state);
std::thread m_main_worker_thread;