Skip to content

Commit 412c943

Browse files
committed
Stop choosing latest plugin version in the API.
This information should come from the core, not be decided upon here.
1 parent 5f31dfa commit 412c943

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

binaryninjacore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// Current ABI version for linking to the core. This is incremented any time
3838
// there are changes to the API that affect linking, including new functions,
3939
// new types, or modifications to existing functions or types.
40-
#define BN_CURRENT_CORE_ABI_VERSION 176
40+
#define BN_CURRENT_CORE_ABI_VERSION 177
4141

4242
// Minimum ABI version that is supported for loading of plugins. Plugins that
4343
// are linked to an ABI version less than this will not be able to load and
@@ -8295,6 +8295,7 @@ extern "C"
82958295
BINARYNINJACOREAPI BNPluginVersion* BNPluginGetVersions(BNPlugin* p, size_t* count);
82968296
BINARYNINJACOREAPI void BNFreePluginVersions(BNPluginVersion* r, size_t count);
82978297
BINARYNINJACOREAPI const char* BNPluginGetCurrentVersionID(BNPlugin* p);
8298+
BINARYNINJACOREAPI const char* BNPluginGetLatestVersionID(BNPlugin* p);
82988299
BINARYNINJACOREAPI BNPluginVersion BNPluginGetCurrentVersion(BNPlugin* p);
82998300
BINARYNINJACOREAPI void BNPluginFreeVersion(BNPluginVersion v);
83008301
BINARYNINJACOREAPI const char* BNPluginGetCommit(BNPlugin* p);

pluginmanager.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ std::string Extension::GetCurrentVersionID() const
199199

200200
std::string Extension::GetLatestVersionID() const
201201
{
202-
auto versions = GetVersions();
203-
if (versions.empty())
204-
return "";
205-
return versions.front().id;
202+
RETURN_STRING(BNPluginGetLatestVersionID(m_object));
206203
}
207204

208205

python/pluginmanager.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ def installed(self) -> bool:
9292
def install(self, version_id=None) -> bool:
9393
"""Attempt to install the given plugin. Defaults to the latest available version."""
9494
self.install_dependencies()
95-
if version_id is None:
96-
version_id = self.current_version.id
9795
return core.BNPluginInstall(self.handle, version_id)
9896

9997
def uninstall(self) -> bool:
@@ -268,6 +266,13 @@ def current_version(self) -> ExtensionVersion:
268266
finally:
269267
core.BNPluginFreeVersion(version)
270268

269+
@property
270+
def latest_version_id(self) -> str:
271+
"""Latest version id available for this platform"""
272+
result = core.BNPluginGetLatestVersionID(self.handle)
273+
assert result is not None, "core.BNPluginGetLatestVersionID returned None"
274+
return result
275+
271276
@property
272277
def versions(self) -> List[ExtensionVersion]:
273278
"""Version metadata for all available plugin versions"""

rust/src/repository/plugin.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ impl Extension {
136136
ExtensionVersion::from_owned_raw(result)
137137
}
138138

139+
/// Latest version id available for this platform
140+
pub fn latest_version_id(&self) -> String {
141+
let result = unsafe { BNPluginGetLatestVersionID(self.handle.as_ptr()) };
142+
assert!(!result.is_null());
143+
unsafe { BnString::into_string(result as *mut c_char) }
144+
}
145+
139146
/// String plugin name
140147
pub fn name(&self) -> String {
141148
let result = unsafe { BNPluginGetName(self.handle.as_ptr()) };

0 commit comments

Comments
 (0)