From a0e5d59aac7a3a5bb774361947e6a02c4e46c467 Mon Sep 17 00:00:00 2001 From: graysky Date: Fri, 10 Jul 2020 19:50:58 -0400 Subject: [PATCH] alarm/kodi-rbp to 18.7.1-2 --- alarm/kodi-rbp/18131.patch | 1256 +++++++++++++++++++++++++++++++++++ alarm/kodi-rbp/PKGBUILD | 15 +- alarm/kodi-rbp/polkit.rules | 3 + 3 files changed, 1269 insertions(+), 5 deletions(-) create mode 100644 alarm/kodi-rbp/18131.patch diff --git a/alarm/kodi-rbp/18131.patch b/alarm/kodi-rbp/18131.patch new file mode 100644 index 000000000..abb2bc765 --- /dev/null +++ b/alarm/kodi-rbp/18131.patch @@ -0,0 +1,1256 @@ +diff --git a/xbmc/network/WebServer.cpp b/xbmc/network/WebServer.cpp +index 7834042..a1c6923 100644 +--- a/xbmc/network/WebServer.cpp ++++ b/xbmc/network/WebServer.cpp +@@ -36,14 +36,18 @@ + + #define MAX_POST_BUFFER_SIZE 2048 + +-#define PAGE_FILE_NOT_FOUND "File not foundFile not found" +-#define NOT_SUPPORTED "Not SupportedThe method you are trying to use is not supported by this server" ++#define PAGE_FILE_NOT_FOUND \ ++ "File not foundFile not found" ++#define NOT_SUPPORTED \ ++ "Not SupportedThe method you are trying to use is not " \ ++ "supported by this server" + + #define HEADER_VALUE_NO_CACHE "no-cache" + +-#define HEADER_NEWLINE "\r\n" ++#define HEADER_NEWLINE "\r\n" + +-typedef struct { ++typedef struct ++{ + std::shared_ptr file; + CHttpRanges ranges; + size_t rangeCountTotal; +@@ -62,7 +66,7 @@ CWebServer::CWebServer() + m_cert() + { + #if defined(TARGET_DARWIN) +- void *stack_addr; ++ void* stack_addr; + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_getstack(&attr, &stack_addr, &m_thread_stacksize); +@@ -86,16 +90,16 @@ static MHD_Response* create_response(size_t size, const void* data, int free, in + return MHD_create_response_from_buffer(size, const_cast(data), mode); + } + +-int CWebServer::AskForAuthentication(const HTTPRequest& request) const ++MHD_RESULT CWebServer::AskForAuthentication(const HTTPRequest& request) const + { +- struct MHD_Response *response = create_response(0, nullptr, MHD_NO, MHD_NO); ++ struct MHD_Response* response = create_response(0, nullptr, MHD_NO, MHD_NO); + if (!response) + { + CLog::Log(LOGERROR, "CWebServer[%hu]: unable to create HTTP Unauthorized response", m_port); + return MHD_NO; + } + +- int ret = AddHeader(response, MHD_HTTP_HEADER_CONNECTION, "close"); ++ MHD_RESULT ret = AddHeader(response, MHD_HTTP_HEADER_CONNECTION, "close"); + if (!ret) + { + CLog::Log(LOGERROR, "CWebServer[%hu]: unable to prepare HTTP Unauthorized response", m_port); +@@ -105,7 +109,10 @@ int CWebServer::AskForAuthentication(const HTTPRequest& request) const + + LogResponse(request, MHD_HTTP_UNAUTHORIZED); + +- ret = MHD_queue_basic_auth_fail_response(request.connection, "XBMC", response); ++ // This MHD_RESULT cast is only necessary for libmicrohttpd 0.9.71 ++ // The return type of MHD_queue_basic_auth_fail_response was fixed for future versions ++ // See https://git.gnunet.org/libmicrohttpd.git/commit/?id=860b42e9180da4dcd7e8690a3fcdb4e37e5772c5 ++ ret = (MHD_RESULT) MHD_queue_basic_auth_fail_response(request.connection, "XBMC", response); + MHD_destroy_response(response); + + return ret; +@@ -135,10 +142,14 @@ bool CWebServer::IsAuthenticated(const HTTPRequest& request) const + return authenticated; + } + +-int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection, +- const char *url, const char *method, +- const char *version, const char *upload_data, +- size_t *upload_data_size, void **con_cls) ++MHD_RESULT CWebServer::AnswerToConnection(void* cls, ++ struct MHD_Connection* connection, ++ const char* url, ++ const char* method, ++ const char* version, ++ const char* upload_data, ++ size_t* upload_data_size, ++ void** con_cls) + { + if (cls == nullptr || con_cls == nullptr || *con_cls == nullptr) + { +@@ -146,7 +157,7 @@ int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection, + return MHD_NO; + } + +- CWebServer *webServer = reinterpret_cast(cls); ++ CWebServer* webServer = reinterpret_cast(cls); + if (webServer == nullptr) + { + CLog::Log(LOGERROR, "CWebServer[unknown]: invalid request received"); +@@ -155,15 +166,22 @@ int CWebServer::AnswerToConnection(void *cls, struct MHD_Connection *connection, + + ConnectionHandler* connectionHandler = reinterpret_cast(*con_cls); + HTTPMethod methodType = GetHTTPMethod(method); +- HTTPRequest request = { webServer, connection, connectionHandler->fullUri, url, methodType, version }; ++ HTTPRequest request = {webServer, connection, connectionHandler->fullUri, ++ url, methodType, version}; + + if (connectionHandler->isNew) + webServer->LogRequest(request); + +- return webServer->HandlePartialRequest(connection, connectionHandler, request, upload_data, upload_data_size, con_cls); ++ return webServer->HandlePartialRequest(connection, connectionHandler, request, upload_data, ++ upload_data_size, con_cls); + } + +-int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, ConnectionHandler* connectionHandler, const HTTPRequest& request, const char *upload_data, size_t *upload_data_size, void **con_cls) ++MHD_RESULT CWebServer::HandlePartialRequest(struct MHD_Connection* connection, ++ ConnectionHandler* connectionHandler, ++ const HTTPRequest& request, ++ const char* upload_data, ++ size_t* upload_data_size, ++ void** con_cls) + { + std::unique_ptr conHandler(connectionHandler); + +@@ -196,17 +214,18 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti + if (handler->GetLastModifiedDate(lastModified) && lastModified.IsValid()) + { + // handle If-Modified-Since or If-Unmodified-Since +- std::string ifModifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_MODIFIED_SINCE); +- std::string ifUnmodifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE); ++ std::string ifModifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue( ++ connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_MODIFIED_SINCE); ++ std::string ifUnmodifiedSince = HTTPRequestHandlerUtils::GetRequestHeaderValue( ++ connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_UNMODIFIED_SINCE); + + CDateTime ifModifiedSinceDate; + CDateTime ifUnmodifiedSinceDate; + // handle If-Modified-Since (but only if the response is cacheable) +- if (cacheable && +- ifModifiedSinceDate.SetFromRFC1123DateTime(ifModifiedSince) && +- lastModified.GetAsUTCDateTime() <= ifModifiedSinceDate) ++ if (cacheable && ifModifiedSinceDate.SetFromRFC1123DateTime(ifModifiedSince) && ++ lastModified.GetAsUTCDateTime() <= ifModifiedSinceDate) + { +- struct MHD_Response *response = create_response(0, nullptr, MHD_NO, MHD_NO); ++ struct MHD_Response* response = create_response(0, nullptr, MHD_NO, MHD_NO); + if (response == nullptr) + { + CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP 304 response", m_port); +@@ -217,7 +236,7 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti + } + // handle If-Unmodified-Since + else if (ifUnmodifiedSinceDate.SetFromRFC1123DateTime(ifUnmodifiedSince) && +- lastModified.GetAsUTCDateTime() > ifUnmodifiedSinceDate) ++ lastModified.GetAsUTCDateTime() > ifUnmodifiedSinceDate) + return SendErrorResponse(request, MHD_HTTP_PRECONDITION_FAILED, request.method); + } + +@@ -231,7 +250,8 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti + // as ownership of the connection handler is passed to libmicrohttpd we must not destroy it + SetupPostDataProcessing(request, conHandler.get(), handler, con_cls); + +- // as ownership of the connection handler has been passed to libmicrohttpd we must not destroy it ++ // as ownership of the connection handler has been passed to libmicrohttpd we must not ++ // destroy it + conHandler.release(); + + return MHD_YES; +@@ -249,7 +269,8 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti + // process additional / remaining POST data + if (ProcessPostData(request, conHandler.get(), upload_data, upload_data_size, con_cls)) + { +- // as ownership of the connection handler has been passed to libmicrohttpd we must not destroy it ++ // as ownership of the connection handler has been passed to libmicrohttpd we must not ++ // destroy it + conHandler.release(); + + return MHD_YES; +@@ -266,7 +287,8 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti + return HandleRequest(conHandler->requestHandler); + } + +- // it's unusual to get more than one call to AnswerToConnection for none-POST requests, but let's handle it anyway ++ // it's unusual to get more than one call to AnswerToConnection for none-POST requests, but ++ // let's handle it anyway + auto requestHandler = FindRequestHandler(request); + if (requestHandler != nullptr) + return HandleRequest(requestHandler); +@@ -276,15 +298,20 @@ int CWebServer::HandlePartialRequest(struct MHD_Connection *connection, Connecti + return SendErrorResponse(request, MHD_HTTP_NOT_FOUND, request.method); + } + +-int CWebServer::HandlePostField(void *cls, enum MHD_ValueKind kind, const char *key, +- const char *filename, const char *content_type, +- const char *transfer_encoding, const char *data, uint64_t off, +- size_t size) ++MHD_RESULT CWebServer::HandlePostField(void* cls, ++ enum MHD_ValueKind kind, ++ const char* key, ++ const char* filename, ++ const char* content_type, ++ const char* transfer_encoding, ++ const char* data, ++ uint64_t off, ++ size_t size) + { +- ConnectionHandler *conHandler = (ConnectionHandler *)cls; ++ ConnectionHandler* conHandler = (ConnectionHandler*)cls; + +- if (conHandler == nullptr || conHandler->requestHandler == nullptr || +- key == nullptr || data == nullptr || size == 0) ++ if (conHandler == nullptr || conHandler->requestHandler == nullptr || key == nullptr || ++ data == nullptr || size == 0) + { + CLog::Log(LOGERROR, "CWebServer: unable to handle HTTP POST field"); + return MHD_NO; +@@ -294,21 +321,21 @@ int CWebServer::HandlePostField(void *cls, enum MHD_ValueKind kind, const char * + return MHD_YES; + } + +-int CWebServer::HandleRequest(const std::shared_ptr& handler) ++MHD_RESULT CWebServer::HandleRequest(const std::shared_ptr& handler) + { + if (handler == nullptr) + return MHD_NO; + + HTTPRequest request = handler->GetRequest(); +- int ret = handler->HandleRequest(); ++ MHD_RESULT ret = handler->HandleRequest(); + if (ret == MHD_NO) + { + CLog::Log(LOGERROR, "CWebServer[%hu]: failed to handle HTTP request for %s", m_port, request.pathUrl.c_str()); + return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method); + } + +- const HTTPResponseDetails &responseDetails = handler->GetResponseDetails(); +- struct MHD_Response *response = nullptr; ++ const HTTPResponseDetails& responseDetails = handler->GetResponseDetails(); ++ struct MHD_Response* response = nullptr; + switch (responseDetails.type) + { + case HTTPNone: +@@ -331,7 +358,8 @@ int CWebServer::HandleRequest(const std::shared_ptr& handle + break; + + case HTTPError: +- ret = CreateErrorResponse(request.connection, responseDetails.status, request.method, response); ++ ret = ++ CreateErrorResponse(request.connection, responseDetails.status, request.method, response); + break; + + default: +@@ -348,13 +376,15 @@ int CWebServer::HandleRequest(const std::shared_ptr& handle + return FinalizeRequest(handler, responseDetails.status, response); + } + +-int CWebServer::FinalizeRequest(const std::shared_ptr& handler, int responseStatus, struct MHD_Response *response) ++MHD_RESULT CWebServer::FinalizeRequest(const std::shared_ptr& handler, ++ int responseStatus, ++ struct MHD_Response* response) + { + if (handler == nullptr || response == nullptr) + return MHD_NO; + +- const HTTPRequest &request = handler->GetRequest(); +- const HTTPResponseDetails &responseDetails = handler->GetResponseDetails(); ++ const HTTPRequest& request = handler->GetRequest(); ++ const HTTPResponseDetails& responseDetails = handler->GetResponseDetails(); + + // if the request handler has set a content type and it hasn't been set as a header, add it + if (!responseDetails.contentType.empty()) +@@ -380,7 +410,8 @@ int CWebServer::FinalizeRequest(const std::shared_ptr& hand + + // if the response can't be cached or the maximum age is 0 force the client not to cache + if (!handler->CanBeCached() || maxAge == 0) +- handler->AddResponseHeader(MHD_HTTP_HEADER_CACHE_CONTROL, "private, max-age=0, " HEADER_VALUE_NO_CACHE); ++ handler->AddResponseHeader(MHD_HTTP_HEADER_CACHE_CONTROL, ++ "private, max-age=0, " HEADER_VALUE_NO_CACHE); + else + { + // create the value of the Cache-Control header +@@ -416,14 +447,14 @@ int CWebServer::FinalizeRequest(const std::shared_ptr& hand + return SendResponse(request, responseStatus, response); + } + +-std::shared_ptr CWebServer::FindRequestHandler(const HTTPRequest& request) const ++std::shared_ptr CWebServer::FindRequestHandler( ++ const HTTPRequest& request) const + { + // look for a IHTTPRequestHandler which can take care of the current request + auto requestHandlerIt = std::find_if(m_requestHandlers.cbegin(), m_requestHandlers.cend(), +- [&request](const IHTTPRequestHandler* requestHandler) +- { +- return requestHandler->CanHandleRequest(request); +- }); ++ [&request](const IHTTPRequestHandler* requestHandler) { ++ return requestHandler->CanHandleRequest(request); ++ }); + + // we found a matching IHTTPRequestHandler so let's get a new instance for this request + if (requestHandlerIt != m_requestHandlers.cend()) +@@ -435,7 +466,8 @@ std::shared_ptr CWebServer::FindRequestHandler(const HTTPRe + bool CWebServer::IsRequestCacheable(const HTTPRequest& request) const + { + // handle Cache-Control +- std::string cacheControl = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CACHE_CONTROL); ++ std::string cacheControl = HTTPRequestHandlerUtils::GetRequestHeaderValue( ++ request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CACHE_CONTROL); + if (!cacheControl.empty()) + { + std::vector cacheControls = StringUtils::Split(cacheControl, ","); +@@ -450,23 +482,26 @@ bool CWebServer::IsRequestCacheable(const HTTPRequest& request) const + } + + // handle Pragma +- std::string pragma = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_PRAGMA); ++ std::string pragma = HTTPRequestHandlerUtils::GetRequestHeaderValue( ++ request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_PRAGMA); + if (pragma.compare(HEADER_VALUE_NO_CACHE) == 0) + return false; + + return true; + } + +-bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime &lastModified) const ++bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime& lastModified) const + { + // parse the Range header and store it in the request object + CHttpRanges ranges; +- bool ranged = ranges.Parse(HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE)); ++ bool ranged = ranges.Parse(HTTPRequestHandlerUtils::GetRequestHeaderValue( ++ request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE)); + + // handle If-Range header but only if the Range header is present + if (ranged && lastModified.IsValid()) + { +- std::string ifRange = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_RANGE); ++ std::string ifRange = HTTPRequestHandlerUtils::GetRequestHeaderValue( ++ request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_IF_RANGE); + if (!ifRange.empty() && lastModified.IsValid()) + { + CDateTime ifRangeDate; +@@ -482,25 +517,33 @@ bool CWebServer::IsRequestRanged(const HTTPRequest& request, const CDateTime &la + return !ranges.IsEmpty(); + } + +-void CWebServer::SetupPostDataProcessing(const HTTPRequest& request, ConnectionHandler *connectionHandler, std::shared_ptr handler, void **con_cls) const ++void CWebServer::SetupPostDataProcessing(const HTTPRequest& request, ++ ConnectionHandler* connectionHandler, ++ std::shared_ptr handler, ++ void** con_cls) const + { + connectionHandler->requestHandler = handler; + +- // we might need to handle the POST data ourselves which is done in the next call to AnswerToConnection ++ // we might need to handle the POST data ourselves which is done in the next call to ++ // AnswerToConnection + *con_cls = connectionHandler; + + // get the content-type of the POST data +- const auto contentType = HTTPRequestHandlerUtils::GetRequestHeaderValue(request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE); ++ const auto contentType = HTTPRequestHandlerUtils::GetRequestHeaderValue( ++ request.connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_CONTENT_TYPE); + if (contentType.empty()) + return; + +- // if the content-type is neither application/x-ww-form-urlencoded nor multipart/form-data we need to handle it ourselves ++ // if the content-type is neither application/x-ww-form-urlencoded nor multipart/form-data we need ++ // to handle it ourselves + if (!StringUtils::EqualsNoCase(contentType, MHD_HTTP_POST_ENCODING_FORM_URLENCODED) && + !StringUtils::EqualsNoCase(contentType, MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA)) + return; + + // otherwise we can use MHD's POST processor +- connectionHandler->postprocessor = MHD_create_post_processor(request.connection, MAX_POST_BUFFER_SIZE, &CWebServer::HandlePostField, static_cast(connectionHandler)); ++ connectionHandler->postprocessor = MHD_create_post_processor( ++ request.connection, MAX_POST_BUFFER_SIZE, &CWebServer::HandlePostField, ++ static_cast(connectionHandler)); + + // MHD doesn't seem to be able to handle this post request + if (connectionHandler->postprocessor == nullptr) +@@ -510,7 +553,11 @@ void CWebServer::SetupPostDataProcessing(const HTTPRequest& request, ConnectionH + } + } + +-bool CWebServer::ProcessPostData(const HTTPRequest& request, ConnectionHandler *connectionHandler, const char *upload_data, size_t *upload_data_size, void **con_cls) const ++bool CWebServer::ProcessPostData(const HTTPRequest& request, ++ ConnectionHandler* connectionHandler, ++ const char* upload_data, ++ size_t* upload_data_size, ++ void** con_cls) const + { + if (connectionHandler->requestHandler == nullptr) + { +@@ -531,10 +578,12 @@ bool CWebServer::ProcessPostData(const HTTPRequest& request, ConnectionHandler * + bool postDataHandled = false; + // either use MHD's POST processor + if (connectionHandler->postprocessor != nullptr) +- postDataHandled = MHD_post_process(connectionHandler->postprocessor, upload_data, *upload_data_size) == MHD_YES; ++ postDataHandled = MHD_post_process(connectionHandler->postprocessor, upload_data, ++ *upload_data_size) == MHD_YES; + // or simply copy the data to the handler + else if (connectionHandler->requestHandler != nullptr) +- postDataHandled = connectionHandler->requestHandler->AddPostData(upload_data, *upload_data_size); ++ postDataHandled = ++ connectionHandler->requestHandler->AddPostData(upload_data, *upload_data_size); + + // abort if the received POST data couldn't be handled + if (!postDataHandled) +@@ -554,7 +603,7 @@ bool CWebServer::ProcessPostData(const HTTPRequest& request, ConnectionHandler * + return true; + } + +-void CWebServer::FinalizePostDataProcessing(ConnectionHandler *connectionHandler) const ++void CWebServer::FinalizePostDataProcessing(ConnectionHandler* connectionHandler) const + { + if (connectionHandler->postprocessor == nullptr) + return; +@@ -562,13 +611,14 @@ void CWebServer::FinalizePostDataProcessing(ConnectionHandler *connectionHandler + MHD_destroy_post_processor(connectionHandler->postprocessor); + } + +-int CWebServer::CreateMemoryDownloadResponse(const std::shared_ptr& handler, struct MHD_Response *&response) const ++MHD_RESULT CWebServer::CreateMemoryDownloadResponse( ++ const std::shared_ptr& handler, struct MHD_Response*& response) const + { + if (handler == nullptr) + return MHD_NO; + +- const HTTPRequest &request = handler->GetRequest(); +- const HTTPResponseDetails &responseDetails = handler->GetResponseDetails(); ++ const HTTPRequest& request = handler->GetRequest(); ++ const HTTPResponseDetails& responseDetails = handler->GetResponseDetails(); + HttpResponseRanges responseRanges = handler->GetResponseData(); + + // check if the response is completely empty +@@ -577,7 +627,7 @@ int CWebServer::CreateMemoryDownloadResponse(const std::shared_ptr 1) || +- (!request.ranges.IsEmpty() && responseRanges.size() > request.ranges.Size())) ++ (!request.ranges.IsEmpty() && responseRanges.size() > request.ranges.Size())) + { + CLog::Log(LOGWARNING, "CWebServer[%hu]: response contains more ranges (%d) than the request asked for (%d)", m_port, (int)responseRanges.size(), (int)request.ranges.Size()); + return SendErrorResponse(request, MHD_HTTP_INTERNAL_SERVER_ERROR, request.method); +@@ -600,33 +650,38 @@ int CWebServer::CreateMemoryDownloadResponse(const std::shared_ptr& handler, struct MHD_Response *&response) const ++MHD_RESULT CWebServer::CreateRangedMemoryDownloadResponse( ++ const std::shared_ptr& handler, struct MHD_Response*& response) const + { + if (handler == nullptr) + return MHD_NO; + +- const HTTPRequest &request = handler->GetRequest(); +- const HTTPResponseDetails &responseDetails = handler->GetResponseDetails(); ++ const HTTPRequest& request = handler->GetRequest(); ++ const HTTPResponseDetails& responseDetails = handler->GetResponseDetails(); + HttpResponseRanges responseRanges = handler->GetResponseData(); + + // if there's no or only one range this is not the right place +@@ -658,8 +713,10 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptrSetResponseStatus(MHD_HTTP_PARTIAL_CONTENT); + // add Content-Range header +- handler->AddResponseHeader(MHD_HTTP_HEADER_CONTENT_RANGE, +- HttpRangeUtils::GenerateContentRangeHeaderValue(firstRangePosition, lastRangePosition, responseDetails.totalLength)); ++ handler->AddResponseHeader( ++ MHD_HTTP_HEADER_CONTENT_RANGE, ++ HttpRangeUtils::GenerateContentRangeHeaderValue(firstRangePosition, lastRangePosition, ++ responseDetails.totalLength)); + + // generate a multipart boundary + std::string multipartBoundary = HttpRangeUtils::GenerateMultipartBoundary(); +@@ -670,7 +727,8 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptrAddResponseHeader(MHD_HTTP_HEADER_CONTENT_TYPE, contentType); + + // generate the multipart boundary with the Content-Type header field +- std::string multipartBoundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundary, contentType); ++ std::string multipartBoundaryWithHeader = ++ HttpRangeUtils::GenerateMultipartBoundaryWithHeader(multipartBoundary, contentType); + + std::string result; + // add all the ranges to the result +@@ -680,14 +738,18 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptr(range->GetData()), static_cast(range->GetLength())); ++ result.append(static_cast(range->GetData()), ++ static_cast(range->GetLength())); + + // check if we need to free the range data +- if (responseDetails.type == HTTPMemoryDownloadFreeNoCopy || responseDetails.type == HTTPMemoryDownloadFreeCopy) ++ if (responseDetails.type == HTTPMemoryDownloadFreeNoCopy || ++ responseDetails.type == HTTPMemoryDownloadFreeCopy) + free(const_cast(range->GetData())); + } + +@@ -697,10 +759,13 @@ int CWebServer::CreateRangedMemoryDownloadResponse(const std::shared_ptrAddResponseHeader(MHD_HTTP_HEADER_CONTENT_LENGTH, StringUtils::Format("%" PRIu64, static_cast(result.size()))); + + // finally create the response +- return CreateMemoryDownloadResponse(request.connection, result.c_str(), result.size(), false, true, response); ++ return CreateMemoryDownloadResponse(request.connection, result.c_str(), result.size(), false, ++ true, response); + } + +-int CWebServer::CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const ++MHD_RESULT CWebServer::CreateRedirect(struct MHD_Connection* connection, ++ const std::string& strURL, ++ struct MHD_Response*& response) const + { + response = create_response(0, nullptr, MHD_NO, MHD_NO); + if (response == nullptr) +@@ -713,13 +778,14 @@ int CWebServer::CreateRedirect(struct MHD_Connection *connection, const std::str + return MHD_YES; + } + +-int CWebServer::CreateFileDownloadResponse(const std::shared_ptr& handler, struct MHD_Response *&response) const ++MHD_RESULT CWebServer::CreateFileDownloadResponse( ++ const std::shared_ptr& handler, struct MHD_Response*& response) const + { + if (handler == nullptr) + return MHD_NO; + +- const HTTPRequest &request = handler->GetRequest(); +- const HTTPResponseDetails &responseDetails = handler->GetResponseDetails(); ++ const HTTPRequest& request = handler->GetRequest(); ++ const HTTPResponseDetails& responseDetails = handler->GetResponseDetails(); + HttpResponseRanges responseRanges = handler->GetResponseData(); + + std::shared_ptr file = std::make_shared(); +@@ -761,7 +827,8 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptrranges = request.ranges; + else +- HTTPRequestHandlerUtils::GetRequestedRanges(request.connection, fileLength, context->ranges); ++ HTTPRequestHandlerUtils::GetRequestedRanges(request.connection, fileLength, ++ context->ranges); + } + + uint64_t firstPosition = 0; +@@ -773,7 +840,8 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptrSetResponseStatus(MHD_HTTP_PARTIAL_CONTENT); + +- // we need to remember that we are ranged because the range length might change and won't be reliable anymore for length comparisons ++ // we need to remember that we are ranged because the range length might change and won't be ++ // reliable anymore for length comparisons + ranged = true; + + context->ranges.GetFirstPosition(firstPosition); +@@ -785,7 +853,8 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptrranges.GetLength(); + +- // adjust the MIME type and range length in case of multiple ranges which requires multipart boundaries ++ // adjust the MIME type and range length in case of multiple ranges which requires multipart ++ // boundaries + if (context->rangeCountTotal > 1) + { + context->boundary = HttpRangeUtils::GenerateMultipartBoundary(); +@@ -793,14 +862,19 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr\r\nContent-Type: \r\n +- context->boundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundary, context->contentType); ++ context->boundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader( ++ context->boundary, context->contentType); + context->boundaryEnd = HttpRangeUtils::GenerateMultipartBoundaryEnd(context->boundary); + + // for every range, we need to add a boundary with header +- for (HttpRanges::const_iterator range = context->ranges.Begin(); range != context->ranges.End(); ++range) ++ for (HttpRanges::const_iterator range = context->ranges.Begin(); ++ range != context->ranges.End(); ++range) + { +- // we need to temporarily add the Content-Range header to the boundary to be able to determine the length +- std::string completeBoundaryWithHeader = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, &*range); ++ // we need to temporarily add the Content-Range header to the boundary to be able to ++ // determine the length ++ std::string completeBoundaryWithHeader = ++ HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, ++ &*range); + totalLength += completeBoundaryWithHeader.size(); + + // add a newline before any new multipart boundary +@@ -815,10 +889,9 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptrranges.GetFirstPosition(context->writePosition); + + // create the response object +- response = MHD_create_response_from_callback(totalLength, 2048, +- &CWebServer::ContentReaderCallback, +- context.get(), +- &CWebServer::ContentReaderFreeCallback); ++ response = ++ MHD_create_response_from_callback(totalLength, 2048, &CWebServer::ContentReaderCallback, ++ context.get(), &CWebServer::ContentReaderFreeCallback); + if (response == nullptr) + { + CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP response for %s to be filled from %s", m_port, request.pathUrl.c_str(), filePath.c_str()); +@@ -829,7 +902,9 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptrAddResponseHeader(MHD_HTTP_HEADER_CONTENT_RANGE, HttpRangeUtils::GenerateContentRangeHeaderValue(firstPosition, lastPosition, fileLength)); ++ handler->AddResponseHeader( ++ MHD_HTTP_HEADER_CONTENT_RANGE, ++ HttpRangeUtils::GenerateContentRangeHeaderValue(firstPosition, lastPosition, fileLength)); + } + else + { +@@ -850,10 +925,13 @@ int CWebServer::CreateFileDownloadResponse(const std::shared_ptr(data), free ? MHD_YES : MHD_NO, copy ? MHD_YES : MHD_NO); ++ response = create_response(size, const_cast(data), free ? MHD_YES : MHD_NO, ++ copy ? MHD_YES : MHD_NO); + if (response == nullptr) + { + CLog::Log(LOGERROR, "CWebServer[%hu]: failed to create a HTTP download response", m_port); +@@ -893,29 +977,33 @@ int CWebServer::CreateMemoryDownloadResponse(struct MHD_Connection *connection, + return MHD_YES; + } + +-int CWebServer::SendResponse(const HTTPRequest& request, int responseStatus, MHD_Response *response) const ++MHD_RESULT CWebServer::SendResponse(const HTTPRequest& request, ++ int responseStatus, ++ MHD_Response* response) const + { + LogResponse(request, responseStatus); + +- int ret = MHD_queue_response(request.connection, responseStatus, response); ++ MHD_RESULT ret = MHD_queue_response(request.connection, responseStatus, response); + MHD_destroy_response(response); + + return ret; + } + +-int CWebServer::SendErrorResponse(const HTTPRequest& request, int errorType, HTTPMethod method) const ++MHD_RESULT CWebServer::SendErrorResponse(const HTTPRequest& request, ++ int errorType, ++ HTTPMethod method) const + { +- struct MHD_Response *response = nullptr; +- int ret = CreateErrorResponse(request.connection, errorType, method, response); ++ struct MHD_Response* response = nullptr; ++ MHD_RESULT ret = CreateErrorResponse(request.connection, errorType, method, response); + if (ret == MHD_NO) + return MHD_NO; + + return SendResponse(request, errorType, response); + } + +-void* CWebServer::UriRequestLogger(void *cls, const char *uri) ++void* CWebServer::UriRequestLogger(void* cls, const char* uri) + { +- CWebServer *webServer = reinterpret_cast(cls); ++ CWebServer* webServer = reinterpret_cast(cls); + + // log the full URI + if (webServer == nullptr) +@@ -935,9 +1023,9 @@ void CWebServer::LogRequest(const char* uri) const + CLog::Log(LOGDEBUG, "CWebServer[%hu]: request received for %s", m_port, uri); + } + +-ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, size_t max) ++ssize_t CWebServer::ContentReaderCallback(void* cls, uint64_t pos, char* buf, size_t max) + { +- HttpFileDownloadContext *context = (HttpFileDownloadContext *)cls; ++ HttpFileDownloadContext* context = (HttpFileDownloadContext*)cls; + if (context == nullptr || context->file == nullptr) + return -1; + +@@ -978,7 +1066,8 @@ ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, si + } + + // put together the boundary for the current range +- std::string boundary = HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, &range); ++ std::string boundary = ++ HttpRangeUtils::GenerateMultipartBoundaryWithHeader(context->boundaryWithHeader, &range); + + // copy the boundary into the buffer + memcpy(buf, boundary.c_str(), boundary.size()); +@@ -999,7 +1088,8 @@ ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, si + maximum = std::min(maximum, end - context->writePosition + 1); + + // seek to the position if necessary +- if (context->file->GetPosition() < 0 || context->writePosition != static_cast(context->file->GetPosition())) ++ if (context->file->GetPosition() < 0 || ++ context->writePosition != static_cast(context->file->GetPosition())) + context->file->Seek(context->writePosition); + + // read data from the file +@@ -1026,16 +1116,19 @@ ssize_t CWebServer::ContentReaderCallback(void *cls, uint64_t pos, char *buf, si + return written; + } + +-void CWebServer::ContentReaderFreeCallback(void *cls) ++void CWebServer::ContentReaderFreeCallback(void* cls) + { +- HttpFileDownloadContext *context = (HttpFileDownloadContext *)cls; ++ HttpFileDownloadContext* context = (HttpFileDownloadContext*)cls; + delete context; + + CLog::Log(LOGDEBUG, LOGWEBSERVER, "CWebServer [OUT] done"); + } + + // local helper +-static void panicHandlerForMHD(void* unused, const char* file, unsigned int line, const char *reason) ++static void panicHandlerForMHD(void* unused, ++ const char* file, ++ unsigned int line, ++ const char* reason) + { + CLog::Log(LOGSEVERE, "CWebServer: MHD serious error: reason \"%s\" in file \"%s\" at line %ui", reason ? reason : "", + file ? file : "", line); +@@ -1063,7 +1156,7 @@ static void logFromMHD(void* unused, const char* fmt, va_list ap) + } + } + +-bool CWebServer::LoadCert(std::string &skey, std::string &scert) ++bool CWebServer::LoadCert(std::string& skey, std::string& scert) + { + XFILE::CFile file; + XFILE::auto_buffer buf; +@@ -1106,63 +1199,52 @@ struct MHD_Daemon* CWebServer::StartMHD(unsigned int flags, int port) + + MHD_set_panic_func(&panicHandlerForMHD, nullptr); + +- if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_SERVICES_WEBSERVERSSL) && +- MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_YES && +- LoadCert(m_key, m_cert)) ++ if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool( ++ CSettings::SETTING_SERVICES_WEBSERVERSSL) && ++ MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_YES && LoadCert(m_key, m_cert)) + // SSL enabled +- return MHD_start_daemon(flags | +- // one thread per connection +- // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1 +- // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop +- MHD_USE_THREAD_PER_CONNECTION ++ return MHD_start_daemon( ++ flags | ++ // one thread per connection ++ // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1 ++ // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop ++ MHD_USE_THREAD_PER_CONNECTION + #if (MHD_VERSION >= 0x00095207) +- | MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */ ++ | ++ MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with ++ MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */ + #endif +- | MHD_USE_DEBUG /* Print MHD error messages to log */ +- | MHD_USE_SSL +- , +- port, +- 0, +- 0, +- &CWebServer::AnswerToConnection, +- this, +- +- MHD_OPTION_CONNECTION_LIMIT, 512, +- MHD_OPTION_CONNECTION_TIMEOUT, timeout, +- MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this, +- MHD_OPTION_EXTERNAL_LOGGER, &logFromMHD, 0, +- MHD_OPTION_THREAD_STACK_SIZE, m_thread_stacksize, +- MHD_OPTION_HTTPS_MEM_KEY, m_key.c_str(), +- MHD_OPTION_HTTPS_MEM_CERT, m_cert.c_str(), +- MHD_OPTION_HTTPS_PRIORITIES, ciphers, +- MHD_OPTION_END); ++ | MHD_USE_DEBUG /* Print MHD error messages to log */ ++ | MHD_USE_SSL, ++ port, 0, 0, &CWebServer::AnswerToConnection, this, ++ ++ MHD_OPTION_CONNECTION_LIMIT, 512, MHD_OPTION_CONNECTION_TIMEOUT, timeout, ++ MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this, ++ MHD_OPTION_EXTERNAL_LOGGER, &logFromMHD, 0, MHD_OPTION_THREAD_STACK_SIZE, ++ m_thread_stacksize, MHD_OPTION_HTTPS_MEM_KEY, m_key.c_str(), MHD_OPTION_HTTPS_MEM_CERT, ++ m_cert.c_str(), MHD_OPTION_HTTPS_PRIORITIES, ciphers, MHD_OPTION_END); + + // No SSL +- return MHD_start_daemon(flags | +- // one thread per connection +- // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1 +- // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop +- MHD_USE_THREAD_PER_CONNECTION ++ return MHD_start_daemon( ++ flags | ++ // one thread per connection ++ // WARNING: set MHD_OPTION_CONNECTION_TIMEOUT to something higher than 1 ++ // otherwise on libmicrohttpd 0.4.4-1 it spins a busy loop ++ MHD_USE_THREAD_PER_CONNECTION + #if (MHD_VERSION >= 0x00095207) +- | MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */ ++ | MHD_USE_INTERNAL_POLLING_THREAD /* MHD_USE_THREAD_PER_CONNECTION must be used only with ++ MHD_USE_INTERNAL_POLLING_THREAD since 0.9.54 */ + #endif +- | MHD_USE_DEBUG /* Print MHD error messages to log */ +- , +- port, +- 0, +- 0, +- &CWebServer::AnswerToConnection, +- this, +- +- MHD_OPTION_CONNECTION_LIMIT, 512, +- MHD_OPTION_CONNECTION_TIMEOUT, timeout, +- MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this, +- MHD_OPTION_EXTERNAL_LOGGER, &logFromMHD, 0, +- MHD_OPTION_THREAD_STACK_SIZE, m_thread_stacksize, +- MHD_OPTION_END); ++ | MHD_USE_DEBUG /* Print MHD error messages to log */ ++ , ++ port, 0, 0, &CWebServer::AnswerToConnection, this, ++ ++ MHD_OPTION_CONNECTION_LIMIT, 512, MHD_OPTION_CONNECTION_TIMEOUT, timeout, ++ MHD_OPTION_URI_LOG_CALLBACK, &CWebServer::UriRequestLogger, this, MHD_OPTION_EXTERNAL_LOGGER, ++ &logFromMHD, 0, MHD_OPTION_THREAD_STACK_SIZE, m_thread_stacksize, MHD_OPTION_END); + } + +-bool CWebServer::Start(uint16_t port, const std::string &username, const std::string &password) ++bool CWebServer::Start(uint16_t port, const std::string& username, const std::string& password) + { + SetCredentials(username, password); + if (!m_running) +@@ -1216,7 +1298,7 @@ bool CWebServer::WebServerSupportsSSL() + return MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_YES; + } + +-void CWebServer::SetCredentials(const std::string &username, const std::string &password) ++void CWebServer::SetCredentials(const std::string& username, const std::string& password) + { + CSingleLock lock(m_critSection); + +@@ -1225,7 +1307,7 @@ void CWebServer::SetCredentials(const std::string &username, const std::string & + m_authenticationRequired = !m_authenticationPassword.empty(); + } + +-void CWebServer::RegisterRequestHandler(IHTTPRequestHandler *handler) ++void CWebServer::RegisterRequestHandler(IHTTPRequestHandler* handler) + { + if (handler == nullptr) + return; +@@ -1236,15 +1318,18 @@ void CWebServer::RegisterRequestHandler(IHTTPRequestHandler *handler) + + m_requestHandlers.push_back(handler); + std::sort(m_requestHandlers.begin(), m_requestHandlers.end(), +- [](IHTTPRequestHandler* lhs, IHTTPRequestHandler* rhs) { return rhs->GetPriority() < lhs->GetPriority(); }); ++ [](IHTTPRequestHandler* lhs, IHTTPRequestHandler* rhs) { ++ return rhs->GetPriority() < lhs->GetPriority(); ++ }); + } + +-void CWebServer::UnregisterRequestHandler(IHTTPRequestHandler *handler) ++void CWebServer::UnregisterRequestHandler(IHTTPRequestHandler* handler) + { + if (handler == nullptr) + return; + +- m_requestHandlers.erase(std::remove(m_requestHandlers.begin(), m_requestHandlers.end(), handler), m_requestHandlers.end()); ++ m_requestHandlers.erase(std::remove(m_requestHandlers.begin(), m_requestHandlers.end(), handler), ++ m_requestHandlers.end()); + } + + void CWebServer::LogRequest(const HTTPRequest& request) const +@@ -1253,9 +1338,11 @@ void CWebServer::LogRequest(const HTTPRequest& request) const + return; + + std::multimap headerValues; +- HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND, headerValues); ++ HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND, ++ headerValues); + std::multimap getValues; +- HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_GET_ARGUMENT_KIND, getValues); ++ HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_GET_ARGUMENT_KIND, ++ getValues); + + CLog::Log(LOGDEBUG, "CWebServer[%hu] [IN] %s %s %s", m_port, request.version.c_str(), GetHTTPMethod(request.method).c_str(), request.pathUrlFull.c_str()); + +@@ -1278,7 +1365,8 @@ void CWebServer::LogResponse(const HTTPRequest& request, int responseStatus) con + return; + + std::multimap headerValues; +- HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND, headerValues); ++ HTTPRequestHandlerUtils::GetRequestHeaderValues(request.connection, MHD_HEADER_KIND, ++ headerValues); + + CLog::Log(LOGDEBUG, "CWebServer[%hu] [OUT] %s %d %s", m_port, request.version.c_str(), responseStatus, request.pathUrlFull.c_str()); + +@@ -1286,7 +1374,7 @@ void CWebServer::LogResponse(const HTTPRequest& request, int responseStatus) con + CLog::Log(LOGDEBUG, "CWebServer[%hu] [OUT] %s: %s", m_port, header.first.c_str(), header.second.c_str()); + } + +-std::string CWebServer::CreateMimeTypeFromExtension(const char *ext) ++std::string CWebServer::CreateMimeTypeFromExtension(const char* ext) + { + if (strcmp(ext, ".kar") == 0) + return "audio/midi"; +@@ -1296,10 +1384,12 @@ std::string CWebServer::CreateMimeTypeFromExtension(const char *ext) + return CMime::GetMimeType(ext); + } + +-int CWebServer::AddHeader(struct MHD_Response *response, const std::string &name, const std::string &value) const ++MHD_RESULT CWebServer::AddHeader(struct MHD_Response* response, ++ const std::string& name, ++ const std::string& value) const + { + if (response == nullptr || name.empty()) +- return 0; ++ return MHD_NO; + + CLog::Log(LOGDEBUG, LOGWEBSERVER, "CWebServer[%hu] [OUT] %s: %s", m_port, name.c_str(), value.c_str()); + +diff --git a/xbmc/network/WebServer.h b/xbmc/network/WebServer.h +index c7a9093..1274a2e 100644 +--- a/xbmc/network/WebServer.h ++++ b/xbmc/network/WebServer.h +@@ -56,17 +56,17 @@ protected: + + virtual void LogRequest(const char* uri) const; + +- virtual int HandlePartialRequest(struct MHD_Connection *connection, ConnectionHandler* connectionHandler, const HTTPRequest& request, ++ virtual MHD_RESULT HandlePartialRequest(struct MHD_Connection *connection, ConnectionHandler* connectionHandler, const HTTPRequest& request, + const char *upload_data, size_t *upload_data_size, void **con_cls); +- virtual int HandleRequest(const std::shared_ptr& handler); +- virtual int FinalizeRequest(const std::shared_ptr& handler, int responseStatus, struct MHD_Response *response); ++ virtual MHD_RESULT HandleRequest(const std::shared_ptr& handler); ++ virtual MHD_RESULT FinalizeRequest(const std::shared_ptr& handler, int responseStatus, struct MHD_Response *response); + + private: + struct MHD_Daemon* StartMHD(unsigned int flags, int port); + + std::shared_ptr FindRequestHandler(const HTTPRequest& request) const; + +- int AskForAuthentication(const HTTPRequest& request) const; ++ MHD_RESULT AskForAuthentication(const HTTPRequest& request) const; + bool IsAuthenticated(const HTTPRequest& request) const; + + bool IsRequestCacheable(const HTTPRequest& request) const; +@@ -76,18 +76,18 @@ private: + bool ProcessPostData(const HTTPRequest& request, ConnectionHandler *connectionHandler, const char *upload_data, size_t *upload_data_size, void **con_cls) const; + void FinalizePostDataProcessing(ConnectionHandler *connectionHandler) const; + +- int CreateMemoryDownloadResponse(const std::shared_ptr& handler, struct MHD_Response *&response) const; +- int CreateRangedMemoryDownloadResponse(const std::shared_ptr& handler, struct MHD_Response *&response) const; ++ MHD_RESULT CreateMemoryDownloadResponse(const std::shared_ptr& handler, struct MHD_Response *&response) const; ++ MHD_RESULT CreateRangedMemoryDownloadResponse(const std::shared_ptr& handler, struct MHD_Response *&response) const; + +- int CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const; +- int CreateFileDownloadResponse(const std::shared_ptr& handler, struct MHD_Response *&response) const; +- int CreateErrorResponse(struct MHD_Connection *connection, int responseType, HTTPMethod method, struct MHD_Response *&response) const; +- int CreateMemoryDownloadResponse(struct MHD_Connection *connection, const void *data, size_t size, bool free, bool copy, struct MHD_Response *&response) const; ++ MHD_RESULT CreateRedirect(struct MHD_Connection *connection, const std::string &strURL, struct MHD_Response *&response) const; ++ MHD_RESULT CreateFileDownloadResponse(const std::shared_ptr& handler, struct MHD_Response *&response) const; ++ MHD_RESULT CreateErrorResponse(struct MHD_Connection *connection, int responseType, HTTPMethod method, struct MHD_Response *&response) const; ++ MHD_RESULT CreateMemoryDownloadResponse(struct MHD_Connection *connection, const void *data, size_t size, bool free, bool copy, struct MHD_Response *&response) const; + +- int SendResponse(const HTTPRequest& request, int responseStatus, MHD_Response *response) const; +- int SendErrorResponse(const HTTPRequest& request, int errorType, HTTPMethod method) const; ++ MHD_RESULT SendResponse(const HTTPRequest& request, int responseStatus, MHD_Response *response) const; ++ MHD_RESULT SendErrorResponse(const HTTPRequest& request, int errorType, HTTPMethod method) const; + +- int AddHeader(struct MHD_Response *response, const std::string &name, const std::string &value) const; ++ MHD_RESULT AddHeader(struct MHD_Response *response, const std::string &name, const std::string &value) const; + + void LogRequest(const HTTPRequest& request) const; + void LogResponse(const HTTPRequest& request, int responseStatus) const; +@@ -100,11 +100,11 @@ private: + static ssize_t ContentReaderCallback (void *cls, uint64_t pos, char *buf, size_t max); + static void ContentReaderFreeCallback(void *cls); + +- static int AnswerToConnection (void *cls, struct MHD_Connection *connection, ++ static MHD_RESULT AnswerToConnection (void *cls, struct MHD_Connection *connection, + const char *url, const char *method, + const char *version, const char *upload_data, + size_t *upload_data_size, void **con_cls); +- static int HandlePostField(void *cls, enum MHD_ValueKind kind, const char *key, ++ static MHD_RESULT HandlePostField(void *cls, enum MHD_ValueKind kind, const char *key, + const char *filename, const char *content_type, + const char *transfer_encoding, const char *data, uint64_t off, + size_t size); +diff --git a/xbmc/network/httprequesthandler/HTTPFileHandler.cpp b/xbmc/network/httprequesthandler/HTTPFileHandler.cpp +index 2101d49..26e5390 100644 +--- a/xbmc/network/httprequesthandler/HTTPFileHandler.cpp ++++ b/xbmc/network/httprequesthandler/HTTPFileHandler.cpp +@@ -23,7 +23,7 @@ CHTTPFileHandler::CHTTPFileHandler(const HTTPRequest &request) + m_lastModified() + { } + +-int CHTTPFileHandler::HandleRequest() ++MHD_RESULT CHTTPFileHandler::HandleRequest() + { + return !m_url.empty() ? MHD_YES : MHD_NO; + } +diff --git a/xbmc/network/httprequesthandler/HTTPFileHandler.h b/xbmc/network/httprequesthandler/HTTPFileHandler.h +index 3c74b52..6121315 100644 +--- a/xbmc/network/httprequesthandler/HTTPFileHandler.h ++++ b/xbmc/network/httprequesthandler/HTTPFileHandler.h +@@ -19,7 +19,7 @@ class CHTTPFileHandler : public IHTTPRequestHandler + public: + ~CHTTPFileHandler() override = default; + +- int HandleRequest() override; ++ MHD_RESULT HandleRequest() override; + + bool CanHandleRanges() const override { return m_canHandleRanges; } + bool CanBeCached() const override { return m_canBeCached; } +diff --git a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp +index de42e7f..6902be0 100644 +--- a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp ++++ b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.cpp +@@ -104,7 +104,7 @@ bool CHTTPImageTransformationHandler::CanHandleRequest(const HTTPRequest &reques + options.find(TRANSFORMATION_OPTION_HEIGHT) != options.end()); + } + +-int CHTTPImageTransformationHandler::HandleRequest() ++MHD_RESULT CHTTPImageTransformationHandler::HandleRequest() + { + if (m_response.type == HTTPError) + return MHD_YES; +diff --git a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h +index c55015e..0d17afc 100644 +--- a/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h ++++ b/xbmc/network/httprequesthandler/HTTPImageTransformationHandler.h +@@ -23,7 +23,7 @@ public: + IHTTPRequestHandler* Create(const HTTPRequest &request) const override { return new CHTTPImageTransformationHandler(request); } + bool CanHandleRequest(const HTTPRequest &request)const override; + +- int HandleRequest() override; ++ MHD_RESULT HandleRequest() override; + + bool CanHandleRanges() const override { return true; } + bool CanBeCached() const override { return true; } +diff --git a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp +index e8e2fa3..a4c3c19 100644 +--- a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp ++++ b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.cpp +@@ -25,7 +25,7 @@ bool CHTTPJsonRpcHandler::CanHandleRequest(const HTTPRequest &request) const + return (request.pathUrl.compare("/jsonrpc") == 0); + } + +-int CHTTPJsonRpcHandler::HandleRequest() ++MHD_RESULT CHTTPJsonRpcHandler::HandleRequest() + { + CHTTPClient client(m_request.method); + bool isRequest = false; +diff --git a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h +index 67c14b6..2659fd5 100644 +--- a/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h ++++ b/xbmc/network/httprequesthandler/HTTPJsonRpcHandler.h +@@ -24,7 +24,7 @@ public: + IHTTPRequestHandler* Create(const HTTPRequest &request) const override { return new CHTTPJsonRpcHandler(request); } + bool CanHandleRequest(const HTTPRequest &request) const override; + +- int HandleRequest() override; ++ MHD_RESULT HandleRequest() override; + + HttpResponseRanges GetResponseData() const override; + +diff --git a/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp b/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp +index 5f9aeef..a07ef0d 100644 +--- a/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp ++++ b/xbmc/network/httprequesthandler/HTTPPythonHandler.cpp +@@ -112,7 +112,7 @@ bool CHTTPPythonHandler::CanHandleRequest(const HTTPRequest &request) const + return true; + } + +-int CHTTPPythonHandler::HandleRequest() ++MHD_RESULT CHTTPPythonHandler::HandleRequest() + { + if (m_response.type == HTTPError || m_response.type == HTTPRedirect) + return MHD_YES; +diff --git a/xbmc/network/httprequesthandler/HTTPPythonHandler.h b/xbmc/network/httprequesthandler/HTTPPythonHandler.h +index 03c1506..166430e 100644 +--- a/xbmc/network/httprequesthandler/HTTPPythonHandler.h ++++ b/xbmc/network/httprequesthandler/HTTPPythonHandler.h +@@ -25,7 +25,7 @@ public: + bool CanBeCached() const override { return false; } + bool GetLastModifiedDate(CDateTime &lastModified) const override; + +- int HandleRequest() override; ++ MHD_RESULT HandleRequest() override; + + HttpResponseRanges GetResponseData() const override { return m_responseRanges; } + +diff --git a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp +index 80d1d67..f2ea1f2 100644 +--- a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp ++++ b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.cpp +@@ -61,7 +61,7 @@ bool HTTPRequestHandlerUtils::GetRequestedRanges(struct MHD_Connection *connecti + return ranges.Parse(GetRequestHeaderValue(connection, MHD_HEADER_KIND, MHD_HTTP_HEADER_RANGE), totalLength); + } + +-int HTTPRequestHandlerUtils::FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value) ++MHD_RESULT HTTPRequestHandlerUtils::FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value) + { + if (cls == nullptr || key == nullptr) + return MHD_NO; +@@ -72,7 +72,7 @@ int HTTPRequestHandlerUtils::FillArgumentMap(void *cls, enum MHD_ValueKind kind, + return MHD_YES; + } + +-int HTTPRequestHandlerUtils::FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value) ++MHD_RESULT HTTPRequestHandlerUtils::FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value) + { + if (cls == nullptr || key == nullptr) + return MHD_NO; +diff --git a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h +index 9a07801..0ec5ed1 100644 +--- a/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h ++++ b/xbmc/network/httprequesthandler/HTTPRequestHandlerUtils.h +@@ -25,6 +25,6 @@ public: + private: + HTTPRequestHandlerUtils() = delete; + +- static int FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value); +- static int FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value); ++ static MHD_RESULT FillArgumentMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value); ++ static MHD_RESULT FillArgumentMultiMap(void *cls, enum MHD_ValueKind kind, const char *key, const char *value); + }; +diff --git a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp +index 01a6b50..0716a5d 100644 +--- a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp ++++ b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.cpp +@@ -18,7 +18,7 @@ bool CHTTPWebinterfaceAddonsHandler::CanHandleRequest(const HTTPRequest &request + return (request.pathUrl.compare("/addons") == 0 || request.pathUrl.compare("/addons/") == 0); + } + +-int CHTTPWebinterfaceAddonsHandler::HandleRequest() ++MHD_RESULT CHTTPWebinterfaceAddonsHandler::HandleRequest() + { + m_responseData = ADDON_HEADER; + ADDON::VECADDONS addons; +diff --git a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h +index e9b1c6d..23cea36 100644 +--- a/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h ++++ b/xbmc/network/httprequesthandler/HTTPWebinterfaceAddonsHandler.h +@@ -21,7 +21,7 @@ public: + IHTTPRequestHandler* Create(const HTTPRequest &request) const override { return new CHTTPWebinterfaceAddonsHandler(request); } + bool CanHandleRequest(const HTTPRequest &request) const override; + +- int HandleRequest() override; ++ MHD_RESULT HandleRequest() override; + + HttpResponseRanges GetResponseData() const override; + +diff --git a/xbmc/network/httprequesthandler/IHTTPRequestHandler.h b/xbmc/network/httprequesthandler/IHTTPRequestHandler.h +index 4b1e40a..8f605ad 100644 +--- a/xbmc/network/httprequesthandler/IHTTPRequestHandler.h ++++ b/xbmc/network/httprequesthandler/IHTTPRequestHandler.h +@@ -22,6 +22,12 @@ + + #include "utils/HttpRangeUtils.h" + ++#if MHD_VERSION >= 0x00097002 ++#define MHD_RESULT enum MHD_Result ++#else ++#define MHD_RESULT int ++#endif ++ + class CDateTime; + class CWebServer; + +@@ -114,7 +120,7 @@ public: + * + * \return MHD_NO if a severe error has occurred otherwise MHD_YES. + */ +- virtual int HandleRequest() = 0; ++ virtual MHD_RESULT HandleRequest() = 0; + + /*! + * \brief Whether the HTTP response could also be provided in ranges. diff --git a/alarm/kodi-rbp/PKGBUILD b/alarm/kodi-rbp/PKGBUILD index 8c676a943..8760e6d9c 100644 --- a/alarm/kodi-rbp/PKGBUILD +++ b/alarm/kodi-rbp/PKGBUILD @@ -12,7 +12,7 @@ _prefix=/usr pkgbase=kodi-rbp pkgname=('kodi-rbp' 'kodi-rbp-eventclients' 'kodi-rbp-tools-texturepacker' 'kodi-rbp-dev') pkgver=18.7.1 -pkgrel=1 +pkgrel=2 _codename=Leia _tag="$pkgver-$_codename" _ffmpeg_version="4.0.4-$_codename-18.4" @@ -31,7 +31,7 @@ makedepends=( 'gperf' 'hicolor-icon-theme' 'jasper' 'java-environment' 'libaacs' 'libass' 'libbluray-kodi-rbp' 'libcdio' 'mariadb-libs' 'libmicrohttpd' 'groff' 'libmodplug' 'libmpeg2' 'libnfs' 'libplist' 'libpulse' 'libssh' 'libcec-rpi' - 'libxrandr' 'libxslt' 'lirc' 'lzo' 'nasm' 'nss-mdns' 'python2-pillow' + 'libxrandr' 'libxslt' 'lirc' 'lzo' 'nasm' 'nss-mdns' 'python2-pillow6' 'python2-pybluez' 'python2-pycryptodomex' 'python2-simplejson' 'raspberrypi-firmware' 'rtmpdump' 'shairplay' 'smbclient' 'speex' 'swig' 'taglib' 'tinyxml' 'unzip' 'upower' 'yajl' 'zip' 'giflib' 'rapidjson' 'polkit' 'libinput' 'libxkbcommon' 'ghostscript' @@ -51,6 +51,7 @@ source=("https://github.com/popcornmix/xbmc/archive/newclock5_$_tag.tar.gz" "http://mirrors.kodi.tv/build-deps/sources/flatbuffers-$_flatbuffers_version.tar.gz" sysusers.conf tmpfiles.conf + 18131.patch ) noextract=( "libdvdcss-$_libdvdcss_version.tar.gz" @@ -66,7 +67,7 @@ sha256sums=('2556a23548b1ec207f413ab3d5602562a354b426445feabc1afee25797562e42' '6eded8b5f52808d5ffa77de546fbf799a255dde2473540e8a8bd46daa6f753d9' 'fe7a1ab2a6e2bf00f756c76545a338d2763003052764d722d492b06b1bc05f5e' 'b31570f95654434b01fd8531612fbb6be77cbc1c519dd60f92feae26eb160f3d' - '9ea592205023ba861603d74b63cdb73126c56372a366dc4cb7beb379073cbb96' + '5d38a895ee7b93689fab79124a3aad23a5e3e643abd08878d778d04066c8d26f' 'e11e7594af35f36ab2711252c3d6bb106908f26605498aef4a9be2d7bc001db2' '38816f8373e243bc5950449b4f3b18938c4e1c59348e3411e23f31db4072e40d' '071e414e61b795f2ff9015b21a85fc009dde967f27780d23092643916538a57a' @@ -76,7 +77,8 @@ sha256sums=('2556a23548b1ec207f413ab3d5602562a354b426445feabc1afee25797562e42' 'e4018e850f80700acee8da296e56e15b1eef711ab15157e542e7d7e1237c3476' '5ca5491e4260cacae30f1a5786d109230db3f3a6e5a0eb45d0d0608293d247e3' 'f521b98232e5035b7cada46cf03975b8d753e93d0802bf22913fceed769f9d96' - '9c5e79ed8719cd032a3b17dac585aeff28a198e37af1da9af68ef1b86bab4d18') + '9c5e79ed8719cd032a3b17dac585aeff28a198e37af1da9af68ef1b86bab4d18' + '1bfa84c0ae99a4ed731261cb39cb347c2809ca63d0d318393bdbbee900bbf8bc') prepare() { # force python 'binary' as python2 [[ -d "$srcdir/path" ]] && rm -rf "$srcdir/path" @@ -87,6 +89,9 @@ prepare() { [[ -d kodi-build ]] && rm -rf kodi-build mkdir $srcdir/kodi-build + + # fix for libmicrohttpd 0.9.71 + patch -Np1 -i ../18131.patch } build() { @@ -141,7 +146,7 @@ package_kodi-rbp() { 'bluez-libs' 'desktop-file-utils' 'freetype2' 'fribidi' 'libcec-rpi' 'hicolor-icon-theme' 'libass' 'libcdio' 'libjpeg-turbo' 'mariadb-libs' 'libmicrohttpd' 'libpulse' 'libssh' 'libxrandr' 'lirc' 'raspberrypi-firmware' - 'libxslt' 'lzo' 'python2-pillow' 'python2-simplejson' 'smbclient' + 'libxslt' 'lzo' 'python2-pillow6' 'python2-simplejson' 'smbclient' 'speex' 'taglib' 'tinyxml' 'xorg-xdpyinfo' 'yajl' 'libinput' 'libxkbcommon' 'libbluray-kodi-rbp' 'fbset' 'libnfs' 'curl' ) diff --git a/alarm/kodi-rbp/polkit.rules b/alarm/kodi-rbp/polkit.rules index 603c1274c..bcf7abf2a 100644 --- a/alarm/kodi-rbp/polkit.rules +++ b/alarm/kodi-rbp/polkit.rules @@ -8,5 +8,8 @@ polkit.addRule(function(action, subject) { if (action.id.indexOf("org.freedesktop.udisks.") == 0) { return polkit.Result.YES; } + if (action.id.indexOf("org.freedesktop.udisks2.") == 0) { + return polkit.Result.YES; + } } });