| 483 | |
| 484 | #if DISTRHO_PLUGIN_WANT_STATE |
| 485 | void UI::stateChanged(const char* const key, const char* const value) |
| 486 | { |
| 487 | #if DISTRHO_UI_USE_WEB_VIEW |
| 488 | if (uiData->webview != nullptr) |
| 489 | { |
| 490 | const size_t keylen = std::strlen(key); |
| 491 | const size_t valuelen = std::strlen(value); |
| 492 | const size_t msglen = keylen + valuelen + 60; |
| 493 | if (char* const msg = static_cast<char*>(std::malloc(msglen))) |
| 494 | { |
| 495 | // TODO escape \\' |
| 496 | std::snprintf(msg, msglen - 1, |
| 497 | "typeof(stateChanged) === 'function' && stateChanged('%s','%s')", key, value); |
| 498 | msg[msglen - 1] = '\0'; |
| 499 | webViewEvaluateJS(uiData->webview, msg); |
| 500 | std::free(msg); |
| 501 | } |
| 502 | } |
| 503 | #else |
| 504 | // unused |
| 505 | (void)key; |
| 506 | (void)value; |
| 507 | #endif |
| 508 | } |
| 509 | #endif |
| 510 | |
| 511 | /* ------------------------------------------------------------------------------------------------------------ |
no test coverage detected