| 181 | } |
| 182 | |
| 183 | void sendFullPatchToRemote(RemoteDetails* const remote) |
| 184 | { |
| 185 | #ifdef CARDINAL_REMOTE_ENABLED |
| 186 | CardinalPluginContext* const context = static_cast<CardinalPluginContext*>(APP); |
| 187 | DISTRHO_SAFE_ASSERT_RETURN(context != nullptr,); |
| 188 | |
| 189 | context->engine->prepareSave(); |
| 190 | context->patch->saveAutosave(); |
| 191 | context->patch->cleanAutosave(); |
| 192 | |
| 193 | std::vector<uint8_t> data; |
| 194 | using namespace rack::system; |
| 195 | |
| 196 | #if ! DISTRHO_PLUGIN_WANT_DIRECT_ACCESS |
| 197 | FILE* const f = std::fopen(join(context->patch->autosavePath, "patch.json").c_str(), "r"); |
| 198 | DISTRHO_SAFE_ASSERT_RETURN(f != nullptr,); |
| 199 | |
| 200 | DEFER({ |
| 201 | std::fclose(f); |
| 202 | }); |
| 203 | |
| 204 | std::fseek(f, 0, SEEK_END); |
| 205 | const long fileSize = std::ftell(f); |
| 206 | DISTRHO_SAFE_ASSERT_RETURN(fileSize > 0,); |
| 207 | |
| 208 | std::fseek(f, 0, SEEK_SET); |
| 209 | char* const fileContent = new char[fileSize+1]; |
| 210 | |
| 211 | DISTRHO_SAFE_ASSERT_RETURN(std::fread(fileContent, fileSize, 1, f) == 1,); |
| 212 | fileContent[fileSize] = '\0'; |
| 213 | static_cast<CardinalBaseUI*>(remote->handle)->setState("patch", fileContent); |
| 214 | delete[] fileContent; |
| 215 | #elif defined(HAVE_LIBLO) |
| 216 | try { |
| 217 | data = archiveDirectory(context->patch->autosavePath, 1); |
| 218 | } DISTRHO_SAFE_EXCEPTION_RETURN("sendFullPatchToRemote",); |
| 219 | |
| 220 | DISTRHO_SAFE_ASSERT_RETURN(data.size() >= 4,); |
| 221 | |
| 222 | const lo_address addr = lo_address_new_from_url(remote->url); |
| 223 | DISTRHO_SAFE_ASSERT_RETURN(addr != nullptr,); |
| 224 | |
| 225 | if (const lo_blob blob = lo_blob_new(data.size(), data.data())) |
| 226 | { |
| 227 | lo_send(addr, "/load", "b", blob); |
| 228 | lo_blob_free(blob); |
| 229 | } |
| 230 | |
| 231 | lo_address_free(addr); |
| 232 | #endif |
| 233 | #endif |
| 234 | } |
| 235 | |
| 236 | void sendScreenshotToRemote(RemoteDetails* const remote, const char* const screenshot) |
| 237 | { |
no test coverage detected