diff --git a/CMakeLists.txt b/CMakeLists.txt index dd2f22c..7418190 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,6 @@ option(WITH_PLUGIN_BOUNTIES "Include Bounties Home plugin" ON) option(WITH_PLUGIN_REDDIT "Include Reddit Home plugin" ON) option(WITH_PLUGIN_REVUO "Include Revuo Home plugin" ON) option(WITH_PLUGIN_CALC "Include Calc tab plugin" ON) -option(WITH_PLUGIN_EXCHANGE "Include Exchange tab plugin" ON) -option(WITH_PLUGIN_LOCALMONERO "Include LocalMonero plugin" ON) option(WITH_PLUGIN_XMRIG "Include XMRig plugin" ON) list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake") diff --git a/src/ContactsWidget.cpp b/src/ContactsWidget.cpp index 5f52297..5c6b77d 100644 --- a/src/ContactsWidget.cpp +++ b/src/ContactsWidget.cpp @@ -20,7 +20,7 @@ ContactsWidget::ContactsWidget(Wallet *wallet, QWidget *parent) ui->setupUi(this); m_btn_addContact = new QPushButton(this); - m_btn_addContact->setIcon(icons()->icon("localMonero_register.svg")); + m_btn_addContact->setIcon(icons()->icon("register.svg")); ui->searchLayout->addWidget(m_btn_addContact, 0, Qt::AlignRight); connect(m_btn_addContact, &QPushButton::clicked, [this]{this->newContact();}); diff --git a/src/SettingsDialog.cpp b/src/SettingsDialog.cpp index 9a84193..03248bd 100644 --- a/src/SettingsDialog.cpp +++ b/src/SettingsDialog.cpp @@ -359,19 +359,6 @@ void Settings::setupMiscTab() { QString redditFrontend = ui->comboBox_redditFrontend->currentText(); conf()->set(Config::redditFrontend, redditFrontend); }); - - // [LocalMonero frontend] - ui->comboBox_localMoneroFrontend->addItem("localmonero.co", "https://localmonero.co"); - ui->comboBox_localMoneroFrontend->addItem("localmonero.co/nojs", "https://localmonero.co/nojs"); - ui->comboBox_localMoneroFrontend->addItem("nehdddktmhvqklsnkjqcbpmb63htee2iznpcbs5tgzctipxykpj6yrid.onion", - "http://nehdddktmhvqklsnkjqcbpmb63htee2iznpcbs5tgzctipxykpj6yrid.onion"); - ui->comboBox_localMoneroFrontend->addItem("yeyar743vuwmm6fpgf3x6bzmj7fxb5uxhuoxx4ea76wqssdi4f3q.b32.i2p", - "http://yeyar743vuwmm6fpgf3x6bzmj7fxb5uxhuoxx4ea76wqssdi4f3q.b32.i2p"); - ui->comboBox_localMoneroFrontend->setCurrentIndex(ui->comboBox_localMoneroFrontend->findData(conf()->get(Config::localMoneroFrontend).toString())); - connect(ui->comboBox_localMoneroFrontend, QOverload::of(&QComboBox::currentIndexChanged), [this]{ - QString localMoneroFrontend = ui->comboBox_localMoneroFrontend->currentData().toString(); - conf()->set(Config::localMoneroFrontend, localMoneroFrontend); - }); } void Settings::onProxySettingsChanged() { diff --git a/src/SettingsDialog.ui b/src/SettingsDialog.ui index f27703c..71dece5 100644 --- a/src/SettingsDialog.ui +++ b/src/SettingsDialog.ui @@ -32,7 +32,7 @@ - 5 + 0 @@ -1109,22 +1109,6 @@ - - - - - 0 - 0 - - - - LocalMonero frontend: - - - - - - diff --git a/src/assets.qrc b/src/assets.qrc index e84bf88..9f91524 100644 --- a/src/assets.qrc +++ b/src/assets.qrc @@ -50,13 +50,6 @@ assets/images/ledger.png assets/images/ledger_unpaired.png assets/images/lightning.png - assets/images/localMonero_search.svg - assets/images/localMonero_buy.svg - assets/images/localMonero_buy_white.svg - assets/images/localMonero_sell.svg - assets/images/localMonero_sell_white.svg - assets/images/localMonero_logo.png - assets/images/localMonero_register.svg assets/images/lock.svg assets/images/microphone.png assets/images/mining.png @@ -70,6 +63,7 @@ assets/images/preferences.svg assets/images/qrcode.png assets/images/qrcode_white.png + assets/images/register.svg assets/images/revealer_c.png assets/images/revealer.png assets/images/seal.png diff --git a/src/assets/images/localMonero_buy.svg b/src/assets/images/localMonero_buy.svg deleted file mode 100644 index 7cfcdb1..0000000 --- a/src/assets/images/localMonero_buy.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/images/localMonero_buy_white.svg b/src/assets/images/localMonero_buy_white.svg deleted file mode 100644 index a64fda4..0000000 --- a/src/assets/images/localMonero_buy_white.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/images/localMonero_logo.png b/src/assets/images/localMonero_logo.png deleted file mode 100644 index 1751ce7..0000000 Binary files a/src/assets/images/localMonero_logo.png and /dev/null differ diff --git a/src/assets/images/localMonero_search.svg b/src/assets/images/localMonero_search.svg deleted file mode 100644 index 17f5218..0000000 --- a/src/assets/images/localMonero_search.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/images/localMonero_sell.svg b/src/assets/images/localMonero_sell.svg deleted file mode 100644 index 9b5f91b..0000000 --- a/src/assets/images/localMonero_sell.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/images/localMonero_sell_white.svg b/src/assets/images/localMonero_sell_white.svg deleted file mode 100644 index fe2cac3..0000000 --- a/src/assets/images/localMonero_sell_white.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/assets/images/localMonero_register.svg b/src/assets/images/register.svg similarity index 100% rename from src/assets/images/localMonero_register.svg rename to src/assets/images/register.svg diff --git a/src/plugins/exchange/ExchangePlugin.cpp b/src/plugins/exchange/ExchangePlugin.cpp deleted file mode 100644 index 69c82cf..0000000 --- a/src/plugins/exchange/ExchangePlugin.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#include "ExchangePlugin.h" - -#include "plugins/PluginRegistry.h" - -ExchangePlugin::ExchangePlugin() -{ -} - -void ExchangePlugin::initialize(Wallet *wallet, QObject *parent) { - this->setParent(parent); - m_tab = new ExchangeWidget(nullptr); -} - -QString ExchangePlugin::id() { - return "exchange"; -} - -int ExchangePlugin::idx() const { - return 50; -} - -QString ExchangePlugin::parent() { - return ""; -} - -QString ExchangePlugin::displayName() { - return "Exchange"; -} - -QString ExchangePlugin::description() { - return {}; -} -QString ExchangePlugin::icon() { - return "update.png"; -} - -QStringList ExchangePlugin::socketData() { - return {}; -} - -Plugin::PluginType ExchangePlugin::type() { - return Plugin::PluginType::TAB; -} - -QWidget* ExchangePlugin::tab() { - return m_tab; -} - -void ExchangePlugin::addSubPlugin(Plugin* plugin) { - m_tab->addTab(plugin); -} - -bool ExchangePlugin::implicitEnable() { - return true; -} - -const bool ExchangePlugin::registered = [] { - PluginRegistry::registerPlugin(ExchangePlugin::create()); - PluginRegistry::getInstance().registerPluginCreator(&ExchangePlugin::create); - return true; -}(); diff --git a/src/plugins/exchange/ExchangePlugin.h b/src/plugins/exchange/ExchangePlugin.h deleted file mode 100644 index 4b842d6..0000000 --- a/src/plugins/exchange/ExchangePlugin.h +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#ifndef EXCHANGEPLUGIN_H -#define EXCHANGEPLUGIN_H - -#include "plugins/Plugin.h" -#include "ExchangeWidget.h" - -class ExchangePlugin : public Plugin { - Q_OBJECT - -public: - explicit ExchangePlugin(); - - QString id() override; - int idx() const override; - QString parent() override; - QString displayName() override; - QString description() override; - QString icon() override; - QStringList socketData() override; - PluginType type() override; - QWidget* tab() override; - bool implicitEnable() override; - void addSubPlugin(Plugin* plugin) override; - - void initialize(Wallet *wallet, QObject *parent) override; - - static ExchangePlugin* create() { return new ExchangePlugin(); } - -private: - ExchangeWidget* m_tab = nullptr; - static const bool registered; -}; - - -#endif //EXCHANGEPLUGIN_H diff --git a/src/plugins/exchange/ExchangeWidget.cpp b/src/plugins/exchange/ExchangeWidget.cpp deleted file mode 100644 index 0a15cb4..0000000 --- a/src/plugins/exchange/ExchangeWidget.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#include "ExchangeWidget.h" -#include "ui_ExchangeWidget.h" - -#include "utils/Icons.h" - -ExchangeWidget::ExchangeWidget(QWidget *parent) - : QWidget(parent) - , ui(new Ui::ExchangeWidget) -{ - ui->setupUi(this); -} - -void ExchangeWidget::addTab(Plugin *plugin) { - QWidget* tab = plugin->tab(); - auto icon = icons()->icon(plugin->icon()); - QString name = plugin->displayName(); - - ui->tabWidget->addTab(tab, icon, name); -} - -ExchangeWidget::~ExchangeWidget() = default; \ No newline at end of file diff --git a/src/plugins/exchange/ExchangeWidget.h b/src/plugins/exchange/ExchangeWidget.h deleted file mode 100644 index e30ddb6..0000000 --- a/src/plugins/exchange/ExchangeWidget.h +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#ifndef EXCHANGEWIDGET_H -#define EXCHANGEWIDGET_H - -#include -#include - -#include "plugins/Plugin.h" - -namespace Ui { - class ExchangeWidget; -} - -class ExchangeWidget : public QWidget -{ - Q_OBJECT - -public: - explicit ExchangeWidget(QWidget *parent = nullptr); - ~ExchangeWidget(); - - void addTab(Plugin *plugin); - -private: - QScopedPointer ui; -}; - - -#endif //EXCHANGEWIDGET_H diff --git a/src/plugins/exchange/ExchangeWidget.ui b/src/plugins/exchange/ExchangeWidget.ui deleted file mode 100644 index 19d75ac..0000000 --- a/src/plugins/exchange/ExchangeWidget.ui +++ /dev/null @@ -1,36 +0,0 @@ - - - ExchangeWidget - - - - 0 - 0 - 400 - 300 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - diff --git a/src/plugins/localmonero/LocalMoneroApi.cpp b/src/plugins/localmonero/LocalMoneroApi.cpp deleted file mode 100644 index 51f4550..0000000 --- a/src/plugins/localmonero/LocalMoneroApi.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#include "LocalMoneroApi.h" - -#include "utils/config.h" - -LocalMoneroApi::LocalMoneroApi(QObject *parent, Networking *network) - : QObject(parent) - , m_network(network) -{ -} - -void LocalMoneroApi::countryCodes() { - QString url = QString("%1/countrycodes").arg(this->getBaseUrl()); - QNetworkReply *reply = m_network->getJson(this, url); - connect(reply, &QNetworkReply::finished, std::bind(&LocalMoneroApi::onResponse, this, reply, Endpoint::COUNTRY_CODES)); -} - -void LocalMoneroApi::currencies() { - QString url = QString("%1/currencies").arg(this->getBaseUrl()); - QNetworkReply *reply = m_network->getJson(this, url); - connect(reply, &QNetworkReply::finished, std::bind(&LocalMoneroApi::onResponse, this, reply, Endpoint::CURRENCIES)); -} - -void LocalMoneroApi::paymentMethods(const QString &countryCode) { - QString url; - if (countryCode.isEmpty()) { - url = QString("%1/payment_methods").arg(this->getBaseUrl()); - } else { - url = QString("%1/payment_methods/%2").arg(this->getBaseUrl(), countryCode); - } - QNetworkReply *reply = m_network->getJson(this, url); - connect(reply, &QNetworkReply::finished, std::bind(&LocalMoneroApi::onResponse, this, reply, Endpoint::PAYMENT_METHODS)); -} - -void LocalMoneroApi::buyMoneroOnline(const QString ¤cyCode, const QString &countryCode, - const QString &paymentMethod, const QString &amount, int page) -{ - QString url = this->getBuySellUrl(true, currencyCode, countryCode, paymentMethod, amount, page); - QNetworkReply *reply = m_network->getJson(this, url); - connect(reply, &QNetworkReply::finished, std::bind(&LocalMoneroApi::onResponse, this, reply, Endpoint::BUY_MONERO_ONLINE)); -} - -void LocalMoneroApi::sellMoneroOnline(const QString ¤cyCode, const QString &countryCode, - const QString &paymentMethod, const QString &amount, int page) -{ - QString url = this->getBuySellUrl(false, currencyCode, countryCode, paymentMethod, amount, page); - QNetworkReply *reply = m_network->getJson(this, url); - connect(reply, &QNetworkReply::finished, std::bind(&LocalMoneroApi::onResponse, this, reply, Endpoint::SELL_MONERO_ONLINE)); -} - -void LocalMoneroApi::accountInfo(const QString &username) { - QString url = QString("%1/account_info/%2").arg(this->getBaseUrl(), username); - QNetworkReply *reply = m_network->getJson(this, url); - connect(reply, &QNetworkReply::finished, std::bind(&LocalMoneroApi::onResponse, this, reply, Endpoint::ACCOUNT_INFO)); -} - -void LocalMoneroApi::onResponse(QNetworkReply *reply, LocalMoneroApi::Endpoint endpoint) { - const bool ok = reply->error() == QNetworkReply::NoError; - const QString err = reply->errorString(); - - QByteArray data = reply->readAll(); - reply->deleteLater(); - - QJsonObject obj; - if (!data.isEmpty() && Utils::validateJSON(data)) { - auto doc = QJsonDocument::fromJson(data); - obj = doc.object(); - } - else if (!ok) { - emit ApiResponse(LocalMoneroResponse{false, endpoint, err, {}}); - return; - } - else { - emit ApiResponse(LocalMoneroResponse{false, endpoint, "Invalid response from LocalMonero", {}}); - return; - } - - if (obj.contains("error")) { - QString errorStr = QJsonDocument(obj["error"].toObject()).toJson(QJsonDocument::Compact); - emit ApiResponse(LocalMoneroResponse{false, endpoint, errorStr, obj}); - return; - } - - emit ApiResponse(LocalMoneroResponse{true, endpoint, "", obj}); -} - -QString LocalMoneroApi::getBuySellUrl(bool buy, const QString ¤cyCode, const QString &countryCode, - const QString &paymentMethod, const QString &amount, int page) -{ - QString url = QString("%1/%2-monero-online/%3").arg(this->getBaseUrl(), buy ? "buy" : "sell", currencyCode); - if (!countryCode.isEmpty() && paymentMethod.isEmpty()) - url += QString("/%1").arg(countryCode); - else if (countryCode.isEmpty() && !paymentMethod.isEmpty()) - url += QString("/%1").arg(paymentMethod); - else if (!countryCode.isEmpty() && !paymentMethod.isEmpty()) - url += QString("/%1/%2").arg(countryCode, paymentMethod); - - QUrlQuery query; - if (!amount.isEmpty() && amount != "0") - query.addQueryItem("amount", amount); - if (page > 0) - query.addQueryItem("page", QString::number(page)); - url += "?" + query.toString(); - return url; -} - -QString LocalMoneroApi::getBaseUrl() { - if (conf()->get(Config::proxy).toInt() == Config::Proxy::Tor && conf()->get(Config::torOnlyAllowOnion).toBool()) { - return "http://nehdddktmhvqklsnkjqcbpmb63htee2iznpcbs5tgzctipxykpj6yrid.onion/api/v1"; - } - - if (conf()->get(Config::proxy).toInt() == Config::Proxy::i2p) { - return "http://yeyar743vuwmm6fpgf3x6bzmj7fxb5uxhuoxx4ea76wqssdi4f3q.b32.i2p/api/v1"; - } - - return "https://agoradesk.com/api/v1"; -} \ No newline at end of file diff --git a/src/plugins/localmonero/LocalMoneroApi.h b/src/plugins/localmonero/LocalMoneroApi.h deleted file mode 100644 index 700e86b..0000000 --- a/src/plugins/localmonero/LocalMoneroApi.h +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#ifndef FEATHER_LOCALMONEROAPI_H -#define FEATHER_LOCALMONEROAPI_H - -#include -#include "utils/Networking.h" - -class LocalMoneroApi : public QObject { - Q_OBJECT - -public: - enum Endpoint { - COUNTRY_CODES, - CURRENCIES, - PAYMENT_METHODS, - BUY_MONERO_ONLINE, - SELL_MONERO_ONLINE, - ACCOUNT_INFO - }; - - struct LocalMoneroResponse { - bool ok; - Endpoint endpoint; - QString message; - QJsonObject obj; - }; - - explicit LocalMoneroApi(QObject *parent, Networking *network); - - void countryCodes(); - void currencies(); - void paymentMethods(const QString &countryCode = ""); - void buyMoneroOnline(const QString ¤cyCode, const QString &countryCode="", const QString &paymentMethod="", const QString &amount = "", int page = 0); - void sellMoneroOnline(const QString ¤cyCode, const QString &countryCode="", const QString &paymentMethod="", const QString &amount = "", int page = 0); - void accountInfo(const QString &username); - -signals: - void ApiResponse(LocalMoneroResponse resp); - -private slots: - void onResponse(QNetworkReply *reply, Endpoint endpoint); - -private: - QString getBuySellUrl(bool buy, const QString ¤cyCode, const QString &countryCode="", const QString &paymentMethod="", const QString &amount = "", int page = 0); - QString getBaseUrl(); - - Networking *m_network; -}; - - -#endif //FEATHER_LOCALMONEROAPI_H diff --git a/src/plugins/localmonero/LocalMoneroInfoDialog.cpp b/src/plugins/localmonero/LocalMoneroInfoDialog.cpp deleted file mode 100644 index cbcdb14..0000000 --- a/src/plugins/localmonero/LocalMoneroInfoDialog.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#include "LocalMoneroInfoDialog.h" -#include "ui_LocalMoneroInfoDialog.h" - -#include "utils/config.h" -#include "utils/Utils.h" - -LocalMoneroInfoDialog::LocalMoneroInfoDialog(QWidget *parent, LocalMoneroModel *model, int row) - : WindowModalDialog(parent) - , ui(new Ui::LocalMoneroInfoDialog) - , m_model(model) - , m_row(row) -{ - ui->setupUi(this); - - setLabelText(ui->label_price, LocalMoneroModel::PriceXMR); - setLabelText(ui->label_seller, LocalMoneroModel::Seller); - setLabelText(ui->label_paymentMethod, LocalMoneroModel::PaymentMethod); - setLabelText(ui->label_paymentDetail, LocalMoneroModel::PaymentMethodDetail); - setLabelText(ui->label_tradeLimits, LocalMoneroModel::Limits); - - QJsonObject offerData = model->getOffer(row); - QString details = offerData["data"].toObject()["msg"].toString(); - details.remove("*"); - - if (details.isEmpty()) { - details = "No details."; - } - - ui->info->setPlainText(details); - - connect(ui->btn_goToOffer, &QPushButton::clicked, this, &LocalMoneroInfoDialog::onGoToOffer); -} - -void LocalMoneroInfoDialog::setLabelText(QLabel *label, LocalMoneroModel::Column column) { - QString data = m_model->data(m_model->index(m_row, column)).toString(); - label->setText(data); -} - -void LocalMoneroInfoDialog::onGoToOffer() { - QJsonObject offerData = m_model->getOffer(m_row); - QString frontend = conf()->get(Config::localMoneroFrontend).toString(); - QString offerUrl = QString("%1/ad/%2").arg(frontend, offerData["data"].toObject()["ad_id"].toString()); - Utils::externalLinkWarning(this, offerUrl); -} - -LocalMoneroInfoDialog::~LocalMoneroInfoDialog() = default; \ No newline at end of file diff --git a/src/plugins/localmonero/LocalMoneroInfoDialog.h b/src/plugins/localmonero/LocalMoneroInfoDialog.h deleted file mode 100644 index 6849264..0000000 --- a/src/plugins/localmonero/LocalMoneroInfoDialog.h +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#ifndef FEATHER_LOCALMONEROINFODIALOG_H -#define FEATHER_LOCALMONEROINFODIALOG_H - -#include -#include - -#include "components.h" -#include "LocalMoneroModel.h" - -namespace Ui { - class LocalMoneroInfoDialog; -} - -class LocalMoneroInfoDialog : public WindowModalDialog -{ - Q_OBJECT - -public: - explicit LocalMoneroInfoDialog(QWidget *parent, LocalMoneroModel *model, int row); - ~LocalMoneroInfoDialog() override; - -private slots: - void onGoToOffer(); - -private: - void setLabelText(QLabel *label, LocalMoneroModel::Column column); - - QScopedPointer ui; - LocalMoneroModel *m_model; - int m_row; -}; - - -#endif //FEATHER_INFODIALOG_H diff --git a/src/plugins/localmonero/LocalMoneroInfoDialog.ui b/src/plugins/localmonero/LocalMoneroInfoDialog.ui deleted file mode 100644 index 6a37b51..0000000 --- a/src/plugins/localmonero/LocalMoneroInfoDialog.ui +++ /dev/null @@ -1,195 +0,0 @@ - - - LocalMoneroInfoDialog - - - - 0 - 0 - 758 - 557 - - - - Offer info - - - - - - Info - - - - - - Price: - - - - - - - TextLabel - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Seller: - - - - - - - TextLabel - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Payment method: - - - - - - - TextLabel - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Trade limits: - - - - - - - TextLabel - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Payment detail: - - - - - - - TextLabel - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Go to offer - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - - - - - - - - buttonBox - accepted() - LocalMoneroInfoDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - LocalMoneroInfoDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/plugins/localmonero/LocalMoneroModel.cpp b/src/plugins/localmonero/LocalMoneroModel.cpp deleted file mode 100644 index 4ec37b4..0000000 --- a/src/plugins/localmonero/LocalMoneroModel.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#include "LocalMoneroModel.h" -#include -#include "utils/Utils.h" - -LocalMoneroModel::LocalMoneroModel(QObject *parent) - : QAbstractTableModel(parent) -{ -} - -int LocalMoneroModel::rowCount(const QModelIndex &parent) const { - return m_data.count(); -} - -int LocalMoneroModel::columnCount(const QModelIndex &parent) const { - return Column::COUNT; -} - -QVariant LocalMoneroModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { - switch (section) { - case Seller: - return QString("Seller"); - case Country: - return QString("Country"); - case PaymentMethod: - return QString("Payment Method"); - case PaymentMethodDetail: - return QString("Detail"); - case PriceXMR: - return QString("Price/XMR"); - case Limits: - return QString("Limits"); - default: - return QVariant(); - } - } - return QVariant(); -} - -QVariant LocalMoneroModel::data(const QModelIndex &index, int role) const { - const int col = index.column(); - const auto row = m_data.at(index.row()).toObject()["data"].toObject(); - - if (row.isEmpty()) { - return QVariant(); - } - - if (role == Qt::DisplayRole) { - switch (col) { - case Column::Seller: { - auto seller = row["profile"].toObject(); - return seller["name"].toString(); - // TODO: online indicator - } - case Column::Country: { - return row["countrycode"].toString(); - } - case Column::PaymentMethod: { - auto paymentMethodCode = row["online_provider"].toString(); - if (paymentMethodCode == "NATIONAL_BANK") { - return QString("National bank transfer"); - } - return m_paymentMethodNames.value(paymentMethodCode, paymentMethodCode); - } - case Column::PaymentMethodDetail: { - auto paymentMethodDetailText = row["payment_method_detail"].toString(); - QString filteredString; // We can't display emojis in QTreeView - for (const auto &Char : paymentMethodDetailText) { - if (Char.unicode() < 256) - filteredString.append(Char); - else - filteredString.append(" "); - } - - return filteredString.trimmed(); - } - case Column::PriceXMR: { - return QString("%1 %2").arg(row["temp_price"].toString(), row["currency"].toString()); - } - case Column::Limits: { - auto minAmount = row["min_amount"].toString(); - auto maxAmount = row["max_amount"].toString(); - if (maxAmount.isEmpty()) { - maxAmount = row["max_amount_available"].toString(); - } - auto currency = row["currency"].toString(); - - if (minAmount.isEmpty() && maxAmount.isEmpty()) { - return QString("Up to any amount %1").arg(currency); - } - - if (!minAmount.isEmpty() && maxAmount.isEmpty()) { - return QString("%1 - any amount %2").arg(minAmount, currency); - } - - if (!minAmount.isEmpty() && !maxAmount.isEmpty()) { - return QString("%1 - %2 %3").arg(minAmount, maxAmount, currency); - } - - if (minAmount.isEmpty() && !maxAmount.isEmpty()) { - return QString("Up to %1 %2").arg(maxAmount, currency); - } - - return QVariant(); - } - } - } - else if (role == Qt::ForegroundRole) { - switch (col) { - case Column::PriceXMR: { - return QVariant(QColor("#388538")); - } - } - } - else if (role == Qt::FontRole) { - switch (col) { - case Column::PriceXMR: { - auto bigFont = Utils::relativeFont(2); - bigFont.setBold(true); - return bigFont; - } - } - } - - return QVariant(); -} - -void LocalMoneroModel::setData(const QJsonArray &data) { - beginResetModel(); - m_data = data; - endResetModel(); -} - -void LocalMoneroModel::addData(const QJsonArray &data) { - beginResetModel(); - - for (const auto &row : data) { - m_data.append(row); - } - - endResetModel(); -} - -void LocalMoneroModel::clearData() { - beginResetModel(); - m_data = {}; - endResetModel(); -} - -void LocalMoneroModel::setPaymentMethods(const QJsonObject &data) { - beginResetModel(); - - m_paymentMethods = data; - m_paymentMethodNames.clear(); - for (const auto &payment_method : data) { - auto code = payment_method.toObject()["code"].toString(); - auto name = payment_method.toObject()["name"].toString(); - - if (!code.isEmpty() && !name.isEmpty()) { - m_paymentMethodNames[code] = name; - } - } - - endResetModel(); -} - -QJsonObject LocalMoneroModel::getOffer(int index) const { - return m_data.at(index).toObject(); -} diff --git a/src/plugins/localmonero/LocalMoneroModel.h b/src/plugins/localmonero/LocalMoneroModel.h deleted file mode 100644 index dc1d62f..0000000 --- a/src/plugins/localmonero/LocalMoneroModel.h +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#ifndef FEATHER_LOCALMONEROMODEL_H -#define FEATHER_LOCALMONEROMODEL_H - -#include -#include -#include -#include - -class LocalMoneroModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - enum Column - { - Seller = 0, - Country, - PaymentMethod, - PaymentMethodDetail, - PriceXMR, - Limits, - COUNT - }; - - LocalMoneroModel(QObject *parent = nullptr); - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - - void setData(const QJsonArray &data); - void setPaymentMethods(const QJsonObject &data); - void addData(const QJsonArray &data); - void clearData(); - - QJsonObject getOffer(int index) const; - -private: - QJsonArray m_data; - QJsonObject m_paymentMethods; - QHash m_paymentMethodNames; -}; - -#endif //FEATHER_LOCALMONEROMODEL_H diff --git a/src/plugins/localmonero/LocalMoneroPlugin.cpp b/src/plugins/localmonero/LocalMoneroPlugin.cpp deleted file mode 100644 index 1881610..0000000 --- a/src/plugins/localmonero/LocalMoneroPlugin.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#include "LocalMoneroPlugin.h" - -LocalMoneroPlugin::LocalMoneroPlugin() -{ -} - -void LocalMoneroPlugin::initialize(Wallet *wallet, QObject *parent) { - this->setParent(parent); - m_tab = new LocalMoneroWidget(nullptr, wallet); -} - -QString LocalMoneroPlugin::id() { - return "localmonero"; -} - -int LocalMoneroPlugin::idx() const { - return 0; -} - -QString LocalMoneroPlugin::parent() { - return "exchange"; -} - -QString LocalMoneroPlugin::displayName() { - return "LocalMonero"; -} - -QString LocalMoneroPlugin::description() { - return {}; -} -QString LocalMoneroPlugin::icon() { - return "localMonero_logo.png"; -} - -QStringList LocalMoneroPlugin::socketData() { - return {"localmonero_countries", "localmonero_currencies", "localmonero_payment_methods"}; -} - -Plugin::PluginType LocalMoneroPlugin::type() { - return Plugin::PluginType::TAB; -} - -QWidget* LocalMoneroPlugin::tab() { - return m_tab; -} - -void LocalMoneroPlugin::skinChanged() { - m_tab->skinChanged(); -} - -const bool LocalMoneroPlugin::registered = [] { - PluginRegistry::registerPlugin(LocalMoneroPlugin::create()); - PluginRegistry::getInstance().registerPluginCreator(&LocalMoneroPlugin::create); - return true; -}(); diff --git a/src/plugins/localmonero/LocalMoneroPlugin.h b/src/plugins/localmonero/LocalMoneroPlugin.h deleted file mode 100644 index edb0199..0000000 --- a/src/plugins/localmonero/LocalMoneroPlugin.h +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#ifndef LOCALMONEROPLUGIN_H -#define LOCALMONEROPLUGIN_H - -#include "plugins/Plugin.h" -#include "LocalMoneroWidget.h" -#include "plugins/PluginRegistry.h" - -class LocalMoneroPlugin : public Plugin { - Q_OBJECT - -public: - explicit LocalMoneroPlugin(); - - QString id() override; - int idx() const override; - QString parent() override; - QString displayName() override; - QString description() override; - QString icon() override; - QStringList socketData() override; - PluginType type() override; - QWidget* tab() override; - - void initialize(Wallet *wallet, QObject *parent) override; - - static LocalMoneroPlugin* create() { return new LocalMoneroPlugin(); } - -public slots: - void skinChanged() override; - -private: - LocalMoneroWidget* m_tab = nullptr; - static const bool registered; -}; - - -#endif //LOCALMONEROPLUGIN_H diff --git a/src/plugins/localmonero/LocalMoneroWidget.cpp b/src/plugins/localmonero/LocalMoneroWidget.cpp deleted file mode 100644 index 8d6a018..0000000 --- a/src/plugins/localmonero/LocalMoneroWidget.cpp +++ /dev/null @@ -1,216 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#include "LocalMoneroWidget.h" -#include "ui_LocalMoneroWidget.h" - -#include -#include - -#include "LocalMoneroInfoDialog.h" -#include "utils/ColorScheme.h" -#include "utils/Icons.h" -#include "utils/WebsocketNotifier.h" - -LocalMoneroWidget::LocalMoneroWidget(QWidget *parent, Wallet *wallet) - : QWidget(parent) - , ui(new Ui::LocalMoneroWidget) - , m_wallet(wallet) -{ - ui->setupUi(this); - - QPixmap logo(":/assets/images/localMonero_logo.png"); - ui->logo->setPixmap(logo.scaled(100, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - - ui->combo_currency->addItem(conf()->get(Config::preferredFiatCurrency).toString()); - - m_network = new Networking(this); - m_api = new LocalMoneroApi(this, m_network); - - m_model = new LocalMoneroModel(this); - ui->treeView->setModel(m_model); - - ui->treeView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); - ui->treeView->header()->setSectionResizeMode(LocalMoneroModel::PaymentMethodDetail, QHeaderView::Stretch); - ui->treeView->header()->setStretchLastSection(false); - - connect(ui->treeView, &QTreeView::doubleClicked, this, &LocalMoneroWidget::viewOfferDetails); - connect(ui->treeView, &QTreeView::customContextMenuRequested, this, &LocalMoneroWidget::showContextMenu); - - connect(ui->btn_search, &QPushButton::clicked, this, &LocalMoneroWidget::onSearchClicked); - connect(ui->btn_signUp, &QPushButton::clicked, this, &LocalMoneroWidget::onSignUpClicked); - connect(m_api, &LocalMoneroApi::ApiResponse, this, &LocalMoneroWidget::onApiResponse); - connect(ui->btn_loadMore, &QPushButton::clicked, this, &LocalMoneroWidget::onLoadMore); - - connect(websocketNotifier(), &WebsocketNotifier::dataReceived, this, [this](const QString& type, const QJsonValue& json) { - if (type == "localmonero_countries") { - this->onWsCountriesReceived(json.toArray()); - } - else if (type == "localmonero_currencies") { - this->onWsCurrenciesReceived(json.toArray()); - } - else if (type == "localmonero_payment_methods") { - this->onWsPaymentMethodsReceived(json.toObject()); - } - }); - - connect(ui->combo_currency, QOverload::of(&QComboBox::currentIndexChanged), this, &LocalMoneroWidget::updatePaymentMethods); - - ui->frame_loadMore->hide(); - - QTimer::singleShot(1, [this]{ - this->skinChanged(); - }); -} - -void LocalMoneroWidget::skinChanged() { - if (ColorScheme::hasDarkBackground(this)) { - ui->radio_buy->setIcon(icons()->icon("localMonero_buy_white.svg")); - ui->radio_sell->setIcon(icons()->icon("localMonero_sell_white.svg")); - } else { - ui->radio_buy->setIcon(icons()->icon("localMonero_buy.svg")); - ui->radio_sell->setIcon(icons()->icon("localMonero_sell.svg")); - } -} - -void LocalMoneroWidget::onSearchClicked() { - m_model->clearData(); - m_currentPage = 0; - ui->btn_search->setEnabled(false); - - this->searchOffers(); -} - -void LocalMoneroWidget::onSignUpClicked() { - QString signupUrl = QString("%1/signup").arg(conf()->get(Config::localMoneroFrontend).toString()); - Utils::externalLinkWarning(this, signupUrl); -} - -void LocalMoneroWidget::onApiResponse(const LocalMoneroApi::LocalMoneroResponse &resp) { - ui->btn_search->setEnabled(true); - - if (!resp.ok) { - Utils::showError(this, "LocalMonero request failed", resp.message); - return; - } - - if (resp.endpoint == LocalMoneroApi::BUY_MONERO_ONLINE - || resp.endpoint == LocalMoneroApi::SELL_MONERO_ONLINE) - { - bool hasNextPage = resp.obj["pagination"].toObject().contains("next"); - ui->frame_loadMore->setVisible(hasNextPage); - - m_model->addData(resp.obj["data"].toObject()["ad_list"].toArray()); - } - else if (resp.endpoint == LocalMoneroApi::PAYMENT_METHODS) { - m_model->setPaymentMethods(resp.obj["data"].toObject()["methods"].toObject()); - } -} - -void LocalMoneroWidget::onLoadMore() { - m_currentPage += 1; - this->searchOffers(m_currentPage); -} - -void LocalMoneroWidget::onWsCountriesReceived(const QJsonArray &countries) { - ui->combo_country->clear(); - ui->combo_country->addItem("Any country"); - for (const auto country : countries) { - ui->combo_country->addItem(country[0].toString(), country[1].toString()); - } -} - -void LocalMoneroWidget::onWsCurrenciesReceived(const QJsonArray ¤cies) { - QString currentText = ui->combo_currency->currentText(); - - ui->combo_currency->clear(); - for (const auto currency : currencies) { - ui->combo_currency->addItem(currency.toString()); - } - - // restore previous selection - int index = ui->combo_currency->findText(currentText); - ui->combo_currency->setCurrentIndex(index); -} - -void LocalMoneroWidget::onWsPaymentMethodsReceived(const QJsonObject &payment_methods) { - m_paymentMethods = payment_methods; - m_model->setPaymentMethods(payment_methods); - this->updatePaymentMethods(); -} - -void LocalMoneroWidget::searchOffers(int page) { - QString amount = ui->line_amount->text(); - QString currencyCode = ui->combo_currency->currentText(); - QString countryCode = ui->combo_country->currentData().toString(); - QString paymentMethod = ui->combo_paymentMethod->currentData().toString(); - - if (ui->radio_buy->isChecked()) - m_api->buyMoneroOnline(currencyCode, countryCode, paymentMethod, amount, page); - else if (ui->radio_sell->isChecked()) - m_api->sellMoneroOnline(currencyCode, countryCode, paymentMethod, amount, page); -} - -void LocalMoneroWidget::showContextMenu(const QPoint &point) { - QModelIndex index = ui->treeView->indexAt(point); - if (!index.isValid()) { - return; - } - - QMenu menu(this); - menu.addAction("Go to offer", this, &LocalMoneroWidget::openOfferUrl); - menu.addAction("View offer details", this, &LocalMoneroWidget::viewOfferDetails); - menu.exec(ui->treeView->viewport()->mapToGlobal(point)); -} - -void LocalMoneroWidget::openOfferUrl() { - QModelIndex index = ui->treeView->currentIndex(); - if (!index.isValid()) { - return; - } - - QJsonObject offerData = m_model->getOffer(index.row()); - QString frontend = conf()->get(Config::localMoneroFrontend).toString(); - - QString offerUrl = QString("%1/ad/%2").arg(frontend, offerData["data"].toObject()["ad_id"].toString()); - - Utils::externalLinkWarning(this, offerUrl); -} - -void LocalMoneroWidget::viewOfferDetails() { - QModelIndex index = ui->treeView->currentIndex(); - if (!index.isValid()) { - return; - } - - QJsonObject offerData = m_model->getOffer(index.row()); - QString details = offerData["data"].toObject()["msg"].toString(); - details.remove("*"); - - if (details.isEmpty()) { - details = "No details."; - } - - LocalMoneroInfoDialog dialog(this, m_model, index.row()); - dialog.exec(); -} - -void LocalMoneroWidget::updatePaymentMethods() { - QString currency = ui->combo_currency->currentText().toUpper(); - - ui->combo_paymentMethod->clear(); - ui->combo_paymentMethod->addItem("Any payment method"); - - for (const auto &payment_method : m_paymentMethods.keys()) { - auto pm = m_paymentMethods[payment_method].toObject(); - - if (pm["currencies"].toArray().contains(currency)) { - QString name = pm["name"].toString(); - if (name.isEmpty()) - name = payment_method; - ui->combo_paymentMethod->addItem(name, payment_method); - } - } -} - -LocalMoneroWidget::~LocalMoneroWidget() = default; \ No newline at end of file diff --git a/src/plugins/localmonero/LocalMoneroWidget.h b/src/plugins/localmonero/LocalMoneroWidget.h deleted file mode 100644 index 518a92f..0000000 --- a/src/plugins/localmonero/LocalMoneroWidget.h +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -// SPDX-FileCopyrightText: 2020-2024 The Monero Project - -#ifndef FEATHER_LOCALMONEROWIDGET_H -#define FEATHER_LOCALMONEROWIDGET_H - -#include - -#include "LocalMoneroApi.h" -#include "LocalMoneroModel.h" -#include "libwalletqt/Wallet.h" - -namespace Ui { - class LocalMoneroWidget; -} - -class LocalMoneroWidget : public QWidget -{ -Q_OBJECT - -public: - explicit LocalMoneroWidget(QWidget *parent, Wallet *wallet); - ~LocalMoneroWidget() override; - -public slots: - void skinChanged(); - -private slots: - void onSearchClicked(); - void onSignUpClicked(); - void onApiResponse(const LocalMoneroApi::LocalMoneroResponse &resp); - void onLoadMore(); - void onWsCountriesReceived(const QJsonArray &countries); - void onWsCurrenciesReceived(const QJsonArray ¤cies); - void onWsPaymentMethodsReceived(const QJsonObject &payment_methods); - -private: - void searchOffers(int page = 0); - void showContextMenu(const QPoint &point); - void openOfferUrl(); - void viewOfferDetails(); - void updatePaymentMethods(); - - QScopedPointer ui; - Wallet *m_wallet; - - int m_currentPage = 0; - - LocalMoneroApi *m_api; - LocalMoneroModel *m_model; - Networking *m_network; - QJsonObject m_paymentMethods; -}; - - -#endif //FEATHER_LOCALMONEROWIDGET_H diff --git a/src/plugins/localmonero/LocalMoneroWidget.ui b/src/plugins/localmonero/LocalMoneroWidget.ui deleted file mode 100644 index 25a8cc7..0000000 --- a/src/plugins/localmonero/LocalMoneroWidget.ui +++ /dev/null @@ -1,385 +0,0 @@ - - - LocalMoneroWidget - - - - 0 - 0 - 1003 - 607 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - - - logo - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 75 - true - - - - LocalMonero.co - - - Qt::AlignBottom|Qt::AlignHCenter - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 80 - 20 - - - - - - - - - - - 0 - 0 - - - - true - - - - Any payment method - - - - - - - - - 0 - 0 - - - - Amount - - - - - - - - 0 - 0 - - - - true - - - - - - - - 0 - 0 - - - - Sell XMR - - - - :/assets/images/localMonero_sell_white.svg:/assets/images/localMonero_sell_white.svg - - - - - - - Search - - - - :/assets/images/localMonero_search.svg:/assets/images/localMonero_search.svg - - - - - - - - 0 - 0 - - - - Buy XMR - - - - :/assets/images/localMonero_buy_white.svg:/assets/images/localMonero_buy_white.svg - - - true - - - - - - - - 0 - 0 - - - - true - - - - Any country - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Maximum - - - - 80 - 20 - - - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - - - Buy Monero. - - - Qt::AlignCenter - - - - - - - Sell Monero. - - - Qt::AlignCenter - - - - - - - Cash or online. - - - Qt::AlignCenter - - - - - - - Anywhere. - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Sign up free - - - - :/assets/images/localMonero_register.svg:/assets/images/localMonero_register.svg - - - - - - - - - - - - Qt::CustomContextMenu - - - false - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Load more - - - - - - - - - - radio_buy - radio_sell - line_amount - combo_currency - combo_country - combo_paymentMethod - btn_search - btn_signUp - btn_loadMore - treeView - - - - - - diff --git a/src/utils/config.cpp b/src/utils/config.cpp index c04799a..9e6cc6d 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -105,7 +105,6 @@ static const QHash configStrings = { "http://127.0.0.1:31312/tx?id=%txid%"}}}, {Config::blockExplorer,{QS("blockExplorer"), "https://xmrchain.net/tx/%txid%"}}, {Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}}, - {Config::localMoneroFrontend, {QS("localMoneroFrontend"), "https://localmonero.co"}}, {Config::bountiesFrontend, {QS("bountiesFrontend"), "https://bounties.monero.social"}}, {Config::lastPath, {QS("lastPath"), QDir::homePath()}}, @@ -131,7 +130,7 @@ static const QHash configStrings = { {Config::useLocalTor, {QS("useLocalTor"), false}}, {Config::initSyncThreshold, {QS("initSyncThreshold"), 360}}, - {Config::enabledPlugins, {QS("enabledPlugins"), QStringList{"tickers", "crowdfunding", "bounties", "reddit", "revuo", "localmonero", "calc", "xmrig"}}}, + {Config::enabledPlugins, {QS("enabledPlugins"), QStringList{"tickers", "crowdfunding", "bounties", "reddit", "revuo", "calc", "xmrig"}}}, {Config::restartRequired, {QS("restartRequired"), false}}, {Config::tickers, {QS("tickers"), QStringList{"XMR", "BTC", "XMR/BTC"}}}, diff --git a/src/utils/config.h b/src/utils/config.h index 9f163e0..c76e946 100644 --- a/src/utils/config.h +++ b/src/utils/config.h @@ -128,7 +128,6 @@ public: blockExplorers, blockExplorer, redditFrontend, - localMoneroFrontend, bountiesFrontend, // unused lastPath,