Fix Bin, IO and Core plugin info (Fix #2764) (#2765)

This commit is contained in:
Florian Märkl 2021-09-19 10:58:08 +02:00 committed by GitHub
parent 3e1b3ce865
commit 7e68147eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 49 deletions

View File

@ -2720,72 +2720,66 @@ QStringList CutterCore::getAnalysisPluginNames()
QList<RzBinPluginDescription> CutterCore::getRBinPluginDescriptions(const QString &type) QList<RzBinPluginDescription> CutterCore::getRBinPluginDescriptions(const QString &type)
{ {
CORE_LOCK();
QList<RzBinPluginDescription> ret; QList<RzBinPluginDescription> ret;
RzListIter *it;
QJsonObject jsonRoot = cmdj("iLj").object(); RzBinPlugin *bp;
for (const QString &key : jsonRoot.keys()) { CutterRzListForeach(core->bin->plugins, it, RzBinPlugin, bp) {
if (!type.isNull() && key != type) RzBinPluginDescription desc;
continue; desc.name = bp->name ? bp->name : "";
desc.description = bp->desc ? bp->desc : "";
QJsonArray pluginArray = jsonRoot[key].toArray(); desc.license = bp->license ? bp->license : "";
desc.type = "bin";
for (const QJsonValue &pluginValue : pluginArray) { ret.append(desc);
QJsonObject pluginObject = pluginValue.toObject(); }
RzBinXtrPlugin *bx;
RzBinPluginDescription desc; CutterRzListForeach(core->bin->binxtrs, it, RzBinXtrPlugin, bx) {
RzBinPluginDescription desc;
desc.name = pluginObject[RJsonKey::name].toString(); desc.name = bx->name ? bx->name : "";
desc.description = pluginObject[RJsonKey::description].toString(); desc.description = bx->desc ? bx->desc : "";
desc.license = pluginObject[RJsonKey::license].toString(); desc.license = bx->license ? bx->license : "";
desc.type = key; desc.type = "xtr";
ret.append(desc);
ret.append(desc);
}
} }
return ret; return ret;
} }
QList<RzIOPluginDescription> CutterCore::getRIOPluginDescriptions() QList<RzIOPluginDescription> CutterCore::getRIOPluginDescriptions()
{ {
CORE_LOCK();
QList<RzIOPluginDescription> ret; QList<RzIOPluginDescription> ret;
RzListIter *it;
QJsonArray plugins = cmdj("oLj").object()["io_plugins"].toArray(); RzIOPlugin *p;
for (const QJsonValue &pluginValue : plugins) { CutterRzListForeach(core->io->plugins, it, RzIOPlugin, p) {
QJsonObject pluginObject = pluginValue.toObject(); RzIOPluginDescription desc;
desc.name = p->name ? p->name : "";
RzIOPluginDescription plugin; desc.description = p->desc ? p->desc : "";
desc.license = p->license ? p->license : "";
plugin.name = pluginObject["name"].toString(); desc.permissions =
plugin.description = pluginObject["description"].toString(); QString("r") +
plugin.license = pluginObject["license"].toString(); (p->write ? "w" : "_") +
plugin.permissions = pluginObject["permissions"].toString(); (p->isdbg ? "d" : "_");
for (const auto &uri : pluginObject["uris"].toArray()) { if (p->uris) {
plugin.uris << uri.toString(); desc.uris = QString::fromUtf8(p->uris).split(",");
} }
ret.append(desc);
ret << plugin;
} }
return ret; return ret;
} }
QList<RzCorePluginDescription> CutterCore::getRCorePluginDescriptions() QList<RzCorePluginDescription> CutterCore::getRCorePluginDescriptions()
{ {
CORE_LOCK();
QList<RzCorePluginDescription> ret; QList<RzCorePluginDescription> ret;
RzListIter *it;
QJsonArray plugins = cmdj("Lcj").array(); RzCorePlugin *p;
for (const QJsonValue &pluginValue : plugins) { CutterRzListForeach(core->plugins, it, RzCorePlugin, p) {
QJsonObject pluginObject = pluginValue.toObject(); RzCorePluginDescription desc;
desc.name = p->name ? p->name : "";
RzCorePluginDescription plugin; desc.description = p->desc ? p->desc : "";
desc.license = p->license ? p->license : "";
plugin.name = pluginObject["Name"].toString(); ret.append(desc);
plugin.description = pluginObject["Description"].toString();
ret << plugin;
} }
return ret; return ret;
} }

View File

@ -194,6 +194,7 @@ struct RzCorePluginDescription
{ {
QString name; QString name;
QString description; QString description;
QString license;
}; };
struct RzAsmPluginDescription struct RzAsmPluginDescription

View File

@ -36,6 +36,7 @@ RizinPluginsDialog::RizinPluginsDialog(QWidget *parent)
QTreeWidgetItem *item = new QTreeWidgetItem(); QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, plugin.name); item->setText(0, plugin.name);
item->setText(1, plugin.description); item->setText(1, plugin.description);
item->setText(2, plugin.license);
ui->RzCoreTreeWidget->addTopLevelItem(item); ui->RzCoreTreeWidget->addTopLevelItem(item);
} }
ui->RzCoreTreeWidget->sortByColumn(0, Qt::AscendingOrder); ui->RzCoreTreeWidget->sortByColumn(0, Qt::AscendingOrder);

View File

@ -128,6 +128,11 @@
<string>Description</string> <string>Description</string>
</property> </property>
</column> </column>
<column>
<property name="text">
<string>License</string>
</property>
</column>
</widget> </widget>
</item> </item>
</layout> </layout>