Browse Source

Move app::APP_*, ABI_*, and API_* variables to rack:: namespace.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
866f684ce4
11 changed files with 57 additions and 57 deletions
  1. +0
    -9
      include/app/common.hpp
  2. +12
    -0
      include/common.hpp
  3. +0
    -25
      src/app/common.cpp
  4. +4
    -4
      src/asset.cpp
  5. +22
    -0
      src/common.cpp
  6. +3
    -3
      src/main.cpp
  7. +3
    -3
      src/patch.cpp
  8. +7
    -7
      src/plugin.cpp
  9. +2
    -2
      src/plugin/Plugin.cpp
  10. +3
    -3
      src/updater.cpp
  11. +1
    -1
      src/window.cpp

+ 0
- 9
include/app/common.hpp View File

@@ -12,15 +12,6 @@ namespace rack {
namespace app { namespace app {




extern const std::string APP_NAME;
extern const std::string APP_VERSION;
extern const std::string APP_ARCH;

extern const std::string ABI_VERSION;

extern const std::string API_URL;
extern const std::string API_VERSION;

static const float SVG_DPI = 75.f; static const float SVG_DPI = 75.f;
static const float MM_PER_IN = 25.4f; static const float MM_PER_IN = 25.4f;




+ 12
- 0
include/common.hpp View File

@@ -163,6 +163,18 @@ struct Exception : std::runtime_error {
}; };




// config

extern const std::string APP_NAME;
extern const std::string APP_VERSION;
extern const std::string APP_ARCH;

extern const std::string ABI_VERSION;

extern const std::string API_URL;
extern const std::string API_VERSION;


} // namespace rack } // namespace rack






+ 0
- 25
src/app/common.cpp View File

@@ -1,25 +0,0 @@
#include <app/common.hpp>


namespace rack {
namespace app {


const std::string APP_NAME = "VCV Rack";
const std::string APP_VERSION = TOSTRING(VERSION);
#if defined ARCH_WIN
const std::string APP_ARCH = "win";
#elif ARCH_MAC
const std::string APP_ARCH = "mac";
#elif defined ARCH_LIN
const std::string APP_ARCH = "lin";
#endif

const std::string ABI_VERSION = "2";

const std::string API_URL = "https://api.vcvrack.com";
const std::string API_VERSION = "2";


} // namespace app
} // namespace rack

+ 4
- 4
src/asset.cpp View File

@@ -126,10 +126,10 @@ void init() {
} }
else { else {
logPath = userDir + "/log.txt"; logPath = userDir + "/log.txt";
pluginsPath = userDir + "/plugins-v" + app::ABI_VERSION;
settingsPath = userDir + "/settings-v" + app::ABI_VERSION + ".json";
autosavePath = userDir + "/autosave-v" + app::ABI_VERSION + ".vcv";
templatePath = userDir + "/template-v" + app::ABI_VERSION + ".vcv";
pluginsPath = userDir + "/plugins-v" + ABI_VERSION;
settingsPath = userDir + "/settings-v" + ABI_VERSION + ".json";
autosavePath = userDir + "/autosave-v" + ABI_VERSION + ".vcv";
templatePath = userDir + "/template-v" + ABI_VERSION + ".vcv";
} }
} }




+ 22
- 0
src/common.cpp View File

@@ -1,6 +1,28 @@
#include <common.hpp> #include <common.hpp>




namespace rack {


const std::string APP_NAME = "VCV Rack";
const std::string APP_VERSION = TOSTRING(VERSION);
#if defined ARCH_WIN
const std::string APP_ARCH = "win";
#elif ARCH_MAC
const std::string APP_ARCH = "mac";
#elif defined ARCH_LIN
const std::string APP_ARCH = "lin";
#endif

const std::string ABI_VERSION = "2";

const std::string API_URL = "https://api.vcvrack.com";
const std::string API_VERSION = "2";


} // namespace rack


#if defined ARCH_WIN #if defined ARCH_WIN
#include <windows.h> #include <windows.h>




+ 3
- 3
src/main.cpp View File

@@ -47,7 +47,7 @@ static void fatalSignalHandler(int sig) {


// This might fail because we might not be in the main thread. // This might fail because we might not be in the main thread.
// But oh well, we're crashing anyway. // But oh well, we're crashing anyway.
std::string text = app::APP_NAME + " has crashed. See " + asset::logPath + " for details.";
std::string text = APP_NAME + " has crashed. See " + asset::logPath + " for details.";
osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, text.c_str()); osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, text.c_str());


abort(); abort();
@@ -58,7 +58,7 @@ int main(int argc, char* argv[]) {
#if defined ARCH_WIN #if defined ARCH_WIN
// Windows global mutex to prevent multiple instances // Windows global mutex to prevent multiple instances
// Handle will be closed by Windows when the process ends // Handle will be closed by Windows when the process ends
HANDLE instanceMutex = CreateMutexW(NULL, true, string::toWstring(app::APP_NAME).c_str());
HANDLE instanceMutex = CreateMutexW(NULL, true, string::toWstring(APP_NAME).c_str());
if (GetLastError() == ERROR_ALREADY_EXISTS) { if (GetLastError() == ERROR_ALREADY_EXISTS) {
osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Rack is already running. Multiple Rack instances are not supported."); osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Rack is already running. Multiple Rack instances are not supported.");
exit(1); exit(1);
@@ -118,7 +118,7 @@ int main(int argc, char* argv[]) {
} }


// Log environment // Log environment
INFO("%s v%s", app::APP_NAME.c_str(), app::APP_VERSION.c_str());
INFO("%s v%s", APP_NAME.c_str(), APP_VERSION.c_str());
INFO("%s", system::getOperatingSystemInfo().c_str()); INFO("%s", system::getOperatingSystemInfo().c_str());
std::string argsList; std::string argsList;
for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) {


+ 3
- 3
src/patch.cpp View File

@@ -270,7 +270,7 @@ json_t* PatchManager::toJson() {
json_t* rootJ = json_object(); json_t* rootJ = json_object();


// version // version
json_t* versionJ = json_string(app::APP_VERSION.c_str());
json_t* versionJ = json_string(APP_VERSION.c_str());
json_object_set_new(rootJ, "version", versionJ); json_object_set_new(rootJ, "version", versionJ);


json_t* engineJ = APP->engine->toJson(); json_t* engineJ = APP->engine->toJson();
@@ -293,8 +293,8 @@ void PatchManager::fromJson(json_t* rootJ) {
json_t* versionJ = json_object_get(rootJ, "version"); json_t* versionJ = json_object_get(rootJ, "version");
if (versionJ) if (versionJ)
version = json_string_value(versionJ); version = json_string_value(versionJ);
if (version != app::APP_VERSION) {
INFO("Patch was made with Rack v%s, current Rack version is v%s", version.c_str(), app::APP_VERSION.c_str());
if (version != APP_VERSION) {
INFO("Patch was made with Rack v%s, current Rack version is v%s", version.c_str(), APP_VERSION.c_str());
} }


// Detect old patches with ModuleWidget::params/inputs/outputs indices. // Detect old patches with ModuleWidget::params/inputs/outputs indices.


+ 7
- 7
src/plugin.cpp View File

@@ -260,7 +260,7 @@ void logIn(const std::string& email, const std::string& password) {
json_t* reqJ = json_object(); json_t* reqJ = json_object();
json_object_set(reqJ, "email", json_string(email.c_str())); json_object_set(reqJ, "email", json_string(email.c_str()));
json_object_set(reqJ, "password", json_string(password.c_str())); json_object_set(reqJ, "password", json_string(password.c_str()));
std::string url = app::API_URL + "/token";
std::string url = API_URL + "/token";
json_t* resJ = network::requestJson(network::METHOD_POST, url, reqJ); json_t* resJ = network::requestJson(network::METHOD_POST, url, reqJ);
json_decref(reqJ); json_decref(reqJ);


@@ -311,7 +311,7 @@ void queryUpdates() {
updateStatus = "Querying for updates..."; updateStatus = "Querying for updates...";


// Get user's plugins list // Get user's plugins list
std::string pluginsUrl = app::API_URL + "/plugins";
std::string pluginsUrl = API_URL + "/plugins";
json_t* pluginsReqJ = json_object(); json_t* pluginsReqJ = json_object();
json_object_set(pluginsReqJ, "token", json_string(settings::token.c_str())); json_object_set(pluginsReqJ, "token", json_string(settings::token.c_str()));
json_t* pluginsResJ = network::requestJson(network::METHOD_GET, pluginsUrl, pluginsReqJ); json_t* pluginsResJ = network::requestJson(network::METHOD_GET, pluginsUrl, pluginsReqJ);
@@ -333,9 +333,9 @@ void queryUpdates() {
} }


// Get library manifests // Get library manifests
std::string manifestsUrl = app::API_URL + "/library/manifests";
std::string manifestsUrl = API_URL + "/library/manifests";
json_t* manifestsReq = json_object(); json_t* manifestsReq = json_object();
json_object_set(manifestsReq, "version", json_string(app::API_VERSION.c_str()));
json_object_set(manifestsReq, "version", json_string(API_VERSION.c_str()));
json_t* manifestsResJ = network::requestJson(network::METHOD_GET, manifestsUrl, manifestsReq); json_t* manifestsResJ = network::requestJson(network::METHOD_GET, manifestsUrl, manifestsReq);
json_decref(manifestsReq); json_decref(manifestsReq);
if (!manifestsResJ) { if (!manifestsResJ) {
@@ -420,13 +420,13 @@ void syncUpdate(Update* update) {
isSyncingUpdate = false; isSyncingUpdate = false;
}); });


std::string downloadUrl = app::API_URL + "/download";
std::string downloadUrl = API_URL + "/download";
downloadUrl += "?token=" + network::encodeUrl(settings::token); downloadUrl += "?token=" + network::encodeUrl(settings::token);
downloadUrl += "&slug=" + network::encodeUrl(update->pluginSlug); downloadUrl += "&slug=" + network::encodeUrl(update->pluginSlug);
downloadUrl += "&version=" + network::encodeUrl(update->version); downloadUrl += "&version=" + network::encodeUrl(update->version);
downloadUrl += "&arch=" + network::encodeUrl(app::APP_ARCH);
downloadUrl += "&arch=" + network::encodeUrl(APP_ARCH);


INFO("Downloading plugin %s %s %s", update->pluginSlug.c_str(), update->version.c_str(), app::APP_ARCH.c_str());
INFO("Downloading plugin %s %s %s", update->pluginSlug.c_str(), update->version.c_str(), APP_ARCH.c_str());


// Download zip // Download zip
std::string pluginDest = asset::pluginsPath + "/" + update->pluginSlug + ".zip"; std::string pluginDest = asset::pluginsPath + "/" + update->pluginSlug + ".zip";


+ 2
- 2
src/plugin/Plugin.cpp View File

@@ -45,8 +45,8 @@ void Plugin::fromJson(json_t* rootJ) {
json_t* versionJ = json_object_get(rootJ, "version"); json_t* versionJ = json_object_get(rootJ, "version");
if (versionJ) if (versionJ)
version = json_string_value(versionJ); version = json_string_value(versionJ);
if (!string::startsWith(version, app::ABI_VERSION + "."))
throw Exception(string::f("Plugin version %s does not match Rack ABI version %s", version.c_str(), app::ABI_VERSION.c_str()));
if (!string::startsWith(version, ABI_VERSION + "."))
throw Exception(string::f("Plugin version %s does not match Rack ABI version %s", version.c_str(), ABI_VERSION.c_str()));
if (version == "") if (version == "")
throw Exception("No plugin version"); throw Exception("No plugin version");




+ 3
- 3
src/updater.cpp View File

@@ -20,7 +20,7 @@ static std::string downloadUrl;




static void checkVersion() { static void checkVersion() {
std::string versionUrl = app::API_URL + "/version";
std::string versionUrl = API_URL + "/version";
json_t* resJ = network::requestJson(network::METHOD_GET, versionUrl, NULL); json_t* resJ = network::requestJson(network::METHOD_GET, versionUrl, NULL);
if (!resJ) { if (!resJ) {
WARN("Request for version failed"); WARN("Request for version failed");
@@ -40,7 +40,7 @@ static void checkVersion() {


json_t* downloadUrlsJ = json_object_get(resJ, "downloadUrls"); json_t* downloadUrlsJ = json_object_get(resJ, "downloadUrls");
if (downloadUrlsJ) { if (downloadUrlsJ) {
json_t* downloadUrlJ = json_object_get(downloadUrlsJ, app::APP_ARCH.c_str());
json_t* downloadUrlJ = json_object_get(downloadUrlsJ, APP_ARCH.c_str());
if (downloadUrlJ) if (downloadUrlJ)
downloadUrl = json_string_value(downloadUrlJ); downloadUrl = json_string_value(downloadUrlJ);
} }
@@ -95,7 +95,7 @@ void update() {




bool isUpdateAvailable() { bool isUpdateAvailable() {
return (version != "") && (version != app::APP_VERSION);
return (version != "") && (version != APP_VERSION);
} }






+ 1
- 1
src/window.cpp View File

@@ -361,7 +361,7 @@ void Window::run() {
gamepad::step(); gamepad::step();


// Set window title // Set window title
std::string windowTitle = app::APP_NAME + " v" + app::APP_VERSION;
std::string windowTitle = APP_NAME + " v" + APP_VERSION;
if (!APP->patch->path.empty()) { if (!APP->patch->path.empty()) {
windowTitle += " - "; windowTitle += " - ";
if (!APP->history->isSaved()) if (!APP->history->isSaved())


Loading…
Cancel
Save