reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 455ac85cceb49e603cd6c572041aad4e0775d92f
parent 169196d86b0b6b3b27eb3322617495ec38d1fa4c
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sun,  4 Jun 2017 03:52:42 -0400

api: create function SetRepository

Diffstat:
Msrc/api.cpp | 37+++++++++++++++++++++++++++++++++++++
Msrc/api.hpp | 1+
Msrc/main.cpp | 1+
3 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/api.cpp b/src/api.cpp @@ -295,3 +295,40 @@ DEFINE_API(PackageEntry*, GetOwner, ((const char*, fn))((char*, errorOut))((int, return nullptr; } }); + +DEFINE_API(bool, SetRepository, ((const char*, name))((const char*, url)) + ((bool, enabled))((int, autoInstall))((bool, commit)) + ((char*, errorOut))((int, errorOut_sz)), R"( + Add the given repository name and URL to the list. Set commit to true on the last call to this function. + + autoInstall: default is 2 (use global setting). +)", { + try { + if(reapack->remote(name).isProtected()) { + if(errorOut) + snprintf(errorOut, errorOut_sz, "this repository is protected"); + return false; + } + + Remote remote(name, url, enabled, boost::lexical_cast<tribool>(autoInstall)); + reapack->config()->remotes.add(remote); + } + catch(const reapack_error &e) { + if(errorOut) + snprintf(errorOut, errorOut_sz, "%s", e.what()); + return false; + } + catch(const boost::bad_lexical_cast &) { + if(errorOut) + snprintf(errorOut, errorOut_sz, "invalid value for autoInstall"); + return false; + } + + if(commit) { + reapack->refreshManager(); + reapack->refreshBrowser(); + reapack->config()->write(); + } + + return true; +}); diff --git a/src/api.hpp b/src/api.hpp @@ -53,6 +53,7 @@ namespace API { extern APIFunc FreeEntry; extern APIFunc GetEntryInfo; extern APIFunc GetOwner; + extern APIFunc SetRepository; }; #endif diff --git a/src/main.cpp b/src/main.cpp @@ -168,6 +168,7 @@ static void setupAPI() reapack->setupAPI(&API::FreeEntry); reapack->setupAPI(&API::GetEntryInfo); reapack->setupAPI(&API::GetOwner); + reapack->setupAPI(&API::SetRepository); } extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT(