This commit is contained in:
J. Nick Koston 2025-07-21 19:39:23 -10:00
parent 97525cfe87
commit 72fd984d4b
No known key found for this signature in database
3 changed files with 142 additions and 623 deletions

View File

@ -1377,7 +1377,6 @@ void APIConnection::complete_authentication_() {
} }
bool APIConnection::send_hello_response(const HelloRequest &msg) { bool APIConnection::send_hello_response(const HelloRequest &msg) {
// Process the request first
this->client_info_.name = msg.client_info; this->client_info_.name = msg.client_info;
this->client_info_.peername = this->helper_->getpeername(); this->client_info_.peername = this->helper_->getpeername();
this->client_api_version_major_ = msg.api_version_major; this->client_api_version_major_ = msg.api_version_major;

File diff suppressed because it is too large Load Diff

View File

@ -575,13 +575,7 @@ class StringType(TypeInfo):
# For SOURCE_SERVER, always use StringRef # For SOURCE_SERVER, always use StringRef
if not self._needs_decode: if not self._needs_decode:
return ( return f"append_quoted_string(out, this->{self.field_name}_ref_);"
f"if (!this->{self.field_name}_ref_.empty()) {{"
f' out.append("\'").append(this->{self.field_name}_ref_.c_str()).append("\'");'
f"}} else {{"
f' out.append("\'").append("").append("\'");'
f"}}"
)
# For SOURCE_BOTH, check if StringRef is set (sending) or use string (received) # For SOURCE_BOTH, check if StringRef is set (sending) or use string (received)
return ( return (
@ -1868,6 +1862,15 @@ namespace api {
namespace esphome { namespace esphome {
namespace api { namespace api {
// Helper function to append a quoted string, handling empty StringRef
static inline void append_quoted_string(std::string &out, const StringRef &ref) {
out.append("'");
if (!ref.empty()) {
out.append(ref.c_str());
}
out.append("'");
}
""" """
content += "namespace enums {\n\n" content += "namespace enums {\n\n"