You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
881B

  1. #include <app/common.hpp>
  2. #include <settings.hpp>
  3. #include <network.hpp>
  4. #include <thread>
  5. namespace rack {
  6. namespace app {
  7. std::string APP_NAME = "VCV Rack";
  8. std::string APP_VERSION = TOSTRING(VERSION);
  9. std::string APP_VERSION_UPDATE;
  10. std::string API_URL = "https://api.vcvrack.com";
  11. std::string API_VERSION = "1";
  12. static void checkVersion() {
  13. std::string versionUrl = app::API_URL + "/version";
  14. json_t *versionResJ = network::requestJson(network::METHOD_GET, versionUrl, NULL);
  15. if (!versionResJ) {
  16. WARN("Request for version failed");
  17. return;
  18. }
  19. DEFER({
  20. json_decref(versionResJ);
  21. });
  22. json_t *versionJ = json_object_get(versionResJ, "version");
  23. if (versionJ)
  24. APP_VERSION_UPDATE = json_string_value(versionJ);
  25. }
  26. void init() {
  27. if (!settings::devMode) {
  28. std::thread t([] {
  29. checkVersion();
  30. });
  31. t.detach();
  32. }
  33. }
  34. } // namespace app
  35. } // namespace rack