summaryrefslogtreecommitdiff
path: root/plugins/warp/ui/plugin.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-10-07 14:32:48 -0400
committerMason Reed <mason@vector35.com>2025-10-07 14:33:34 -0400
commit4a227e0523391bc026bf96c3c31d44a39cac1701 (patch)
treecc603b899a446fb469a0be3ae4c2c77e6351c091 /plugins/warp/ui/plugin.cpp
parent3e24f6ab0b373d8718e26a19ac296044cc0d19c6 (diff)
[WARP] Format UI plugin
Diffstat (limited to 'plugins/warp/ui/plugin.cpp')
-rw-r--r--plugins/warp/ui/plugin.cpp114
1 files changed, 56 insertions, 58 deletions
diff --git a/plugins/warp/ui/plugin.cpp b/plugins/warp/ui/plugin.cpp
index b1cc9a5b..e8088d7c 100644
--- a/plugins/warp/ui/plugin.cpp
+++ b/plugins/warp/ui/plugin.cpp
@@ -10,7 +10,7 @@
using namespace BinaryNinja;
-QIcon GetColoredIcon(const QString &iconPath, const QColor &color)
+QIcon GetColoredIcon(const QString& iconPath, const QColor& color)
{
auto pixmap = QPixmap(iconPath);
auto mask = pixmap.createMaskFromColor(QColor(0, 0, 0), Qt::MaskInColor);
@@ -24,7 +24,7 @@ Ref<BackgroundTask> GetMatcherTask()
// TODO: What happens if we have multiple views open matching? This fails.
// Look for the matcher background task to determine if we are stopping or starting it.
Ref<BackgroundTask> matcherTask = nullptr;
- for (const auto &task: BackgroundTask::GetRunningTasks())
+ for (const auto& task : BackgroundTask::GetRunningTasks())
{
std::string progressText = task->GetProgressText();
if (progressText.find("Matching on WARP") != std::string::npos)
@@ -35,22 +35,29 @@ Ref<BackgroundTask> GetMatcherTask()
void ShowNetworkNotice()
{
- // By default, network access is disabled for WARP, this function will show the user a notice to enable it and restart.
+ // By default, network access is disabled for WARP, this function will show the user a notice to enable it and
+ // restart.
const auto settings = Settings::Instance();
const bool networkNoticeShown = QSettings().value("warp/NetworkNoticeShown", false).toBool();
QSettings().setValue("warp/NetworkNoticeShown", true);
if (!networkNoticeShown && settings->Contains("network.enableWARP") && !settings->Get<bool>("network.enableWARP"))
{
- const bool enable = ShowMessageBox("Enable WARP Network Access?",
- "Network access is disabled by default. Enable WARP network features now?\n\n"
- "You can change this later in Settings.",
- YesNoButtonSet, InformationIcon) == YesButton;
+ const bool enable =
+ ShowMessageBox("Enable WARP Network Access?",
+ "Network access is disabled by default. Enable WARP network features now?\n\n"
+ "You can change this later in Settings.",
+ YesNoButtonSet, InformationIcon)
+ == YesButton;
settings->Set("network.enableWARP", enable);
// TODO: Add a notifyRestartRequired call here
if (enable)
- ShowMessageBox("WARP Network Enabled", "Please restart Binary Ninja to allow WARP to make requests to the server.", OKButtonSet, InformationIcon);
+ ShowMessageBox("WARP Network Enabled",
+ "Please restart Binary Ninja to allow WARP to make requests to the server.", OKButtonSet,
+ InformationIcon);
else
- ShowMessageBox("WARP Network Disabled", "WARP network access will remain disabled. You can enable it later from Settings.", OKButtonSet, InformationIcon);
+ ShowMessageBox("WARP Network Disabled",
+ "WARP network access will remain disabled. You can enable it later from Settings.", OKButtonSet,
+ InformationIcon);
}
}
@@ -63,24 +70,24 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
ShowNetworkNotice();
m_headerWidget = new QWidget();
- QHBoxLayout *headerLayout = new QHBoxLayout();
+ QHBoxLayout* headerLayout = new QHBoxLayout();
headerLayout->setContentsMargins(0, 0, 0, 0);
headerLayout->setSpacing(0);
- QToolBar *headerToolbar = new QToolBar(this);
+ QToolBar* headerToolbar = new QToolBar(this);
headerToolbar->setContentsMargins(0, 0, 0, 0);
headerToolbar->setIconSize(QSize(20, 20));
auto fetchIcon = GetColoredIcon(":/icons/images/arrow-pull.png", getThemeColor(BlueStandardHighlightColor));
auto fetchAction = headerToolbar->addAction(fetchIcon, "Fetch data from WARP containers", [this]() {
- UIActionHandler *handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
+ UIActionHandler* handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
handler->executeAction("WARP\\Fetch");
});
fetchAction->setToolTip("Fetch data from WARP containers");
auto commitIcon = GetColoredIcon(":/icons/images/arrow-push.png", getThemeColor(BlueStandardHighlightColor));
auto commitAction = headerToolbar->addAction(commitIcon, "Commit a WARP file to a source", [this]() {
- UIActionHandler *handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
+ UIActionHandler* handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
handler->executeAction("WARP\\Commit File");
});
commitAction->setToolTip("Commit a WARP file to a source");
@@ -90,14 +97,14 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
auto loadIcon = GetColoredIcon(":/icons/images/file-add.png", getThemeColor(BlueStandardHighlightColor));
auto loadAction = headerToolbar->addAction(loadIcon, "Load Signature File", [this]() {
- UIActionHandler *handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
+ UIActionHandler* handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
handler->executeAction("WARP\\Load File");
});
loadAction->setToolTip("Load a signature file to match against");
auto saveIcon = GetColoredIcon(":/icons/images/edit.png", getThemeColor(BlueStandardHighlightColor));
auto saveAction = headerToolbar->addAction(saveIcon, "Create Signature File", [this]() {
- UIActionHandler *handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
+ UIActionHandler* handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
handler->executeAction("WARP\\Create\\From Current View");
});
saveAction->setToolTip("Save data to a signature file");
@@ -105,10 +112,10 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
headerToolbar->addSeparator();
static auto matcherStopIcon = GetColoredIcon(":/icons/images/stop.png", getThemeColor(RedStandardHighlightColor));
- static auto matcherStartIcon = GetColoredIcon(":/icons/images/start.png",
- getThemeColor(GreenStandardHighlightColor));
+ static auto matcherStartIcon =
+ GetColoredIcon(":/icons/images/start.png", getThemeColor(GreenStandardHighlightColor));
m_matcherAction = headerToolbar->addAction(matcherStartIcon, "Run Matcher", [this]() {
- UIActionHandler *handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
+ UIActionHandler* handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
if (Ref<BackgroundTask> matcherTask = GetMatcherTask())
matcherTask->Cancel();
else if (!isMatcherRunning)
@@ -120,9 +127,7 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
m_matcherAction->setToolTip("Run the matcher on all functions");
auto refreshIcon = GetColoredIcon(":/icons/images/refresh.png", getThemeColor(BlueStandardHighlightColor));
- auto refreshAction = headerToolbar->addAction(refreshIcon, "Refresh the view data", [this]() {
- Update();
- });
+ auto refreshAction = headerToolbar->addAction(refreshIcon, "Refresh the view data", [this]() { Update(); });
refreshAction->setToolTip("Refresh the sidebar data");
// Push the toolbar to the right using a stretch space.
@@ -130,31 +135,31 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
headerLayout->addWidget(headerToolbar, 0);
m_headerWidget->setLayout(headerLayout);
- QFrame *currentFunctionFrame = new QFrame(this);
+ QFrame* currentFunctionFrame = new QFrame(this);
m_currentFunctionWidget = new WarpCurrentFunctionWidget();
- QVBoxLayout *currentFunctionLayout = new QVBoxLayout();
+ QVBoxLayout* currentFunctionLayout = new QVBoxLayout();
currentFunctionLayout->setContentsMargins(0, 0, 0, 0);
currentFunctionLayout->setSpacing(0);
currentFunctionLayout->addWidget(m_currentFunctionWidget);
currentFunctionFrame->setLayout(currentFunctionLayout);
- QFrame *matchedFrame = new QFrame(this);
+ QFrame* matchedFrame = new QFrame(this);
m_matchedWidget = new WarpMatchedWidget(m_data);
- QVBoxLayout *matchedLayout = new QVBoxLayout();
+ QVBoxLayout* matchedLayout = new QVBoxLayout();
matchedLayout->setContentsMargins(0, 0, 0, 0);
matchedLayout->setSpacing(0);
matchedLayout->addWidget(m_matchedWidget);
matchedFrame->setLayout(matchedLayout);
- QFrame *containerFrame = new QFrame(this);
+ QFrame* containerFrame = new QFrame(this);
m_containerWidget = new WarpContainersPane();
- QVBoxLayout *containerLayout = new QVBoxLayout();
+ QVBoxLayout* containerLayout = new QVBoxLayout();
containerLayout->setContentsMargins(0, 0, 0, 0);
containerLayout->setSpacing(0);
containerLayout->addWidget(m_containerWidget);
containerFrame->setLayout(containerLayout);
- QVBoxLayout *layout = new QVBoxLayout(this);
+ QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
@@ -167,11 +172,7 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
this->setLayout(layout);
// Do a full update if analysis has been done, otherwise we may persist old data and not have new data.
- m_analysisEvent = new AnalysisCompletionEvent(m_data, [this]() {
- ExecuteOnMainThread([this]() {
- Update();
- });
- });
+ m_analysisEvent = new AnalysisCompletionEvent(m_data, [this]() { ExecuteOnMainThread([this]() { Update(); }); });
const std::shared_ptr<WarpFetcher> fetcher = WarpFetcher::Global();
fetcher->AddCompletionCallback([this]() {
@@ -188,9 +189,7 @@ WarpSidebarWidget::~WarpSidebarWidget()
m_analysisEvent->Cancel();
}
-void WarpSidebarWidget::focus()
-{
-}
+void WarpSidebarWidget::focus() {}
void WarpSidebarWidget::Update()
{
@@ -203,15 +202,16 @@ void WarpSidebarWidget::Update()
void WarpSidebarWidget::setMatcherActionIcon(bool running)
{
static auto matcherStopIcon = GetColoredIcon(":/icons/images/stop.png", getThemeColor(RedStandardHighlightColor));
- static auto matcherStartIcon = GetColoredIcon(":/icons/images/start.png",
- getThemeColor(GreenStandardHighlightColor));
+ static auto matcherStartIcon =
+ GetColoredIcon(":/icons/images/start.png", getThemeColor(GreenStandardHighlightColor));
isMatcherRunning = running;
if (running)
{
m_matcherAction->setIcon(matcherStopIcon);
m_matcherAction->setToolTip("Stop the matcher");
m_matcherAction->setIconText("Stop Matcher");
- } else
+ }
+ else
{
m_matcherAction->setIcon(matcherStartIcon);
m_matcherAction->setToolTip("Run the matcher on all functions");
@@ -219,7 +219,7 @@ void WarpSidebarWidget::setMatcherActionIcon(bool running)
}
}
-void WarpSidebarWidget::notifyViewChanged(ViewFrame *view)
+void WarpSidebarWidget::notifyViewChanged(ViewFrame* view)
{
if (!view)
return;
@@ -230,7 +230,7 @@ void WarpSidebarWidget::notifyViewChanged(ViewFrame *view)
// TODO: We need to set some stuff here prolly.
}
-void WarpSidebarWidget::notifyViewLocationChanged(View *view, const ViewLocation &location)
+void WarpSidebarWidget::notifyViewLocationChanged(View* view, const ViewLocation& location)
{
// Warp sidebar really should only update if it is visible, otherwise its a waste of cycles.
if (!this->isVisible())
@@ -241,25 +241,23 @@ void WarpSidebarWidget::notifyViewLocationChanged(View *view, const ViewLocation
m_currentFunctionWidget->SetCurrentFunction(function);
}
-WarpSidebarWidgetType::WarpSidebarWidgetType() : SidebarWidgetType(QImage(":/icons/images/warp.png"), "WARP")
-{
-
-}
-
+WarpSidebarWidgetType::WarpSidebarWidgetType() : SidebarWidgetType(QImage(":/icons/images/warp.png"), "WARP") {}
-extern "C" {
-BN_DECLARE_UI_ABI_VERSION
-BINARYNINJAPLUGIN void CorePluginDependencies()
+extern "C"
{
- // We must have WARP to enable this plugin!
- AddRequiredPluginDependency("warp_ninja");
-}
+ BN_DECLARE_UI_ABI_VERSION
-BINARYNINJAPLUGIN bool UIPluginInit()
-{
- RegisterWarpFetchFunctionsCommand();
- Sidebar::addSidebarWidgetType(new WarpSidebarWidgetType());
- return true;
-}
+ BINARYNINJAPLUGIN void CorePluginDependencies()
+ {
+ // We must have WARP to enable this plugin!
+ AddRequiredPluginDependency("warp_ninja");
+ }
+
+ BINARYNINJAPLUGIN bool UIPluginInit()
+ {
+ RegisterWarpFetchFunctionsCommand();
+ Sidebar::addSidebarWidgetType(new WarpSidebarWidgetType());
+ return true;
+ }
}