77
88#include " action.h"
99#include " fetcher.h"
10+ #include " misc.h"
1011
1112using namespace BinaryNinja ;
1213
@@ -35,8 +36,6 @@ WarpFetchDialog::WarpFetchDialog(BinaryViewRef bv,
3536 for (const auto &c: m_containers)
3637 m_containerCombo->addItem (QString::fromStdString (c->GetName ()));
3738
38- // TODO: Need to add tooltip to explain that a source must have atleast one of these tags to be considered.
39-
4039 // Tags editor
4140 m_tagsList = new QListWidget (this );
4241 m_addTagBtn = new QPushButton (this );
@@ -67,13 +66,13 @@ WarpFetchDialog::WarpFetchDialog(BinaryViewRef bv,
6766 m_tagsList->setToolTip (" A source must have atleast ONE of these tags to be considered" );
6867
6968 // Defaults from processor tags
70- for (const auto &t: m_fetchProcessor-> GetTags ( ))
69+ for (const auto &t: GetAllowedTagsFromView (m_bv ))
7170 AddListItem (m_tagsList, QString::fromStdString (t));
7271
7372 // Batch size and matcher checkbox
7473 m_batchSize = new QSpinBox (this );
7574 m_batchSize->setRange (10 , 1000 );
76- m_batchSize->setValue (100 );
75+ m_batchSize->setValue (GetBatchSizeFromView (m_bv) );
7776 m_batchSize->setToolTip (" Number of functions to fetch in each batch" );
7877
7978 m_rerunMatcher = new QCheckBox (" Re-run matcher after fetch" , this );
@@ -84,17 +83,14 @@ WarpFetchDialog::WarpFetchDialog(BinaryViewRef bv,
8483 m_clearProcessed->setChecked (false );
8584
8685 form->addRow (new QLabel (" Container: " ), m_containerCombo);
87- // TODO: Need to plumb this through to the fetcher, and also likely have a blacklisted or whitelist mode for this dialog.
88- // TODO: Alos wan to prefill the list of sources from the view/global settings.
89- // form->addRow(new QLabel("Allowed Sources: "), srcWrapper);
9086 form->addRow (new QLabel (" Allowed Tags: " ), tagWrapper);
9187 form->addRow (new QLabel (" Batch Size: " ), m_batchSize);
9288 form->addRow (m_rerunMatcher);
9389 form->addRow (m_clearProcessed);
9490
9591 auto buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this );
9692 connect (buttons, &QDialogButtonBox::accepted, this , &WarpFetchDialog::onAccept);
97- connect (buttons, &QDialogButtonBox::rejected, this , &QDialog::reject );
93+ connect (buttons, &QDialogButtonBox::rejected, this , &WarpFetchDialog::onReject );
9894
9995 auto root = new QVBoxLayout (this );
10096 root->addLayout (form);
@@ -149,12 +145,12 @@ void WarpFetchDialog::onAccept()
149145 if (idx > 0 ) // 0 == All Containers
150146 containerIndex = static_cast <size_t >(idx - 1 );
151147
152- auto tags = collectTags ();
153148 const auto batch = static_cast <size_t >(m_batchSize->value ());
154149 const bool rerun = m_rerunMatcher->isChecked ();
155150
156- // Persist tags to the shared processor for consistency across navigation
157- m_fetchProcessor->SetTags (tags);
151+ const auto tags = collectTags ();
152+ // Persist tags to the view settings.
153+ SetTagsToView (m_bv, tags);
158154
159155 if (m_clearProcessed->isChecked ())
160156 m_fetchProcessor->ClearProcessed ();
@@ -165,8 +161,16 @@ void WarpFetchDialog::onAccept()
165161 accept ();
166162}
167163
164+ void WarpFetchDialog::onReject ()
165+ {
166+ const auto tags = collectTags ();
167+ // Persist tags to the view settings.
168+ SetTagsToView (m_bv, tags);
169+ reject ();
170+ }
171+
168172void WarpFetchDialog::runBatchedFetch (const std::optional<size_t > &containerIndex,
169- const std::vector<Warp::SourceTag> &tags ,
173+ const std::vector<Warp::SourceTag> &allowedTags ,
170174 size_t batchSize,
171175 bool rerunMatcher)
172176{
@@ -186,7 +190,7 @@ void WarpFetchDialog::runBatchedFetch(const std::optional<size_t> &containerInde
186190 auto bv = m_bv;
187191
188192 // TODO: Too many captures in this thing lol.
189- WorkerInteractiveEnqueue ([fetcher, bv, funcs = std::move (funcs), batchSize, rerunMatcher, task]() mutable {
193+ WorkerInteractiveEnqueue ([fetcher, bv, funcs = std::move (funcs), batchSize, rerunMatcher, task, allowedTags ]() mutable {
190194 size_t processed = 0 ;
191195 size_t batchIndex = 0 ;
192196
@@ -198,7 +202,7 @@ void WarpFetchDialog::runBatchedFetch(const std::optional<size_t> &containerInde
198202 for (size_t i = 0 ; i < thisBatchCount; ++i)
199203 fetcher->AddPendingFunction (funcs[processed + i]);
200204
201- fetcher->FetchPendingFunctions ();
205+ fetcher->FetchPendingFunctions (allowedTags );
202206
203207 ++batchIndex;
204208 processed += thisBatchCount;
@@ -219,8 +223,6 @@ void RegisterWarpFetchFunctionsCommand()
219223{
220224 // Register a UI action and bind it globally. Add it to the Tools menu.
221225 const QString actionName = " WARP\\ Fetch" ;
222-
223- // TODO: Because we register this in every widget this will happen, this is bad behavior!
224226 if (!UIAction::isActionRegistered (actionName))
225227 UIAction::registerAction (actionName);
226228
0 commit comments