diff options
author | Eugene Sandulenko | 2016-07-22 15:38:24 +0300 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | d57fca4665e65bca1cf487fb109d020d1233e800 (patch) | |
tree | c5a8b0e88f4c55e0f2e2afb2f78a4cd1f89d66f3 /backends/networking/curl | |
parent | cccfe7c247fed9b00c100e64433439386d6ef077 (diff) | |
download | scummvm-rg350-d57fca4665e65bca1cf487fb109d020d1233e800.tar.gz scummvm-rg350-d57fca4665e65bca1cf487fb109d020d1233e800.tar.bz2 scummvm-rg350-d57fca4665e65bca1cf487fb109d020d1233e800.zip |
CLOUD: JANITORIAL: Fix code formatting
Diffstat (limited to 'backends/networking/curl')
-rw-r--r-- | backends/networking/curl/cloudicon.cpp | 19 | ||||
-rw-r--r-- | backends/networking/curl/connectionmanager.cpp | 30 | ||||
-rw-r--r-- | backends/networking/curl/curljsonrequest.cpp | 12 | ||||
-rw-r--r-- | backends/networking/curl/curlrequest.cpp | 9 | ||||
-rw-r--r-- | backends/networking/curl/networkreadstream.cpp | 21 | ||||
-rw-r--r-- | backends/networking/curl/request.cpp | 8 |
6 files changed, 66 insertions, 33 deletions
diff --git a/backends/networking/curl/cloudicon.cpp b/backends/networking/curl/cloudicon.cpp index 80e26169dd..1c1ecf2f85 100644 --- a/backends/networking/curl/cloudicon.cpp +++ b/backends/networking/curl/cloudicon.cpp @@ -83,14 +83,16 @@ bool CloudIcon::draw() { if (g_system) { Graphics::TransparentSurface *surface = &_icon; makeAlphaIcon((_showingDisabled ? _disabledIcon : _icon), _currentAlpha); - if (_alphaIcon.getPixels()) surface = &_alphaIcon; + if (_alphaIcon.getPixels()) + surface = &_alphaIcon; if (surface && surface->getPixels()) { int x = g_system->getOverlayWidth() - surface->w - 10, y = 10; g_system->copyRectToOSD(surface->getPixels(), surface->pitch, x, y, surface->w, surface->h); } } - if (stop) _showingDisabled = false; + if (stop) + _showingDisabled = false; return stop; } @@ -103,7 +105,8 @@ void CloudIcon::showDisabled() { #include "backends/networking/curl/cloudicon_disabled_data.h" void CloudIcon::initIcons() { - if (_iconsInited) return; + if (_iconsInited) + return; loadIcon(_icon, cloudicon_data, ARRAYSIZE(cloudicon_data)); loadIcon(_disabledIcon, cloudicon_disabled_data, ARRAYSIZE(cloudicon_disabled_data)); _iconsInited = true; @@ -120,14 +123,18 @@ void CloudIcon::loadIcon(Graphics::TransparentSurface &icon, byte *data, uint32 Graphics::PixelFormat f = g_system->getOSDFormat(); if (f != s->format) { Graphics::TransparentSurface *s2 = s->convertTo(f); - if (s2) icon.copyFrom(*s2); - else warning("CloudIcon::loadIcon: failed converting TransparentSurface"); + if (s2) + icon.copyFrom(*s2); + else + warning("CloudIcon::loadIcon: failed converting TransparentSurface"); delete s2; } else { icon.copyFrom(*s); } delete s; - } else warning("CloudIcon::loadIcon: failed reading TransparentSurface from PNGDecoder"); + } else { + warning("CloudIcon::loadIcon: failed reading TransparentSurface from PNGDecoder"); + } } void CloudIcon::makeAlphaIcon(Graphics::TransparentSurface &icon, float alpha) { diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp index cb0e24645e..1d5fd0d0cb 100644 --- a/backends/networking/curl/connectionmanager.cpp +++ b/backends/networking/curl/connectionmanager.cpp @@ -50,9 +50,11 @@ ConnectionManager::~ConnectionManager() { for (Common::Array<RequestWithCallback>::iterator i = _requests.begin(); i != _requests.end(); ++i) { Request *request = i->request; RequestCallback callback = i->onDeleteCallback; - if (request) request->finish(); + if (request) + request->finish(); delete request; - if (callback) (*callback)(request); + if (callback) + (*callback)(request); } _requests.clear(); @@ -70,7 +72,8 @@ void ConnectionManager::registerEasyHandle(CURL *easy) const { Request *ConnectionManager::addRequest(Request *request, RequestCallback callback) { _addedRequestsMutex.lock(); _addedRequests.push_back(RequestWithCallback(request, callback)); - if (!_timerStarted) startTimer(); + if (!_timerStarted) + startTimer(); _addedRequestsMutex.unlock(); return request; } @@ -81,7 +84,8 @@ void ConnectionManager::showCloudDisabledIcon() { } Common::String ConnectionManager::urlEncode(Common::String s) const { - if (!_multi) return ""; + if (!_multi) + return ""; char *output = curl_easy_escape(_multi, s.c_str(), s.size()); if (output) { Common::String result = output; @@ -128,8 +132,10 @@ void ConnectionManager::handle() { //lock mutex here (in case another handle() would be called before this one ends) _handleMutex.lock(); ++_frame; - if (_frame % CLOUD_PERIOD == 0) interateRequests(); - if (_frame % CURL_PERIOD == 0) processTransfers(); + if (_frame % CLOUD_PERIOD == 0) + interateRequests(); + if (_frame % CURL_PERIOD == 0) + processTransfers(); if (_icon.draw() && _requests.empty() && !hasAddedRequests()) stopTimer(); @@ -150,13 +156,16 @@ void ConnectionManager::interateRequests() { for (Common::Array<RequestWithCallback>::iterator i = _requests.begin(); i != _requests.end();) { Request *request = i->request; if (request) { - if (request->state() == PROCESSING) request->handle(); - else if (request->state() == RETRY) request->handleRetry(); + if (request->state() == PROCESSING) + request->handle(); + else if (request->state() == RETRY) + request->handleRetry(); } if (!request || request->state() == FINISHED) { delete (i->request); - if (i->onDeleteCallback) (*i->onDeleteCallback)(i->request); //that's not a mistake (we're passing an address and that method knows there is no object anymore) + if (i->onDeleteCallback) + (*i->onDeleteCallback)(i->request); //that's not a mistake (we're passing an address and that method knows there is no object anymore) _requests.erase(i); continue; } @@ -179,7 +188,8 @@ void ConnectionManager::processTransfers() { NetworkReadStream *stream; curl_easy_getinfo(easyHandle, CURLINFO_PRIVATE, &stream); - if (stream) stream->finished(); + if (stream) + stream->finished(); if (curlMsg->msg == CURLMSG_DONE) { debug(9, "ConnectionManager: SUCCESS (%d - %s)", curlMsg->data.result, curl_easy_strerror(curlMsg->data.result)); diff --git a/backends/networking/curl/curljsonrequest.cpp b/backends/networking/curl/curljsonrequest.cpp index 7f7cbca2e0..4d87aa2649 100644 --- a/backends/networking/curl/curljsonrequest.cpp +++ b/backends/networking/curl/curljsonrequest.cpp @@ -49,7 +49,8 @@ char *CurlJsonRequest::getPreparedContents() { byte *result = _contentsStream.getData(); uint32 size = _contentsStream.size(); for (uint32 i = 0; i < size; ++i) { - if (result[i] == '\n') result[i] = ' '; //yeah, kinda stupid + if (result[i] == '\n') + result[i] = ' '; //yeah, kinda stupid else if (result[i] < 0x20 || result[i] > 0x7f) result[i] = '.'; } @@ -85,7 +86,8 @@ void CurlJsonRequest::handle() { } void CurlJsonRequest::restart() { - if (_stream) delete _stream; + if (_stream) + delete _stream; _stream = nullptr; _contentsStream = Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); //with no stream available next handle() will create another one @@ -93,8 +95,10 @@ void CurlJsonRequest::restart() { void CurlJsonRequest::finishJson(Common::JSONValue *json) { Request::finishSuccess(); - if (_jsonCallback) (*_jsonCallback)(JsonResponse(this, json)); //potential memory leak, free it in your callbacks! - else delete json; + if (_jsonCallback) + (*_jsonCallback)(JsonResponse(this, json)); //potential memory leak, free it in your callbacks! + else + delete json; } bool CurlJsonRequest::jsonIsObject(Common::JSONValue *item, const char *warningPrefix) { diff --git a/backends/networking/curl/curlrequest.cpp b/backends/networking/curl/curlrequest.cpp index 4420b6f524..2d5bb1fa2b 100644 --- a/backends/networking/curl/curlrequest.cpp +++ b/backends/networking/curl/curlrequest.cpp @@ -63,7 +63,8 @@ void CurlRequest::handle() { } void CurlRequest::restart() { - if (_stream) delete _stream; + if (_stream) + delete _stream; _stream = nullptr; //with no stream available next handle() will create another one } @@ -78,7 +79,8 @@ Common::String CurlRequest::date() const { Common::String result = ""; char c; for (const char *i = position + 6; c = *i, c != 0; ++i) { - if (c == '\n' || c == '\r') break; + if (c == '\n' || c == '\r') + break; result += c; } return result; @@ -135,7 +137,8 @@ void CurlRequest::setBuffer(byte *buffer, uint32 size) { if (_postFields != "") warning("CurlRequest: added POST fields would be ignored, because buffer added"); - if (_bytesBuffer) delete _bytesBuffer; + if (_bytesBuffer) + delete _bytesBuffer; _bytesBuffer = buffer; _bytesBufferSize = size; diff --git a/backends/networking/curl/networkreadstream.cpp b/backends/networking/curl/networkreadstream.cpp index 1764a939fd..5c760d9e01 100644 --- a/backends/networking/curl/networkreadstream.cpp +++ b/backends/networking/curl/networkreadstream.cpp @@ -31,25 +31,29 @@ namespace Networking { static size_t curlDataCallback(char *d, size_t n, size_t l, void *p) { NetworkReadStream *stream = (NetworkReadStream *)p; - if (stream) return stream->write(d, n * l); + if (stream) + return stream->write(d, n * l); return 0; } static size_t curlReadDataCallback(char *d, size_t n, size_t l, void *p) { NetworkReadStream *stream = (NetworkReadStream *)p; - if (stream) return stream->fillWithSendingContents(d, n * l); + if (stream) + return stream->fillWithSendingContents(d, n * l); return 0; } static size_t curlHeadersCallback(char *d, size_t n, size_t l, void *p) { NetworkReadStream *stream = (NetworkReadStream *)p; - if (stream) return stream->addResponseHeaders(d, n * l); + if (stream) + return stream->addResponseHeaders(d, n * l); return 0; } static int curlProgressCallback(void *p, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) { NetworkReadStream *stream = (NetworkReadStream *)p; - if (stream) stream->setProgress(dlnow, dltotal); + if (stream) + stream->setProgress(dlnow, dltotal); return 0; } @@ -171,7 +175,8 @@ uint32 NetworkReadStream::read(void *dataPtr, uint32 dataSize) { uint32 actuallyRead = MemoryReadWriteStream::read(dataPtr, dataSize); if (actuallyRead == 0) { - if (_requestComplete) _eos = true; + if (_requestComplete) + _eos = true; return 0; } @@ -205,7 +210,8 @@ Common::String NetworkReadStream::responseHeaders() const { uint32 NetworkReadStream::fillWithSendingContents(char *bufferToFill, uint32 maxSize) { uint32 size = _sendingContentsSize - _sendingContentsPos; - if (size > maxSize) size = maxSize; + if (size > maxSize) + size = maxSize; for (uint32 i = 0; i < size; ++i) { bufferToFill[i] = _sendingContentsBuffer[_sendingContentsPos + i]; } @@ -219,7 +225,8 @@ uint32 NetworkReadStream::addResponseHeaders(char *buffer, uint32 size) { } double NetworkReadStream::getProgress() const { - if (_progressTotal < 1) return 0; + if (_progressTotal < 1) + return 0; return (double)_progressDownloaded / (double)_progressTotal; } diff --git a/backends/networking/curl/request.cpp b/backends/networking/curl/request.cpp index 4a2704fc76..30af48a478 100644 --- a/backends/networking/curl/request.cpp +++ b/backends/networking/curl/request.cpp @@ -39,8 +39,9 @@ Request::~Request() { } void Request::handleRetry() { - if (_retryInSeconds > 0) --_retryInSeconds; - else { + if (_retryInSeconds > 0) { + --_retryInSeconds; + } else { _state = PROCESSING; restart(); } @@ -64,7 +65,8 @@ Common::String Request::date() const { return ""; } void Request::finishError(ErrorResponse error) { _state = FINISHED; - if (_errorCallback) (*_errorCallback)(error); + if (_errorCallback) + (*_errorCallback)(error); } void Request::finishSuccess() { _state = FINISHED; } |