@@ -12,15 +12,6 @@ namespace rack { | |||
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 MM_PER_IN = 25.4f; | |||
@@ -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 | |||
@@ -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 |
@@ -126,10 +126,10 @@ void init() { | |||
} | |||
else { | |||
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"; | |||
} | |||
} | |||
@@ -1,6 +1,28 @@ | |||
#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 | |||
#include <windows.h> | |||
@@ -47,7 +47,7 @@ static void fatalSignalHandler(int sig) { | |||
// This might fail because we might not be in the main thread. | |||
// 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()); | |||
abort(); | |||
@@ -58,7 +58,7 @@ int main(int argc, char* argv[]) { | |||
#if defined ARCH_WIN | |||
// Windows global mutex to prevent multiple instances | |||
// 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) { | |||
osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, "Rack is already running. Multiple Rack instances are not supported."); | |||
exit(1); | |||
@@ -118,7 +118,7 @@ int main(int argc, char* argv[]) { | |||
} | |||
// 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()); | |||
std::string argsList; | |||
for (int i = 0; i < argc; i++) { | |||
@@ -270,7 +270,7 @@ json_t* PatchManager::toJson() { | |||
json_t* rootJ = json_object(); | |||
// 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_t* engineJ = APP->engine->toJson(); | |||
@@ -293,8 +293,8 @@ void PatchManager::fromJson(json_t* rootJ) { | |||
json_t* versionJ = json_object_get(rootJ, "version"); | |||
if (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. | |||
@@ -260,7 +260,7 @@ void logIn(const std::string& email, const std::string& password) { | |||
json_t* reqJ = json_object(); | |||
json_object_set(reqJ, "email", json_string(email.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_decref(reqJ); | |||
@@ -311,7 +311,7 @@ void queryUpdates() { | |||
updateStatus = "Querying for updates..."; | |||
// Get user's plugins list | |||
std::string pluginsUrl = app::API_URL + "/plugins"; | |||
std::string pluginsUrl = API_URL + "/plugins"; | |||
json_t* pluginsReqJ = json_object(); | |||
json_object_set(pluginsReqJ, "token", json_string(settings::token.c_str())); | |||
json_t* pluginsResJ = network::requestJson(network::METHOD_GET, pluginsUrl, pluginsReqJ); | |||
@@ -333,9 +333,9 @@ void queryUpdates() { | |||
} | |||
// Get library manifests | |||
std::string manifestsUrl = app::API_URL + "/library/manifests"; | |||
std::string manifestsUrl = API_URL + "/library/manifests"; | |||
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_decref(manifestsReq); | |||
if (!manifestsResJ) { | |||
@@ -420,13 +420,13 @@ void syncUpdate(Update* update) { | |||
isSyncingUpdate = false; | |||
}); | |||
std::string downloadUrl = app::API_URL + "/download"; | |||
std::string downloadUrl = API_URL + "/download"; | |||
downloadUrl += "?token=" + network::encodeUrl(settings::token); | |||
downloadUrl += "&slug=" + network::encodeUrl(update->pluginSlug); | |||
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 | |||
std::string pluginDest = asset::pluginsPath + "/" + update->pluginSlug + ".zip"; | |||
@@ -45,8 +45,8 @@ void Plugin::fromJson(json_t* rootJ) { | |||
json_t* versionJ = json_object_get(rootJ, "version"); | |||
if (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 == "") | |||
throw Exception("No plugin version"); | |||
@@ -20,7 +20,7 @@ static std::string downloadUrl; | |||
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); | |||
if (!resJ) { | |||
WARN("Request for version failed"); | |||
@@ -40,7 +40,7 @@ static void checkVersion() { | |||
json_t* downloadUrlsJ = json_object_get(resJ, "downloadUrls"); | |||
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) | |||
downloadUrl = json_string_value(downloadUrlJ); | |||
} | |||
@@ -95,7 +95,7 @@ void update() { | |||
bool isUpdateAvailable() { | |||
return (version != "") && (version != app::APP_VERSION); | |||
return (version != "") && (version != APP_VERSION); | |||
} | |||
@@ -361,7 +361,7 @@ void Window::run() { | |||
gamepad::step(); | |||
// 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()) { | |||
windowTitle += " - "; | |||
if (!APP->history->isSaved()) | |||